ps99-api 2.3.0 → 2.3.1

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.
@@ -10,6 +10,7 @@ permissions:
10
10
  issues: write # to be able to comment on released issues
11
11
  pull-requests: write # to be able to comment on released pull requests
12
12
  id-token: write # to enable use of OIDC for npm provenance
13
+ pages: write
13
14
 
14
15
  concurrency:
15
16
  group: "pages"
package/README.md CHANGED
@@ -3,7 +3,6 @@
3
3
  [![npm version](https://badge.fury.io/js/ps99-api.svg)](https://badge.fury.io/js/ps99-api)
4
4
  ![Website](https://img.shields.io/website?url=https%3A%2F%2Fjoekiller.github.io%2Fnode-ps99-api)
5
5
 
6
-
7
6
  Pet Simulator Public API wrapper written in Typescript.
8
7
 
9
8
  ## Installation
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "name": "example-ps99-api-webapp-2",
3
+ "homepage": "https://joekiller.github.io/node-ps99-api",
3
4
  "version": "1.0.0",
4
5
  "description": "A demonstration of using the Pet Simulator 99 node-ps99-api library.",
5
6
  "private": true,
@@ -4,26 +4,28 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Pet Simulator 99 API</title>
7
- <link rel="manifest" href="/manifest.json" />
8
- <link rel="icon" href="/icons/icon-192x192.png" />
7
+ <link rel="manifest" href="/node-ps99-api/manifest.json" />
8
+ <link rel="icon" href="/node-ps99-api/icons/icon-192x192.png" />
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
12
- <script src="/bundle.js"></script>
12
+ <script src="/node-ps99-api/bundle.js"></script>
13
13
  <script>
14
14
  if ("serviceWorker" in navigator) {
15
15
  window.addEventListener("load", function () {
16
- navigator.serviceWorker.register("/service-worker.js").then(
17
- function (registration) {
18
- console.log(
19
- "ServiceWorker registration successful with scope: ",
20
- registration.scope,
21
- );
22
- },
23
- function (error) {
24
- console.log("ServiceWorker registration failed: ", error);
25
- },
26
- );
16
+ navigator.serviceWorker
17
+ .register("/node-ps99-api/service-worker.js")
18
+ .then(
19
+ function (registration) {
20
+ console.log(
21
+ "ServiceWorker registration successful with scope: ",
22
+ registration.scope,
23
+ );
24
+ },
25
+ function (error) {
26
+ console.log("ServiceWorker registration failed: ", error);
27
+ },
28
+ );
27
29
  });
28
30
  }
29
31
  </script>
@@ -9,7 +9,7 @@ import Footer from "./components/Footer";
9
9
 
10
10
  const App: React.FC = () => {
11
11
  return (
12
- <Router>
12
+ <Router basename="/node-ps99-api">
13
13
  <Header />
14
14
  <Routes>
15
15
  <Route path="/" element={<HomePage />} />
@@ -1,58 +1,38 @@
1
- import React, { useState, useEffect } from "react";
2
- import { useOnlineStatus } from "../hooks/useOnlineStatus";
1
+ import React from "react";
3
2
 
4
3
  const Footer: React.FC = () => {
5
- const isOnline = useOnlineStatus();
6
- const [lastUpdate, setLastUpdate] = useState<string | null>(null);
7
- const [loading, setLoading] = useState(false);
8
-
9
- const updateLastUpdate = () => {
10
- setLastUpdate(new Date().toLocaleString());
11
- };
12
-
13
- useEffect(() => {
14
- const fetchData = async () => {
15
- setLoading(true);
16
- // Simulate a fetch call to update lastUpdate time
17
- await new Promise((resolve) => setTimeout(resolve, 1000));
18
- updateLastUpdate();
19
- setLoading(false);
20
- };
21
-
22
- fetchData();
23
-
24
- window.addEventListener("online", updateLastUpdate);
25
- window.addEventListener("offline", updateLastUpdate);
26
-
27
- return () => {
28
- window.removeEventListener("online", updateLastUpdate);
29
- window.removeEventListener("offline", updateLastUpdate);
30
- };
31
- }, []);
32
-
33
4
  return (
34
5
  <footer
35
- style={{
36
- display: "flex",
37
- justifyContent: "space-between",
38
- padding: "1em",
39
- borderTop: "1px solid #ccc",
40
- }}
6
+ style={{ textAlign: "center", padding: "1em", background: "#f8f9fa" }}
41
7
  >
42
8
  <div>
43
- {loading ? (
44
- <span>♻️ Loading...</span>
45
- ) : (
46
- <span>Last update: {lastUpdate}</span>
47
- )}
48
- </div>
49
- <div>
50
- {isOnline ? (
51
- <span style={{ color: "green" }}>● Online</span>
52
- ) : (
53
- <span style={{ color: "red" }}>● Offline</span>
54
- )}
9
+ <a href="https://badge.fury.io/js/ps99-api">
10
+ <img
11
+ src="https://badge.fury.io/js/ps99-api.svg"
12
+ alt="npm version"
13
+ height="18"
14
+ />
15
+ </a>
16
+ &nbsp;
17
+ <a href="https://github.com/joekiller/node-ps99-api">
18
+ <img
19
+ src="https://img.shields.io/badge/source-github-blue?logo=github"
20
+ alt="GitHub source"
21
+ height="18"
22
+ />
23
+ </a>
55
24
  </div>
25
+ <p>
26
+ &copy; {new Date().getFullYear()} Joseph "
27
+ <a
28
+ href="https://joekiller.com"
29
+ target="_blank"
30
+ rel="noopener noreferrer"
31
+ >
32
+ joekiller
33
+ </a>
34
+ " Lawson. All rights reserved.
35
+ </p>
56
36
  </footer>
57
37
  );
58
38
  };
@@ -49,5 +49,5 @@ export const GenericFetchComponent = <T,>({
49
49
  return <div>Loading...</div>;
50
50
  }
51
51
 
52
- return <>{render(data)}</>;
52
+ return <div>{render(data)}</div>;
53
53
  };
@@ -6,20 +6,60 @@ const Header: React.FC = () => {
6
6
  const pathnames = location.pathname.split("/").filter((x) => x);
7
7
 
8
8
  return (
9
- <nav>
10
- <ol>
11
- <li>
12
- <Link to="/">Home</Link>
13
- </li>
14
- {pathnames.map((value, index) => {
15
- const to = `/${pathnames.slice(0, index + 1).join("/")}`;
16
- return (
17
- <li key={to}>
18
- <Link to={to}>{decodeURIComponent(value)}</Link>
19
- </li>
20
- );
21
- })}
22
- </ol>
9
+ <nav
10
+ style={{
11
+ padding: "1em",
12
+ background: "#f8f9fa",
13
+ borderBottom: "1px solid #e7e7e7",
14
+ display: "flex",
15
+ justifyContent: "space-between",
16
+ alignItems: "center",
17
+ }}
18
+ >
19
+ <div style={{ display: "flex", alignItems: "center" }}>
20
+ <Link
21
+ to="/"
22
+ style={{
23
+ textDecoration: "none",
24
+ color: "#007bff",
25
+ display: "flex",
26
+ alignItems: "center",
27
+ }}
28
+ >
29
+ <img
30
+ src="/node-ps99-api/icons/icon-192x192.png"
31
+ alt="Home"
32
+ style={{ width: "40px", height: "40px", marginRight: "0.5em" }}
33
+ />
34
+ </Link>
35
+ <ol
36
+ style={{ display: "flex", listStyle: "none", padding: 0, margin: 0 }}
37
+ >
38
+ <li style={{ margin: "0 0.5em" }}>
39
+ <Link to="/" style={{ textDecoration: "none", color: "#007bff" }}>
40
+ Home
41
+ </Link>
42
+ </li>
43
+ {pathnames.map((value, index) => {
44
+ const to = `/${pathnames.slice(0, index + 1).join("/")}`;
45
+ return (
46
+ <li key={to} style={{ margin: "0 0.5em" }}>
47
+ <Link
48
+ to={to}
49
+ style={{ textDecoration: "none", color: "#007bff" }}
50
+ >
51
+ {decodeURIComponent(value)}
52
+ </Link>
53
+ </li>
54
+ );
55
+ })}
56
+ </ol>
57
+ </div>
58
+ <h1 style={{ margin: 0 }}>
59
+ <Link to="/" style={{ textDecoration: "none", color: "#007bff" }}>
60
+ Pet Simulator 99 API
61
+ </Link>
62
+ </h1>
23
63
  </nav>
24
64
  );
25
65
  };
@@ -3,10 +3,22 @@ import { Link } from "react-router-dom";
3
3
 
4
4
  const HomePage: React.FC = () => {
5
5
  return (
6
- <div>
6
+ <div style={{ textAlign: "center", padding: "2em" }}>
7
7
  <h1>Welcome to Pet Simulator 99 API</h1>
8
+ <p>Your one-stop solution for accessing all Pet Simulator 99 data.</p>
8
9
  <p>Select a collection to get started:</p>
9
- <Link to="/collections">View Collections</Link>
10
+ <Link
11
+ to="/collections"
12
+ style={{
13
+ padding: "0.5em 1em",
14
+ background: "#007bff",
15
+ color: "#fff",
16
+ textDecoration: "none",
17
+ borderRadius: "4px",
18
+ }}
19
+ >
20
+ View Collections
21
+ </Link>
10
22
  </div>
11
23
  );
12
24
  };
@@ -1,5 +1,6 @@
1
1
  const path = require("path");
2
2
  const CopyWebpackPlugin = require("copy-webpack-plugin");
3
+ const HtmlWebpackPlugin = require("html-webpack-plugin");
3
4
 
4
5
  module.exports = {
5
6
  entry: "./src/index.tsx",
@@ -13,7 +14,7 @@ module.exports = {
13
14
  },
14
15
  {
15
16
  test: /\.css$/i,
16
- use: ["css-loader"],
17
+ use: ["style-loader", "css-loader"], // Add style-loader here to properly handle CSS
17
18
  },
18
19
  ],
19
20
  },
@@ -26,11 +27,23 @@ module.exports = {
26
27
  output: {
27
28
  filename: "bundle.js",
28
29
  path: path.resolve(__dirname, "dist"),
29
- publicPath: "/",
30
+ publicPath: "/node-ps99-api/",
30
31
  },
31
32
  plugins: [
33
+ new HtmlWebpackPlugin({
34
+ template: path.join(__dirname, "public", "index.html"),
35
+ publicPath: "/node-ps99-api/",
36
+ }),
32
37
  new CopyWebpackPlugin({
33
- patterns: [{ from: path.resolve(__dirname, "public") }],
38
+ patterns: [
39
+ {
40
+ from: path.resolve(__dirname, "public"),
41
+ to: path.resolve(__dirname, "dist"),
42
+ globOptions: {
43
+ ignore: ["**/index.html"], // Ignore index.html to avoid conflict
44
+ },
45
+ },
46
+ ],
34
47
  }),
35
48
  ],
36
49
  devServer: {
@@ -39,6 +52,8 @@ module.exports = {
39
52
  },
40
53
  compress: true,
41
54
  port: 9000,
42
- historyApiFallback: true,
55
+ historyApiFallback: {
56
+ index: "/node-ps99-api/index.html",
57
+ },
43
58
  },
44
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ps99-api",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Pet Simulator Public API wrapper written in Typescript.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",