pixelass commited on
Commit
deda484
•
1 Parent(s): 34bac1b

fix: reload triggers

Browse files
Files changed (3) hide show
  1. package-lock.json +36 -0
  2. package.json +1 -0
  3. src/pages/index.tsx +21 -18
package-lock.json CHANGED
@@ -13,6 +13,7 @@
13
  "@emotion/react": "11.10.6",
14
  "@emotion/server": "11.10.0",
15
  "@emotion/styled": "11.10.6",
 
16
  "@mui/icons-material": "5.11.16",
17
  "@mui/material": "5.12.0",
18
  "axios": "1.3.5",
@@ -430,6 +431,30 @@
430
  "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz",
431
  "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA=="
432
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
433
  "node_modules/@mui/base": {
434
  "version": "5.0.0-alpha.125",
435
  "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.125.tgz",
@@ -5543,6 +5568,12 @@
5543
  "node": ">=0.10.0"
5544
  }
5545
  },
 
 
 
 
 
 
5546
  "node_modules/ms": {
5547
  "version": "2.1.2",
5548
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@@ -10648,6 +10679,11 @@
10648
  "node": ">= 6"
10649
  }
10650
  },
 
 
 
 
 
10651
  "node_modules/stop-iteration-iterator": {
10652
  "version": "1.0.0",
10653
  "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz",
 
13
  "@emotion/react": "11.10.6",
14
  "@emotion/server": "11.10.0",
15
  "@emotion/styled": "11.10.6",
16
+ "@monaco-editor/react": "4.5.0",
17
  "@mui/icons-material": "5.11.16",
18
  "@mui/material": "5.12.0",
19
  "axios": "1.3.5",
 
431
  "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz",
432
  "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA=="
433
  },
434
+ "node_modules/@monaco-editor/loader": {
435
+ "version": "1.3.3",
436
+ "resolved": "https://registry.npmjs.org/@monaco-editor/loader/-/loader-1.3.3.tgz",
437
+ "integrity": "sha512-6KKF4CTzcJiS8BJwtxtfyYt9shBiEv32ateQ9T4UVogwn4HM/uPo9iJd2Dmbkpz8CM6Y0PDUpjnZzCwC+eYo2Q==",
438
+ "dependencies": {
439
+ "state-local": "^1.0.6"
440
+ },
441
+ "peerDependencies": {
442
+ "monaco-editor": ">= 0.21.0 < 1"
443
+ }
444
+ },
445
+ "node_modules/@monaco-editor/react": {
446
+ "version": "4.5.0",
447
+ "resolved": "https://registry.npmjs.org/@monaco-editor/react/-/react-4.5.0.tgz",
448
+ "integrity": "sha512-VJMkp5Fe1+w8pLEq8tZPHZKu8zDXQIA1FtiDTSNccg1D3wg1YIZaH2es2Qpvop1k62g3c/YySRb3bnGXu2XwYQ==",
449
+ "dependencies": {
450
+ "@monaco-editor/loader": "^1.3.3"
451
+ },
452
+ "peerDependencies": {
453
+ "monaco-editor": ">= 0.25.0 < 1",
454
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
455
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
456
+ }
457
+ },
458
  "node_modules/@mui/base": {
459
  "version": "5.0.0-alpha.125",
460
  "resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-alpha.125.tgz",
 
5568
  "node": ">=0.10.0"
5569
  }
5570
  },
5571
+ "node_modules/monaco-editor": {
5572
+ "version": "0.37.1",
5573
+ "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.37.1.tgz",
5574
+ "integrity": "sha512-jLXEEYSbqMkT/FuJLBZAVWGuhIb4JNwHE9kPTorAVmsdZ4UzHAfgWxLsVtD7pLRFaOwYPhNG9nUCpmFL1t/dIg==",
5575
+ "peer": true
5576
+ },
5577
  "node_modules/ms": {
5578
  "version": "2.1.2",
5579
  "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
 
10679
  "node": ">= 6"
10680
  }
10681
  },
