code-battles 1.5.7 → 1.5.8

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.
Files changed (62) hide show
  1. package/dist/cjs/index.js +10 -17
  2. package/dist/esm/index.js +10 -17
  3. package/package.json +9 -8
  4. package/dist/code_battles/__init__.py +0 -31
  5. package/dist/code_battles/__pycache__/__init__.cpython-312.pyc +0 -0
  6. package/dist/code_battles/__pycache__/battles.cpython-312.pyc +0 -0
  7. package/dist/code_battles/__pycache__/utilities.cpython-312.pyc +0 -0
  8. package/dist/code_battles/battles.py +0 -970
  9. package/dist/code_battles/js.pyi +0 -136
  10. package/dist/code_battles/pyodide/ffi/__init__.pyi +0 -2
  11. package/dist/code_battles/pyscript/__init__.pyi +0 -4
  12. package/dist/code_battles/pyscript/ffi/__init__.pyi +0 -3
  13. package/dist/code_battles/utilities.py +0 -321
  14. package/dist/code_battles/worker.py +0 -6
  15. package/dist/pyscript/codemirror-BEtcgaoQ.js +0 -2
  16. package/dist/pyscript/codemirror-BEtcgaoQ.js.map +0 -1
  17. package/dist/pyscript/codemirror_commands-DDxffOmd.js +0 -2
  18. package/dist/pyscript/codemirror_commands-DDxffOmd.js.map +0 -1
  19. package/dist/pyscript/codemirror_lang-python-CnWnFqxD.js +0 -2
  20. package/dist/pyscript/codemirror_lang-python-CnWnFqxD.js.map +0 -1
  21. package/dist/pyscript/codemirror_language-CjmvX4ix.js +0 -2
  22. package/dist/pyscript/codemirror_language-CjmvX4ix.js.map +0 -1
  23. package/dist/pyscript/codemirror_state-D1qTXrff.js +0 -2
  24. package/dist/pyscript/codemirror_state-D1qTXrff.js.map +0 -1
  25. package/dist/pyscript/codemirror_view-DVb8uYMr.js +0 -2
  26. package/dist/pyscript/codemirror_view-DVb8uYMr.js.map +0 -1
  27. package/dist/pyscript/core-CjO3FOKB.js +0 -2
  28. package/dist/pyscript/core-CjO3FOKB.js.map +0 -1
  29. package/dist/pyscript/core.css +0 -1
  30. package/dist/pyscript/core.js +0 -2
  31. package/dist/pyscript/core.js.map +0 -1
  32. package/dist/pyscript/deprecations-manager-pFtn19mE.js +0 -2
  33. package/dist/pyscript/deprecations-manager-pFtn19mE.js.map +0 -1
  34. package/dist/pyscript/error-tq-z48YI.js +0 -2
  35. package/dist/pyscript/error-tq-z48YI.js.map +0 -1
  36. package/dist/pyscript/index-S1Do43bx.js +0 -2
  37. package/dist/pyscript/index-S1Do43bx.js.map +0 -1
  38. package/dist/pyscript/mpy-DovD7Qjy.js +0 -2
  39. package/dist/pyscript/mpy-DovD7Qjy.js.map +0 -1
  40. package/dist/pyscript/py-BUsUWVJg.js +0 -2
  41. package/dist/pyscript/py-BUsUWVJg.js.map +0 -1
  42. package/dist/pyscript/py-editor-CeySmmer.js +0 -2
  43. package/dist/pyscript/py-editor-CeySmmer.js.map +0 -1
  44. package/dist/pyscript/py-terminal-CH_wV7wQ.js +0 -2
  45. package/dist/pyscript/py-terminal-CH_wV7wQ.js.map +0 -1
  46. package/dist/pyscript/storage.js +0 -2
  47. package/dist/pyscript/storage.js.map +0 -1
  48. package/dist/pyscript/toml-CvAfdf9_.js +0 -3
  49. package/dist/pyscript/toml-CvAfdf9_.js.map +0 -1
  50. package/dist/pyscript/toml-DiUM0_qs.js +0 -3
  51. package/dist/pyscript/toml-DiUM0_qs.js.map +0 -1
  52. package/dist/pyscript/xterm-BY7uk_OU.js +0 -2
  53. package/dist/pyscript/xterm-BY7uk_OU.js.map +0 -1
  54. package/dist/pyscript/xterm-readline-CZfBw7ic.js +0 -2
  55. package/dist/pyscript/xterm-readline-CZfBw7ic.js.map +0 -1
  56. package/dist/pyscript/xterm.css +0 -7
  57. package/dist/pyscript/xterm_addon-fit--gyF3PcZ.js +0 -2
  58. package/dist/pyscript/xterm_addon-fit--gyF3PcZ.js.map +0 -1
  59. package/dist/pyscript/xterm_addon-web-links-Cnej-nJ6.js +0 -2
  60. package/dist/pyscript/xterm_addon-web-links-Cnej-nJ6.js.map +0 -1
  61. package/dist/pyscript/zip-DrwYHuF9.js +0 -2
  62. package/dist/pyscript/zip-DrwYHuF9.js.map +0 -1
