Skip to content

Commit

Permalink
new release (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy authored Aug 12, 2024
2 parents 3a7e26c + f7615ae commit d5e5baa
Show file tree
Hide file tree
Showing 336 changed files with 6,514 additions and 14,226 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
node_modules
rsbuild.config.ts
*.module.css.d.ts
*.generated.ts
generated
public
98 changes: 80 additions & 18 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,75 @@
{
"extends": "zardoy",
"extends": [
"zardoy",
"plugin:@stylistic/disable-legacy"
],
"ignorePatterns": [
"!*.js",
"prismarine-viewer/"
"!*.js"
],
"plugins": [
"@stylistic"
],
"rules": {
"space-infix-ops": "error",
"no-multi-spaces": "error",
"space-before-function-paren": "error",
"space-in-parens": [
// style
"@stylistic/space-infix-ops": "error",
"@stylistic/no-multi-spaces": "error",
"@stylistic/no-trailing-spaces": "error",
"@stylistic/space-before-function-paren": "error",
"@stylistic/array-bracket-spacing": "error",
// would be great to have but breaks TS code like (url?) => ...
// "@stylistic/arrow-parens": [
// "error",
// "as-needed"
// ],
"@stylistic/arrow-spacing": "error",
"@stylistic/block-spacing": "error",
"@stylistic/brace-style": [
"error",
"never"
"1tbs",
{
"allowSingleLine": true
}
],
"object-curly-spacing": [
// too annoying to be forced to multi-line, probably should be enforced to never
// "@stylistic/comma-dangle": [
// "error",
// "always-multiline"
// ],
"@stylistic/computed-property-spacing": "error",
"@stylistic/dot-location": [
"error",
"always"
"property"
],
"@stylistic/eol-last": "error",
"@stylistic/function-call-spacing": "error",
"@stylistic/function-paren-newline": [
"error",
"consistent"
],
"@stylistic/generator-star-spacing": "error",
"@stylistic/implicit-arrow-linebreak": "error",
"@stylistic/indent-binary-ops": [
"error",
2
],
"comma-spacing": "error",
"semi": [
"@stylistic/function-call-argument-newline": [
"error",
"consistent"
],
"@stylistic/space-in-parens": [
"error",
"never"
],
"comma-dangle": [
"@stylistic/object-curly-spacing": [
"error",
"always"
],
"@stylistic/comma-spacing": "error",
"@stylistic/semi": [
"error",
// todo maybe "always-multiline"?
"only-multiline"
"never"
],
"indent": [
"@stylistic/indent": [
"error",
2,
{
Expand All @@ -36,13 +79,30 @@
]
}
],
"quotes": [
"@stylistic/quotes": [
"error",
"single",
{
"allowTemplateLiterals": true
}
],
"@stylistic/key-spacing": "error",
"@stylistic/keyword-spacing": "error",
// "@stylistic/line-comment-position": "error", // not needed
// "@stylistic/lines-around-comment": "error", // also not sure if needed
// "@stylistic/max-len": "error", // also not sure if needed
// "@stylistic/linebreak-style": "error", // let git decide
"@stylistic/max-statements-per-line": [
"error",
{
"max": 5
}
],
// "@stylistic/member-delimiter-style": "error",
// "@stylistic/multiline-ternary": "error", // not needed
// "@stylistic/newline-per-chained-call": "error", // not sure if needed
"@stylistic/new-parens": "error",
"@stylistic/no-confusing-arrow": "error",
// perf
"import/no-deprecated": "off",
// ---
Expand All @@ -52,6 +112,7 @@
// intentional: improve readability in some cases
"no-else-return": "off",
"@typescript-eslint/padding-line-between-statements": "off",
"@typescript-eslint/no-dynamic-delete": "off",
"arrow-body-style": "off",
"unicorn/prefer-ternary": "off",
"unicorn/switch-case-braces": "off",
Expand Down Expand Up @@ -88,6 +149,7 @@
"@typescript-eslint/no-confusing-void-expression": "off",
"unicorn/no-empty-file": "off",
"unicorn/prefer-event-target": "off",
"@typescript-eslint/member-ordering": "off",
// needs to be fixed actually
"complexity": "off",
"@typescript-eslint/no-floating-promises": "warn",
Expand All @@ -102,7 +164,7 @@
"*.js"
],
"rules": {
"space-before-function-paren": [
"@stylistic/space-before-function-paren": [
"error",
{
"anonymous": "always",
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
# cache: "pnpm"
- run: pnpm install
- run: pnpm check-build
- run: pnpm build-playground
- run: pnpm build-storybook
- run: pnpm test-unit
- run: pnpm lint
- run: pnpm tsx scripts/buildNpmReact.ts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/next-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- run: pnpm build-storybook
- name: Copy playground files
run: node prismarine-viewer/esbuild.mjs && cp prismarine-viewer/public/index.html .vercel/output/static/playground.html && cp prismarine-viewer/public/playground.js .vercel/output/static/playground.js
run: pnpm build-playground && cp prismarine-viewer/public/index.html .vercel/output/static/playground.html && cp prismarine-viewer/public/playground.js .vercel/output/static/playground.js
- name: Download Generated Sounds map
run: node scripts/downloadSoundsMap.mjs
- name: Deploy Project Artifacts to Vercel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- run: pnpm build-storybook
- name: Copy playground files
run: node prismarine-viewer/esbuild.mjs && cp prismarine-viewer/public/index.html .vercel/output/static/playground.html && cp prismarine-viewer/public/playground.js .vercel/output/static/playground.js
run: pnpm build-playground && cp prismarine-viewer/public/index.html .vercel/output/static/playground.html && cp prismarine-viewer/public/playground.js .vercel/output/static/playground.js
- name: Download Generated Sounds map
run: node scripts/downloadSoundsMap.mjs
- name: Deploy Project Artifacts to Vercel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- run: vercel build --token=${{ secrets.VERCEL_TOKEN }} --prod
- run: pnpm build-storybook
- name: Copy playground files
run: node prismarine-viewer/esbuild.mjs && cp prismarine-viewer/public/index.html .vercel/output/static/playground.html && cp prismarine-viewer/public/playground.js .vercel/output/static/playground.js
run: pnpm build-playground && cp prismarine-viewer/public/index.html .vercel/output/static/playground.html && cp prismarine-viewer/public/playground.js .vercel/output/static/playground.js
- name: Download Generated Sounds map
run: node scripts/downloadSoundsMap.mjs
- name: Deploy Project to Vercel
Expand Down
5 changes: 2 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"configurations": [
// UPDATED: all configs below are misconfigured and will crash vscode, open dist/index.html and use live preview debug instead
// recommended as much faster
{
// to launch "C:\Program Files\Google\Chrome Beta\Application\chrome.exe" --remote-debugging-port=9222
Expand Down Expand Up @@ -29,7 +28,7 @@
"type": "chrome",
"name": "Launch Chrome",
"request": "launch",
"url": "http://localhost:8080/",
"url": "http://localhost:3000/",
"pathMapping": {
"/": "${workspaceFolder}/dist"
},
Expand All @@ -50,7 +49,7 @@
"name": "Attach Firefox",
"request": "attach",
// comment if using webpack
"url": "http://localhost:8080/",
"url": "http://localhost:3000/",
"webRoot": "${workspaceFolder}/",
"skipFiles": [
// "<node_internals>/**/*vendors*"
Expand Down
42 changes: 39 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,50 @@ After forking the repository, run the following commands to get started:

## Project Structure

There are 3 main parts of the project:

### Core (`src`)

This is the main app source code which reuses all the other parts of the project.

> The first version used Webpack, then was migrated to Esbuild and now is using Rsbuild!
- Scripts:
- Start: `pnpm start`, `pnpm dev-rsbuild` (if you don't need proxy server also running)
- Build: `pnpm build` (note that `build` script builds only the core app, not the whole project!)

Paths:

- `src` - main app source code
- `src/react` - React components - almost all UI is in this folder. Almost every component has its base (reused in app and storybook) and `Provider` - which is a component that provides context to its children. Consider looking at DeathScreen component to see how it's used.
- `src/menus` - Old Lit Element GUI. In the process of migration to React.

- `prismarine-viewer` - Improved version of <https://github.com/prismarineJS/prismarine-viewer>. Here is everything related to rendering the game world itself (no ui at all). Two most important parts here are:
### Renderer: Playground & Mesher (`prismarine-viewer`)

- Playground Scripts:
- Start: `pnpm run-playground` (playground, mesher + server) or `pnpm watch-playground`
- Build: `pnpm build-playground` or `node prismarine-viewer/esbuild.mjs`

- Mesher Scripts:
- Start: `pnpm watch-mesher`
- Build: `pnpm build-mesher`

Paths:

- `prismarine-viewer` - Improved and refactored version of <https://github.com/prismarineJS/prismarine-viewer>. Here is everything related to rendering the game world itself (no ui at all). Two most important parts here are:
- `prismarine-viewer/viewer/lib/worldrenderer.ts` - adding new objects to three.js happens here (sections)
- `prismarine-viewer/viewer/lib/models.ts` - preparing data for rendering (blocks) - happens in worker: out file - `worker.js`, building - `prismarine-viewer/buildWorker.mjs`
- `prismarine-viewer/examples/playground.ts` - Playground (source of <mcraft.fun/playground.html>) Use this for testing render changes. You can also modify playground code.
- `prismarine-viewer/examples/playground.ts` - Playground (source of <mcraft.fun/playground.html>) Use this for testing any rendering changes. You can also modify the playground code.

### Storybook (`.storybook`)

Storybook is a tool for easier developing and testing React components.
Path of all Storybook stories is `src/react/**/*.stories.tsx`.

- Scripts:
- Start: `pnpm storybook`
- Build: `pnpm build-storybook`

## Core-related

How different modules are used:

Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# ---- Build Stage ----
FROM node:18-alpine AS build
# Without git installing the npm packages fails
RUN apk add --no-cache git python3 make g++ cairo-dev pango-dev jpeg-dev giflib-dev librsvg-dev
RUN apk add git
WORKDIR /app
COPY . /app
# install pnpm
RUN npm i -g [email protected]
RUN pnpm install
# TODO need flat --no-root-optional
RUN node ./scripts/dockerPrepare.mjs
RUN pnpm i

# TODO for development
# EXPOSE 9090
Expand All @@ -29,4 +31,4 @@ RUN npm i -g [email protected]
RUN npm init -yp
RUN pnpm i express github:zardoy/prismarinejs-net-browserify compression cors
EXPOSE 8080
ENTRYPOINT ["node", "server.js"]
ENTRYPOINT ["node", "server.js", "--prod"]
Loading

0 comments on commit d5e5baa

Please sign in to comment.