@articles-media/articles-dev-box 1.3.1 → 1.3.3

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.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  Shared code, functions, and components that are commonly used across Articles Media projects.
6
6
 
7
7
  # Warning
8
- None of this is meant to work outside the Articles Media frontend React ecosystem. Breaking changes are being made in between patch releases until 1.1.0, when we switch to major release for breaking.
8
+ A lot of this package is expected to be consumed in a Articles Media related React ecosystem. See Package Exports section for more details.
9
9
 
10
10
  ## Getting Started
11
11
 
@@ -63,6 +63,7 @@ npm run dev
63
63
  | useFullscreen | Hook for going fullscreen on the body or provided element | |
64
64
  | typicalZustandStoreExcludes | Array of strings that every game published by Articles Media would want to normally exclude from persisting in base game store. | Catching Game and School Run |
65
65
  | typicalZustandStoreStateSlice | Slice of zustand states that every game normally uses | Catching Game and School Run |
66
+ | zustandSocketStoreSlice | Slice of zustand states that every game normally uses for sockets | School Run
66
67
  | getSignOutRedirectUrl | Handles signout redirect api logic | Catching Game |
67
68
  | GlobalClientModals | Imports all global client modals like FriendsList, CreditsModal, SettingsModal, InfoModal, and so on | USA Tycoon |
68
69
  | generateRandomNickname | Reusable way of doing random nicknames from package | USA Tycoon |
@@ -8,8 +8,8 @@ var import_classnames = /* @__PURE__ */ __toESM(require_classnames(), 1);
8
8
  var StatusModal = lazy(() => import("./StatusModal-DkHAimHp.js"));
