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

A lot of cool features! #14

Merged
merged 42 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
82e5a93
test vercel preview deploys on ci
zardoy Sep 1, 2023
dabbadf
oops fix prevuilt target
zardoy Sep 1, 2023
f166de5
vercel: get correct env
zardoy Sep 1, 2023
ce7ddd5
fix dragndrop files in firefox and / action
zardoy Sep 1, 2023
ac0170b
download minecraft-data on demand
zardoy Sep 2, 2023
a228e1c
allow to load worlf from ?map= qs url
zardoy Sep 2, 2023
e2bb768
refactor to utils for fixes
zardoy Sep 2, 2023
3a87bc4
add eruda
zardoy Sep 2, 2023
0406f48
cleanup preparedata
zardoy Sep 2, 2023
2f11aeb
try to fix with css loading with webpack + new space-squid esbuild re…
zardoy Sep 3, 2023
cfb04a1
fix inventory & hotbar crash on unknown itme
zardoy Sep 3, 2023
b396d3f
add firefox attach config that I don't use
zardoy Sep 3, 2023
ee67e85
add singleplayer explainer a few load steps
zardoy Sep 3, 2023
d6824aa
do not bundle large assets package, cleanup esbuildPlugins
zardoy Sep 3, 2023
7f7ff2c
speed preparedata
zardoy Sep 3, 2023
091ccaf
fix always showing mobile inventory button
zardoy Sep 3, 2023
ce6e02e
refactor controls to use contro-max!
zardoy Sep 4, 2023
3bf2b28
fix sw error, cache mc-data
zardoy Sep 4, 2023
babf7ae
controls: use ctrl only as activation to match original game behavior
zardoy Sep 4, 2023
2244e17
dispose world on exit (that should finally allow clean exit)
zardoy Sep 4, 2023
360ed68
singlePlayerServer -> localServer (intention: will allow other player…
zardoy Sep 4, 2023
327504a
upstream fork changes
zardoy Sep 4, 2023
aa58d05
display sync error as well!
zardoy Sep 4, 2023
e34d780
change default singleplayer version to 1.8.8 as it supports more feat…
zardoy Sep 4, 2023
0f096be
add visual sneaking + touch support
zardoy Sep 4, 2023
f44c1d6
add force reload chunks (F3+A)
zardoy Sep 4, 2023
caff286
enable eruda only on mobile
zardoy Sep 4, 2023
ea7e0b9
loadFolder -> loadSave
zardoy Sep 4, 2023
3daefc2
build prismarine-viewer locally which should increase install speed
zardoy Sep 4, 2023
32482d8
add a way to disable prompts on load
zardoy Sep 4, 2023
568ca7c
add a way to always init eruda
zardoy Sep 4, 2023
4a56c66
try to use prepare instead of postinstall
zardoy Sep 4, 2023
e54ab51
should fix build
zardoy Sep 4, 2023
bbb3c13
fix autoversion (download data on demand)
zardoy Sep 4, 2023
1605c4f
fix regression (hopefully have tests)
zardoy Sep 4, 2023
bd8fa23
not sure how but try to disable automatic deploys on vercel
zardoy Sep 4, 2023
cd050b0
rn workflow, fixes
zardoy Sep 4, 2023
6c675ad
disable silent
zardoy Sep 4, 2023
0535c20
try to increaese snapshot timeout
zardoy Sep 4, 2023
29e6851
better download ui & fix qs conflict
zardoy Sep 4, 2023
d1e658a
dont test before publish
zardoy Sep 4, 2023
6e2dfb7
fix: excellent in-game gamepad support
zardoy Sep 4, 2023
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
23 changes: 23 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Vercel Deploy Preview
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
workflow_dispatch:
pull_request:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Global Dependencies
run: npm install --global vercel pnpm
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
18 changes: 9 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
run: npm i -g pnpm
- run: pnpm install
- run: pnpm build
- uses: cypress-io/github-action@v5
with:
install: false
start: pnpm prod-start
- uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-images
path: cypress/integration/__image_snapshots__/
# - uses: cypress-io/github-action@v5
# with:
# install: false
# start: pnpm prod-start
# - uses: actions/upload-artifact@v3
# if: failure()
# with:
# name: cypress-images
# path: cypress/integration/__image_snapshots__/
- uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_modules/
package-lock.json
.vscode
public
**/public
*.log
.env.local
Thumbs.db
Expand All @@ -13,3 +13,4 @@ dist
world
out
*.iml
.vercel
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"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 @@ -43,5 +44,18 @@
"<node_internals>/**/*minecraftData*"
],
},
{
// to launch "C:\Program Files\Mozilla Firefox\firefox.exe" -start-debugger-server
"type": "firefox",
"name": "Attach Firefox",
"request": "attach",
// comment if using webpack
"url": "http://localhost:8080/",
"webRoot": "${workspaceFolder}/",
"skipFiles": [
// "<node_internals>/**/*vendors*"
"<node_internals>/**/*minecraftData*"
],
},
]
}
2 changes: 1 addition & 1 deletion cypress/integration/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ it('Loads & renders singleplayer', () => {
// todo replace with data-test
cy.get('#title-screen').find('.menu > div:nth-child(2) > pmui-button:nth-child(1)', { includeShadowDom: true, }).click()
// todo implement load event
cy.wait(6000)
cy.wait(12000)
//@ts-ignore
cy.get('body').toMatchImageSnapshot({
// imageConfig: {
Expand Down
18 changes: 2 additions & 16 deletions esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@ import { getSwAdditionalEntries } from './scripts/build.js'
/** @type {import('esbuild').BuildOptions} */
let baseConfig = {}

// // legacy html config
// baseConfig = {
// entryPoints: ['index.html'],
// assetNames: 'assets/[name]',
// chunkNames: '[ext]/[name]',
// outdir: 'dist',
// outfile: undefined,
// plugins: [
// htmlPlugin({
// scriptsTarget: 'esnext',
// })
// ],
// }

// // testing config
// baseConfig = {
// entryPoints: ['files/index.js'],
Expand All @@ -35,8 +21,7 @@ try {
await import('./localSettings.mjs')
} catch { }

fs.copyFileSync('index.html', 'dist/index.html')
fs.writeFileSync('dist/index.html', fs.readFileSync('dist/index.html', 'utf8').replace('<!-- inject script -->', '<script src="index.js"></script>'), 'utf8')
fs.writeFileSync('dist/index.html', fs.readFileSync('index.html', 'utf8').replace('<!-- inject script -->', '<script src="index.js"></script>'), 'utf8')

const watch = process.argv.includes('--watch') || process.argv.includes('-w')
const prod = process.argv.includes('--prod')
Expand Down Expand Up @@ -142,6 +127,7 @@ if (watch) {
skipWaiting: true,
clientsClaim: true,
additionalManifestEntries: getSwAdditionalEntries(),
globPatterns: [],
swDest: 'dist/service-worker.js',
})
}
Expand Down
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<script>
window.startLoad = Date.now()
</script>
<script type="module">
window.addEventListener('hashchange', (e) => {
if (e.newURL.endsWith('#dev')) {
// todo precache (check offline)?
import('https://cdn.skypack.dev/eruda').then(({ default: eruda }) => {
eruda.init()
})
}
})
</script>
<title>Prismarine Web Client</title>
<link rel="stylesheet" href="index.css">
<link rel="favicon" href="favicon.ico">
Expand Down
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.5.0",
"description": "A minecraft client running in a browser",
"scripts": {
"start": "node scripts/build.js copyFilesDev && node esbuild.mjs --minify --watch",
"start": "node scripts/build.js copyFilesDev && node scripts/prepareData.mjs && node esbuild.mjs --minify --watch",
"start-watch-script": "nodemon -w esbuild.mjs esbuild.mjs",
"build": "node scripts/build.js copyFiles && node esbuild.mjs --minify --prod",
"build": "node scripts/build.js copyFiles && node scripts/prepareData.mjs && node esbuild.mjs --minify --prod",
"watch": "node scripts/build.js copyFilesDev && webpack serve --config webpack.dev.js --progress",
"test:cypress": "cypress run",
"test:e2e": "start-test http-get://localhost:8080 test:cypress",
Expand All @@ -20,7 +20,7 @@
"author": "PrismarineJS",
"license": "MIT",
"dependencies": {
"@dimaka/interface": "0.0.0-dev",
"@dimaka/interface": "0.0.1",
"@emotion/css": "^11.11.2",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
"@types/react": "^18.2.20",
Expand All @@ -32,6 +32,7 @@
"compression": "^1.7.4",
"cypress-plugin-snapshots": "^1.4.4",
"diamond-square": "^1.2.0",
"eruda": "^3.0.1",
"esbuild": "^0.19.2",
"esbuild-loader": "^4.0.0",
"esbuild-plugin-polyfill-node": "^0.3.0",
Expand All @@ -47,7 +48,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-refresh": "^0.14.0",
"space-squid": "github:zardoy/space-squid",
"space-squid": "github:zardoy/space-squid#everything",
"speed-measure-webpack-plugin": "^1.5.0",
"stats.js": "^0.17.0",
"url": "^0.11.1",
Expand All @@ -61,8 +62,10 @@
"buffer": "^6.0.3",
"clean-webpack-plugin": "^4.0.0",
"constants-browserify": "^1.0.0",
"contro-max": "^0.1.1",
"copy-webpack-plugin": "^11.0.0",
"crypto-browserify": "^3.12.0",
"css-loader": "^6.8.1",
"cypress": "^9.5.4",
"cypress-esbuild-preprocessor": "^1.0.2",
"events": "^3.3.0",
Expand All @@ -73,27 +76,28 @@
"https-browserify": "^1.0.0",
"lodash-webpack-plugin": "^0.11.6",
"memfs": "^3.5.3",
"minecraft-inventory-gui": "github:zardoy/minecraft-inventory-gui#next",
"mineflayer": "github:zardoy/mineflayer#custom",
"mineflayer-pathfinder": "^2.4.4",
"npm-run-all": "^4.1.5",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"prismarine-viewer": "./prismarine-viewer",
"prismarine-viewer2": "github:PrismarineJS/prismarine-viewer",
"process": "github:PrismarineJS/node-process",
"rimraf": "^5.0.1",
"stream-browserify": "^3.0.0",
"style-loader": "^3.3.3",
"three": "0.128.0",
"timers-browserify": "^2.0.12",
"url-loader": "^4.1.1",
"use-typed-event-listener": "^4.0.2",
"vite": "^4.4.9",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-middleware": "^6.1.1",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.9.0",
"workbox-webpack-plugin": "^6.6.0",
"minecraft-inventory-gui": "github:zardoy/minecraft-inventory-gui#next"
"workbox-webpack-plugin": "^6.6.0"
},
"pnpm": {
"overrides": {
Expand Down
62 changes: 62 additions & 0 deletions prismarine-viewer/buildWorker.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { context } from 'esbuild'
import { build } from 'esbuild'
import { polyfillNode } from 'esbuild-plugin-polyfill-node'
import path from 'path'
import { fileURLToPath } from 'url'

const allowedWorkerFiles = ['blocks', 'blockCollisionShapes', 'tints', 'blockStates',
'biomes', 'features', 'version', 'legacy', 'versions', 'version', 'protocolVersions']

const __dirname = path.dirname(fileURLToPath(new URL(import.meta.url)))

/** @type {import('esbuild').BuildOptions} */
const buildOptions = {
bundle: true,
banner: {
js: 'globalThis.global = globalThis;process = {env: {}, versions: {}, };',
},
platform: 'browser',
entryPoints: [path.join(__dirname, './viewer/lib/worker.js')],
outfile: path.join(__dirname, './public/worker.js'),
minify: true,
drop: [
'debugger'
],
sourcemap: true,
plugins: [
{
name: 'external-json',
setup (build) {
build.onResolve({ filter: /\.json$/ }, args => {
const fileName = args.path.split('/').pop().replace('.json', '')
if (args.resolveDir.includes('minecraft-data') && !allowedWorkerFiles.includes(fileName)) {
// console.log('skipped', fileName)
return { path: args.path, namespace: 'empty-file', }
}
})
build.onResolve({
filter: /^zlib$/,
}, ({ path }) => {
return {
path,
namespace: 'empty-file',
}
})
build.onLoad({
filter: /.*/,
namespace: 'empty-file',
}, () => {
return { contents: 'module.exports = undefined', loader: 'js' }
})
}
},
polyfillNode(),
],
}

if (process.argv.includes('-w')) {
const ctx = await context(buildOptions)
await ctx.watch()
} else {
await build(buildOptions)
}
Loading
Loading