package/dist/cjs/index.js CHANGED
@@ -8,6 +8,7 @@ var core = require('@mantine/core');
8
8
  var dates = require('@mantine/dates');
9
9
  var hooks = require('@mantine/hooks');
10
10
  var notifications = require('@mantine/notifications');
11
+ require('dayjs/locale/en');
11
12
  var app = require('firebase/app');
12
13
  var auth = require('firebase/auth');
13
14
  var firestore = require('firebase/firestore');
@@ -16,14 +17,6 @@ var reactRouterDom = require('react-router-dom');
16
17
  var dropzone = require('@mantine/dropzone');
17
18
  var jsxRuntime = require('react/jsx-runtime');
18
19
 
19
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
20
-
21
- var en = {exports: {}};
22
-
23
- (function (module, exports) {
24
- !function(e,n){module.exports=n();}(commonjsGlobal,(function(){return {name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var n=["th","st","nd","rd"],t=e%100;return "["+e+(n[(t-20)%10]||n[t]||n[0])+"]"}}}));
25
- } (en));
26
-
27
20
  /*! *****************************************************************************
28
21
  Copyright (c) Microsoft Corporation.
29
22
 
@@ -458,7 +451,7 @@ const useLocalStorage = ({ key, defaultValue, }) => {
458
451
  const userSetValue = (newValue) => {
459
452
  setValue(newValue);
460
453
  if (typeof newValue === "function") {
461
- newValue = newValue(value);
454
+ newValue = newValue(getLocalStorage(key, defaultValue !== null && defaultValue !== void 0 ? defaultValue : null));
462
455
  }
463
456
  if (newValue !== undefined) {
464
457
  localStorage.setItem(key, JSON.stringify(newValue));
@@ -515,6 +508,8 @@ const useAdmin = () => {
515
508
  return (((_a = authentication.currentUser) === null || _a === void 0 ? void 0 : _a.email) === `${configuration.admin}@gmail.com`);
516
509
  };
517
510
 
511
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
512
+
518
513
  var propTypes = {exports: {}};
519
514
 
520
515
  var reactIs = {exports: {}};
@@ -15857,10 +15852,6 @@ const AutoScrollButton = () => {
15857
15852
  key: "Auto Scroll",
15858
15853
  defaultValue: true,
15859
15854
  });
15860
- React.useEffect(() => {
15861
- // @ts-ignore
15862
- window.autoScroll = autoScroll;
15863
- }, [autoScroll]);
15864
15855
  return (React.createElement(core.Button, { color: autoScroll ? "green" : "yellow", fullWidth: true, mb: "xs", leftSection: React.createElement("i", { className: "fa-solid fa-angles-down" }), onClick: () => setAutoScroll((s) => !s) },
15865
15856
  "Auto Scroll ",
15866
15857
  autoScroll ? "Enabled" : "Disabled"));
@@ -15892,13 +15883,15 @@ const LogViewer = ({ playerNames }) => {
15892
15883
  const con = document.getElementById("console");
15893
15884
  if (con) {
15894
15885
  setLogs((l) => [...l, { playerIndex, text, color }]);
15895
- // @ts-ignore
15896
- if (window.autoScroll) {
15897
- con.scrollTop = con.scrollHeight;
15898
- }
15899
15886
  }
15900
15887
  };
15901
15888
  }, []);
15889
+ React.useEffect(() => {
15890
+ const con = document.getElementById("console");
15891
+ if (con && getLocalStorage("Auto Scroll", true)) {
15892
+ con.scrollTop = con.scrollHeight;
15893
+ }
15894
+ }, [logs]);
15902
15895
  return (React.createElement(React.Fragment, null,
15903
15896
  React.createElement("h1", { style: { color: "white", textAlign: "center", margin: 0 } }, "Console"),
15904
15897
  React.createElement(AutoScrollButton, null),
package/dist/esm/index.js CHANGED
@@ -6,6 +6,7 @@ import { TextInput, Button, Alert, Slider, Box, Select, NumberInput, Table, Badg
6
6
  import { TimeInput, DatesProvider } from '@mantine/dates';
7
7
  import { useColorScheme, useViewportSize } from '@mantine/hooks';
8
8
  import { notifications, Notifications } from '@mantine/notifications';
9
+ import 'dayjs/locale/en';
9
10
  import { initializeApp } from 'firebase/app';
10
11
  import { onAuthStateChanged, signInWithEmailAndPassword, signOut, getAuth } from 'firebase/auth';
11
12
  import { onSnapshot, refEqual, doc, getDoc, setDoc, Timestamp, getFirestore } from 'firebase/firestore';
@@ -14,14 +15,6 @@ import { useNavigate, useLocation, useParams, useSearchParams, Routes, Route, Br
14
15
  import { Dropzone } from '@mantine/dropzone';
15
16
  import { jsx } from 'react/jsx-runtime';
16
17
 
17
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
18
-
19
- var en = {exports: {}};
20
-
21
- (function (module, exports) {
22
- !function(e,n){module.exports=n();}(commonjsGlobal,(function(){return {name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var n=["th","st","nd","rd"],t=e%100;return "["+e+(n[(t-20)%10]||n[t]||n[0])+"]"}}}));
23
- } (en));
24
-
25
18
  /*! *****************************************************************************
26
19
  Copyright (c) Microsoft Corporation.
27
20
 
@@ -456,7 +449,7 @@ const useLocalStorage = ({ key, defaultValue, }) => {
456
449
  const userSetValue = (newValue) => {
457
450
  setValue(newValue);
458
451
  if (typeof newValue === "function") {
459
- newValue = newValue(value);
452
+ newValue = newValue(getLocalStorage(key, defaultValue !== null && defaultValue !== void 0 ? defaultValue : null));
460
453
  }
461
454
  if (newValue !== undefined) {
462
455
  localStorage.setItem(key, JSON.stringify(newValue));
@@ -513,6 +506,8 @@ const useAdmin = () => {
513
506
  return (((_a = authentication.currentUser) === null || _a === void 0 ? void 0 : _a.email) === `${configuration.admin}@gmail.com`);
514
507
  };
515
508
 
509
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
510
+
516
511
  var propTypes = {exports: {}};
517
512
 
518
513
  var reactIs = {exports: {}};
@@ -15855,10 +15850,6 @@ const AutoScrollButton = () => {
15855
15850
  key: "Auto Scroll",
15856
15851
  defaultValue: true,
15857
15852
  });
15858
- useEffect(() => {
15859
- // @ts-ignore
15860
- window.autoScroll = autoScroll;
15861
- }, [autoScroll]);
15862
15853
  return (React.createElement(Button, { color: autoScroll ? "green" : "yellow", fullWidth: true, mb: "xs", leftSection: React.createElement("i", { className: "fa-solid fa-angles-down" }), onClick: () => setAutoScroll((s) => !s) },
15863
15854
  "Auto Scroll ",
15864
15855
  autoScroll ? "Enabled" : "Disabled"));
@@ -15890,13 +15881,15 @@ const LogViewer = ({ playerNames }) => {
15890
15881
  const con = document.getElementById("console");
15891
15882
  if (con) {
15892
15883
  setLogs((l) => [...l, { playerIndex, text, color }]);
15893
- // @ts-ignore
15894
- if (window.autoScroll) {
15895
- con.scrollTop = con.scrollHeight;
15896
- }
15897
15884
  }
15898
15885
  };
15899
15886
  }, []);
15887
+ useEffect(() => {
15888
+ const con = document.getElementById("console");
15889
+ if (con && getLocalStorage("Auto Scroll", true)) {
15890
+ con.scrollTop = con.scrollHeight;
15891
+ }
15892
+ }, [logs]);
15900
15893
  return (React.createElement(React.Fragment, null,
15901
15894
  React.createElement("h1", { style: { color: "white", textAlign: "center", margin: 0 } }, "Console"),
15902
15895
  React.createElement(AutoScrollButton, null),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-battles",
3
- "version": "1.5.7",
3
+ "version": "1.5.8",
4
4
  "description": "A library for building interactive competitive coding battles",
5
5
  "repository": "https://github.com/noamzaks/code-battles",
6
6
  "homepage": "https://code-battles.readthedocs.org",
@@ -38,12 +38,13 @@
38
38
  "tsparticles": "^3.5.0"
39
39
  },
40
40
  "peerDependencies": {
41
- "@mantine/core": "^7.13.5",
42
- "@mantine/dates": "^7.13.5",
43
- "@mantine/dropzone": "^7.13.5",
44
- "@mantine/hooks": "^7.13.5",
45
- "@mantine/notifications": "^7.13.5",
46
- "firebase": "^11.0.1",
41
+ "@mantine/core": "^7.14.0",
42
+ "@mantine/dates": "^7.14.0",
43
+ "@mantine/dropzone": "^7.14.0",
44
+ "@mantine/hooks": "^7.14.0",
45
+ "@mantine/notifications": "^7.14.0",
46
+ "dayjs": "^1.11.13",
47
+ "firebase": "^11.0.2",
47
48
  "react": "^18.3.1",
48
49
  "react-dom": "^18.3.1",
49
50
  "react-router-dom": "^6.28.0"
@@ -57,7 +58,7 @@
57
58
  "@types/react": "^18.3.12",
58
59
  "@types/react-dom": "^18.3.1",
59
60
  "chokidar-cli": "^3.0.0",
60
- "rollup": "^4.24.4",
61
+ "rollup": "^4.26.0",
61
62
  "rollup-plugin-copy": "^3.5.0",
62
63
  "rollup-plugin-dts": "^6.1.1",
63
64
  "rollup-plugin-import-css": "^3.5.6",
@@ -1,31 +0,0 @@
1
- import sys
2
-
3
- from code_battles.utilities import GameCanvas, Alignment, is_web, is_worker
4
- from code_battles.battles import CodeBattles
5
-
6
-
7
- def run_game(battles: CodeBattles):
8
- """
9
- Binds the given code battles instance to the React code to enable all simulations.
10
- """
11
-
12
- if is_web():
13
- from js import window
14
- from pyscript.ffi import create_proxy
15
-
16
- window._startSimulation = create_proxy(battles._start_simulation)
17
- window._startSimulationFromFile = create_proxy(
18
- battles._start_simulation_from_file
19
- )
20
- elif is_worker():
21
- setattr(
22
- sys.modules["__main__"],
23
- "_run_webworker_simulation",
24
- battles._run_webworker_simulation,
25
- )
26
- setattr(sys.modules["__main__"], "__export__", ["_run_webworker_simulation"])
27
- else:
28
- battles._run_local_simulation()
29
-
30
-
31
- __all__ = ["CodeBattles", "GameCanvas", "Alignment", "run_game"]