Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit 85a21d4

Browse files
authored
Merge pull request #181 from latitudegames/0.0.67
0.0.67
2 parents 9c1f7b6 + 8836560 commit 85a21d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+783
-175
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"type": "pwa-chrome",
99
"request": "launch",
1010
"name": "Launch Chrome against localhost",
11-
"url": "http://localhost:3001",
11+
"url": "http://localhost:3003",
1212
"sourceMap": true,
1313
"webRoot": "${workspaceFolder}/client",
1414
"trace": true,

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ In the project directory, you can run:
5050
### `yarn start`
5151

5252
Runs @thoth/client in the development mode.\
53-
Open [http://localhost:3001](http://localhost:3001) to view it in the browser.
53+
Open [http://localhost:3003](http://localhost:3003) to view it in the browser.
5454

5555
### `yarn build`
5656

client/.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ EXTEND_ESLINT = true
44

55
REACT_APP_SITE_ROOT_URL_PROD=https://thoth.latitude.io
66

7-
REACT_APP_SITE_ROOT_URL=http://localhost:3001
7+
REACT_APP_SITE_ROOT_URL=http://localhost:3003
88
REACT_APP_LAPI_ROOT_URL=http://localhost:8000
99

1010
REACT_APP_LAPI_ROOT_URL_PROD=https://api.latitude.io
@@ -15,3 +15,4 @@ REACT_APP_SITE_STAGING=https://62264f21c3a9860ad1e5bdd3--optimistic-turing-def91
1515
REACT_APP_OAUTH_CLIENT_ID=a6b51c87-7565-42ab-a4b0-38a07f3b6c56
1616

1717
REACT_APP_SHAREDB=false
18+
REACT_APP_WEBSOCKETS=false

client/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ EXTEND_ESLINT = true
22

33
# This prod site root assumes the netlify build context $URL is available, replace for other hosts
44
REACT_APP_SITE_ROOT_URL_PROD=$URL
5-
REACT_APP_SITE_ROOT_URL=http://localhost:3001
5+
REACT_APP_SITE_ROOT_URL=http://localhost:3003
66
REACT_APP_LAPI_ROOT_URL=http://localhost:8000
77
REACT_APP_LAPI_ROOT_URL_PROD=https://api.latitude.io
88
REACT_APP_SITE_STAGING=https://62264f21c3a9860ad1e5bdd3--optimistic-turing-def916.netlify.app/

client/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ In the project directory, you can run:
1515
### `yarn start`
1616

1717
Runs the app in the development mode.\
18-
Open [http://localhost:3001](http://localhost:3001) to view it in the browser.
18+
Open [http://localhost:3003](http://localhost:3003) to view it in the browser.
1919

2020
The page will reload if you make edits.\
2121
You will also see any lint errors in the console.

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@callstack/async-storage": "^2.0.3",
2424
"@emotion/react": "^11.8.2",
2525
"@emotion/styled": "^11.8.1",
26-
"@latitudegames/thoth-core": "^0.0.66",
26+
"@latitudegames/thoth-core": "^0.0.67",
2727
"@monaco-editor/react": "^4.2.1",
2828
"@mui/icons-material": "^5.5.1",
2929
"@mui/material": "^5.5.3",

client/src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ export const appRootUrl =
1212

1313
// coercing this into a boolean
1414
export const sharedb = process.env.REACT_APP_SHAREDB === 'true'
15+
export const websockets = process.env.REACT_APP_WEBSOCKETS === 'true'
1516
export const websocketUrl = 'ws://localhost:8080'

client/src/contexts/AppProviders.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import AuthProvider from './AuthProvider'
99
import PubSubProvider from './PubSubProvider'
1010
import SharedbProvider from './SharedbProvider'
1111
import ToastProvider from './ToastProvider'
12+
import WebSocketProvider from './WebSocketProvider'
1213

1314
declare module '@mui/styles/defaultTheme' {
1415
// eslint-disable-next-line @typescript-eslint/no-empty-interface
@@ -28,6 +29,7 @@ const providers = [
2829
[ThemeProvider, { theme: darkTheme }],
2930
ToastProvider,
3031
AuthProvider,
32+
WebSocketProvider,
3133
SharedbProvider,
3234
]
3335

client/src/contexts/PubSubProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const events = {
2323
UPDATE_SUBSPELL: 'updateSubspell',
2424
DELETE_SUBSPELL: 'deleteSubspell',
2525
$SUBSPELL_UPDATED: spellId => `subspellUpdated:${spellId}`,
26+
$TRIGGER: (tabId, nodeId) => `triggerNode:${tabId}:${nodeId}`,
2627
$PLAYTEST_INPUT: tabId => `playtestInput:${tabId}`,
2728
$PLAYTEST_PRINT: tabId => `playtestPrint:${tabId}`,
2829
$DEBUG_PRINT: tabId => `debugPrint:${tabId}`,

client/src/contexts/SharedbProvider.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
import { sharedb, websocketUrl } from '@/config'
1+
import { sharedb } from '@/config'
22
import { useContext, createContext, useEffect, useState } from 'react'
33
import { Doc } from 'sharedb'
44

5-
import ReconnectingWebSocket from 'reconnecting-websocket'
65
import client from 'sharedb/lib/client'
76
import { Socket } from 'sharedb/lib/sharedb'
87
import { Spell } from '@latitudegames/thoth-core/types'
98
import LoadingScreen from '@/components/LoadingScreen/LoadingScreen'
9+
import { useWebSocket } from './WebSocketProvider'
1010

1111
const Connection = client.Connection
1212

1313
interface SharedbContext {
1414
connection: client.Connection | null
15-
socket: Socket | null
1615
getSpellDoc: (spell: Spell) => Doc | null
1716
}
1817

1918
const Context = createContext<SharedbContext>({
2019
connection: null,
21-
socket: null,
2220
getSpellDoc: () => null,
2321
})
2422

@@ -28,14 +26,12 @@ export const docMap = new Map()
2826

2927
// Might want to namespace these
3028
const SharedbProvider = ({ children }) => {
31-
const [socket, setSocket] = useState<Socket | null>(null)
29+
const { socket } = useWebSocket()
3230
const [connection, setConnection] = useState<client.Connection | null>(null)
3331

3432
useEffect(() => {
35-
const _socket = new ReconnectingWebSocket(websocketUrl)
36-
const _connection = new Connection(_socket as Socket)
33+
const _connection = new Connection(socket as Socket)
3734
setConnection(_connection)
38-
setSocket(_socket as Socket)
3935
}, [])
4036

4137
const getSpellDoc = (spell: Spell) => {
@@ -61,7 +57,6 @@ const SharedbProvider = ({ children }) => {
6157
}
6258

6359
const publicInterface: SharedbContext = {
64-
socket,
6560
connection,
6661
getSpellDoc,
6762
}

0 commit comments

Comments
 (0)