diff --git a/proto.sh b/proto.sh index cc61e79..f7b13ff 100644 --- a/proto.sh +++ b/proto.sh @@ -1,3 +1,10 @@ #!/usr/bin/env sh -protoc -I="./protos" --go_out="./pkg" --js_out=import_style=commonjs,binary:"web/player/src/protos" ./protos/*.proto +# protoc -I="./protos" --go_out="./pkg" --js_out=library=blubli,binary:"web/src/Player/protos" ./protos/*.proto +# protoc -I="./protos" --js_out=library=Message_pb,binary:"web/src/Player/protos" ./protos/*.proto +protoc -I="./protos" --js_out=import_style=commonjs,binary:"web/src/Player/protos" ./protos/*.proto + +# import jspb from 'google-protobuf' + +# // var jspb = require('google-protobuf'); +# goog.object.extend(window.proto = window.proto || {}, proto.csgo); \ No newline at end of file diff --git a/web/src/Player/App.jsx b/web/src/Player/App.jsx index 1d677e5..5fd414e 100644 --- a/web/src/Player/App.jsx +++ b/web/src/Player/App.jsx @@ -6,12 +6,12 @@ import Player from "./Player"; import Map2d from "./map/Map2d"; import InfoPanel from "./panel/InfoPanel"; import '../libs/wasm_exec.js'; +import './protos/Message_pb.js' export function PlayerApp() { const [messageBus] = useState(new MessageBus()) const [player] = useState(new Player(messageBus)) const [serverHost] = useState(window.location.host.includes("localhost") ? "http://localhost:8080" : ""); - const proto = require("./protos/Message_pb.js"); useEffect(() => { console.log("run run run") diff --git a/web/src/Player/index.js b/web/src/Player/index.js deleted file mode 100644 index edbf7b4..0000000 --- a/web/src/Player/index.js +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import './index.css'; -import App from './App'; -import reportWebVitals from './reportWebVitals'; -import {createRoot} from 'react-dom/client'; - -const container = document.getElementById('root'); -const root = createRoot(container); -root.render(); - -// If you want to start measuring performance in your app, pass a function -// to log results (for example: reportWebVitals(console.log)) -// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals -if (window.location.host.includes("localhost")) { - reportWebVitals(console.log); -} diff --git a/web/src/Player/protos/Message_pb.js b/web/src/Player/protos/Message_pb.js index ba0db80..7c7a84d 100644 --- a/web/src/Player/protos/Message_pb.js +++ b/web/src/Player/protos/Message_pb.js @@ -10,16 +10,17 @@ // GENERATED CODE -- DO NOT EDIT! /* eslint-disable */ // @ts-nocheck +import jspb from 'google-protobuf' -var jspb = require('google-protobuf'); +// var jspb = require('google-protobuf'); var goog = jspb; -var global = (function() { - if (this) { return this; } - if (typeof window !== 'undefined') { return window; } - if (typeof global !== 'undefined') { return global; } - if (typeof self !== 'undefined') { return self; } - return Function('return this')(); -}.call(null)); +var global = + (typeof globalThis !== 'undefined' && globalThis) || + (typeof window !== 'undefined' && window) || + (typeof global !== 'undefined' && global) || + (typeof self !== 'undefined' && self) || + (function () { return this; }).call(null) || + Function('return this')(); goog.exportSymbol('proto.csgo.Bomb', null, global); goog.exportSymbol('proto.csgo.Bomb.BombState', null, global); @@ -4400,4 +4401,4 @@ proto.csgo.Demo.prototype.setPlatform = function(value) { }; -goog.object.extend(exports, proto.csgo); +goog.object.extend(window.proto = window.proto || {}, proto.csgo); diff --git a/web/vite.config.js b/web/vite.config.js index 0e309b2..e43bd1f 100644 --- a/web/vite.config.js +++ b/web/vite.config.js @@ -4,4 +4,6 @@ import preact from '@preact/preset-vite'; // https://vitejs.dev/config/ export default defineConfig({ plugins: [preact()], + open: true, + port: 3000, });