Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAGPIE integration (sims in analyzer) #1186

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile-fe
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ENV PATH /opt/liwords-ui/node_modules/.bin:$PATH

COPY ./liwords-ui/package.json ./liwords-ui/package-lock.json ./
COPY ./liwords-ui/wolges-wasm-pkg ./wolges-wasm-pkg
COPY ./liwords-ui/magpie-wasm-pkg ./magpie-wasm-pkg

RUN ["npm", "ci"]

Expand Down
14 changes: 13 additions & 1 deletion cmd/liwords-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,18 @@ func NewLoggingServerHooks() *twirp.ServerHooks {
}
}

// this CORS middleware is needed for SharedArrayBuffer to be enabled!
// func corsMiddlewareGenerator() (mw func(http.Handler) http.Handler) {
// mw = func(h http.Handler) http.Handler {
// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// w.Header().Add("Cross-Origin-Opener-Policy", "same-origin")
// w.Header().Add("Cross-Origin-Embedder-Policy", "require-corp")
// h.ServeHTTP(w, r)
// })
// }
// return
// }

// func NewInterceptorCustomError() twirp.Interceptor {
// return func(next twirp.Method) twirp.Method {
// return func(ctx context.Context, req interface{}) (interface{}, error) {
Expand Down Expand Up @@ -197,7 +209,7 @@ func main() {
apiserver.AuthenticationMiddlewareGenerator(stores.SessionStore),
apiserver.APIKeyMiddlewareGenerator(),
config.CtxMiddlewareGenerator(cfg),

// corsMiddlewareGenerator(),
hlog.AccessHandler(func(r *http.Request, status int, size int, d time.Duration) {
path := strings.Split(r.URL.Path, "/")
method := path[len(path)-1]
Expand Down
7 changes: 4 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ services:
# networks:
# - aeronet

socket:
&socketsetup
socket: &socketsetup
build:
context: ../liwords-socket
dockerfile: Dockerfile-dev
Expand Down Expand Up @@ -209,7 +208,9 @@ services:
- traefik.enable=true

- "traefik.http.middlewares.floc.headers.customresponseheaders.Permissions-Policy=interest-cohort=()"
- "traefik.http.routers.liwords-fe.middlewares=floc"
- "traefik.http.middlewares.cors-opener.headers.customresponseheaders.Cross-Origin-Opener-Policy=same-origin"
- "traefik.http.middlewares.cors-embedder.headers.customresponseheaders.Cross-Origin-Embedder-Policy=require-corp"
- "traefik.http.routers.liwords-fe.middlewares=floc,cors-opener,cors-embedder"
- "traefik.http.routers.liwords-fe.rule=PathPrefix(`/`)"
- "traefik.http.routers.liwords-fe.service=liwords-fe-service"
- "traefik.http.routers.liwords-fe.entrypoints=web"
Expand Down
1 change: 1 addition & 0 deletions liwords-ui/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ build/*
public/*
src/react-app-env.d.ts
src/serviceWorker.ts
magpie-wasm-pkg/*
3 changes: 2 additions & 1 deletion liwords-ui/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
src/gen/**/*.js
src/gen/**/*.ts
src/gen/**/*.ts
src/magpie-wasm-pkg/*
39 changes: 20 additions & 19 deletions liwords-ui/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@ module.exports = {
// reduce bundle size by only including antd icons we need
resolve: {
alias: {
"@ant-design/icons$": path.resolve(__dirname, "./src/icons.js")
}
'@ant-design/icons$': path.resolve(__dirname, './src/icons.js'),
},
},

webpack: function(config, env) {
webpack: function (config, env) {
/*
const wasmExtensionRegExp = /\.wasm$/;
config.module.rules.forEach((rule) => {
(rule.oneOf || []).forEach((oneOf) => {
(rule.oneOf || []).forEach((oneOf) => {
if (!oneOf.loader && oneOf.type === 'asset/resource') {
oneOf.exclude.push(wasmExtensionRegExp);
oneOf.exclude.push(wasmExtensionRegExp);
}
});
});
});

*/
config.experiments = {
asyncWebAssembly: true,
asyncWebAssembly: true,
};
return config;
},

devServer: function(configFunction) {
return function(proxy, allowedHost) {
devServer: function (configFunction) {
return function (proxy, allowedHost) {
const config = configFunction(proxy, allowedHost);
config.webSocketServer = config.webSocketServer || {};
config.webSocketServer.options = {
Expand All @@ -35,20 +36,20 @@ module.exports = {
if (process.env.WDS_PROXY) {
console.log('Webpack dev-server proxy is on...');
config.proxy = {
...config.proxy,
'/twirp': 'http://localhost:8001',
'/gameimg': 'http://localhost:8001',
'/ws': {
target: 'ws://localhost:8087',
ws: true
}
...config.proxy,
'/twirp': 'http://localhost:8001',
'/gameimg': 'http://localhost:8001',
'/ws': {
target: 'ws://localhost:8087',
ws: true,
},
};
}
config.client = {
...config.client,
overlay: false,
};
return config;
}
}
};
},
};
Loading