10682
+ "node_modules/state-local": {
10683
+ "version": "1.0.7",
10684
+ "resolved": "https://registry.npmjs.org/state-local/-/state-local-1.0.7.tgz",
10685
+ "integrity": "sha512-HTEHMNieakEnoe33shBYcZ7NX83ACUjCu8c40iOGEZsngj9zRnkqS9j1pqQPXwobB0ZcVTk27REb7COQ0UR59w=="
10686
+ },
10687
  "node_modules/stop-iteration-iterator": {
10688
  "version": "1.0.0",
10689
  "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz",
package.json CHANGED
@@ -42,6 +42,7 @@
42
  "@emotion/react": "11.10.6",
43
  "@emotion/server": "11.10.0",
44
  "@emotion/styled": "11.10.6",
 
45
  "@mui/icons-material": "5.11.16",
46
  "@mui/material": "5.12.0",
47
  "axios": "1.3.5",
 
42
  "@emotion/react": "11.10.6",
43
  "@emotion/server": "11.10.0",
44
  "@emotion/styled": "11.10.6",
45
+ "@monaco-editor/react": "4.5.0",
46
  "@mui/icons-material": "5.11.16",
47
  "@mui/material": "5.12.0",
48
  "axios": "1.3.5",
src/pages/index.tsx CHANGED
@@ -35,14 +35,16 @@ import { useHost } from "esdeka/react";
35
  import CircularProgress from "@mui/material/CircularProgress";
36
  import CssBaseline from "@mui/material/CssBaseline";
37
  import Slider from "@mui/material/Slider";
 
 
38
 
39
  const base = {
40
  default: `
41
  const canvas = document.querySelector('canvas');
42
  const ctx = canvas.getContext('2d');
43
- const FPS = 60;
44
  /*60FPS draw cycle*/
45
  function draw(){
 
46
  setTimeout(requestAnimationFrame(draw),1000/FPS)
47
  }
48
  draw();
@@ -71,7 +73,7 @@ export default function Home() {
71
  const { broadcast, call, subscribe } = useHost(ref, "fail4");
72
 
73
  const connection = useRef(false);
74
- const [tries, setTries] = useState(5);
75
 
76
  // Send a connection request
77
  useEffect(() => {
@@ -84,6 +86,8 @@ export default function Home() {
84
 
85
  const timeout = setTimeout(() => {
86
  if (current) {
 
 
87
  call({ template: current.content });
88
  }
89
 
@@ -102,9 +106,8 @@ export default function Home() {
102
  switch (action.type) {
103
  case "answer":
104
  connection.current = true;
105
- setTimeout(() => {
106
- setLoadingLive(false);
107
- }, 1_500);
108
  console.log("connected");
109
  break;
110
  default:
@@ -121,15 +124,15 @@ export default function Home() {
121
  }, [subscribe, loadingLive]);
122
 
123
  // Broadcast store to guest
124
- useEffect(() => {
125
- const current = answers.find(({ id }) => id === runningId);
126
- if (connection.current && current) {
127
- broadcast({ template: current.content });
128
- }
129
- return () => {
130
- /* Consistency */
131
- };
132
- }, [broadcast, runningId, answers]);
133
 
134
  // useEffect(() => {
135
  // const current = answers.find(({ id }) => id === runningId);
@@ -147,7 +150,7 @@ export default function Home() {
147
  if (ref.current) {
148
  ref.current.src = `/live?${nanoid()}`;
149
  setLoadingLive(true);
150
- setTries(3);
151
  }
152
  }
153
 
@@ -206,7 +209,7 @@ export default function Home() {
206
  color="inherit"
207
  aria-label="Clear Prompt"
208
  onClick={async () => {
209
- broadcast({ template: base.default });
210
  setActiveId("1");
211
  setTemplate(base.default);
212
  reload();
@@ -227,8 +230,8 @@ export default function Home() {
227
  id="prompt"
228
  name="prompt"
229
  label="Prompt"
230
- placeholder="add a red heart"
231
- defaultValue="add a red heart"
232
  maxRows={6}
233
  InputProps={{
234
  style: fontMono.style,
 
35
  import CircularProgress from "@mui/material/CircularProgress";
36
  import CssBaseline from "@mui/material/CssBaseline";
37
  import Slider from "@mui/material/Slider";
38
+ // import dynamic from "next/dynamic";
39
+ // const MonacoEditor = dynamic(import("@monaco-editor/react"), { ssr: false });
40
 
41
  const base = {
42
  default: `
43
  const canvas = document.querySelector('canvas');
44
  const ctx = canvas.getContext('2d');
 
45
  /*60FPS draw cycle*/
46
  function draw(){
47
+ const FPS = 60;
48
  setTimeout(requestAnimationFrame(draw),1000/FPS)
49
  }
50
  draw();
 
73
  const { broadcast, call, subscribe } = useHost(ref, "fail4");
74
 
75
  const connection = useRef(false);
76
+ const [tries, setTries] = useState(1);
77
 
78
  // Send a connection request
79
  useEffect(() => {
 
86
 
87
  const timeout = setTimeout(() => {
88
  if (current) {
89
+ // call({ template: "" });
90
+
91
  call({ template: current.content });
92
  }
93
 
 
106
  switch (action.type) {
107
  case "answer":
108
  connection.current = true;
109
+ setLoadingLive(false);
110
+
 
111
  console.log("connected");
112
  break;
113
  default:
 
124
  }, [subscribe, loadingLive]);
125
 
126
  // Broadcast store to guest
127
+ // useEffect(() => {
128
+ // const current = answers.find(({ id }) => id === runningId);
129
+ // if (connection.current && current) {
130
+ // broadcast({ template: current.content });
131
+ // }
132
+ // return () => {
133
+ // /* Consistency */
134
+ // };
135
+ // }, [broadcast, runningId, answers]);
136
 
137
  // useEffect(() => {
138
  // const current = answers.find(({ id }) => id === runningId);
 
150
  if (ref.current) {
151
  ref.current.src = `/live?${nanoid()}`;
152
  setLoadingLive(true);
153
+ setTries(1);
154
  }
155
  }
156
 
 
209
  color="inherit"
210
  aria-label="Clear Prompt"
211
  onClick={async () => {
212
+ // broadcast({ template: base.default });
213
  setActiveId("1");
214
  setTemplate(base.default);
215
  reload();
 
230
  id="prompt"
231
  name="prompt"
232
  label="Prompt"
233
+ placeholder="red heart"
234
+ defaultValue="red heart"
235
  maxRows={6}
236
  InputProps={{
237
  style: fontMono.style,