Skip to content

Commit

Permalink
many usability fixes (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy authored Sep 29, 2023
2 parents 8aa4e35 + 54365d8 commit 1935c9d
Show file tree
Hide file tree
Showing 57 changed files with 1,582 additions and 3,684 deletions.
26 changes: 24 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
{
"extends": "zardoy",
"ignorePatterns": [
"!*.js"
],
"rules": {
"no-multi-spaces": "error",
"space-in-parens": [
"error",
"never"
],
"object-curly-spacing": [
"error",
"always"
],
"comma-spacing": "error",
"semi": [
"error",
"never"
],
"comma-dangle": [
"error",
// todo maybe "always-multiline"?
"only-multiline"
],
"indent": [
"error",
2,
{
"SwitchCase": 2,
"SwitchCase": 1,
"ignoredNodes": [
"TemplateLiteral"
]
Expand Down Expand Up @@ -65,9 +83,13 @@
"@typescript-eslint/no-require-imports": "off",
"unicorn/prefer-number-properties": "off",
"@typescript-eslint/no-confusing-void-expression": "off",
"unicorn/no-empty-file": "off",
"unicorn/prefer-event-target": "off",
// needs to be fixed actually
"@typescript-eslint/no-floating-promises": "warn",
"no-async-promise-executor": "off",
"no-bitwise": "off"
"no-bitwise": "off",
"unicorn/filename-case": "off",
"max-depth": "off"
}
}
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
uses: actions/checkout@master
- name: Install pnpm
run: npm i -g pnpm
# todo this needs investigating fixing
- run: pnpm install
- run: pnpm lint
- run: pnpm check-build
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Install Global Dependencies
run: npm install --global vercel pnpm
Expand Down
12 changes: 6 additions & 6 deletions cypress/integration/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const compareRenderedFlatWorld = () => {
}

const testWorldLoad = () => {
cy.document().then({ timeout: 20_000, }, doc => {
cy.document().then({ timeout: 20_000 }, doc => {
return new Cypress.Promise(resolve => {
doc.addEventListener('cypress-world-ready', resolve)
})
Expand All @@ -49,7 +49,7 @@ it('Loads & renders singleplayer', () => {
},
renderDistance: 2
})
cy.get('#title-screen').find('[data-test-id="singleplayer-button"]', { includeShadowDom: true, }).click()
cy.get('#title-screen').find('[data-test-id="singleplayer-button"]', { includeShadowDom: true }).click()
testWorldLoad()
})

Expand All @@ -58,15 +58,15 @@ it('Joins to server', () => {
window.localStorage.version = ''
visit()
// todo replace with data-test
cy.get('#title-screen').find('[data-test-id="connect-screen-button"]', { includeShadowDom: true, }).click()
cy.get('input#serverip', { includeShadowDom: true, }).clear().focus().type('localhost')
cy.get('[data-test-id="connect-to-server"]', { includeShadowDom: true, }).click()
cy.get('#title-screen').find('[data-test-id="connect-screen-button"]', { includeShadowDom: true }).click()
cy.get('input#serverip', { includeShadowDom: true }).clear().focus().type('localhost')
cy.get('[data-test-id="connect-to-server"]', { includeShadowDom: true }).click()
testWorldLoad()
})

it('Loads & renders zip world', () => {
cleanVisit()
cy.get('#title-screen').find('[data-test-id="select-file-folder"]', { includeShadowDom: true, }).click({ shiftKey: true })
cy.get('#title-screen').find('[data-test-id="select-file-folder"]', { includeShadowDom: true }).click({ shiftKey: true })
cy.get('input[type="file"]').selectFile('cypress/superflat.zip', { force: true })
testWorldLoad()
})
Expand Down
38 changes: 19 additions & 19 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ const { initPlugin } = require('cypress-plugin-snapshots/plugin')
const polyfill = require('esbuild-plugin-polyfill-node')

module.exports = (on, config) => {
initPlugin(on, config)
on('file:preprocessor', cypressEsbuildPreprocessor({
esbuildOptions: {
plugins: [
polyfill.polyfillNode({
polyfills: {
crypto: true,
},
})
],
},
}))
on('task', {
log (message) {
console.log(message)
return null
},
})
return config
initPlugin(on, config)
on('file:preprocessor', cypressEsbuildPreprocessor({
esbuildOptions: {
plugins: [
polyfill.polyfillNode({
polyfills: {
crypto: true,
},
})
],
},
}))
on('task', {
log (message) {
console.log(message)
return null
},
})
return config
}
7 changes: 4 additions & 3 deletions esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const banner = [
// report reload time
dev && 'if (sessionStorage.lastReload) { const [rebuild, reloadStart] = sessionStorage.lastReload.split(","); const now = Date.now(); console.log(`rebuild + reload:`, +rebuild, "+", now - reloadStart, "=", ((+rebuild + (now - reloadStart)) / 1000).toFixed(1) + "s");sessionStorage.lastReload = ""; }',
// auto-reload
dev && ';(() => new EventSource("/esbuild").onmessage = ({ data: _data }) => { if (!_data) return; const data = JSON.parse(_data); if (!data.update) return; sessionStorage.lastReload = `${data.update.time},${Date.now()}`; location.reload() })();'
dev && 'window.noAutoReload ??= false;(() => new EventSource("/esbuild").onmessage = ({ data: _data }) => { if (!_data) return; const data = JSON.parse(_data); if (!data.update) return;console.log("[esbuild] Page is outdated");document.title = `[O] ${document.title}`;if (window.noAutoReload || localStorage.noAutoReload) return; if (localStorage.autoReloadVisible && document.visibilityState !== "visible") return; sessionStorage.lastReload = `${data.update.time},${Date.now()}`; location.reload() })();'
].filter(Boolean)

const buildingVersion = new Date().toISOString().split(':')[0]
Expand All @@ -35,14 +35,15 @@ const ctx = await esbuild.context({
// logLevel: 'debug',
logLevel: 'info',
platform: 'browser',
sourcemap: true,
sourcemap: prod ? true : 'inline',
outdir: 'dist',
mainFields: [
'browser', 'module', 'main'
],
keepNames: true,
banner: {
js: banner.join('\n'),
// using \n breaks sourcemaps!
js: banner.join(';'),
},
alias: {
events: 'events', // make explicit
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,29 @@
"esbuild": "^0.19.3",
"esbuild-plugin-polyfill-node": "^0.3.0",
"express": "^4.18.2",
"cors": "^2.8.5",
"flying-squid": "github:zardoy/space-squid#everything",
"fs-extra": "^11.1.1",
"iconify-icon": "^1.0.8",
"jszip": "^3.10.1",
"lit": "^2.8.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"minecraft-assets": "^1.9.1",
"minecraft-data": "^3.0.0",
"net-browserify": "github:zardoy/prismarinejs-net-browserify",
"peerjs": "^1.5.0",
"pretty-bytes": "^6.1.1",
"qrcode.react": "^3.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"stats-gl": "^1.0.5",
"stats.js": "^0.17.0",
"valtio": "^1.11.1",
"workbox-build": "^7.0.0"
},
"devDependencies": {
"@types/lodash-es": "^4.17.9",
"@types/stats.js": "^0.17.1",
"@types/three": "0.128.0",
"assert": "^2.0.0",
"browserify-zlib": "^0.2.0",
Expand All @@ -63,6 +68,7 @@
"crypto-browserify": "^3.12.0",
"cypress": "^9.5.4",
"cypress-esbuild-preprocessor": "^1.0.2",
"path-exists-cli": "^2.0.0",
"eslint": "^8.50.0",
"eslint-config-zardoy": "^0.2.17",
"events": "^3.3.0",
Expand All @@ -76,7 +82,7 @@
"npm-run-all": "^4.1.5",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"prismarine-viewer": "./prismarine-viewer",
"prismarine-viewer": "link:prismarine-viewer",
"process": "github:PrismarineJS/node-process",
"rimraf": "^5.0.1",
"stream-browserify": "^3.0.0",
Expand Down
Loading

0 comments on commit 1935c9d

Please sign in to comment.