9
9
  function GlobalBody({ fontawesome = true }) {
10
10
  const [statusModal, setStatusModal] = useState(false);
11
- const { data: mainSiteStatus, error: mainSiteStatusError, isLoading: mainSiteStatusLoading, mutate: mainSiteStatusMutate } = useMainSiteStatus({ disable: process.env.NODE_ENV !== "development" });
12
- const { data: authSiteStatus, error: authSiteStatusError, isLoading: authSiteStatusLoading, mutate: authSiteStatusMutate } = useAuthSiteStatus({ disable: process.env.NODE_ENV !== "development" });
11
+ const { data: mainSiteStatus, error: mainSiteStatusError, isLoading: mainSiteStatusLoading, mutate: mainSiteStatusMutate } = useMainSiteStatus({ disable: process.env.NODE_ENV !== "development" || process.env.NEXT_PUBLIC_ENABLE_ARTICLES === "false" });
12
+ const { data: authSiteStatus, error: authSiteStatusError, isLoading: authSiteStatusLoading, mutate: authSiteStatusMutate } = useAuthSiteStatus({ disable: process.env.NODE_ENV !== "development" || process.env.NEXT_PUBLIC_ENABLE_ARTICLES === "false" });
13
13
  return /* @__PURE__ */ jsxs(Fragment, { children: [fontawesome && /* @__PURE__ */ jsx("link", {
14
14
  rel: "stylesheet",
15
15
  href: `https://cdn.articles.media/fonts/fontawesome/css/all.min.css`
package/dist/InfoModal.js CHANGED
@@ -29,12 +29,15 @@ function InfoModal({ show, setShow, useStore, packageInfo, infoModalConfig }) {
29
29
  children: [/* @__PURE__ */ jsx("div", {
30
30
  className: "ratio ratio-16x9",
31
31
  children: darkMode ? /* @__PURE__ */ jsx("img", { src: infoModalConfig?.previewImage }) : /* @__PURE__ */ jsx("img", { src: infoModalConfig?.previewImage })
32
- }), /* @__PURE__ */ jsx("div", {
32
+ }), /* @__PURE__ */ jsxs("div", {
33
33
  className: "p-3",
34
- children: /* @__PURE__ */ jsx("div", {
34
+ children: [/* @__PURE__ */ jsx("div", {
35
35
  className: "",
36
36
  children: packageInfo?.description
37
- })
37
+ }), infoModalConfig?.appendContent && /* @__PURE__ */ jsx("div", {
38
+ className: "mt-2",
39
+ children: infoModalConfig.appendContent
40
+ })]
38
41
  })]
39
42
  }),
40
43
  /* @__PURE__ */ jsxs(Modal.Footer, {
@@ -11,7 +11,7 @@ var SessionButton = lazy(() => import("./SessionButton.js"));
11
11
  var ReturnToLauncherButton = lazy(() => import("./ReturnToLauncherButton.js"));
12
12
  var GameScoreboard = lazy(() => import("./GameScoreboard.js"));
13
13
  var Ad = lazy(() => import("./Ad.js"));
14
- function PageTemplateLandingPage({ useStore, useSocketStore, RotatingMascot, Link, logoImage, backgroundImage, CardBodyOverride, singlePlayerConfig, multiplayerConfig, brandingTextClass, disableHero, disableAd, disableGameScoreboard, maxInnerWidth = "20rem", AdditionalContent = null, PostCardContent = null, PostExtrasContent = null, PreHeroContent = null, PostHeroContent = null, NicknameInputConfig = null, CardOverride = null, LandingBackgroundAnimation = null }) {
14
+ function PageTemplateLandingPage({ useStore, useSocketStore, RotatingMascot, Link, logoImage, backgroundImage, CardBodyOverride, singlePlayerConfig, multiplayerConfig, brandingTextClass, disableHero, heroOverride, disableAd, disableGameScoreboard, gameScoreboardConfig, maxInnerWidth = "20rem", AdditionalContent = null, PostCardContent = null, PostExtrasContent = null, PreHeroContent = null, PostHeroContent = null, NicknameInputConfig = null, CardOverride = null, LandingBackgroundAnimation = null }) {
15
15
  const { data: userToken, error: userTokenError, isLoading: userTokenLoading, mutate: userTokenMutate } = useUserToken(process.env.NEXT_PUBLIC_GAME_PORT);
16
16
  const { data: userDetails, error: userDetailsError, isLoading: userDetailsLoading, mutate: userDetailsMutate } = useUserDetails({ token: userToken });
17
17
  const darkMode = useStore((state) => state.darkMode);
@@ -42,7 +42,7 @@ function PageTemplateLandingPage({ useStore, useSocketStore, RotatingMascot, Lin
42
42
  style: { "width": maxInnerWidth },
43
43
  children: [
44
44
  PreHeroContent && PreHeroContent,
45
- !disableHero && /* @__PURE__ */ jsxs("div", {
45
+ heroOverride ? heroOverride : !disableHero && /* @__PURE__ */ jsxs("div", {
46
46
  className: "landing-hero text-center mb-2",
47
47
  children: [/* @__PURE__ */ jsx("img", {
48
48
  src: logoImage,
@@ -157,7 +157,7 @@ function PageTemplateLandingPage({ useStore, useSocketStore, RotatingMascot, Lin
157
157
  ]
158
158
  }),
159
159
  PostCardContent && PostCardContent,
160
- /* @__PURE__ */ jsxs("div", {
160
+ process.env.NEXT_PUBLIC_ENABLE_ARTICLES !== "false" && /* @__PURE__ */ jsxs("div", {
161
161
  className: "extras",
162
162
  children: [/* @__PURE__ */ jsx(SessionButton, {
163
163
  port: process.env.NEXT_PUBLIC_GAME_PORT,
@@ -180,7 +180,8 @@ function PageTemplateLandingPage({ useStore, useSocketStore, RotatingMascot, Lin
180
180
  alignItems: "center"
181
181
  },
182
182
  children: /* @__PURE__ */ jsx(RotatingMascot, {})
183
- }) })
183
+ }) }),
184
+ ...gameScoreboardConfig
184
185
  }),
185
186
  !disableAd && /* @__PURE__ */ jsx(Ad, {
186
187
  style: "Default",
@@ -246,7 +246,7 @@ function OtherTab({ useStore, config }) {
246
246
  var package_default = {
247
247
  name: "@articles-media/articles-dev-box",
248
248
  description: "Shared code, functions, and components for different Articles Media projects.",
249
- version: "1.3.1",
249
+ version: "1.3.3",
250
250
  type: "module",
251
251
  sideEffects: false,
252
252
  imports: { "#root/src/*": "./src/*" },
@@ -289,6 +289,8 @@ var package_default = {
289
289
  "./useFullscreen": "./dist/useFullscreen.js",
290
290
  "./typicalZustandStoreExcludes": "./dist/typicalZustandStoreExcludes.js",
291
291
  "./typicalZustandStoreStateSlice": "./dist/typicalZustandStoreStateSlice.js",
292
+ "./zustandSocketStoreSlice": "./dist/zustandSocketStoreSlice.js",
293
+ "./useSocketStoreSlice": "./dist/useSocketStoreSlice.js",
292
294
  "./defaultGameNextConfig": "./dist/defaultGameNextConfig.js",
293
295
  "./defaultGameThemeConfig": "./dist/defaultGameThemeConfig.js",
294
296
  "./getSignOutRedirectUrl": "./dist/getSignOutRedirectUrl.js",
@@ -1,2 +1,2 @@
1
- import { t as SettingsModal } from "./SettingsModal-BguWq4Q_.js";
1
+ import { t as SettingsModal } from "./SettingsModal-Bud-D-3m.js";
2
2
  export { SettingsModal as default };
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ import { t as GameScoreboard } from "./GameScoreboard-BvE_sIDW.js";
16
16
  import PageTemplateLandingPage from "./PageTemplateLandingPage.js";
17
17
  import GlobalHead from "./GlobalHead.js";
18
18
  import GlobalBody_default from "./GlobalBody.js";
19
- import { t as SettingsModal } from "./SettingsModal-BguWq4Q_.js";
19
+ import { t as SettingsModal } from "./SettingsModal-Bud-D-3m.js";
20
20
  import CreditsModal from "./CreditsModal.js";
21
21
  import InfoModal from "./InfoModal.js";
22
22
  import DarkModeHandler from "./DarkModeHandler.js";
@@ -27,8 +27,9 @@ import InviteModal from "./InviteModal.js";
27
27
  import ReusedSocketLogicHandler from "./ReusedSocketLogicHandler.js";
28
28
  import typicalZustandStoreExcludes from "./typicalZustandStoreExcludes.js";
29
29
  import typicalZustandStoreStateSlice from "./typicalZustandStoreStateSlice.js";
30
+ import zustandSocketStoreSlice from "./zustandSocketStoreSlice.js";
30
31
  import defaultGameNextConfig from "./defaultGameNextConfig.js";
31
32
  import getTheme from "./defaultGameThemeConfig.js";
32
33
  import getSignOutRedirectUrl from "./getSignOutRedirectUrl.js";
33
34
  import generateRandomNickname from "./generateRandomNickname.js";
34
- export { Ad_default as Ad, ArticlesAd, CreditsModal, DarkModeHandler, FriendsList, GameMenu, PrimaryButtonGroup as GameMenuPrimaryButtonGroup, GameScoreboard, GlobalBody_default as GlobalBody, GlobalHead, HasNoMouseHandler, InfoModal, InviteModal, NicknameInput, PageTemplateLandingPage, ReturnToLauncherButton, ReusedSocketLogicHandler, SessionButton, SettingsModal, SignInButton, SocketServerUrlHandler, ToontownModeHandler, ViewUserModal, defaultGameNextConfig, getTheme as defaultGameThemeConfig, generateRandomNickname, getSignOutRedirectUrl, typicalZustandStoreExcludes, typicalZustandStoreStateSlice, useFullscreen, useUserDetails, useUserFriends, useUserToken };
35
+ export { Ad_default as Ad, ArticlesAd, CreditsModal, DarkModeHandler, FriendsList, GameMenu, PrimaryButtonGroup as GameMenuPrimaryButtonGroup, GameScoreboard, GlobalBody_default as GlobalBody, GlobalHead, HasNoMouseHandler, InfoModal, InviteModal, NicknameInput, PageTemplateLandingPage, ReturnToLauncherButton, ReusedSocketLogicHandler, SessionButton, SettingsModal, SignInButton, SocketServerUrlHandler, ToontownModeHandler, ViewUserModal, defaultGameNextConfig, getTheme as defaultGameThemeConfig, generateRandomNickname, getSignOutRedirectUrl, typicalZustandStoreExcludes, typicalZustandStoreStateSlice, useFullscreen, useUserDetails, useUserFriends, useUserToken, zustandSocketStoreSlice };
@@ -101,7 +101,9 @@ var typicalZustandStoreStateSlice = (set, get, generateRandomNickname) => ({
101
101
  hasNoMouse: null,
102
102
  setHasNoMouse: (value) => set({ hasNoMouse: value }),
103
103
  isTouchCapable: null,
104
- setIsTouchCapable: (value) => set({ isTouchCapable: value })
104
+ setIsTouchCapable: (value) => set({ isTouchCapable: value }),
105
+ modelSource: process.env.NEXT_PUBLIC_MODEL_SOURCE || "Local",
106
+ setModelSource: (value) => set({ modelSource: value })
105
107
  });
106
108
  //#endregion
107
109
  export { typicalZustandStoreStateSlice as default };
@@ -5,7 +5,7 @@ var fetcher = (url) => fetch(url).then((res) => {
5
5
  return res.json();
6
6
  });
7
7
  var useUserToken = (port) => {
8
- const { data, error, isLoading, mutate } = useSWR(process.env.NODE_ENV === "development" ? `http://localhost:${port}/api/token` : "/api/token", fetcher, {
8
+ const { data, error, isLoading, mutate } = useSWR(process.env.NEXT_PUBLIC_ENABLE_ARTICLES !== "false" ? process.env.NODE_ENV === "development" ? `http://localhost:${port}/api/token` : "/api/token" : false, fetcher, {
9
9
  revalidateOnFocus: false,
10
10
  revalidateOnReconnect: false,
11
11
  shouldRetryOnError: false,
@@ -0,0 +1,51 @@
1
+ //#region src/constants/zustandSocketStoreSlice.js
2
+ var game_name_key = process.env.NEXT_PUBLIC_GAME_KEY;
3
+ function zustandSocketStoreSlice(set, get, io) {
4
+ return {
5
+ socket: io({ autoConnect: false }),
6
+ serverUrl: process.env.NEXT_PUBLIC_NODE_SERVER,
7
+ connectSocket: (url) => {
8
+ const newSocket = io(url || process.env.NEXT_PUBLIC_NODE_SERVER, {
9
+ transports: ["websocket"],
10
+ autoConnect: false,
11
+ reconnection: true,
12
+ reconnectionDelay: 5e3,
13
+ reconnectionDelayMax: 1e4,
14
+ query: { client: process.env.NEXT_PUBLIC_GAME_KEY }
15
+ });
16
+ newSocket.connect();
17
+ set({ socket: newSocket });
18
+ },
19
+ setServerUrl: (url) => set({ serverUrl: url }),
20
+ disconnectSocket: () => set((state) => {
21
+ state.socket?.disconnect();
22
+ return {};
23
+ }),
24
+ startGame: (gameId, status) => {
25
+ set((state) => {
26
+ state.socket.emit(`game:${game_name_key}:start`, {
27
+ game_id: gameId,
28
+ status
29
+ });
30
+ return {};
31
+ });
32
+ },
33
+ totalUsers: 0,
34
+ setTotalUsers: (total) => set({ totalUsers: total }),
35
+ connected: false,
36
+ setConnected: (total) => set({ connected: total }),
37
+ authenticated: false,
38
+ setAuthenticated: (value) => set({ authenticated: value }),
39
+ loginSocket: (data) => {
40
+ set((state) => {
41
+ state.socket.emit("login-socket", {
42
+ ...data,
43
+ game_name: process.env.NEXT_PUBLIC_GAME_NAME
44
+ });
45
+ return {};
46
+ });
47
+ }
48
+ };
49
+ }
50
+ //#endregion
51
+ export { zustandSocketStoreSlice as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@articles-media/articles-dev-box",
3
3
  "description": "Shared code, functions, and components for different Articles Media projects.",
4
- "version": "1.3.1",
4
+ "version": "1.3.3",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "imports": {
@@ -48,6 +48,8 @@
48
48
  "./useFullscreen": "./dist/useFullscreen.js",
49
49
  "./typicalZustandStoreExcludes": "./dist/typicalZustandStoreExcludes.js",
50
50
  "./typicalZustandStoreStateSlice": "./dist/typicalZustandStoreStateSlice.js",
51
+ "./zustandSocketStoreSlice": "./dist/zustandSocketStoreSlice.js",
52
+ "./useSocketStoreSlice": "./dist/useSocketStoreSlice.js",
51
53
  "./defaultGameNextConfig": "./dist/defaultGameNextConfig.js",
52
54
  "./defaultGameThemeConfig": "./dist/defaultGameThemeConfig.js",
53
55
  "./getSignOutRedirectUrl": "./dist/getSignOutRedirectUrl.js",