From 7884b5cffcb5d050dda52161b14c7dd09cc5c159 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Mon, 25 Mar 2024 13:47:01 +0300 Subject: [PATCH 01/56] three shake three.js (#94) --- scripts/esbuildPlugins.mjs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/esbuildPlugins.mjs b/scripts/esbuildPlugins.mjs index 07938c6ec..95d88b8ed 100644 --- a/scripts/esbuildPlugins.mjs +++ b/scripts/esbuildPlugins.mjs @@ -27,7 +27,8 @@ const plugins = [ build.onLoad({ filter: /minecraft-data[\/\\]data.js$/, }, (args) => { - const version = supportedVersions.at(-1); + const version = supportedVersions.at(-1) + if (!version) throw new Error('unreachable') const data = MCData(version) const defaultVersionsObj = { // default protocol data, needed for auto-version @@ -47,6 +48,14 @@ const plugins = [ }, () => { throw new Error('hit banned package') }) + + build.onResolve({ + filter: /^three$/, + }, async ({ kind, resolveDir }) => { + return { + path: (await build.resolve('three/src/Three.js', { kind, resolveDir })).path, + } + }) } }, { From 07491fd72c45cea6030e888723639266ae4ea78e Mon Sep 17 00:00:00 2001 From: gguio <109200692+gguio@users.noreply.github.com> Date: Tue, 26 Mar 2024 17:00:11 +0400 Subject: [PATCH 02/56] feat: effects + system indicators in hud! (#95) Co-authored-by: gguio --- prismarine-viewer/viewer/lib/worldrenderer.ts | 1 + src/browserfs.ts | 24 +++- src/globalState.ts | 1 + src/index.ts | 2 + src/loadSave.ts | 4 +- src/react/IndicatorEffects.css | 35 ++++++ src/react/IndicatorEffects.stories.tsx | 35 ++++++ src/react/IndicatorEffects.tsx | 111 ++++++++++++++++ src/react/IndicatorEffectsProvider.tsx | 118 ++++++++++++++++++ src/react/effectsImages.ts | 76 +++++++++++ src/reactUi.tsx | 2 + src/utils.ts | 6 + 12 files changed, 413 insertions(+), 2 deletions(-) create mode 100644 src/react/IndicatorEffects.css create mode 100644 src/react/IndicatorEffects.stories.tsx create mode 100644 src/react/IndicatorEffects.tsx create mode 100644 src/react/IndicatorEffectsProvider.tsx create mode 100644 src/react/effectsImages.ts diff --git a/prismarine-viewer/viewer/lib/worldrenderer.ts b/prismarine-viewer/viewer/lib/worldrenderer.ts index 1b67a3421..a3c0f79c0 100644 --- a/prismarine-viewer/viewer/lib/worldrenderer.ts +++ b/prismarine-viewer/viewer/lib/worldrenderer.ts @@ -342,6 +342,7 @@ export class WorldRenderer { } setSectionDirty (pos, value = true) { + this.renderUpdateEmitter.emit('dirty', pos, value) this.cleanChunkTextures(pos.x, pos.z) // todo don't do this! // Dispatch sections to workers based on position // This guarantees uniformity accross workers and that a given section diff --git a/src/browserfs.ts b/src/browserfs.ts index 42159b490..ebe8acfdd 100644 --- a/src/browserfs.ts +++ b/src/browserfs.ts @@ -60,7 +60,18 @@ fs.promises = new Proxy(Object.fromEntries(['readFile', 'writeFile', 'stat', 'mk if (p === 'open' && fsState.isReadonly) { args[1] = 'r' // read-only, zipfs throw otherwise } - return target[p](...args) + if (p === 'readFile') { + fsState.openReadOperations++ + } else if (p === 'writeFile') { + fsState.openWriteOperations++ + } + return target[p](...args).finally(() => { + if (p === 'readFile') { + fsState.openReadOperations-- + } else if (p === 'writeFile') { + fsState.openWriteOperations-- + } + }) } } }) @@ -77,7 +88,18 @@ fs.promises.open = async (...args) => { return } + if (x === 'read') { + fsState.openReadOperations++ + } else if (x === 'write' || x === 'close') { + fsState.openWriteOperations++ + } fs[x](fd, ...args, (err, bytesRead, buffer) => { + if (x === 'read') { + fsState.openReadOperations-- + } else if (x === 'write' || x === 'close') { + // todo that's not correct + fsState.openWriteOperations-- + } if (err) throw err // todo if readonly probably there is no need to open at all (return some mocked version - check reload)? if (x === 'write' && !fsState.isReadonly) { diff --git a/src/globalState.ts b/src/globalState.ts index 749b3a8fc..392d5fd9c 100644 --- a/src/globalState.ts +++ b/src/globalState.ts @@ -129,6 +129,7 @@ export type AppConfig = { export const miscUiState = proxy({ currentDisplayQr: null as string | null, currentTouch: null as boolean | null, + hasErrors: false, singleplayer: false, flyingSquid: false, wanOpened: false, diff --git a/src/index.ts b/src/index.ts index e10f60a93..162f19a2b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -318,6 +318,7 @@ async function connect (connectOptions: { server?: string; singleplayer?: any; username: string; password?: any; proxy?: any; botVersion?: any; serverOverrides?; serverOverridesFlat?; peerId?: string }) { if (miscUiState.gameLoaded) return + miscUiState.hasErrors = false lastConnectOptions.value = connectOptions document.getElementById('play-screen').style = 'display: none;' removePanorama() @@ -378,6 +379,7 @@ async function connect (connectOptions: { console.error(err) errorAbortController.abort() if (isCypress()) throw err + miscUiState.hasErrors = true if (miscUiState.gameLoaded) return setLoadingScreenStatus(`Error encountered. ${err}`, true) diff --git a/src/loadSave.ts b/src/loadSave.ts index a707da4d4..655fbea88 100644 --- a/src/loadSave.ts +++ b/src/loadSave.ts @@ -17,7 +17,9 @@ export const fsState = proxy({ isReadonly: false, syncFs: false, inMemorySave: false, - saveLoaded: false + saveLoaded: false, + openReadOperations: 0, + openWriteOperations: 0, }) const PROPOSE_BACKUP = true diff --git a/src/react/IndicatorEffects.css b/src/react/IndicatorEffects.css new file mode 100644 index 000000000..2902bfeed --- /dev/null +++ b/src/react/IndicatorEffects.css @@ -0,0 +1,35 @@ +.effectsScreen-container { + position: fixed; + top: 6%; + left: 0px; + z-index: -1; + pointer-events: none; +} + +.indicators-container { + display: flex; + font-size: 0.7em; +} + +.effects-container { + display: flex; + flex-direction: column; +} + +.effect-box { + display: flex; + align-items: center; +} + +.effect-box__image { + width: 23px; + margin-right: 3px; +} + +.effect-box__time { + font-size: 0.65rem; +} + +.effect-box__level { + font-size: 0.45rem; +} diff --git a/src/react/IndicatorEffects.stories.tsx b/src/react/IndicatorEffects.stories.tsx new file mode 100644 index 000000000..455718fe0 --- /dev/null +++ b/src/react/IndicatorEffects.stories.tsx @@ -0,0 +1,35 @@ +import 'iconify-icon' + +import type { Meta, StoryObj } from '@storybook/react' + +import IndicatorEffects, { defaultIndicatorsState } from './IndicatorEffects' +import { images } from './effectsImages' + +const meta: Meta = { + component: IndicatorEffects +} + +export default meta +type Story = StoryObj; + +export const Primary: Story = { + args: { + indicators: defaultIndicatorsState, + effects: [ + { + image: images.glowing, + time: 200, + level: 255, + removeEffect (image: string) {}, + reduceTime (image: string) {} + }, + { + image: images.absorption, + time: 30, + level: 99, + removeEffect (image: string) {}, + reduceTime (image: string) {} + } + ], + } +} diff --git a/src/react/IndicatorEffects.tsx b/src/react/IndicatorEffects.tsx new file mode 100644 index 000000000..b767cc237 --- /dev/null +++ b/src/react/IndicatorEffects.tsx @@ -0,0 +1,111 @@ +import { useMemo, useEffect, useRef } from 'react' +import PixelartIcon from './PixelartIcon' +import './IndicatorEffects.css' + + + +function formatTime (seconds: number): string { + if (seconds < 0) return '' + const minutes = Math.floor(seconds / 60) + const remainingSeconds = seconds % 60 + const formattedMinutes = String(minutes).padStart(2, '0') + const formattedSeconds = String(remainingSeconds).padStart(2, '0') + return `${formattedMinutes}:${formattedSeconds}` +} + +export type EffectType = { + image: string, + time: number, + level: number, + removeEffect: (image: string) => void, + reduceTime: (image: string) => void +} + +const EffectBox = ({ image, time, level }: Pick) => { + + const formattedTime = useMemo(() => formatTime(time), [time]) + + return
+ +
+ {formattedTime ? ( + // if time is negative then effect is shown without time. + // Component should be removed manually with time = 0 +
{formattedTime}
+ ) : null } + {level > 0 && level < 256 ? ( +
{level + 1}
+ ) : null } +
+
+} + +export const defaultIndicatorsState = { + chunksLoading: false, + readingFiles: false, + readonlyFiles: false, + writingFiles: false, // saving + appHasErrors: false, +} + +const indicatorIcons: Record = { + chunksLoading: 'add-grid', + readingFiles: 'arrow-bar-down', + writingFiles: 'arrow-bar-up', + appHasErrors: 'alert', + readonlyFiles: 'file-off', +} + +export default ({ indicators, effects }: {indicators: typeof defaultIndicatorsState, effects: readonly EffectType[]}) => { + const effectsRef = useRef(effects) + useEffect(() => { + effectsRef.current = effects + }, [effects]) + + useEffect(() => { + // todo use more precise timer for each effect + const interval = setInterval(() => { + for (const [index, effect] of effectsRef.current.entries()) { + if (effect.time === 0) { + // effect.removeEffect(effect.image) + return + } + effect.reduceTime(effect.image) + } + }, 1000) + + return () => { + clearInterval(interval) + } + }, []) + + const indicatorsMapped = Object.entries(defaultIndicatorsState).map(([key, state]) => ({ + icon: indicatorIcons[key], + // preserve order + state: indicators[key], + })) + return
+
+ { + indicatorsMapped.map((indicator) =>
+ +
) + } +
+
+ { + effects.map( + (effect) => + ) + } +
+
+} diff --git a/src/react/IndicatorEffectsProvider.tsx b/src/react/IndicatorEffectsProvider.tsx new file mode 100644 index 000000000..00b78d8a1 --- /dev/null +++ b/src/react/IndicatorEffectsProvider.tsx @@ -0,0 +1,118 @@ +import { proxy, useSnapshot } from 'valtio' +import { useEffect, useMemo } from 'react' +import { inGameError } from '../utils' +import { fsState } from '../loadSave' +import { miscUiState } from '../globalState' +import IndicatorEffects, { EffectType, defaultIndicatorsState } from './IndicatorEffects' +import { images } from './effectsImages' + +export const state = proxy({ + indicators: { + chunksLoading: false + }, + effects: [] as EffectType[] +}) + +export const addEffect = (newEffect: Omit) => { + const effectIndex = getEffectIndex(newEffect as EffectType) + if (typeof effectIndex === 'number') { + state.effects[effectIndex].time = newEffect.time + state.effects[effectIndex].level = newEffect.level + } else { + const effect = { ...newEffect, reduceTime, removeEffect } + state.effects.push(effect) + } +} + +const removeEffect = (image: string) => { + for (const [index, effect] of (state.effects).entries()) { + if (effect.image === image) { + state.effects.splice(index, 1) + } + } +} + +const reduceTime = (image: string) => { + for (const [index, effect] of (state.effects).entries()) { + if (effect.image === image) { + effect.time -= 1 + } + } +} + +const getEffectIndex = (newEffect: EffectType) => { + for (const [index, effect] of (state.effects).entries()) { + if (effect.image === newEffect.image) { + return index + } + } + return null +} + +export default () => { + const stateIndicators = useSnapshot(state.indicators) + const { hasErrors } = useSnapshot(miscUiState) + const { isReadonly, openReadOperations, openWriteOperations } = useSnapshot(fsState) + const allIndicators: typeof defaultIndicatorsState = { + readonlyFiles: isReadonly, + writingFiles: openWriteOperations > 0, + readingFiles: openReadOperations > 0, + appHasErrors: hasErrors, + ...stateIndicators, + } + + useEffect(() => { + let alreadyWaiting = false + const listener = () => { + if (alreadyWaiting) return + state.indicators.chunksLoading = true + alreadyWaiting = true + void viewer.waitForChunksToRender().then(() => { + state.indicators.chunksLoading = false + alreadyWaiting = false + }) + } + viewer.world.renderUpdateEmitter.on('dirty', listener) + + return () => { + viewer.world.renderUpdateEmitter.off('dirty', listener) + } + }, []) + + const effects = useSnapshot(state.effects) + + useMemo(() => { + const effectsImages = Object.fromEntries(loadedData.effectsArray.map((effect) => { + const nameKebab = effect.name.replaceAll(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`).slice(1) + return [effect.id, images[nameKebab]] + })) + bot.on('entityEffect', (entity, effect) => { + if (entity.id !== bot.entity.id) return + const image = effectsImages[effect.id] ?? null + if (!image) { + inGameError(`received unknown effect id ${effect.id}}`) + return + } + const newEffect = { + image, + time: effect.duration / 20, // duration received in ticks + level: effect.amplifier, + } + addEffect(newEffect) + }) + bot.on('entityEffectEnd', (entity, effect) => { + if (entity.id !== bot.entity.id) return + const image = effectsImages[effect.id] ?? null + if (!image) { + inGameError(`received unknown effect id ${effect.id}}}`) + return + } + removeEffect(image) + }) + }, []) + + return +} diff --git a/src/react/effectsImages.ts b/src/react/effectsImages.ts new file mode 100644 index 000000000..21421e0f6 --- /dev/null +++ b/src/react/effectsImages.ts @@ -0,0 +1,76 @@ +import absorption from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/absorption.png' +import glowing from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/glowing.png' +import instant_health from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/instant_health.png' +import nausea from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/nausea.png' +import slow_falling from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/slow_falling.png' +import weakness from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/weakness.png' +import bad_omen from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/bad_omen.png' +import haste from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/haste.png' +import invisibility from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/invisibility.png' +import night_vision from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/night_vision.png' +import slowness from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/slowness.png' +import wither from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/wither.png' +import blindness from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/blindness.png' +import health_boost from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/health_boost.png' +import jump_boost from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/jump_boost.png' +import poison from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/poison.png' +import speed from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/speed.png' +import conduit_power from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/conduit_power.png' +import hero_of_the_village from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/hero_of_the_village.png' +import levitation from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/levitation.png' +import regeneration from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/regeneration.png' +import strength from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/strength.png' +import dolphins_grace from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/dolphins_grace.png' +import hunger from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/hunger.png' +import luck from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/luck.png' +import resistance from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/resistance.png' +import unluck from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/unluck.png' +import fire_resistance from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/fire_resistance.png' +import instant_damage from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/instant_damage.png' +import mining_fatigue from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/mining_fatigue.png' +import saturation from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/saturation.png' +import water_breathing from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/water_breathing.png' +import darkness from 'minecraft-assets/minecraft-assets/data/1.20.2/mob_effect/darkness.png' + +interface Images { + [key: string]: string; +} + +// Export an object containing image URLs +export const images: Images = { + absorption, + glowing, + instant_health, + nausea, + slow_falling, + weakness, + bad_omen, + haste, + invisibility, + night_vision, + slowness, + wither, + blindness, + health_boost, + jump_boost, + poison, + speed, + conduit_power, + hero_of_the_village, + levitation, + regeneration, + strength, + dolphins_grace, + hunger, + luck, + resistance, + unluck, + bad_luck: unluck, + good_luck: luck, + fire_resistance, + instant_damage, + mining_fatigue, + saturation, + water_breathing, + darkness +} diff --git a/src/reactUi.tsx b/src/reactUi.tsx index aa1d74dd9..d56cb8056 100644 --- a/src/reactUi.tsx +++ b/src/reactUi.tsx @@ -16,6 +16,7 @@ import ChatProvider from './react/ChatProvider' import TitleProvider from './react/TitleProvider' import ScoreboardProvider from './react/ScoreboardProvider' import SignEditorProvider from './react/SignEditorProvider' +import IndicatorEffectsProvider from './react/IndicatorEffectsProvider' import SoundMuffler from './react/SoundMuffler' import TouchControls from './react/TouchControls' import widgets from './react/widgets' @@ -65,6 +66,7 @@ const InGameUi = () => { + diff --git a/src/utils.ts b/src/utils.ts index 61ceeeb80..39bf940e1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -20,6 +20,12 @@ export const toNumber = (val) => { return isNaN(num) ? undefined : num } +export const inGameError = (err) => { + console.error(err) + // todo report + miscUiState.hasErrors = true +} + export const pointerLock = { get hasPointerLock () { return document.pointerLockElement From 1c45ded8055c73e64c09c4f1cad0f7551973a451 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 28 Mar 2024 01:41:48 +0300 Subject: [PATCH 03/56] fix page loadeding indicator showing sometimes --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 162f19a2b..3a8fbd5cf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -919,7 +919,7 @@ downloadAndOpenFile().then((downloadAction) => { const initialLoader = document.querySelector('.initial-loader') as HTMLElement | null if (initialLoader) { initialLoader.style.opacity = '0' - window.pageLoaded = true } +window.pageLoaded = true void possiblyHandleStateVariable() From f2803b9b3ac399dc84802e6041732e59bd52fe84 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 6 Apr 2024 15:22:50 +0300 Subject: [PATCH 04/56] remove alias set --- .github/workflows/preview.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 2a5f56659..025984460 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -42,10 +42,6 @@ jobs: with: run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} id: deploy - - name: Set deployment alias - # only if on branch next - if: github.ref == 'refs/heads/next' - run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ secrets.TEST_PREVIEW_DOMAIN }} --token=${{ secrets.VERCEL_TOKEN }} - uses: mshick/add-pr-comment@v2 with: message: | From b89aab72d0a92d8129024f5d3c8168b59befa633 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Tue, 9 Apr 2024 03:28:55 +0300 Subject: [PATCH 05/56] ci: text aliases --- .github/workflows/next-deploy.yml | 8 +++++++- scripts/githubActions.mjs | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 scripts/githubActions.mjs diff --git a/.github/workflows/next-deploy.yml b/.github/workflows/next-deploy.yml index 93c46aebc..d7d4d322e 100644 --- a/.github/workflows/next-deploy.yml +++ b/.github/workflows/next-deploy.yml @@ -2,6 +2,7 @@ name: Vercel Deploy Next env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + ALIASES: ${{ vars.ALIASES }} on: push: branches: @@ -30,8 +31,13 @@ jobs: with: run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} id: deploy + - name: Get deployment alias + run: node scripts/githubActions.mjs getAlias + - run: echo $OUTPUT + env: + OUTPUT: ${{ steps.repos.outputs.alias }} - name: Set deployment alias - run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ secrets.TEST_PREVIEW_DOMAIN }} --token=${{ secrets.VERCEL_TOKEN }} + run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ secrets.TEST_PREVIEW_DOMAIN }} --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro # - uses: mshick/add-pr-comment@v2 # with: # message: | diff --git a/scripts/githubActions.mjs b/scripts/githubActions.mjs new file mode 100644 index 000000000..f392da559 --- /dev/null +++ b/scripts/githubActions.mjs @@ -0,0 +1,23 @@ +const fns = { + async getAlias () { + const aliasesRaw = process.env.ALIASES + if (!aliasesRaw) throw new Error('No aliases found') + const aliases = aliasesRaw.split('\n').map((x) => x.search('=')) + const githubActionsPull = process.env.GITHUB_REF.match(/refs\/pull\/(\d+)\/merge/) + if (!githubActionsPull) throw new Error(`Not a pull request, got ${process.env.GITHUB_REF}`) + const prNumber = githubActionsPull[1] + const alias = aliases.find((x) => x[0] === prNumber) + if (alias) { + console.log('Found alias', alias[1]) + // set github output + console.log(`::set-output name=alias::${alias[1]}`) + } + } +} + +const fn = fns[process.argv[2]] +if (fn) { + fn() +} else { + console.error('Function not found') +} From ac3448c74502e6e23c357c1614bc81dab3beb354 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Tue, 9 Apr 2024 03:47:03 +0300 Subject: [PATCH 06/56] ci: set custom mcraft aliases for PRs! (#99) --- .github/workflows/next-deploy.yml | 5 ----- .github/workflows/preview.yml | 7 +++++++ scripts/githubActions.mjs | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/next-deploy.yml b/.github/workflows/next-deploy.yml index d7d4d322e..7ee33ac09 100644 --- a/.github/workflows/next-deploy.yml +++ b/.github/workflows/next-deploy.yml @@ -31,11 +31,6 @@ jobs: with: run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} id: deploy - - name: Get deployment alias - run: node scripts/githubActions.mjs getAlias - - run: echo $OUTPUT - env: - OUTPUT: ${{ steps.repos.outputs.alias }} - name: Set deployment alias run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ secrets.TEST_PREVIEW_DOMAIN }} --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro # - uses: mshick/add-pr-comment@v2 diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 025984460..44c554803 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -2,6 +2,7 @@ name: Vercel Deploy Preview env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + ALIASES: ${{ vars.ALIASES }} on: issue_comment: types: [created] @@ -48,3 +49,9 @@ jobs: Deployed to Vercel Preview: ${{ steps.deploy.outputs.stdout }} [Playground](${{ steps.deploy.outputs.stdout }}/playground.html) [Storybook](${{ steps.deploy.outputs.stdout }}/storybook/) + - name: Get deployment alias + run: node scripts/githubActions.mjs getAlias + id: alias + - name: Set deployment alias + if: ${{ steps.alias.outputs.alias != '' }} + run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ steps.alias.outputs.alias }} --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro diff --git a/scripts/githubActions.mjs b/scripts/githubActions.mjs index f392da559..ac218f568 100644 --- a/scripts/githubActions.mjs +++ b/scripts/githubActions.mjs @@ -1,20 +1,29 @@ +//@ts-check +import fs from 'fs' +import os from 'os' + const fns = { async getAlias () { const aliasesRaw = process.env.ALIASES if (!aliasesRaw) throw new Error('No aliases found') - const aliases = aliasesRaw.split('\n').map((x) => x.search('=')) + const aliases = aliasesRaw.split('\n').map((x) => x.split('=')) const githubActionsPull = process.env.GITHUB_REF.match(/refs\/pull\/(\d+)\/merge/) if (!githubActionsPull) throw new Error(`Not a pull request, got ${process.env.GITHUB_REF}`) const prNumber = githubActionsPull[1] const alias = aliases.find((x) => x[0] === prNumber) if (alias) { - console.log('Found alias', alias[1]) // set github output - console.log(`::set-output name=alias::${alias[1]}`) + setOutput('alias', alias[1]) } } } +function setOutput(key, value) { + // Temporary hack until core actions library catches up with github new recommendations + const output = process.env['GITHUB_OUTPUT'] + fs.appendFileSync(output, `${key}=${value}${os.EOL}`) +} + const fn = fns[process.argv[2]] if (fn) { fn() From 0b15ac9ba099c5e1183003efdbb5576e06d531bb Mon Sep 17 00:00:00 2001 From: Vitaly Date: Tue, 9 Apr 2024 15:59:35 +0300 Subject: [PATCH 07/56] ci: improve aliases set --- .github/workflows/preview.yml | 6 +++++- scripts/githubActions.mjs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 44c554803..cdefd2e20 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -49,9 +49,13 @@ jobs: Deployed to Vercel Preview: ${{ steps.deploy.outputs.stdout }} [Playground](${{ steps.deploy.outputs.stdout }}/playground.html) [Storybook](${{ steps.deploy.outputs.stdout }}/storybook/) + - run: git checkout next scripts/githubActions.mjs - name: Get deployment alias run: node scripts/githubActions.mjs getAlias id: alias + env: + ALIASES: ${{ env.ALIASES }} + PULL_URL: ${{ github.event.comment.issue.pull_request.url }} - name: Set deployment alias - if: ${{ steps.alias.outputs.alias != '' }} + if: ${{ steps.alias.outputs.alias != '' && steps.alias.outputs.alias != 'mcraft.fun' && steps.alias.outputs.alias != 's.mcraft.fun' }} run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ steps.alias.outputs.alias }} --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro diff --git a/scripts/githubActions.mjs b/scripts/githubActions.mjs index ac218f568..ba7b8566d 100644 --- a/scripts/githubActions.mjs +++ b/scripts/githubActions.mjs @@ -7,7 +7,7 @@ const fns = { const aliasesRaw = process.env.ALIASES if (!aliasesRaw) throw new Error('No aliases found') const aliases = aliasesRaw.split('\n').map((x) => x.split('=')) - const githubActionsPull = process.env.GITHUB_REF.match(/refs\/pull\/(\d+)\/merge/) + const githubActionsPull = process.env.PULL_URL?.split('/').at(-1) if (!githubActionsPull) throw new Error(`Not a pull request, got ${process.env.GITHUB_REF}`) const prNumber = githubActionsPull[1] const alias = aliases.find((x) => x[0] === prNumber) From 2a396d118792ca7000f734928dcd9b19ca052f24 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 9 Apr 2024 16:40:32 +0300 Subject: [PATCH 08/56] ci: disable next checkout as its not available in some repoes --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index cdefd2e20..52f8bc294 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -49,7 +49,7 @@ jobs: Deployed to Vercel Preview: ${{ steps.deploy.outputs.stdout }} [Playground](${{ steps.deploy.outputs.stdout }}/playground.html) [Storybook](${{ steps.deploy.outputs.stdout }}/storybook/) - - run: git checkout next scripts/githubActions.mjs + # - run: git checkout next scripts/githubActions.mjs - name: Get deployment alias run: node scripts/githubActions.mjs getAlias id: alias From bf655b075b686285c1163d9d511f457c101d58a8 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 11 Apr 2024 05:14:16 +0300 Subject: [PATCH 09/56] ci: try sticky messages --- .github/workflows/preview.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 52f8bc294..f0cdc190c 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -45,6 +45,7 @@ jobs: id: deploy - uses: mshick/add-pr-comment@v2 with: + refresh-message-position: true message: | Deployed to Vercel Preview: ${{ steps.deploy.outputs.stdout }} [Playground](${{ steps.deploy.outputs.stdout }}/playground.html) From be87a57192cae816b695ab6d2f8611ca2e0b022c Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 11 Apr 2024 05:18:14 +0300 Subject: [PATCH 10/56] fix indicator not disappearing sometimes --- src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.ts b/src/index.ts index 3a8fbd5cf..99f433e6c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -919,6 +919,7 @@ downloadAndOpenFile().then((downloadAction) => { const initialLoader = document.querySelector('.initial-loader') as HTMLElement | null if (initialLoader) { initialLoader.style.opacity = '0' + initialLoader.style.pointerEvents = 'none' } window.pageLoaded = true From df0bf14f14ddc3f99dc0a8f37c9c1d6547be867c Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Thu, 11 Apr 2024 05:19:32 +0300 Subject: [PATCH 11/56] ci: post deploy message on each deploy --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index f0cdc190c..6ce2b927a 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -45,7 +45,7 @@ jobs: id: deploy - uses: mshick/add-pr-comment@v2 with: - refresh-message-position: true + allow-repeats: true message: | Deployed to Vercel Preview: ${{ steps.deploy.outputs.stdout }} [Playground](${{ steps.deploy.outputs.stdout }}/playground.html) From 4d74730742b9a6dc08f2433faa1ec98f2e7cfa71 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Thu, 11 Apr 2024 05:36:54 +0300 Subject: [PATCH 12/56] ci: fix pull url in the preview script --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 6ce2b927a..03990d04c 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -56,7 +56,7 @@ jobs: id: alias env: ALIASES: ${{ env.ALIASES }} - PULL_URL: ${{ github.event.comment.issue.pull_request.url }} + PULL_URL: ${{ github.event.issue.pull_request.url }} - name: Set deployment alias if: ${{ steps.alias.outputs.alias != '' && steps.alias.outputs.alias != 'mcraft.fun' && steps.alias.outputs.alias != 's.mcraft.fun' }} run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ steps.alias.outputs.alias }} --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro From da44ad40fc322bf4f85610c31f7fbae729488b0a Mon Sep 17 00:00:00 2001 From: Vitaly Date: Sun, 14 Apr 2024 23:22:23 +0300 Subject: [PATCH 13/56] feat: allow to setup temporary options & commands overrides in QS that wont be saved --- src/index.ts | 10 +++++++++- src/optionsStorage.ts | 13 +++++++++++-- src/react/OptionsItems.tsx | 11 ++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 99f433e6c..bbbb060d5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -315,7 +315,7 @@ const cleanConnectIp = (host: string | undefined, defaultPort: string | undefine } async function connect (connectOptions: { - server?: string; singleplayer?: any; username: string; password?: any; proxy?: any; botVersion?: any; serverOverrides?; serverOverridesFlat?; peerId?: string + server?: string; singleplayer?: any; username: string; password?: any; proxy?: any; botVersion?: any; serverOverrides?; serverOverridesFlat?; peerId?: string; ignoreQs?: boolean }) { if (miscUiState.gameLoaded) return miscUiState.hasErrors = false @@ -826,6 +826,14 @@ async function connect (connectOptions: { document.dispatchEvent(new Event('cypress-world-ready')) }) }) + + if (!connectOptions.ignoreQs) { + const qs = new URLSearchParams(window.location.search) + for (let command of qs.getAll('command')) { + if (!command.startsWith('/')) command = `/${command}` + bot.chat(command) + } + } } listenGlobalEvents() diff --git a/src/optionsStorage.ts b/src/optionsStorage.ts index 8490053cb..9e13bf473 100644 --- a/src/optionsStorage.ts +++ b/src/optionsStorage.ts @@ -3,6 +3,7 @@ import { proxy, subscribe } from 'valtio/vanilla' // weird webpack configuration bug: it cant import valtio/utils in this file import { subscribeKey } from 'valtio/utils' +import { omitObj } from '@zardoy/utils' const defaultOptions = { renderDistance: 2, @@ -80,6 +81,12 @@ const defaultOptions = { wysiwygSignEditor: 'auto' as 'auto' | 'always' | 'never', } +const qsOptionsRaw = new URLSearchParams(location.search).getAll('setting') +export const qsOptions = Object.fromEntries(qsOptionsRaw.map(o => { + const [key, value] = o.split(':') + return [key, JSON.parse(value)] +})) + const migrateOptions = (options: Partial>) => { if (options.highPerformanceGpu) { options.gpuPreference = 'high-performance' @@ -96,7 +103,8 @@ export type AppOptions = typeof defaultOptions export const options: AppOptions = proxy({ ...defaultOptions, - ...migrateOptions(JSON.parse(localStorage.options || '{}')) + ...migrateOptions(JSON.parse(localStorage.options || '{}')), + ...qsOptions }) window.options = window.settings = options @@ -112,7 +120,8 @@ Object.defineProperty(window, 'debugChangedOptions', { }) subscribe(options, () => { - localStorage.options = JSON.stringify(options) + const saveOptions = omitObj(options, ...Object.keys(qsOptions) as [any]) + localStorage.options = JSON.stringify(saveOptions) }) type WatchValue = >(proxy: T, callback: (p: T) => void) => void diff --git a/src/react/OptionsItems.tsx b/src/react/OptionsItems.tsx index 5c0941e63..74e82051c 100644 --- a/src/react/OptionsItems.tsx +++ b/src/react/OptionsItems.tsx @@ -2,7 +2,7 @@ import { useSnapshot } from 'valtio' import { noCase } from 'change-case' import { titleCase } from 'title-case' import { useMemo } from 'react' -import { options } from '../optionsStorage' +import { options, qsOptions } from '../optionsStorage' import Button from './Button' import Slider from './Slider' import Screen from './Screen' @@ -30,6 +30,11 @@ export type OptionMeta = GeneralItem & ({ render: () => React.ReactNode, }) +// todo not reactive +const isDisabled = (id) => { + return qsOptions.includes(id) +} + export const OptionButton = ({ item }: { item: Extract }) => { const optionValue = useSnapshot(options)[item.id!] @@ -74,7 +79,7 @@ export const OptionButton = ({ item }: { item: Extract { + return { options[item.id!] = value }} unit={item.unit} valueDisplay={valueDisplay} updateOnDragEnd={item.delayApply} /> } From 889e652455c3f5b576d78910abb7298c1133bac9 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Mon, 15 Apr 2024 02:04:33 +0300 Subject: [PATCH 14/56] fix: Make hideable vercel live feedback --- src/index.ts | 4 +++- src/react/OptionsItems.tsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index bbbb060d5..7fd99b149 100644 --- a/src/index.ts +++ b/src/index.ts @@ -871,7 +871,9 @@ document.body.addEventListener('touchend', (e) => { activeTouch = undefined }) document.body.addEventListener('touchstart', (e) => { - if (!isGameActive(true)) return + const ignoreElem = (e.target as HTMLElement).matches('vercel-live-feedback') + if (!isGameActive(true) || ignoreElem) return + // we always prevent default behavior to disable magnifier on ios, but by doing so we also disable click events e.preventDefault() let firstClickable // todo remove composedPath and this workaround when lit-element is fully dropped const path = e.composedPath() as Array<{ click?: () => void }> diff --git a/src/react/OptionsItems.tsx b/src/react/OptionsItems.tsx index 74e82051c..9351d66b4 100644 --- a/src/react/OptionsItems.tsx +++ b/src/react/OptionsItems.tsx @@ -32,7 +32,7 @@ export type OptionMeta = GeneralItem & ({ // todo not reactive const isDisabled = (id) => { - return qsOptions.includes(id) + return Object.keys(qsOptions).includes(id) } export const OptionButton = ({ item }: { item: Extract }) => { From aafdb6469435ce3869fd4a21b2a6436ebc69abd2 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Mon, 15 Apr 2024 05:44:25 +0300 Subject: [PATCH 15/56] outdated commit hints in ci!! (#101) --- .github/workflows/ci.yml | 9 +++- package.json | 3 ++ prismarine-viewer/package.json | 2 +- .../viewer/prepare/generateTextures.ts | 6 +-- .../viewer/prepare/postinstall.ts | 12 +++++ scripts/outdatedGitPackages.mjs | 52 +++++++++++++++++++ scripts/updateGitPackages.mjs | 26 ---------- 7 files changed, 77 insertions(+), 33 deletions(-) create mode 100644 prismarine-viewer/viewer/prepare/postinstall.ts create mode 100644 scripts/outdatedGitPackages.mjs delete mode 100644 scripts/updateGitPackages.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe7c8ba64..3bc45b5ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,10 @@ jobs: uses: actions/checkout@master - name: Install pnpm run: npm i -g pnpm - # todo this needs investigating fixing + - uses: actions/setup-node@v4 + with: + node-version: 18 + # cache: "pnpm" - run: pnpm install - run: pnpm lint - run: pnpm check-build @@ -24,3 +27,7 @@ jobs: with: name: cypress-images path: cypress/integration/__image_snapshots__/ + - run: node scripts/outdatedGitPackages.mjs + # if: github.ref == 'refs/heads/next' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 881be9cc6..d6ea66556 100644 --- a/package.json +++ b/package.json @@ -144,6 +144,9 @@ "prismarine-provider-anvil": "github:zardoy/prismarine-provider-anvil#everything", "minecraft-protocol": "github:zardoy/minecraft-protocol#everything", "react": "^18.2.0" + }, + "updateConfig": { + "ignoreDependencies": [] } } } diff --git a/prismarine-viewer/package.json b/prismarine-viewer/package.json index 529aa9ae4..7d7b6b81d 100644 --- a/prismarine-viewer/package.json +++ b/prismarine-viewer/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "postinstall": "pnpm generate-textures && node buildWorker.mjs", - "generate-textures": "tsx viewer/prepare/generateTextures.ts" + "generate-textures": "tsx viewer/prepare/postinstall.ts" }, "author": "PrismarineJS", "license": "MIT", diff --git a/prismarine-viewer/viewer/prepare/generateTextures.ts b/prismarine-viewer/viewer/prepare/generateTextures.ts index b9a5e3e5f..2a196ccbb 100644 --- a/prismarine-viewer/viewer/prepare/generateTextures.ts +++ b/prismarine-viewer/viewer/prepare/generateTextures.ts @@ -1,6 +1,6 @@ import path from 'path' import { makeBlockTextureAtlas } from './atlas' -import { McAssets, prepareBlocksStates } from './modelsBuilder' +import { prepareBlocksStates } from './modelsBuilder' import mcAssets from 'minecraft-assets' import fs from 'fs-extra' import { prepareMoreGeneratedBlocks } from './moreGeneratedBlocks' @@ -9,10 +9,6 @@ import { generateItemsAtlases } from './genItemsAtlas' const publicPath = path.resolve(__dirname, '../../public') const texturesPath = path.join(publicPath, 'textures') -if (fs.existsSync(texturesPath) && !process.argv.includes('-f')) { - console.log('textures folder already exists, skipping...') - process.exit(0) -} fs.mkdirSync(texturesPath, { recursive: true }) const blockStatesPath = path.join(publicPath, 'blocksStates') diff --git a/prismarine-viewer/viewer/prepare/postinstall.ts b/prismarine-viewer/viewer/prepare/postinstall.ts new file mode 100644 index 000000000..bf70d26c0 --- /dev/null +++ b/prismarine-viewer/viewer/prepare/postinstall.ts @@ -0,0 +1,12 @@ +import path from 'path' +import fs from 'fs' + +const publicPath = path.resolve(__dirname, '../../public') +const texturesPath = path.join(publicPath, 'textures') + +if (fs.existsSync(texturesPath) && !process.argv.includes('-f')) { + console.log('textures folder already exists, skipping...') + process.exit(0) +} else { + import('./generateTextures') +} diff --git a/scripts/outdatedGitPackages.mjs b/scripts/outdatedGitPackages.mjs new file mode 100644 index 000000000..c6a3b2d5f --- /dev/null +++ b/scripts/outdatedGitPackages.mjs @@ -0,0 +1,52 @@ +// pnpm bug workaround +import fs from 'fs' +import { parse } from 'yaml' +import _ from 'lodash' + +const lockfile = parse(fs.readFileSync('./pnpm-lock.yaml', 'utf8')) +const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8')) +const depsKeys = ['dependencies', 'devDependencies'] + +const githubToken = process.env.GITHUB_TOKEN +const ignoreDeps = packageJson.pnpm?.updateConfig?.ignoreDependencies ?? [] + +const outdatedDeps = [] + +const allDepsObj = {} + +for (const [key, val] of Object.entries(lockfile.importers)) { + // Object.assign(allDepsObj, val) + _.merge(allDepsObj, val) +} + +for (const [depsKey, deps] of Object.entries(allDepsObj)) { + for (const [depName, { specifier, version }] of Object.entries(deps)) { + if (ignoreDeps.includes(depName)) continue + if (!specifier.startsWith('github:')) continue + // console.log('checking github:', depName, version, specifier) + + let possiblyBranch = specifier.match(/#(.*)$/)?.[1] ?? '' + if (possiblyBranch) possiblyBranch = `/${possiblyBranch}` + const sha = version.split('/').slice(3).join('/').replace(/\(.+/, '') + const repo = version.split('/').slice(1, 3).join('/') + + const lastCommitJson = await fetch(`https://api.github.com/repos/${repo}/commits${possiblyBranch}?per_page=1`, { + headers: { + Authorization: githubToken ? `token ${githubToken}` : undefined, + }, + }).then(res => res.json()) + + const lastCommitActual = lastCommitJson ?? lastCommitJson[0] + const lastCommitActualSha = Array.isArray(lastCommitActual) ? lastCommitActual[0]?.sha : lastCommitActual?.sha + if (lastCommitActualSha === undefined) debugger + if (sha !== lastCommitActualSha) { + // console.log(`Outdated ${depName} github.com/${repo} : ${sha} -> ${lastCommitActualSha} (${lastCommitActual.commit.message})`) + outdatedDeps.push({ depName, repo, sha, lastCommitActualSha }) + } + } + +} + +if (outdatedDeps.length) { + throw new Error(`Outdated dependencies found: \n${outdatedDeps.map(({ depName, repo, sha, lastCommitActualSha }) => `${depName} github.com/${repo} : ${sha} -> ${lastCommitActualSha}`).join('\n')}`) +} diff --git a/scripts/updateGitPackages.mjs b/scripts/updateGitPackages.mjs deleted file mode 100644 index 14524587e..000000000 --- a/scripts/updateGitPackages.mjs +++ /dev/null @@ -1,26 +0,0 @@ -// pnpm bug workaround -import fs from 'fs' -import { parse } from 'yaml' - -const lockfile = parse(fs.readFileSync('./pnpm-lock.yaml', 'utf8')) - -const depsKeys = ['dependencies', 'devDependencies'] - -for (const importer of Object.values(lockfile.importers)) { - for (const depsKey of depsKeys) { - for (const [depName, { specifier, version }] of Object.entries(importer[depsKey])) { - if (!specifier.startsWith('github:')) continue - let branch = specifier.match(/#(.*)$/)?.[1] ?? '' - if (branch) branch = `/${branch}` - const sha = version.split('/').slice(3).join('/').replace(/\(.+/, '') - const repo = version.split('/').slice(1, 3).join('/') - const lastCommitJson = await fetch(`https://api.github.com/repos/${repo}/commits${branch}?per_page=1`).then(res => res.json()) - const lastCommitActual = lastCommitJson ?? lastCommitJson[0] - const lastCommitActualSha = lastCommitActual?.sha - if (lastCommitActualSha === undefined) debugger - if (sha !== lastCommitActualSha) { - console.log(`Outdated ${depName} github.com/${repo} : ${sha} -> ${lastCommitActualSha} (${lastCommitActual.commit.message})`) - } - } - } -} From 954169d1b9d1f96e36cce33914a442a10236b8b0 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Mon, 15 Apr 2024 05:45:14 +0300 Subject: [PATCH 16/56] enable outdated deps check only on next --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3bc45b5ee..cbd123187 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,6 @@ jobs: name: cypress-images path: cypress/integration/__image_snapshots__/ - run: node scripts/outdatedGitPackages.mjs - # if: github.ref == 'refs/heads/next' + if: github.ref == 'refs/heads/next' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 10662bcbc06221aabc4b86aa33e7dcd28d40c002 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Tue, 16 Apr 2024 05:24:47 +0300 Subject: [PATCH 17/56] feat: Add auto jump (disabled by default for PC & Gamepad users) (#100) --- package.json | 2 + pnpm-lock.yaml | 546 ++++++++++++++++++++++++++++----------- src/entities.ts | 31 +++ src/optionsGuiScheme.tsx | 7 + src/optionsStorage.ts | 1 + 5 files changed, 442 insertions(+), 145 deletions(-) diff --git a/package.json b/package.json index d6ea66556..b91bb11e9 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@dimaka/interface": "0.0.3-alpha.0", "@floating-ui/react": "^0.26.1", "@mui/base": "5.0.0-beta.34", + "@nxg-org/mineflayer-auto-jump": "^0.7.5", "@nxg-org/mineflayer-tracker": "^1.2.1", "@react-oauth/google": "^0.12.1", "@types/gapi": "^0.0.47", @@ -136,6 +137,7 @@ }, "pnpm": { "overrides": { + "@nxg-org/mineflayer-physics-util": "1.5.8", "three": "0.154.0", "diamond-square": "github:zardoy/diamond-square", "prismarine-block": "github:zardoy/prismarine-block#next-era", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 483f0277f..4c43c6ba1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,7 @@ settings: excludeLinksFromLockfile: false overrides: + '@nxg-org/mineflayer-physics-util': 1.5.8 three: 0.154.0 diamond-square: github:zardoy/diamond-square prismarine-block: github:zardoy/prismarine-block#next-era @@ -27,6 +28,9 @@ importers: '@mui/base': specifier: 5.0.0-beta.34 version: 5.0.0-beta.34(@types/react@18.2.20)(react-dom@18.2.0)(react@18.2.0) + '@nxg-org/mineflayer-auto-jump': + specifier: ^0.7.5 + version: 0.7.5 '@nxg-org/mineflayer-tracker': specifier: ^1.2.1 version: 1.2.1 @@ -186,7 +190,7 @@ importers: optionalDependencies: systeminformation: specifier: ^5.21.22 - version: 5.21.24 + version: 5.22.7 devDependencies: '@storybook/addon-essentials': specifier: ^7.4.6 @@ -202,13 +206,13 @@ importers: version: 7.4.6(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2) '@storybook/react-vite': specifier: ^7.4.6 - version: 7.4.6(react-dom@18.2.0)(react@18.2.0)(rollup@2.79.1)(typescript@5.2.2)(vite@4.5.2) + version: 7.4.6(react-dom@18.2.0)(react@18.2.0)(rollup@2.79.1)(typescript@5.2.2)(vite@4.5.3) '@storybook/web-components': specifier: ^7.4.6 version: 7.4.6(lit@2.8.0)(react-dom@18.2.0)(react@18.2.0) '@storybook/web-components-vite': specifier: ^7.4.6 - version: 7.4.6(lit@2.8.0)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(vite@4.5.2) + version: 7.4.6(lit@2.8.0)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(vite@4.5.3) '@types/lodash-es': specifier: ^4.17.9 version: 4.17.9 @@ -256,7 +260,7 @@ importers: version: 8.50.0 eslint-config-zardoy: specifier: ^0.2.17 - version: 0.2.17(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.33.2)(eslint@8.50.0)(typescript@5.2.2) + version: 0.2.17(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.34.1)(eslint@8.50.0)(typescript@5.2.2) events: specifier: ^3.3.0 version: 3.3.0 @@ -436,15 +440,15 @@ packages: default-browser-id: 3.0.0 dev: true - /@azure/msal-common@14.7.0: - resolution: {integrity: sha512-WexujW5jKWib7xtIxR7fEVyd5xcA3FNwenELy2HO4YC/ivTFdsEcDhtpKQuRUHqXRwxoqBblyZzTAhBm4v6fHA==} + /@azure/msal-common@14.9.0: + resolution: {integrity: sha512-yzBPRlWPnTBeixxLNI3BBIgF5/bHpbhoRVuuDBnYjCyWRavaPUsKAHUDYLqpGkBLDciA6TCc6GOxN4/S3WiSxg==} engines: {node: '>=0.8.0'} - /@azure/msal-node@2.6.3: - resolution: {integrity: sha512-ojjJqUwb297T5Tcln4PbJANFEqRXfbQXcyOrtdr1HQYIo+dSuCT/o0nG6bFVihf6fcNykDwJLCQPVXzTkx/oGg==} + /@azure/msal-node@2.7.0: + resolution: {integrity: sha512-wXD8LkUvHICeSWZydqg6o8Yvv+grlBEcmLGu+QEI4FcwFendbTEZrlSygnAXXSOCVaGAirWLchca35qrgpO6Jw==} engines: {node: '>=16'} dependencies: - '@azure/msal-common': 14.7.0 + '@azure/msal-common': 14.9.0 jsonwebtoken: 9.0.2 uuid: 8.3.2 @@ -3138,7 +3142,7 @@ packages: regenerator-runtime: 0.13.11 dev: false - /@joshwooding/vite-plugin-react-docgen-typescript@0.2.1(typescript@5.2.2)(vite@4.5.2): + /@joshwooding/vite-plugin-react-docgen-typescript@0.2.1(typescript@5.2.2)(vite@4.5.3): resolution: {integrity: sha512-ou4ZJSXMMWHqGS4g8uNRbC5TiTWxAgQZiVucoUrOCWuPrTbkpJbmVyIi9jU72SBry7gQtuMEDp4YR8EEXAg7VQ==} peerDependencies: typescript: '>= 4.3.x' @@ -3152,7 +3156,7 @@ packages: magic-string: 0.27.0 react-docgen-typescript: 2.2.2(typescript@5.2.2) typescript: 5.2.2 - vite: 4.5.2 + vite: 4.5.3 dev: true /@jridgewell/gen-mapping@0.3.3: @@ -3337,6 +3341,19 @@ packages: dev: false optional: true + /@nxg-org/mineflayer-auto-jump@0.7.5: + resolution: {integrity: sha512-wvPLPW06nxz9/WimNdReF41I6mSQcxAcJFFBmN9geaSdnPkr8GVxq6daJSDwXXktNsh8/NBusJhMkJGh6eNnZg==} + dependencies: + '@nxg-org/mineflayer-physics-util': 1.5.8 + strict-event-emitter-types: 2.0.0 + dev: false + + /@nxg-org/mineflayer-physics-util@1.5.8: + resolution: {integrity: sha512-KmCkAqpUo8BbuRdIBs6+V2hWHehz++PRz3lRwIsb47CuG0u4sgLYh37RY3ifAznC6uWvmPK+q3B4ZXwJzPy1MQ==} + dependencies: + '@nxg-org/mineflayer-util-plugin': 1.8.3 + dev: false + /@nxg-org/mineflayer-tracker@1.2.1: resolution: {integrity: sha512-SI1ffF8zvg3/ZNE021Ja2W0FZPN+WbQDZf8yFqOcXtPRXAtM9W6HvoACdzXep8BZid7WYgYLIgjKpB+9RqvCNQ==} dependencies: @@ -4370,7 +4387,7 @@ packages: - supports-color dev: true - /@storybook/builder-vite@7.4.6(typescript@5.2.2)(vite@4.5.2): + /@storybook/builder-vite@7.4.6(typescript@5.2.2)(vite@4.5.3): resolution: {integrity: sha512-xV9STYK+TkqWWTf2ydm6jx+7P70fjD2UPd1XTUw08uKszIjhuuxk+bG/OF5R1E25mPunAKXm6kBFh351AKejBg==} peerDependencies: '@preact/preset-vite': '*' @@ -4405,7 +4422,7 @@ packages: remark-slug: 6.1.0 rollup: 3.29.4 typescript: 5.2.2 - vite: 4.5.2 + vite: 4.5.3 transitivePeerDependencies: - encoding - supports-color @@ -4746,7 +4763,7 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: true - /@storybook/react-vite@7.4.6(react-dom@18.2.0)(react@18.2.0)(rollup@2.79.1)(typescript@5.2.2)(vite@4.5.2): + /@storybook/react-vite@7.4.6(react-dom@18.2.0)(react@18.2.0)(rollup@2.79.1)(typescript@5.2.2)(vite@4.5.3): resolution: {integrity: sha512-jkjnrf3FxzR5wcmebXRPflrsM4WIDjWyW/NVFJwxi5PeIOk7fE7/QAPrm4NFRUu2Q7DeuH3oLKsw8bigvUI9RA==} engines: {node: '>=16'} peerDependencies: @@ -4754,17 +4771,17 @@ packages: react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 vite: ^3.0.0 || ^4.0.0 dependencies: - '@joshwooding/vite-plugin-react-docgen-typescript': 0.2.1(typescript@5.2.2)(vite@4.5.2) + '@joshwooding/vite-plugin-react-docgen-typescript': 0.2.1(typescript@5.2.2)(vite@4.5.3) '@rollup/pluginutils': 5.0.5(rollup@2.79.1) - '@storybook/builder-vite': 7.4.6(typescript@5.2.2)(vite@4.5.2) + '@storybook/builder-vite': 7.4.6(typescript@5.2.2)(vite@4.5.3) '@storybook/react': 7.4.6(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2) - '@vitejs/plugin-react': 3.1.0(vite@4.5.2) + '@vitejs/plugin-react': 3.1.0(vite@4.5.3) ast-types: 0.14.2 magic-string: 0.30.4 react: 18.2.0 react-docgen: 6.0.0-alpha.3 react-dom: 18.2.0(react@18.2.0) - vite: 4.5.2 + vite: 4.5.3 transitivePeerDependencies: - '@preact/preset-vite' - encoding @@ -4866,14 +4883,14 @@ packages: file-system-cache: 2.3.0 dev: true - /@storybook/web-components-vite@7.4.6(lit@2.8.0)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(vite@4.5.2): + /@storybook/web-components-vite@7.4.6(lit@2.8.0)(react-dom@18.2.0)(react@18.2.0)(typescript@5.2.2)(vite@4.5.3): resolution: {integrity: sha512-L/y6MTLbqfHaM0faK9Yl8n5PIyW4daZrtk7NfaOT6UjgNFjOx3o4CctYew6oj90cNk5HdZQX2OZny043GxDLZw==} engines: {node: ^14.18 || >=16} peerDependencies: react: ^18.2.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 dependencies: - '@storybook/builder-vite': 7.4.6(typescript@5.2.2)(vite@4.5.2) + '@storybook/builder-vite': 7.4.6(typescript@5.2.2)(vite@4.5.3) '@storybook/core-server': 7.4.6 '@storybook/node-logger': 7.4.6 '@storybook/web-components': 7.4.6(lit@2.8.0)(react-dom@18.2.0)(react@18.2.0) @@ -5184,6 +5201,13 @@ packages: /@types/node@20.11.19: resolution: {integrity: sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==} + requiresBuild: true + dependencies: + undici-types: 5.26.5 + optional: true + + /@types/node@20.12.7: + resolution: {integrity: sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==} dependencies: undici-types: 5.26.5 @@ -5248,10 +5272,10 @@ packages: '@types/scheduler': 0.16.3 csstype: 3.1.2 - /@types/readable-stream@4.0.10: - resolution: {integrity: sha512-AbUKBjcC8SHmImNi4yK2bbjogQlkFSg7shZCcicxPQapniOlajG8GCc39lvXzCWX4lLRRs7DM3VAeSlqmEVZUA==} + /@types/readable-stream@4.0.11: + resolution: {integrity: sha512-R3eUMUTTKoIoaz7UpYLxvZCrOmCRPRbAmoDDHKcimTEySltaJhF8hLzj4+EzyDifiX5eK6oDQGSfmNnXjxZzYQ==} dependencies: - '@types/node': 20.11.19 + '@types/node': 20.12.7 safe-buffer: 5.1.2 /@types/resolve@1.17.1: @@ -5534,7 +5558,7 @@ packages: eslint-visitor-keys: 3.4.3 dev: true - /@vitejs/plugin-react@3.1.0(vite@4.5.2): + /@vitejs/plugin-react@3.1.0(vite@4.5.3): resolution: {integrity: sha512-AfgcRL8ZBhAlc3BFdigClmTUMISmmzHn7sB2h9U1odvc5U/MjWXsAaz18b/WoppUTDBzxOJwo2VdClfUcItu9g==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: @@ -5545,7 +5569,7 @@ packages: '@babel/plugin-transform-react-jsx-source': 7.22.5(@babel/core@7.22.11) magic-string: 0.27.0 react-refresh: 0.14.0 - vite: 4.5.2 + vite: 4.5.3 transitivePeerDependencies: - supports-color dev: true @@ -5718,7 +5742,7 @@ packages: prismarine-nbt: 2.5.0 prismarine-provider-anvil: github.com/zardoy/prismarine-provider-anvil/0ddcd9d48574113308e1fbebef60816aced0846f(minecraft-data@3.62.0) prismarine-windows: 2.9.0 - prismarine-world: github.com/zardoy/prismarine-world/c358222204d21fe7d45379fbfcefb047f926c786 + prismarine-world: github.com/zardoy/prismarine-world/6ae6f009d38460de284f8c226c665f04cbad9465 random-seed: 0.3.0 range: 0.0.3 readline: 1.3.0 @@ -6014,11 +6038,35 @@ packages: is-string: 1.0.7 dev: true + /array-includes@3.1.8: + resolution: {integrity: sha512-itaWrbYbqpGXkGhZPGUulwnhVf5Hpy1xiCFsGqyIGglbBxmG5vSjxQen3/WGOjPpNEv1RtBLKxbmVXm8HpJStQ==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-abstract: 1.23.3 + es-object-atoms: 1.0.0 + get-intrinsic: 1.2.4 + is-string: 1.0.7 + dev: true + /array-union@2.1.0: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} engines: {node: '>=8'} dev: true + /array.prototype.findlast@1.2.5: + resolution: {integrity: sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-abstract: 1.23.3 + es-errors: 1.3.0 + es-object-atoms: 1.0.0 + es-shim-unscopables: 1.0.2 + dev: true + /array.prototype.flat@1.3.2: resolution: {integrity: sha512-djYB+Zx2vLewY8RWlNCUdHjDXs2XOgm602S9E7P/UpHgfeHL00cRiIF+IN/G/aUJ7kGPb6yO/ErDI5V2s8iycA==} engines: {node: '>= 0.4'} @@ -6039,12 +6087,21 @@ packages: es-shim-unscopables: 1.0.0 dev: true + /array.prototype.toreversed@1.1.2: + resolution: {integrity: sha512-wwDCoT4Ck4Cz7sLtgUmzR5UV3YF5mFHUlbChCzZBQZ+0m2cl/DH3tKgvphv1nKgFsJ48oCSg6p91q2Vm0I/ZMA==} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-abstract: 1.23.3 + es-shim-unscopables: 1.0.2 + dev: true + /array.prototype.tosorted@1.1.3: resolution: {integrity: sha512-/DdH4TiTmOKzyQbp/eadcCVexiCb36xJg7HshYOYJnNZFDj33GEv0P7GxsynpShhq4OLYJzbGcBDkLsDt7MnNg==} dependencies: call-bind: 1.0.7 define-properties: 1.2.1 - es-abstract: 1.22.4 + es-abstract: 1.23.3 es-errors: 1.3.0 es-shim-unscopables: 1.0.2 dev: true @@ -6068,11 +6125,11 @@ packages: array-buffer-byte-length: 1.0.1 call-bind: 1.0.7 define-properties: 1.2.1 - es-abstract: 1.22.4 + es-abstract: 1.23.3 es-errors: 1.3.0 get-intrinsic: 1.2.4 is-array-buffer: 3.0.4 - is-shared-array-buffer: 1.0.2 + is-shared-array-buffer: 1.0.3 dev: true /arraybuffer.slice@0.0.7: @@ -6157,12 +6214,6 @@ packages: /async@3.2.5: resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} - /asynciterator.prototype@1.0.0: - resolution: {integrity: sha512-wwHYEIS0Q80f5mosx3L/dfG5t5rjEa9Ft51GTaNt862EnpyGHpgz2RkZvLPp1oF5TnAiTohkEKVEu8pQPJI7Vg==} - dependencies: - has-symbols: 1.0.3 - dev: true - /asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} @@ -6174,9 +6225,11 @@ packages: resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} engines: {node: '>= 0.4'} - /available-typed-arrays@1.0.6: - resolution: {integrity: sha512-j1QzY8iPNPG4o4xmO3ptzpRxTciqD3MgEHtifP/YnJpIo58Xu+ne4BejlbkuaLfXn/nz6HFiw29bLpj2PNMdGg==} + /available-typed-arrays@1.0.7: + resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} engines: {node: '>= 0.4'} + dependencies: + possible-typed-array-names: 1.0.0 dev: true /aws-sign2@0.7.0: @@ -6188,7 +6241,7 @@ packages: /axios@0.21.4(debug@4.3.4): resolution: {integrity: sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==} dependencies: - follow-redirects: 1.15.5(debug@4.3.4) + follow-redirects: 1.15.6(debug@4.3.4) transitivePeerDependencies: - debug @@ -7305,6 +7358,33 @@ packages: dependencies: assert-plus: 1.0.0 + /data-view-buffer@1.0.1: + resolution: {integrity: sha512-0lht7OugA5x3iJLOWFhWK/5ehONdprk0ISXqVFn/NFrDu+cuc8iADFrGQz5BnRK7LLU3JmkbXSxaqX+/mXYtUA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + es-errors: 1.3.0 + is-data-view: 1.0.1 + dev: true + + /data-view-byte-length@1.0.1: + resolution: {integrity: sha512-4J7wRJD3ABAzr8wP+OcIcqq2dlUKp4DVflx++hs5h5ZKydWMI6/D/fAot+yh6g2tHh8fLFTvNOaVN357NvSrOQ==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + es-errors: 1.3.0 + is-data-view: 1.0.1 + dev: true + + /data-view-byte-offset@1.0.0: + resolution: {integrity: sha512-t/Ygsytq+R995EJ5PZlD4Cu56sWa8InXySaViRzw9apusqsOO2bQP+SbYzAhR0pFKoB+43lYy8rWban9JSuXnA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + es-errors: 1.3.0 + is-data-view: 1.0.1 + dev: true + /dayjs@1.11.9: resolution: {integrity: sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA==} @@ -7945,17 +8025,21 @@ packages: unbox-primitive: 1.0.2 which-typed-array: 1.1.11 - /es-abstract@1.22.4: - resolution: {integrity: sha512-vZYJlk2u6qHYxBOTjAeg7qUxHdNfih64Uu2J8QqWgXZ2cri0ZpJAkzDUK/q593+mvKwlxyaxr6F1Q+3LKoQRgg==} + /es-abstract@1.23.3: + resolution: {integrity: sha512-e+HfNH61Bj1X9/jLc5v1owaLYuHdeHHSQlkhCBiTK8rBvKaULl/beGMxwrMXjpYrv4pz22BlY570vVePA2ho4A==} engines: {node: '>= 0.4'} dependencies: array-buffer-byte-length: 1.0.1 arraybuffer.prototype.slice: 1.0.3 - available-typed-arrays: 1.0.6 + available-typed-arrays: 1.0.7 call-bind: 1.0.7 + data-view-buffer: 1.0.1 + data-view-byte-length: 1.0.1 + data-view-byte-offset: 1.0.0 es-define-property: 1.0.0 es-errors: 1.3.0 - es-set-tostringtag: 2.0.2 + es-object-atoms: 1.0.0 + es-set-tostringtag: 2.0.3 es-to-primitive: 1.2.1 function.prototype.name: 1.1.6 get-intrinsic: 1.2.4 @@ -7963,15 +8047,16 @@ packages: globalthis: 1.0.3 gopd: 1.0.1 has-property-descriptors: 1.0.2 - has-proto: 1.0.1 + has-proto: 1.0.3 has-symbols: 1.0.3 - hasown: 2.0.1 + hasown: 2.0.2 internal-slot: 1.0.7 is-array-buffer: 3.0.4 is-callable: 1.2.7 - is-negative-zero: 2.0.2 + is-data-view: 1.0.1 + is-negative-zero: 2.0.3 is-regex: 1.1.4 - is-shared-array-buffer: 1.0.2 + is-shared-array-buffer: 1.0.3 is-string: 1.0.7 is-typed-array: 1.1.13 is-weakref: 1.0.2 @@ -7979,17 +8064,17 @@ packages: object-keys: 1.1.1 object.assign: 4.1.5 regexp.prototype.flags: 1.5.2 - safe-array-concat: 1.1.0 + safe-array-concat: 1.1.2 safe-regex-test: 1.0.3 - string.prototype.trim: 1.2.8 - string.prototype.trimend: 1.0.7 - string.prototype.trimstart: 1.0.7 - typed-array-buffer: 1.0.1 - typed-array-byte-length: 1.0.0 - typed-array-byte-offset: 1.0.0 - typed-array-length: 1.0.4 + string.prototype.trim: 1.2.9 + string.prototype.trimend: 1.0.8 + string.prototype.trimstart: 1.0.8 + typed-array-buffer: 1.0.2 + typed-array-byte-length: 1.0.1 + typed-array-byte-offset: 1.0.2 + typed-array-length: 1.0.6 unbox-primitive: 1.0.2 - which-typed-array: 1.1.14 + which-typed-array: 1.1.15 dev: true /es-define-property@1.0.0: @@ -8002,31 +8087,37 @@ packages: resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} engines: {node: '>= 0.4'} - /es-iterator-helpers@1.0.17: - resolution: {integrity: sha512-lh7BsUqelv4KUbR5a/ZTaGGIMLCjPGPqJ6q+Oq24YP0RdyptX1uzm4vvaqzk7Zx3bpl/76YLTTDj9L7uYQ92oQ==} + /es-iterator-helpers@1.0.18: + resolution: {integrity: sha512-scxAJaewsahbqTYrGKJihhViaM6DDZDDoucfvzNbK0pOren1g/daDQ3IAhzn+1G14rBG7w+i5N+qul60++zlKA==} engines: {node: '>= 0.4'} dependencies: - asynciterator.prototype: 1.0.0 call-bind: 1.0.7 define-properties: 1.2.1 - es-abstract: 1.22.4 + es-abstract: 1.23.3 es-errors: 1.3.0 - es-set-tostringtag: 2.0.2 + es-set-tostringtag: 2.0.3 function-bind: 1.1.2 get-intrinsic: 1.2.4 globalthis: 1.0.3 has-property-descriptors: 1.0.2 - has-proto: 1.0.1 + has-proto: 1.0.3 has-symbols: 1.0.3 internal-slot: 1.0.7 iterator.prototype: 1.1.2 - safe-array-concat: 1.1.0 + safe-array-concat: 1.1.2 dev: true /es-module-lexer@0.9.3: resolution: {integrity: sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==} dev: true + /es-object-atoms@1.0.0: + resolution: {integrity: sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==} + engines: {node: '>= 0.4'} + dependencies: + es-errors: 1.3.0 + dev: true + /es-set-tostringtag@2.0.1: resolution: {integrity: sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==} engines: {node: '>= 0.4'} @@ -8035,13 +8126,13 @@ packages: has: 1.0.3 has-tostringtag: 1.0.0 - /es-set-tostringtag@2.0.2: - resolution: {integrity: sha512-BuDyupZt65P9D2D2vA/zqcI3G5xRsklm5N3xCwuiy+/vKy8i0ifdsQP1sLgO4tZDSCaQUSnmC48khknGMV3D2Q==} + /es-set-tostringtag@2.0.3: + resolution: {integrity: sha512-3T8uNMC3OQTHkFUsFq8r/BwAXLHvU/9O9mE0fBc/MY5iq/8H7ncvO947LmYA6ldWw9Uh8Yhf25zu6n7nML5QWQ==} engines: {node: '>= 0.4'} dependencies: get-intrinsic: 1.2.4 has-tostringtag: 1.0.2 - hasown: 2.0.1 + hasown: 2.0.2 dev: true /es-shim-unscopables@1.0.0: @@ -8053,7 +8144,7 @@ packages: /es-shim-unscopables@1.0.2: resolution: {integrity: sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw==} dependencies: - hasown: 2.0.1 + hasown: 2.0.2 dev: true /es-to-primitive@1.2.1: @@ -8228,7 +8319,7 @@ packages: eslint: 8.50.0 dev: true - /eslint-config-xo-react@0.27.0(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.33.2)(eslint@8.50.0): + /eslint-config-xo-react@0.27.0(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.34.1)(eslint@8.50.0): resolution: {integrity: sha512-wiV215xQIn71XZyyVfaOXHaFpR1B14IJttwOjMi/eqUK1s+ojJdHr7eHqTLaGUfh6FKgWha1QNwePlIXx7mBUg==} engines: {node: '>=12'} peerDependencies: @@ -8237,7 +8328,7 @@ packages: eslint-plugin-react-hooks: '>=4.3.0' dependencies: eslint: 8.50.0 - eslint-plugin-react: 7.33.2(eslint@8.50.0) + eslint-plugin-react: 7.34.1(eslint@8.50.0) eslint-plugin-react-hooks: 4.6.0(eslint@8.50.0) dev: true @@ -8266,7 +8357,7 @@ packages: eslint: 8.50.0 dev: true - /eslint-config-zardoy@0.2.17(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.33.2)(eslint@8.50.0)(typescript@5.2.2): + /eslint-config-zardoy@0.2.17(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.34.1)(eslint@8.50.0)(typescript@5.2.2): resolution: {integrity: sha512-d31WsjyVSQqHbzTpBSmH96+nw5gwY2yhDbZatU89gr+U8ou1FRUkJSApYJUgmcINt8AQocj1RDDAVYmVSILZgQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} peerDependencies: @@ -8286,7 +8377,7 @@ packages: eslint: 8.50.0 eslint-config-prettier: 8.10.0(eslint@8.50.0) eslint-config-xo: 0.43.1(eslint@8.50.0) - eslint-config-xo-react: 0.27.0(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.33.2)(eslint@8.50.0) + eslint-config-xo-react: 0.27.0(eslint-plugin-react-hooks@4.6.0)(eslint-plugin-react@7.34.1)(eslint@8.50.0) eslint-config-xo-typescript: 1.0.1(@typescript-eslint/eslint-plugin@6.1.0)(@typescript-eslint/parser@6.7.3)(eslint@8.50.0)(typescript@5.2.2) eslint-plugin-eslint-comments: 3.2.0(eslint@8.50.0) eslint-plugin-import: 2.27.5(@typescript-eslint/parser@6.7.3)(eslint@8.50.0) @@ -8420,29 +8511,31 @@ packages: eslint: 8.50.0 dev: true - /eslint-plugin-react@7.33.2(eslint@8.50.0): - resolution: {integrity: sha512-73QQMKALArI8/7xGLNI/3LylrEYrlKZSb5C9+q3OtOewTnMQi5cT+aE9E41sLCmli3I9PGGmD1yiZydyo4FEPw==} + /eslint-plugin-react@7.34.1(eslint@8.50.0): + resolution: {integrity: sha512-N97CxlouPT1AHt8Jn0mhhN2RrADlUAsk1/atcT2KyA/l9Q/E6ll7OIGwNumFmWfZ9skV3XXccYS19h80rHtgkw==} engines: {node: '>=4'} peerDependencies: eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 dependencies: - array-includes: 3.1.7 + array-includes: 3.1.8 + array.prototype.findlast: 1.2.5 array.prototype.flatmap: 1.3.2 + array.prototype.toreversed: 1.1.2 array.prototype.tosorted: 1.1.3 doctrine: 2.1.0 - es-iterator-helpers: 1.0.17 + es-iterator-helpers: 1.0.18 eslint: 8.50.0 estraverse: 5.3.0 jsx-ast-utils: 3.3.5 minimatch: 3.1.2 - object.entries: 1.1.7 - object.fromentries: 2.0.7 - object.hasown: 1.1.3 - object.values: 1.1.7 + object.entries: 1.1.8 + object.fromentries: 2.0.8 + object.hasown: 1.1.4 + object.values: 1.2.0 prop-types: 15.8.1 resolve: 2.0.0-next.5 semver: 6.3.1 - string.prototype.matchall: 4.0.10 + string.prototype.matchall: 4.0.11 dev: true /eslint-plugin-sonarjs@0.19.0(eslint@8.50.0): @@ -8973,8 +9066,8 @@ packages: debug: 4.3.4(supports-color@8.1.1) dev: true - /follow-redirects@1.15.5(debug@4.3.4): - resolution: {integrity: sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==} + /follow-redirects@1.15.6(debug@4.3.4): + resolution: {integrity: sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==} engines: {node: '>=4.0'} peerDependencies: debug: '*' @@ -9465,6 +9558,11 @@ packages: resolution: {integrity: sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==} engines: {node: '>= 0.4'} + /has-proto@1.0.3: + resolution: {integrity: sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==} + engines: {node: '>= 0.4'} + dev: true + /has-symbols@1.0.3: resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==} engines: {node: '>= 0.4'} @@ -9514,6 +9612,13 @@ packages: dependencies: function-bind: 1.1.2 + /hasown@2.0.2: + resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} + engines: {node: '>= 0.4'} + dependencies: + function-bind: 1.1.2 + dev: true + /he@1.2.0: resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} hasBin: true @@ -9811,8 +9916,8 @@ packages: engines: {node: '>= 0.4'} dependencies: es-errors: 1.3.0 - hasown: 2.0.1 - side-channel: 1.0.5 + hasown: 2.0.2 + side-channel: 1.0.6 dev: true /invariant@2.2.4: @@ -9913,7 +10018,14 @@ packages: /is-core-module@2.13.1: resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} dependencies: - hasown: 2.0.1 + hasown: 2.0.2 + dev: true + + /is-data-view@1.0.1: + resolution: {integrity: sha512-AHkaJrsUVW6wq6JS8y3JnM/GJF/9cf+k20+iDzlSaJrinEo5+7vRiteOSwBhHRiAyQATN1AmY4hwzxJKPmYf+w==} + engines: {node: '>= 0.4'} + dependencies: + is-typed-array: 1.1.13 dev: true /is-date-object@1.0.5: @@ -9987,8 +10099,9 @@ packages: dev: false optional: true - /is-map@2.0.2: - resolution: {integrity: sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg==} + /is-map@2.0.3: + resolution: {integrity: sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==} + engines: {node: '>= 0.4'} dev: true /is-module@1.0.0: @@ -10006,6 +10119,11 @@ packages: resolution: {integrity: sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==} engines: {node: '>= 0.4'} + /is-negative-zero@2.0.3: + resolution: {integrity: sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==} + engines: {node: '>= 0.4'} + dev: true + /is-number-object@1.0.7: resolution: {integrity: sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==} engines: {node: '>= 0.4'} @@ -10065,8 +10183,9 @@ packages: engines: {node: '>=0.10.0'} dev: false - /is-set@2.0.2: - resolution: {integrity: sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g==} + /is-set@2.0.3: + resolution: {integrity: sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==} + engines: {node: '>= 0.4'} dev: true /is-shared-array-buffer@1.0.2: @@ -10074,6 +10193,13 @@ packages: dependencies: call-bind: 1.0.2 + /is-shared-array-buffer@1.0.3: + resolution: {integrity: sha512-nA2hv5XIhLR3uVzDDfCIknerhx8XUKnstuOERPNNIinXG7v9u+ohXF67vxm4TPTEPU6lm61ZkwP3c9PCB97rhg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + dev: true + /is-stream@2.0.1: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} @@ -10100,7 +10226,7 @@ packages: resolution: {integrity: sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==} engines: {node: '>= 0.4'} dependencies: - which-typed-array: 1.1.14 + which-typed-array: 1.1.15 dev: true /is-typedarray@1.0.0: @@ -10110,8 +10236,9 @@ packages: resolution: {integrity: sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==} engines: {node: '>=10'} - /is-weakmap@2.0.1: - resolution: {integrity: sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==} + /is-weakmap@2.0.2: + resolution: {integrity: sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==} + engines: {node: '>= 0.4'} dev: true /is-weakref@1.0.2: @@ -10119,8 +10246,9 @@ packages: dependencies: call-bind: 1.0.2 - /is-weakset@2.0.2: - resolution: {integrity: sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==} + /is-weakset@2.0.3: + resolution: {integrity: sha512-LvIm3/KWzS9oRFHugab7d+M/GcBXuXX5xZkzPmN+NxihdQlZUQ4dWuSV1xR/sq6upL1TJEDrfBgRepHFdBtSNQ==} + engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.7 get-intrinsic: 1.2.4 @@ -10201,8 +10329,8 @@ packages: define-properties: 1.2.1 get-intrinsic: 1.2.4 has-symbols: 1.0.3 - reflect.getprototypeof: 1.0.5 - set-function-name: 2.0.1 + reflect.getprototypeof: 1.0.6 + set-function-name: 2.0.2 dev: true /jackspeak@2.3.0: @@ -10290,8 +10418,8 @@ packages: regenerator-runtime: 0.13.11 dev: false - /jose@4.15.4: - resolution: {integrity: sha512-W+oqK4H+r5sITxfxpSU+MMdr/YSWGvgZMQDIsNoBDGGy4i7GBPTtvFKibQzW06n3U3TqHjhvBJsirShsEJ6eeQ==} + /jose@4.15.5: + resolution: {integrity: sha512-jc7BFxgKPKi94uOvEmzlSWFFe2+vASyXaKUpdQKatWAESU2MWjDfFf0fdfc83CDKcA5QecabZeNLyfhe3yKNkg==} /jpeg-js@0.3.7: resolution: {integrity: sha512-9IXdWudL61npZjvLuVe/ktHiA41iE8qFyLB+4VDTblEsWBzeg8WQTlktdUK4CdncUqtUgUg0bbOmTE2bKBKaBQ==} @@ -10466,10 +10594,10 @@ packages: resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==} engines: {node: '>=4.0'} dependencies: - array-includes: 3.1.7 + array-includes: 3.1.8 array.prototype.flat: 1.3.2 object.assign: 4.1.5 - object.values: 1.1.7 + object.values: 1.2.0 dev: true /jszip@3.10.1: @@ -11815,29 +11943,32 @@ packages: object-keys: 1.1.1 dev: true - /object.entries@1.1.7: - resolution: {integrity: sha512-jCBs/0plmPsOnrKAfFQXRG2NFjlhZgjjcBLSmTnEhU8U6vVTsVe8ANeQJCHTl3gSsI4J+0emOoCgoKlmQPMgmA==} + /object.entries@1.1.8: + resolution: {integrity: sha512-cmopxi8VwRIAw/fkijJohSfpef5PdN0pMQJN6VC/ZKvn0LIknWD8KtgY6KlQdEc4tIjcQ3HxSMmnvtzIscdaYQ==} engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.7 define-properties: 1.2.1 - es-abstract: 1.22.4 + es-object-atoms: 1.0.0 dev: true - /object.fromentries@2.0.7: - resolution: {integrity: sha512-UPbPHML6sL8PI/mOqPwsH4G6iyXcCGzLin8KvEPenOZN5lpCNBZZQ+V62vdjB1mQHrmqGQt5/OJzemUA+KJmEA==} + /object.fromentries@2.0.8: + resolution: {integrity: sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ==} engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.7 define-properties: 1.2.1 - es-abstract: 1.22.4 + es-abstract: 1.23.3 + es-object-atoms: 1.0.0 dev: true - /object.hasown@1.1.3: - resolution: {integrity: sha512-fFI4VcYpRHvSLXxP7yiZOMAd331cPfd2p7PFDVbgUsYOfCT3tICVqXWngbjr4m49OvsBwUBQ6O2uQoJvy3RexA==} + /object.hasown@1.1.4: + resolution: {integrity: sha512-FZ9LZt9/RHzGySlBARE3VF+gE26TxR38SdmqOqliuTnl9wrKulaQs+4dee1V+Io8VfxqzAfHu6YuRgUy8OHoTg==} + engines: {node: '>= 0.4'} dependencies: define-properties: 1.2.1 - es-abstract: 1.22.4 + es-abstract: 1.23.3 + es-object-atoms: 1.0.0 dev: true /object.values@1.1.7: @@ -11849,6 +11980,15 @@ packages: es-abstract: 1.22.2 dev: true + /object.values@1.2.0: + resolution: {integrity: sha512-yBYjY9QX2hnRmZHAjG/f13MzmBzxzYgQhFrke06TTyKY5zSTEqkOeukBzIdVA3j3ulu8Qa3MbVFShV7T2RmGtQ==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-object-atoms: 1.0.0 + dev: true + /omggif@1.0.10: resolution: {integrity: sha512-LMJTtvgc/nugXj0Vcrrs68Mn2D1r0zf630VNtqtpI1FEO7e+O9FP4gqs9AcnBaSEeoHIPm28u6qgPR0oyEpGSw==} dev: false @@ -12296,6 +12436,11 @@ packages: - supports-color dev: true + /possible-typed-array-names@1.0.0: + resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==} + engines: {node: '>= 0.4'} + dev: true + /postcss@8.4.31: resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} engines: {node: ^10 || ^12 || >=14} @@ -12304,13 +12449,13 @@ packages: picocolors: 1.0.0 source-map-js: 1.0.2 - /postcss@8.4.35: - resolution: {integrity: sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==} + /postcss@8.4.38: + resolution: {integrity: sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==} engines: {node: ^10 || ^12 || >=14} dependencies: nanoid: 3.3.7 picocolors: 1.0.0 - source-map-js: 1.0.2 + source-map-js: 1.2.0 dev: true /potpack@1.0.2: @@ -12376,13 +12521,13 @@ packages: engines: {node: '>= 0.8'} dev: true - /prismarine-auth@2.4.1: - resolution: {integrity: sha512-DwDI3Ucxf/eThJJo5QVzlywFrJulL1fK1z6F8bybvddim8YgudRksQc3w4cE2m0hPPHfE1BRd5lh1NpedrixMQ==} + /prismarine-auth@2.4.2: + resolution: {integrity: sha512-Cq4woGobnFYYfMBDh1WITW+Vs98toN91qAFBvBitwV7IwJaiSAh2Nl+WPUEGeg5eLBoSPpSyCVT8P2oi7Cav8g==} dependencies: - '@azure/msal-node': 2.6.3 + '@azure/msal-node': 2.7.0 '@xboxreplay/xboxlive-auth': 3.3.3(debug@4.3.4) debug: 4.3.4(supports-color@8.1.1) - jose: 4.15.4 + jose: 4.15.5 node-fetch: 2.7.0 smart-buffer: 4.2.0 uuid-1345: 1.0.2 @@ -12483,7 +12628,7 @@ packages: minecraft-data: 3.62.0 prismarine-block: github.com/zardoy/prismarine-block/ada4ec3fdfbbc1cc20ab01d0e23f0718a77cc1a0 prismarine-nbt: 2.2.1 - prismarine-world: github.com/zardoy/prismarine-world/c358222204d21fe7d45379fbfcefb047f926c786 + prismarine-world: github.com/zardoy/prismarine-world/6ae6f009d38460de284f8c226c665f04cbad9465 vec3: 0.1.8 dev: false @@ -13243,13 +13388,13 @@ packages: strip-indent: 4.0.0 dev: true - /reflect.getprototypeof@1.0.5: - resolution: {integrity: sha512-62wgfC8dJWrmxv44CA36pLDnP6KKl3Vhxb7PL+8+qrrFMMoJij4vgiMP8zV4O8+CBMXY1mHxI5fITGHXFHVmQQ==} + /reflect.getprototypeof@1.0.6: + resolution: {integrity: sha512-fmfw4XgoDke3kdI6h4xcUz1dG8uaiv5q9gcEwLS4Pnth2kxT+GZ7YehS1JTMGBQmtV7Y4GFGbs2re2NqhdozUg==} engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.7 define-properties: 1.2.1 - es-abstract: 1.22.4 + es-abstract: 1.23.3 es-errors: 1.3.0 get-intrinsic: 1.2.4 globalthis: 1.0.3 @@ -13297,7 +13442,7 @@ packages: call-bind: 1.0.7 define-properties: 1.2.1 es-errors: 1.3.0 - set-function-name: 2.0.1 + set-function-name: 2.0.2 dev: true /regexpp@3.2.0: @@ -13546,8 +13691,8 @@ packages: has-symbols: 1.0.3 isarray: 2.0.5 - /safe-array-concat@1.1.0: - resolution: {integrity: sha512-ZdQ0Jeb9Ofti4hbt5lX3T2JcAamT9hfzYU1MNB+z/jaEbB6wfFfPIR/zEORmZqobkCCJhSjodobH6WHNmJ97dg==} + /safe-array-concat@1.1.2: + resolution: {integrity: sha512-vj6RsCsWBCf19jIeHEfkRMw8DPiBb+DMXklQ/1SGDHOMlHdPUkZXFQ2YdplS23zESTijAcurb1aSgJA3AgMu1Q==} engines: {node: '>=0.4'} dependencies: call-bind: 1.0.7 @@ -13704,6 +13849,16 @@ packages: functions-have-names: 1.2.3 has-property-descriptors: 1.0.0 + /set-function-name@2.0.2: + resolution: {integrity: sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==} + engines: {node: '>= 0.4'} + dependencies: + define-data-property: 1.1.4 + es-errors: 1.3.0 + functions-have-names: 1.2.3 + has-property-descriptors: 1.0.2 + dev: true + /set-harmonic-interval@1.0.1: resolution: {integrity: sha512-AhICkFV84tBP1aWqPwLZqFvAwqEoVA9kxNMniGEUvzOlm4vLmOFLiTT3UZ6bziJTy4bOVpzWGTfSCbmaayGx8g==} engines: {node: '>=6.9'} @@ -13787,6 +13942,16 @@ packages: get-intrinsic: 1.2.4 object-inspect: 1.13.1 + /side-channel@1.0.6: + resolution: {integrity: sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + es-errors: 1.3.0 + get-intrinsic: 1.2.4 + object-inspect: 1.13.1 + dev: true + /siginfo@2.0.0: resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} dev: true @@ -14017,6 +14182,11 @@ packages: resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} engines: {node: '>=0.10.0'} + /source-map-js@1.2.0: + resolution: {integrity: sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==} + engines: {node: '>=0.10.0'} + dev: true + /source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} dependencies: @@ -14175,6 +14345,10 @@ packages: resolution: {integrity: sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==} dev: true + /strict-event-emitter-types@2.0.0: + resolution: {integrity: sha512-Nk/brWYpD85WlOgzw5h173aci0Teyv8YdIAEtV+N88nDB0dLlazZyJMIsN6eo1/AR61l+p6CJTG1JIyFaoNEEA==} + dev: false + /string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -14204,6 +14378,25 @@ packages: regexp.prototype.flags: 1.5.1 set-function-name: 2.0.1 side-channel: 1.0.4 + dev: false + + /string.prototype.matchall@4.0.11: + resolution: {integrity: sha512-NUdh0aDavY2og7IbBPenWqR9exH+E26Sv8e0/eTe1tltDGZL+GtBkDAnnyBtmekfK6/Dq3MkcGtzXFEd1LQrtg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-abstract: 1.23.3 + es-errors: 1.3.0 + es-object-atoms: 1.0.0 + get-intrinsic: 1.2.4 + gopd: 1.0.1 + has-symbols: 1.0.3 + internal-slot: 1.0.7 + regexp.prototype.flags: 1.5.2 + set-function-name: 2.0.2 + side-channel: 1.0.6 + dev: true /string.prototype.padend@3.1.4: resolution: {integrity: sha512-67otBXoksdjsnXXRUq+KMVTdlVRZ2af422Y0aTyTjVaoQkGr3mxl2Bc5emi7dOQ3OGVVQQskmLEWwFXwommpNw==} @@ -14222,6 +14415,16 @@ packages: define-properties: 1.2.1 es-abstract: 1.22.2 + /string.prototype.trim@1.2.9: + resolution: {integrity: sha512-klHuCNxiMZ8MlsOihJhJEBJAiMVqU3Z2nEXWfWnIqjN0gEFS9J9+IxKozWWtQGcgoa1WUZzLjKPTr4ZHNFTFxw==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-abstract: 1.23.3 + es-object-atoms: 1.0.0 + dev: true + /string.prototype.trimend@1.0.7: resolution: {integrity: sha512-Ni79DqeB72ZFq1uH/L6zJ+DKZTkOtPIHovb3YZHQViE+HDouuU4mBrLOLDn5Dde3RF8qw5qVETEjhu9locMLvA==} dependencies: @@ -14229,6 +14432,14 @@ packages: define-properties: 1.2.1 es-abstract: 1.22.2 + /string.prototype.trimend@1.0.8: + resolution: {integrity: sha512-p73uL5VCHCO2BZZ6krwwQE3kCzM7NKmis8S//xEC6fQonchbum4eP6kR4DLEjQFO3Wnj3Fuo8NM0kOSjVdHjZQ==} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-object-atoms: 1.0.0 + dev: true + /string.prototype.trimstart@1.0.7: resolution: {integrity: sha512-NGhtDFu3jCEm7B4Fy0DpLewdJQOZcQ0rGbwQ/+stjnrp2i+rlKeCvos9hOIeCmqwratM47OBxY7uFZzjxHXmrg==} dependencies: @@ -14236,6 +14447,15 @@ packages: define-properties: 1.2.1 es-abstract: 1.22.2 + /string.prototype.trimstart@1.0.8: + resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + define-properties: 1.2.1 + es-object-atoms: 1.0.0 + dev: true + /string_decoder@0.10.31: resolution: {integrity: sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==} requiresBuild: true @@ -14349,8 +14569,8 @@ packages: resolution: {integrity: sha512-AsS729u2RHUfEra9xJrE39peJcc2stq2+poBXX8bcM08Y6g9j/i/PUzwNQqkaJde7Ntg1TO7bSREbR5sdosQ+g==} dev: true - /systeminformation@5.21.24: - resolution: {integrity: sha512-xQada8ByGGFoRXJaUptGgddn3i7IjtSdqNdCKzB8xkzsM7pHnfLYBWxkPdGzhZ0Z/l+W1yo+aZQZ74d2isj8kw==} + /systeminformation@5.22.7: + resolution: {integrity: sha512-AWxlP05KeHbpGdgvZkcudJpsmChc2Y5Eo/GvxG/iUA/Aws5LZKHAMSeAo+V+nD+nxWZaxrwpWcnx4SH3oxNL3A==} engines: {node: '>=8.0.0'} os: [darwin, linux, win32, freebsd, openbsd, netbsd, sunos, android] hasBin: true @@ -14735,8 +14955,8 @@ packages: get-intrinsic: 1.2.1 is-typed-array: 1.1.12 - /typed-array-buffer@1.0.1: - resolution: {integrity: sha512-RSqu1UEuSlrBhHTWC8O9FnPjOduNs4M7rJ4pRKoEjtx1zUNOPN2sSXHLDX+Y2WPbHIxbvg4JFo2DNAEfPIKWoQ==} + /typed-array-buffer@1.0.2: + resolution: {integrity: sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==} engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.7 @@ -14753,6 +14973,17 @@ packages: has-proto: 1.0.1 is-typed-array: 1.1.12 + /typed-array-byte-length@1.0.1: + resolution: {integrity: sha512-3iMJ9q0ao7WE9tWcaYKIptkNBuOIcZCCT0d4MRvuuH88fEoEH62IuQe0OtraD3ebQEoTRk8XCBoknUNc1Y67pw==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + for-each: 0.3.3 + gopd: 1.0.1 + has-proto: 1.0.3 + is-typed-array: 1.1.13 + dev: true + /typed-array-byte-offset@1.0.0: resolution: {integrity: sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg==} engines: {node: '>= 0.4'} @@ -14763,6 +14994,18 @@ packages: has-proto: 1.0.1 is-typed-array: 1.1.12 + /typed-array-byte-offset@1.0.2: + resolution: {integrity: sha512-Ous0vodHa56FviZucS2E63zkgtgrACj7omjwd/8lTEMEPFFyjfixMZ1ZXenpgCFBBt4EC1J2XsyVS2gkG0eTFA==} + engines: {node: '>= 0.4'} + dependencies: + available-typed-arrays: 1.0.7 + call-bind: 1.0.7 + for-each: 0.3.3 + gopd: 1.0.1 + has-proto: 1.0.3 + is-typed-array: 1.1.13 + dev: true + /typed-array-length@1.0.4: resolution: {integrity: sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng==} dependencies: @@ -14770,6 +15013,18 @@ packages: for-each: 0.3.3 is-typed-array: 1.1.12 + /typed-array-length@1.0.6: + resolution: {integrity: sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==} + engines: {node: '>= 0.4'} + dependencies: + call-bind: 1.0.7 + for-each: 0.3.3 + gopd: 1.0.1 + has-proto: 1.0.3 + is-typed-array: 1.1.13 + possible-typed-array-names: 1.0.0 + dev: true + /typed-emitter@1.4.0: resolution: {integrity: sha512-weBmoo3HhpKGgLBOYwe8EB31CzDFuaK7CCL+axXhUYhn4jo6DSkHnbefboCF5i4DQ2aMFe0C/FdTWcPdObgHyg==} @@ -15250,8 +15505,8 @@ packages: optionalDependencies: fsevents: 2.3.3 - /vite@4.5.2: - resolution: {integrity: sha512-tBCZBNSBbHQkaGyhGCDUGqeo2ph8Fstyp6FMSvTtsXeZSPpSMGlviAOav2hxVTqFcx8Hj/twtWKsMJXNY0xI8w==} + /vite@4.5.3: + resolution: {integrity: sha512-kQL23kMeX92v3ph7IauVkXkikdDRsYMGTVl5KY2E9OY4ONLvkHf04MDTbnfo6NKxZiDLWzVpP5oTa8hQD8U3dg==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true peerDependencies: @@ -15279,7 +15534,7 @@ packages: optional: true dependencies: esbuild: 0.18.20 - postcss: 8.4.35 + postcss: 8.4.38 rollup: 3.29.4 optionalDependencies: fsevents: 2.3.3 @@ -15451,17 +15706,18 @@ packages: is-weakref: 1.0.2 isarray: 2.0.5 which-boxed-primitive: 1.0.2 - which-collection: 1.0.1 - which-typed-array: 1.1.14 + which-collection: 1.0.2 + which-typed-array: 1.1.15 dev: true - /which-collection@1.0.1: - resolution: {integrity: sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==} + /which-collection@1.0.2: + resolution: {integrity: sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==} + engines: {node: '>= 0.4'} dependencies: - is-map: 2.0.2 - is-set: 2.0.2 - is-weakmap: 2.0.1 - is-weakset: 2.0.2 + is-map: 2.0.3 + is-set: 2.0.3 + is-weakmap: 2.0.2 + is-weakset: 2.0.3 dev: true /which-typed-array@1.1.11: @@ -15474,11 +15730,11 @@ packages: gopd: 1.0.1 has-tostringtag: 1.0.0 - /which-typed-array@1.1.14: - resolution: {integrity: sha512-VnXFiIW8yNn9kIHN88xvZ4yOWchftKDsRJ8fEPacX/wl1lOvBrhsJ/OeJCXq7B0AaijRuqgzSKalJoPk+D8MPg==} + /which-typed-array@1.1.15: + resolution: {integrity: sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==} engines: {node: '>= 0.4'} dependencies: - available-typed-arrays: 1.0.6 + available-typed-arrays: 1.0.7 call-bind: 1.0.7 for-each: 0.3.3 gopd: 1.0.1 @@ -15929,7 +16185,7 @@ packages: prismarine-recipe: 1.3.1(prismarine-registry@1.7.0) prismarine-registry: 1.7.0 prismarine-windows: 2.9.0 - prismarine-world: github.com/zardoy/prismarine-world/c358222204d21fe7d45379fbfcefb047f926c786 + prismarine-world: github.com/zardoy/prismarine-world/6ae6f009d38460de284f8c226c665f04cbad9465 protodef: 1.15.0 typed-emitter: 1.4.0 vec3: 0.1.8 @@ -15989,7 +16245,7 @@ packages: version: 1.45.0 engines: {node: '>=14'} dependencies: - '@types/readable-stream': 4.0.10 + '@types/readable-stream': 4.0.11 aes-js: 3.1.2 buffer-equal: 1.0.1 debug: 4.3.4(supports-color@8.1.1) @@ -16000,7 +16256,7 @@ packages: minecraft-folder-path: 1.2.0 node-fetch: 2.7.0 node-rsa: 0.4.2 - prismarine-auth: 2.4.1 + prismarine-auth: 2.4.2 prismarine-nbt: 2.5.0 prismarine-realms: 1.3.2 protodef: 1.15.0 @@ -16037,8 +16293,8 @@ packages: - minecraft-data dev: false - github.com/zardoy/prismarine-world/c358222204d21fe7d45379fbfcefb047f926c786: - resolution: {tarball: https://codeload.github.com/zardoy/prismarine-world/tar.gz/c358222204d21fe7d45379fbfcefb047f926c786} + github.com/zardoy/prismarine-world/6ae6f009d38460de284f8c226c665f04cbad9465: + resolution: {tarball: https://codeload.github.com/zardoy/prismarine-world/tar.gz/6ae6f009d38460de284f8c226c665f04cbad9465} name: prismarine-world version: 3.6.2 engines: {node: '>=8.0.0'} diff --git a/src/entities.ts b/src/entities.ts index 0889c9edb..58c445f1b 100644 --- a/src/entities.ts +++ b/src/entities.ts @@ -1,9 +1,39 @@ import { Entity } from 'prismarine-entity' import tracker from '@nxg-org/mineflayer-tracker' +import { loader as autoJumpPlugin } from '@nxg-org/mineflayer-auto-jump' +import { subscribeKey } from 'valtio/utils' import { options, watchValue } from './optionsStorage' +import { miscUiState } from './globalState' + + +const updateAutoJump = () => { + if (!bot?.autoJumper) return + const autoJump = options.autoJump === 'auto' ? miscUiState.currentTouch && !miscUiState.usingGamepadInput : options.autoJump === 'always' + bot.autoJumper.setOpts({ + jumpIntoWater: false, + jumpOnAllEdges: false, + // strictBlockCollision: true, + }) + if (autoJump) { + bot.autoJumper.enable() + } else { + bot.autoJumper.disable() + } +} +subscribeKey(options, 'autoJump', () => { + updateAutoJump() +}) +subscribeKey(miscUiState, 'usingGamepadInput', () => { + updateAutoJump() +}) +subscribeKey(miscUiState, 'currentTouch', () => { + updateAutoJump() +}) customEvents.on('gameLoaded', () => { bot.loadPlugin(tracker) + bot.loadPlugin(autoJumpPlugin) + updateAutoJump() // todo cleanup (move to viewer, also shouldnt be used at all) const playerPerAnimation = {} as Record @@ -13,6 +43,7 @@ customEvents.on('gameLoaded', () => { window.debugEntityMetadata[e.username] = e // todo entity spawn timing issue, check perf if (viewer.entities.entities[e.id]?.playerObject) { + // todo throttle! bot.tracker.trackEntity(e) const { playerObject } = viewer.entities.entities[e.id] playerObject.backEquipment = e.equipment.some((item) => item?.name === 'elytra') ? 'elytra' : 'cape' diff --git a/src/optionsGuiScheme.tsx b/src/optionsGuiScheme.tsx index 13e6388b2..b54f34986 100644 --- a/src/optionsGuiScheme.tsx +++ b/src/optionsGuiScheme.tsx @@ -208,6 +208,13 @@ export const guiOptionsScheme: { touchControlsType: { values: [['classic', 'Classic'], ['joystick-buttons', 'New']], }, + autoJump: { + values: [ + 'always', + 'auto', + 'never' + ], + }, }, { custom () { diff --git a/src/optionsStorage.ts b/src/optionsStorage.ts index 9e13bf473..25c8b3c70 100644 --- a/src/optionsStorage.ts +++ b/src/optionsStorage.ts @@ -71,6 +71,7 @@ const defaultOptions = { showCursorBlockInSpectator: false, renderEntities: true, chatSelect: false, + autoJump: 'auto' as 'auto' | 'always' | 'never', // advanced bot options autoRespawn: false, From 219f525409cea9e3e92229f2e6e522a9c2d5fae9 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 16 Apr 2024 06:37:22 +0300 Subject: [PATCH 18/56] support for custom input keys / gamepad buttons (no ui yet) --- package.json | 2 +- pnpm-lock.yaml | 9 +++++---- src/controls.ts | 11 ++++++++--- src/index.ts | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index b91bb11e9..d6969dc29 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "browserify-zlib": "^0.2.0", "buffer": "^6.0.3", "constants-browserify": "^1.0.0", - "contro-max": "^0.1.1", + "contro-max": "^0.1.2", "crypto-browserify": "^3.12.0", "cypress": "^10.11.0", "cypress-esbuild-preprocessor": "^1.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4c43c6ba1..b9857220c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -244,8 +244,8 @@ importers: specifier: ^1.0.0 version: 1.0.0 contro-max: - specifier: ^0.1.1 - version: 0.1.1(typescript@5.2.2) + specifier: ^0.1.2 + version: 0.1.2(typescript@5.2.2) crypto-browserify: specifier: ^3.12.0 version: 3.12.0 @@ -7091,8 +7091,9 @@ packages: resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==} engines: {node: '>= 0.6'} - /contro-max@0.1.1(typescript@5.2.2): - resolution: {integrity: sha512-H+bzJWxiuxu98Tz8iGs1occMkRlr9fOzfOKeflVU8bD5teAEiJu8zjVnNSbweLQIR+Vhdynygv18N69t97rVAw==} + /contro-max@0.1.2(typescript@5.2.2): + resolution: {integrity: sha512-mY9aRQ9on/iyzvyhb4OD/10WRRKulVd92F7cxMFVn3rq5EwI+gZitGpHN2mp9+IzwRgBJrOKr1C051b3YlEktQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dependencies: emittery: 0.10.2 lodash-es: 4.17.21 diff --git a/src/controls.ts b/src/controls.ts index 48c051791..90ca29bf0 100644 --- a/src/controls.ts +++ b/src/controls.ts @@ -16,8 +16,8 @@ import { showOptionsModal } from './react/SelectOption' import widgets from './react/widgets' import { getItemFromBlock } from './botUtils' -// doesnt seem to work for now -const customKeymaps = proxy(JSON.parse(localStorage.keymap || '{}')) +// todo move this to shared file with component +export const customKeymaps = proxy(JSON.parse(localStorage.keymap || '{}')) subscribe(customKeymaps, () => { localStorage.keymap = JSON.parse(customKeymaps) }) @@ -322,11 +322,16 @@ document.addEventListener('keydown', (e) => { if (!isGameActive(false)) return if (hardcodedPressedKeys.has('F3')) { const keybind = f3Keybinds.find((v) => v.key === e.code) - if (keybind) keybind.action() + if (keybind) { + keybind.action() + e.stopPropagation() + } return } hardcodedPressedKeys.add(e.code) +}, { + capture: true, }) document.addEventListener('keyup', (e) => { hardcodedPressedKeys.delete(e.code) diff --git a/src/index.ts b/src/index.ts index 7fd99b149..edbd8a92b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -871,7 +871,7 @@ document.body.addEventListener('touchend', (e) => { activeTouch = undefined }) document.body.addEventListener('touchstart', (e) => { - const ignoreElem = (e.target as HTMLElement).matches('vercel-live-feedback') + const ignoreElem = (e.target as HTMLElement).matches('vercel-live-feedback') || (e.target as HTMLElement).closest('.hotbar') if (!isGameActive(true) || ignoreElem) return // we always prevent default behavior to disable magnifier on ios, but by doing so we also disable click events e.preventDefault() From f747ff1c2b9dd8e11826a384874721642b56e166 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Tue, 16 Apr 2024 06:43:24 +0300 Subject: [PATCH 19/56] feat: auto parkour mode! (implies auto-jump) --- src/entities.ts | 9 ++++++--- src/optionsGuiScheme.tsx | 3 +++ src/optionsStorage.ts | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/entities.ts b/src/entities.ts index 58c445f1b..59a437722 100644 --- a/src/entities.ts +++ b/src/entities.ts @@ -8,10 +8,10 @@ import { miscUiState } from './globalState' const updateAutoJump = () => { if (!bot?.autoJumper) return - const autoJump = options.autoJump === 'auto' ? miscUiState.currentTouch && !miscUiState.usingGamepadInput : options.autoJump === 'always' + const autoJump = options.parkourMode || (options.autoJump === 'auto' ? miscUiState.currentTouch && !miscUiState.usingGamepadInput : options.autoJump === 'always') bot.autoJumper.setOpts({ - jumpIntoWater: false, - jumpOnAllEdges: false, + jumpIntoWater: options.parkourMode, + jumpOnAllEdges: options.parkourMode, // strictBlockCollision: true, }) if (autoJump) { @@ -23,6 +23,9 @@ const updateAutoJump = () => { subscribeKey(options, 'autoJump', () => { updateAutoJump() }) +subscribeKey(options, 'parkourMode', () => { + updateAutoJump() +}) subscribeKey(miscUiState, 'usingGamepadInput', () => { updateAutoJump() }) diff --git a/src/optionsGuiScheme.tsx b/src/optionsGuiScheme.tsx index b54f34986..71ea9cd34 100644 --- a/src/optionsGuiScheme.tsx +++ b/src/optionsGuiScheme.tsx @@ -221,6 +221,9 @@ export const guiOptionsScheme: { const { touchControlsType } = useSnapshot(options) return + + + })} + + })} + + +} + +const AwaitingInputOverlay = ({ isGamepad }) => { + return
+ {isGamepad ? 'Press the button on the gamepad' : 'Press the key'}. + Press ESC to cancel. +
+} diff --git a/src/react/MessageFormatted.css b/src/react/MessageFormatted.css new file mode 100644 index 000000000..7e5be00ac --- /dev/null +++ b/src/react/MessageFormatted.css @@ -0,0 +1,5 @@ +/* base global styles */ + +.formatted-message { + text-shadow: 1px 1px 0px #3f3f3f;; +} diff --git a/src/react/MessageFormatted.tsx b/src/react/MessageFormatted.tsx index cc1a089ce..95ab064c5 100644 --- a/src/react/MessageFormatted.tsx +++ b/src/react/MessageFormatted.tsx @@ -2,9 +2,10 @@ import { ComponentProps } from 'react' import { render } from '@xmcl/text-component' import { noCase } from 'change-case' import mojangson from 'mojangson' +import { openURL } from 'prismarine-viewer/viewer/lib/simpleUtils' import { MessageFormatPart } from '../botUtils' -import { openURL } from '../menus/components/common' import { chatInputValueGlobal } from './ChatContainer' +import './MessageFormatted.css' const hoverItemToText = (hoverEvent: MessageFormatPart['hoverEvent']) => { try { @@ -27,7 +28,7 @@ const hoverItemToText = (hoverEvent: MessageFormatPart['hoverEvent']) => { } } catch (err) { // todo report critical error - console.error('Failed to parse message hover', err) + reportError?.('Failed to parse message hover' + err.message) return undefined } } @@ -84,7 +85,7 @@ export const MessagePart = ({ part, ...props }: { part: MessageFormatPart } & Co export default ({ parts }: { parts: readonly MessageFormatPart[] }) => { return ( - + {parts.map((part, i) => )} ) diff --git a/src/react/MobileTopButtons.module.css b/src/react/MobileTopButtons.module.css new file mode 100644 index 000000000..1b142d3ff --- /dev/null +++ b/src/react/MobileTopButtons.module.css @@ -0,0 +1,37 @@ +.mobile-top-btns { + display: none; + flex-direction: row; + position: fixed; + top: 0; + left: 50%; + transform: translate(-50%); + gap: 0 5px; + z-index: -1; +} + +.pause-btn, +.chat-btn { + --scale: 1.3; + border: none; + outline: 0.5px solid white; + width: calc(14px * var(--scale)); + height: calc(14px * var(--scale)); + background-image: url('extra-textures/gui.png'); + background-size: calc(256px * var(--scale)); + background-position-x: calc(var(--scale) * -202px); + background-position-y: calc(var(--scale) * -66px); +} + +.chat-btn { + background-position-y: calc(var(--scale) * -84px); +} +.debug-btn { + background: #9c8c86; + font-size: 8px; + /* todo make other buttons centered */ + /* margin-right: 5px; */ + color: white; + font-family: minecraft, mojangles, monospace; + padding: 4px 6px; + outline: 0.5px solid white; +} diff --git a/src/react/MobileTopButtons.tsx b/src/react/MobileTopButtons.tsx new file mode 100644 index 000000000..c4acb0282 --- /dev/null +++ b/src/react/MobileTopButtons.tsx @@ -0,0 +1,57 @@ +import { useEffect, useRef } from 'react' +import { f3Keybinds } from '../controls' +import { watchValue } from '../optionsStorage' +import { showModal, miscUiState, activeModalStack, hideCurrentModal } from '../globalState' +import { showOptionsModal } from './SelectOption' +import useLongPress from './useLongPress' +import styles from './MobileTopButtons.module.css' + + +export default () => { + const elRef = useRef(null) + + const showMobileControls = (bl) => { + if (elRef.current) elRef.current.style.display = bl ? 'flex' : 'none' + } + + useEffect(() => { + watchValue(miscUiState, o => { + showMobileControls(o.currentTouch) + }) + }, []) + + const onLongPress = async () => { + const select = await showOptionsModal('', f3Keybinds.filter(f3Keybind => f3Keybind.mobileTitle).map(f3Keybind => f3Keybind.mobileTitle)) + if (!select) return + const f3Keybind = f3Keybinds.find(f3Keybind => f3Keybind.mobileTitle === select) + if (f3Keybind) f3Keybind.action() + } + + const defaultOptions = { + shouldPreventDefault: true, + delay: 500, + } + const longPressEvent = useLongPress(onLongPress, () => {}, defaultOptions) + + // ios note: just don't use +
+ + +
+ + {singleplayer ? ( +
+ + {(navigator.share as typeof navigator.share | undefined) ? ( +
+ ) : null} + + + +} diff --git a/src/react/PlayerListOverlay.css b/src/react/PlayerListOverlay.css new file mode 100644 index 000000000..b36801c0f --- /dev/null +++ b/src/react/PlayerListOverlay.css @@ -0,0 +1,80 @@ + +.playerlist-container { + position: absolute; + background-color: rgba(0, 0, 0, 0.3); + top: 9px; + left: 50%; + transform: translate(-50%); + width: fit-content; + padding: 1px; + display: flex; + flex-direction: column; + gap: 1px 0; + place-items: center; + z-index: 30; +} + +.playerlist-header, .playerlist-footer { + font-size: 0.5rem +} + +.playerlist-title { + color: white; + text-shadow: 1px 1px 0px #3f3f3f; + font-size: 10px; + margin: 0; + padding: 0; +} + +.playerlist-entry { + overflow: hidden; + color: white; + font-size: 10px; + margin: 0px; + line-height: calc(100% - 1px); + text-shadow: 1px 1px 0px #3f3f3f; + font-family: mojangles, minecraft, monospace; + background: rgba(255, 255, 255, 0.1); + width: 100%; +} + +.active-player { + color: rgb(42, 204, 237); + text-shadow: 1px 1px 0px rgb(4, 44, 67); +} + +.playerlist-ping { + text-align: right; + float: right; + padding-left: 10px; +} + +.playerlist-ping-value { + color: rgb(114, 255, 114); + text-shadow: 1px 1px 0px rgb(28, 105, 28); + float: left; + margin: 0; + margin-right: 1px; +} + +.playerlist-ping-label { + text-shadow: 1px 1px 0px #3f3f3f; + color: white; + float: right; + margin: 0px; +} + +.player-lists { + display: flex; + flex-direction: row; + place-items: center; + place-content: center; + gap: 0 4px; +} + +.player-list { + display: flex; + flex-direction: column; + gap: 1px 0; + min-width: 80px; +} diff --git a/src/react/PlayerListOverlay.stories.tsx b/src/react/PlayerListOverlay.stories.tsx new file mode 100644 index 000000000..cb2d972f4 --- /dev/null +++ b/src/react/PlayerListOverlay.stories.tsx @@ -0,0 +1,20 @@ +import type { Meta, StoryObj } from '@storybook/react' + +import PlayerListOverlay from './PlayerListOverlay' + +const meta: Meta = { + component: PlayerListOverlay +} + +export default meta +type Story = StoryObj; + +export const Primary: Story = { + args: { + playersLists: [], + clientId: '', + tablistHeader: 'Header', + tablistFooter: 'Footer', + serverIP: '95.163.228.101', + } +} diff --git a/src/react/PlayerListOverlay.tsx b/src/react/PlayerListOverlay.tsx new file mode 100644 index 000000000..ee43ae2c2 --- /dev/null +++ b/src/react/PlayerListOverlay.tsx @@ -0,0 +1,41 @@ +import MessageFormattedString from './MessageFormattedString' +import './PlayerListOverlay.css' + + +type PlayersLists = Array> + +type PlayerListOverlayProps = { + playersLists: PlayersLists, + clientId: string, + tablistHeader: string | Record | null, + tablistFooter: string | Record | null, + serverIP: string +} + +export default ({ playersLists, clientId, tablistHeader, tablistFooter, serverIP }: PlayerListOverlayProps) => { + + return
+ Server IP: {serverIP} +
+ +
+
+ {playersLists.map((list, index) => ( +
+ {list.map(player => ( +
+ +
+

{player.ping}

+

ms

+
+
+ ))} +
+ ))} +
+
+ +
+
+} diff --git a/src/react/PlayerListOverlayProvider.tsx b/src/react/PlayerListOverlayProvider.tsx new file mode 100644 index 000000000..42e8c7353 --- /dev/null +++ b/src/react/PlayerListOverlayProvider.tsx @@ -0,0 +1,91 @@ +import { useSnapshot } from 'valtio' +import { useState, useEffect, useMemo } from 'react' +import { isGameActive, miscUiState } from '../globalState' +import MessageFormattedString from './MessageFormattedString' +import PlayerListOverlay from './PlayerListOverlay' +import './PlayerListOverlay.css' + + +const MAX_ROWS_PER_COL = 10 + +type Players = typeof bot.players + +export default () => { + const { serverIp } = useSnapshot(miscUiState) + const [clientId, setClientId] = useState('') + const [players, setPlayers] = useState({}) + const [isOpen, setIsOpen] = useState(false) + + const handleKeyDown = (e) => { + if (!isGameActive(true)) return + if (e.key === 'Tab') { + setIsOpen(prev => true) + e.preventDefault() + } + } + + const handleKeyUp = (e) => { + if (e.key === 'Tab') { + setIsOpen(prev => false) + e.preventDefault() + } + } + + useMemo(() => { + function requestUpdate () { + // Placeholder for requestUpdate logic + setPlayers(bot.players) + } + + bot.on('playerUpdated', () => requestUpdate()) + bot.on('playerJoined', () => requestUpdate()) + bot.on('playerLeft', () => requestUpdate()) + }, []) + + useEffect(() => { + setPlayers(bot.players) + if (bot.player) { + setClientId(bot.player.uuid) + } else { + bot._client.on('player_info', () => { + setClientId(bot.player?.uuid) + }) + } + + document.addEventListener('keydown', handleKeyDown) + document.addEventListener('keyup', handleKeyUp) + + return () => { + document.removeEventListener('keydown', handleKeyDown) + document.removeEventListener('keyup', handleKeyUp) + } + }, [serverIp]) + + + const playersArray = Object.values(players).sort((a, b) => { + if (a.username > b.username) return 1 + if (a.username < b.username) return -1 + return 0 + }) + const lists = [] as Array + + let tempList = [] as typeof playersArray + for (let i = 0; i < playersArray.length; i++) { + tempList.push(playersArray[i]) + + if ((i + 1) % MAX_ROWS_PER_COL === 0 || i + 1 === playersArray.length) { + lists.push([...tempList]) + tempList = [] + } + } + + if (!isOpen) return null + + return +} diff --git a/src/react/SharedHudVars.tsx b/src/react/SharedHudVars.tsx new file mode 100644 index 000000000..acdcc2376 --- /dev/null +++ b/src/react/SharedHudVars.tsx @@ -0,0 +1,27 @@ +import { CSSProperties, useEffect } from 'react' +import icons from 'minecraft-assets/minecraft-assets/data/1.17.1/gui/icons.png' + +export default ({ children }) => { + useEffect(() => { + if (document.getElementById('hud-vars-style')) return + // 1. Don't inline long data URLs for better DX in elements tab + // 2. Easier application to globally override icons with custom image (eg from resourcepacks) + const css = /* css */` + :root { + --gui-icons: url(${icons}), url(${icons}); + } + ` + const style = document.createElement('style') + style.id = 'hud-vars-style' + style.textContent = css + document.head.appendChild(style) + }, []) + + const customVars = { + '--safe-area-inset-bottom': 'calc(env(safe-area-inset-bottom) / 2)' + } as CSSProperties + + return
{children}
+} diff --git a/src/react/Singleplayer.tsx b/src/react/Singleplayer.tsx index c00ffc8c8..a4d8c559e 100644 --- a/src/react/Singleplayer.tsx +++ b/src/react/Singleplayer.tsx @@ -51,8 +51,8 @@ const World = ({ name, isFocused, title, lastPlayed, size, detail = '', onFocus, world preview
{title}
-
{timeRelativeFormatted} {detail.slice(-30)}
-
{sizeFormatted}
+
{timeRelativeFormatted} {detail.slice(-30)}
+
{sizeFormatted}
} diff --git a/src/react/XPBar.module.css b/src/react/XPBar.module.css new file mode 100644 index 000000000..e9598f995 --- /dev/null +++ b/src/react/XPBar.module.css @@ -0,0 +1,33 @@ +.xp-bar-bg { + z-index: -1; + position: fixed; + left: 50%; + bottom: calc(var(--safe-area-inset-bottom) + 25px); + transform: translate(-50%); + width: 182px; + height: 5px; + background-image: url('minecraft-assets/minecraft-assets/data/1.16.4/gui/icons.png'); + background-size: 256px; + background-position-y: -64px; +} + +.xp-bar { + width: 182px; + height: 5px; + background-image: url('minecraft-assets/minecraft-assets/data/1.17.1/gui/icons.png'); + background-size: 256px; + background-position-y: -69px; +} + + +.xp-label { + position: fixed; + top: -8px; + left: 50%; + transform: translate(-50%); + font-size: 10px; + font-family: minecraft, mojangles, monospace; + color: rgb(30, 250, 30); + text-shadow: 0px -1px #000, 0px 1px #000, 1px 0px #000, -1px 0px #000; + z-index: 10; +} diff --git a/src/react/XPBar.stories.tsx b/src/react/XPBar.stories.tsx new file mode 100644 index 000000000..a7890b1a8 --- /dev/null +++ b/src/react/XPBar.stories.tsx @@ -0,0 +1,28 @@ +import type { Meta, StoryObj } from '@storybook/react' + +import XPBar from './XPBar' + +const meta: Meta = { + component: XPBar +} + +export default meta +type Story = StoryObj; + +export const Primary: Story = { + args: { + progress: 1, + level: 5 + }, + // add slider for progress + argTypes: { + progress: { + control: { + type: 'range', + min: 0, + max: 1, + step: 0.1 + } + } + } +} diff --git a/src/react/XPBar.tsx b/src/react/XPBar.tsx new file mode 100644 index 000000000..1b3a7a856 --- /dev/null +++ b/src/react/XPBar.tsx @@ -0,0 +1,16 @@ +import SharedHudVars from './SharedHudVars' +import styles from './XPBar.module.css' + +export default ({ progress, level, gamemode }: { progress: number; level: number, gamemode: string }) => ( + +
+
+ 0 ? 'block' : 'none' }}>{level} +
+
+) + diff --git a/src/react/XPBarProvider.tsx b/src/react/XPBarProvider.tsx new file mode 100644 index 000000000..4ee1a3921 --- /dev/null +++ b/src/react/XPBarProvider.tsx @@ -0,0 +1,26 @@ +import { useState, useMemo } from 'react' +import { GameMode } from 'mineflayer' +import XPBar from './XPBar' + + +export default () => { + const [progress, setProgress] = useState(0) + const [level, setLevel] = useState(0) + const [gamemode, setGamemode] = useState(bot.game.gameMode) + + useMemo(() => { + const onXpUpdate = () => { + setProgress(bot.experience.progress) + setLevel(bot.experience.level) + } + onXpUpdate() + + bot.on('experience', onXpUpdate) + + bot.on('game', () => { + setGamemode(prev => bot.game.gameMode) + }) + }, []) + + return +} diff --git a/src/react/armorValues.ts b/src/react/armorValues.ts new file mode 100644 index 000000000..cf17edbcd --- /dev/null +++ b/src/react/armorValues.ts @@ -0,0 +1,52 @@ +interface Armor { + 'helmet': number; + 'chestplate': number | null; + 'leggings': number | null; + 'boots': number | null; +} + +export const armor: { [material: string]: Armor } = { + 'turtle': { + 'helmet': 2, + 'chestplate': null, + 'leggings': null, + 'boots': null + }, + 'leather': { + 'helmet': 1, + 'chestplate': 3, + 'leggings': 2, + 'boots': 1 + }, + 'golden': { + 'helmet': 2, + 'chestplate': 5, + 'leggings': 3, + 'boots': 1 + }, + 'chainmail': { + 'helmet': 2, + 'chestplate': 5, + 'leggings': 4, + 'boots': 1 + }, + 'iron': { + 'helmet': 2, + 'chestplate': 6, + 'leggings': 5, + 'boots': 2 + }, + 'diamond': { + 'helmet': 3, + 'chestplate': 8, + 'leggings': 6, + 'boots': 3 + }, + 'netherite': { + 'helmet': 3, + 'chestplate': 8, + 'leggings': 6, + 'boots': 3 + } +} + diff --git a/src/react/simpleUtils.ts b/src/react/simpleUtils.ts new file mode 100644 index 000000000..d9519d20c --- /dev/null +++ b/src/react/simpleUtils.ts @@ -0,0 +1,5 @@ +import prettyBytes from 'pretty-bytes' + +export const getFixedFilesize = (bytes: number) => { + return prettyBytes(bytes, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) +} diff --git a/src/react/singleplayer.module.css b/src/react/singleplayer.module.css index 3258ba295..1e092b399 100644 --- a/src/react/singleplayer.module.css +++ b/src/react/singleplayer.module.css @@ -34,6 +34,10 @@ flex-direction: column; font-size: 11px; } +.world_info_description_line { + color: #999; + white-space: nowrap; +} .world_image { height: 100%; aspect-ratio: 1; diff --git a/src/react/useLongPress.ts b/src/react/useLongPress.ts new file mode 100644 index 000000000..3807221d0 --- /dev/null +++ b/src/react/useLongPress.ts @@ -0,0 +1,64 @@ +import { useCallback, useRef, useState } from 'react' + +interface LongPressOptions { + shouldPreventDefault?: boolean; + delay?: number; +} + +const useLongPress = ( + onLongPress: () => void, + onClick: () => void, + { shouldPreventDefault = true, delay = 300 }: LongPressOptions = {} +) => { + const [longPressTriggered, setLongPressTriggered] = useState(false) + const timeout = useRef() + const target = useRef(null) + + const start = useCallback( + (event: React.MouseEvent | React.TouchEvent) => { + if (shouldPreventDefault && event.target) { + event.target.addEventListener('touchend', preventDefault, { + passive: false + }) + target.current = event.target + } + timeout.current = window.setTimeout(() => { + onLongPress() + setLongPressTriggered(true) + }, delay) + }, + [onLongPress, delay, shouldPreventDefault] + ) + + const clear = useCallback( + (event: React.MouseEvent | React.TouchEvent, shouldTriggerClick = true) => { + if (timeout.current) clearTimeout(timeout.current) + if (shouldTriggerClick && !longPressTriggered) onClick() + setLongPressTriggered(false) + if (shouldPreventDefault && target.current) { + target.current.removeEventListener('touchend', preventDefault) + } + }, + [shouldPreventDefault, onClick, longPressTriggered] + ) + + return { + onMouseDown: (e: React.MouseEvent) => start(e), + onTouchStart: (e: React.TouchEvent) => start(e), + onMouseUp: (e: React.MouseEvent) => clear(e), + onMouseLeave: (e: React.MouseEvent) => clear(e, false), + onTouchEnd: (e: React.TouchEvent) => clear(e) + } +} + +const preventDefault = (event: Event) => { + if (!('touches' in event)) return + + const touchEvent = event as TouchEvent + if (touchEvent.touches.length < 2 && event.preventDefault) { + event.preventDefault() + } +} + +export default useLongPress + diff --git a/src/reactUi.tsx b/src/reactUi.tsx index d56cb8056..4c5f15162 100644 --- a/src/reactUi.tsx +++ b/src/reactUi.tsx @@ -3,6 +3,7 @@ import { renderToDom, ErrorBoundary } from '@zardoy/react-util' import { useSnapshot } from 'valtio' import { QRCodeSVG } from 'qrcode.react' import { createPortal } from 'react-dom' +import { useEffect, useMemo, useState } from 'react' import { miscUiState } from './globalState' import DeathScreenProvider from './react/DeathScreenProvider' import OptionsRenderApp from './react/OptionsRenderApp' @@ -17,6 +18,12 @@ import TitleProvider from './react/TitleProvider' import ScoreboardProvider from './react/ScoreboardProvider' import SignEditorProvider from './react/SignEditorProvider' import IndicatorEffectsProvider from './react/IndicatorEffectsProvider' +import PlayerListOverlayProvider from './react/PlayerListOverlayProvider' +import HudBarsProvider from './react/HudBarsProvider' +import XPBarProvider from './react/XPBarProvider' +import DebugOverlay from './react/DebugOverlay' +import MobileTopButtons from './react/MobileTopButtons' +import PauseScreen from './react/PauseScreen' import SoundMuffler from './react/SoundMuffler' import TouchControls from './react/TouchControls' import widgets from './react/widgets' @@ -24,6 +31,8 @@ import { useIsWidgetActive } from './react/utils' import GlobalSearchInput from './GlobalSearchInput' import TouchAreasControlsProvider from './react/TouchAreasControlsProvider' import NotificationProvider, { showNotification } from './react/NotificationProvider' +import HotbarRenderApp from './react/HotbarRenderApp' +import Crosshair from './react/Crosshair' const RobustPortal = ({ children, to }) => { return createPortal({children}, to) @@ -54,6 +63,25 @@ const DisplayQr = () => { } +// mounted earlier than ingame ui TODO +const GameHud = ({ children }) => { + const { loadedDataVersion } = useSnapshot(miscUiState) + const [gameLoaded, setGameLoaded] = useState(false) + + useEffect(() => { + customEvents.on('mineflayerBotCreated', () => { + bot.once('inject_allowed', () => { + setGameLoaded(true) + }) + }) + }, []) + useEffect(() => { + if (!loadedDataVersion) setGameLoaded(false) + }, [loadedDataVersion]) + + return gameLoaded ? children : null +} + const InGameUi = () => { const { gameLoaded } = useSnapshot(miscUiState) if (!gameLoaded) return @@ -62,12 +90,21 @@ const InGameUi = () => { {/* apply scaling */} + + + + + + + + + @@ -105,6 +142,8 @@ const App = () => { + {/* + */} } @@ -121,3 +160,17 @@ renderToDom(, { strictMode: false, selector: '#react-root', }) + +disableReactProfiling() +function disableReactProfiling () { + //@ts-expect-error + window.performance.markOrig = window.performance.mark + //@ts-expect-error + window.performance.mark = (name, options) => { + // ignore react internal marks + if (!name.startsWith('⚛') && !localStorage.enableReactProfiling) { + //@ts-expect-error + window.performance.markOrig(name, options) + } + } +} diff --git a/src/scaleInterface.ts b/src/scaleInterface.ts new file mode 100644 index 000000000..9eac457d4 --- /dev/null +++ b/src/scaleInterface.ts @@ -0,0 +1,31 @@ +import { proxy } from 'valtio' +import { subscribeKey } from 'valtio/utils' +import { options } from './optionsStorage' + +export const currentScaling = proxy({ + scale: 1, +}) + +const setScale = () => { + const scaleValues = [ + { width: 971, height: 670, scale: 2 }, + { width: null, height: 430, scale: 1.5 }, + { width: 590, height: null, scale: 1 } + ] + + const { innerWidth, innerHeight } = window + + let result = options.guiScale + for (const { width, height, scale } of scaleValues) { + if ((width && innerWidth <= width) || (height && innerHeight <= height)) { + result = scale + } + } + + currentScaling.scale = result + document.documentElement.style.setProperty('--guiScale', String(result)) +} + +setScale() +subscribeKey(options, 'guiScale', setScale) +window.addEventListener('resize', setScale) diff --git a/src/texturePack.ts b/src/texturePack.ts index 8c251b499..566e10dab 100644 --- a/src/texturePack.ts +++ b/src/texturePack.ts @@ -6,7 +6,7 @@ import { subscribeKey } from 'valtio/utils' import { proxy, ref } from 'valtio' import { getVersion } from 'prismarine-viewer/viewer/lib/version' import blocksFileNames from '../generated/blocks.json' -import type { BlockStates } from './playerWindows' +import type { BlockStates } from './inventoryWindows' import { copyFilesAsync, copyFilesAsyncWithProgress, mkdirRecursive, removeFileRecursiveAsync } from './browserfs' import { setLoadingScreenStatus } from './utils' import { showNotification } from './react/NotificationProvider' diff --git a/src/watchOptions.ts b/src/watchOptions.ts index 4380c6f31..1493e7d18 100644 --- a/src/watchOptions.ts +++ b/src/watchOptions.ts @@ -14,7 +14,7 @@ watchValue(options, o => { document.documentElement.style.setProperty('--chatScale', `${o.chatScale / 100}`) document.documentElement.style.setProperty('--chatWidth', `${o.chatWidth}px`) document.documentElement.style.setProperty('--chatHeight', `${o.chatHeight}px`) - document.documentElement.style.setProperty('--guiScale', `${o.guiScale}`) + // gui scale is set in scaleInterface.ts }) /** happens once */ From 7a28dfc4888d4d546d6dbfdc7944494de1da8c4a Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 20 Apr 2024 22:10:10 +0300 Subject: [PATCH 48/56] fix water fog --- src/water.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/water.ts b/src/water.ts index 8bdb2698c..9f8ec557a 100644 --- a/src/water.ts +++ b/src/water.ts @@ -9,8 +9,8 @@ customEvents.on('gameLoaded', () => { watchUnloadForCleanup(cleanup) const updateInWater = () => { - const waterBr = bot.entity.effects.find(effect => loadedData.effects[effect.id].name === 'water_breathing') - if (inWater && waterBr) { + const waterBr = Object.keys(bot.entity.effects).find((effect: any) => loadedData.effects[effect.id].name === 'water_breathing') + if (inWater) { viewer.scene.fog = new THREE.Fog(0x00_00_ff, 0.1, waterBr ? 100 : 20) // Set the fog color to blue if the bot is in water. } else { cleanup() From 241e5d3d1aa528b0a45b8b961b0c16b8d6fb2714 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Wed, 24 Apr 2024 17:10:44 +0300 Subject: [PATCH 49/56] do not override pnpm ver --- .github/workflows/preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 2f866235d..9da50d0ae 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -28,7 +28,7 @@ jobs: node-version: 18 cache: "pnpm" - name: Install Global Dependencies - run: npm install --global vercel pnpm + run: npm install --global vercel - name: Pull Vercel Environment Information run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} - name: Build Project Artifacts From 619aa5b06376e4fcf6335205cd350dd977ae367b Mon Sep 17 00:00:00 2001 From: Vitaly Date: Wed, 24 Apr 2024 17:16:16 +0300 Subject: [PATCH 50/56] optimize light update in single chunks --- prismarine-viewer/viewer/lib/viewer.ts | 8 ++++---- prismarine-viewer/viewer/lib/worldDataEmitter.ts | 6 +++--- prismarine-viewer/viewer/lib/worldrendererCommon.ts | 12 +++++++----- src/watchOptions.ts | 3 ++- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/prismarine-viewer/viewer/lib/viewer.ts b/prismarine-viewer/viewer/lib/viewer.ts index 1b11ac63d..9cb7eb3db 100644 --- a/prismarine-viewer/viewer/lib/viewer.ts +++ b/prismarine-viewer/viewer/lib/viewer.ts @@ -77,8 +77,8 @@ export class Viewer { // this.primitives.clear() } - addColumn (x, z, chunk) { - this.world.addColumn(x, z, chunk) + addColumn (x, z, chunk, isLightUpdate = false) { + this.world.addColumn(x, z, chunk, isLightUpdate) } removeColumn (x: string, z: string) { @@ -148,9 +148,9 @@ export class Viewer { // this.updatePrimitive(p) }) - emitter.on('loadChunk', ({ x, z, chunk, worldConfig }) => { + emitter.on('loadChunk', ({ x, z, chunk, worldConfig, isLightUpdate }) => { this.world.worldConfig = worldConfig - this.addColumn(x, z, chunk) + this.addColumn(x, z, chunk, isLightUpdate) }) // todo remove and use other architecture instead so data flow is clear emitter.on('blockEntities', (blockEntities) => { diff --git a/prismarine-viewer/viewer/lib/worldDataEmitter.ts b/prismarine-viewer/viewer/lib/worldDataEmitter.ts index fa916c514..6743e3372 100644 --- a/prismarine-viewer/viewer/lib/worldDataEmitter.ts +++ b/prismarine-viewer/viewer/lib/worldDataEmitter.ts @@ -75,7 +75,7 @@ export class WorldDataEmitter extends EventEmitter { bot._client.on('update_light', ({ chunkX, chunkZ }) => { const chunkPos = new Vec3(chunkX * 16, 0, chunkZ * 16) - this.loadChunk(chunkPos) + this.loadChunk(chunkPos, true) }) this.emitter.on('listening', () => { @@ -128,7 +128,7 @@ export class WorldDataEmitter extends EventEmitter { } } - async loadChunk (pos: ChunkPos) { + async loadChunk (pos: ChunkPos, isLightUpdate = false) { const [botX, botZ] = chunkPos(this.lastPos) const dx = Math.abs(botX - Math.floor(pos.x / 16)) const dz = Math.abs(botZ - Math.floor(pos.z / 16)) @@ -143,7 +143,7 @@ export class WorldDataEmitter extends EventEmitter { worldHeight: column['worldHeight'] ?? 256, } //@ts-ignore - this.emitter.emit('loadChunk', { x: pos.x, z: pos.z, chunk, blockEntities: column.blockEntities, worldConfig }) + this.emitter.emit('loadChunk', { x: pos.x, z: pos.z, chunk, blockEntities: column.blockEntities, worldConfig, isLightUpdate }) this.loadedChunks[`${pos.x},${pos.z}`] = true } } else { diff --git a/prismarine-viewer/viewer/lib/worldrendererCommon.ts b/prismarine-viewer/viewer/lib/worldrendererCommon.ts index ae2a91d3b..439839773 100644 --- a/prismarine-viewer/viewer/lib/worldrendererCommon.ts +++ b/prismarine-viewer/viewer/lib/worldrendererCommon.ts @@ -211,7 +211,7 @@ export abstract class WorldRendererCommon } - addColumn (x, z, chunk) { + addColumn (x: number, z: number, chunk: any, isLightUpdate: boolean) { if (this.workers.length === 0) throw new Error('workers not initialized yet') this.initialChunksLoad = false this.loadedChunks[`${x},${z}`] = true @@ -222,10 +222,12 @@ export abstract class WorldRendererCommon for (let y = this.worldConfig.minY; y < this.worldConfig.worldHeight; y += 16) { const loc = new Vec3(x, y, z) this.setSectionDirty(loc) - this.setSectionDirty(loc.offset(-16, 0, 0)) - this.setSectionDirty(loc.offset(16, 0, 0)) - this.setSectionDirty(loc.offset(0, 0, -16)) - this.setSectionDirty(loc.offset(0, 0, 16)) + if (!isLightUpdate || this.mesherConfig.smoothLighting) { + this.setSectionDirty(loc.offset(-16, 0, 0)) + this.setSectionDirty(loc.offset(16, 0, 0)) + this.setSectionDirty(loc.offset(0, 0, -16)) + this.setSectionDirty(loc.offset(0, 0, 16)) + } } } diff --git a/src/watchOptions.ts b/src/watchOptions.ts index 1493e7d18..009463be2 100644 --- a/src/watchOptions.ts +++ b/src/watchOptions.ts @@ -44,7 +44,8 @@ export const watchOptionsAfterViewerInit = () => { viewer.entities.setVisible(o.renderEntities) }) - viewer.world.mesherConfig.smoothLighting = options.smoothLighting + // viewer.world.mesherConfig.smoothLighting = options.smoothLighting + viewer.world.mesherConfig.smoothLighting = false // todo not supported for now subscribeKey(options, 'smoothLighting', () => { viewer.world.mesherConfig.smoothLighting = options.smoothLighting; (viewer.world as WorldRendererThree).rerenderAllChunks() From d7f5e98fe35164fc9351f3bb814b1a260ffd784e Mon Sep 17 00:00:00 2001 From: Vitaly Date: Fri, 26 Apr 2024 09:44:04 +0300 Subject: [PATCH 51/56] update typescript to 5.5 --- package.json | 2 +- pnpm-lock.yaml | 138 +++++++++--------- .../viewer/lib/worldDataEmitter.ts | 4 +- src/inventoryWindows.ts | 4 +- src/react/MessageFormatted.tsx | 2 +- src/react/SoundMuffler.tsx | 6 +- 6 files changed, 78 insertions(+), 78 deletions(-) diff --git a/package.json b/package.json index e99818660..dee909a86 100644 --- a/package.json +++ b/package.json @@ -133,7 +133,7 @@ "stream-browserify": "^3.0.0", "three": "0.154.0", "timers-browserify": "^2.0.12", - "typescript": "^5.2.2", + "typescript": "5.5.0-beta", "use-typed-event-listener": "^4.0.2", "vitest": "^0.34.6", "yaml": "^2.3.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5eb5111ad..fc504d178 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -207,16 +207,16 @@ importers: version: 7.4.6(@types/react-dom@18.2.7)(@types/react@18.2.20)(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@storybook/react': specifier: ^7.4.6 - version: 7.4.6(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(typescript@5.2.2) + version: 7.4.6(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(typescript@5.5.0-beta) '@storybook/react-vite': specifier: ^7.4.6 - version: 7.4.6(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(rollup@2.79.1)(typescript@5.2.2)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2)) + version: 7.4.6(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(rollup@2.79.1)(typescript@5.5.0-beta)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2)) '@storybook/web-components': specifier: ^7.4.6 version: 7.4.6(encoding@0.1.13)(lit@2.8.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) '@storybook/web-components-vite': specifier: ^7.4.6 - version: 7.4.6(encoding@0.1.13)(lit@2.8.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(typescript@5.2.2)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2)) + version: 7.4.6(encoding@0.1.13)(lit@2.8.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(typescript@5.5.0-beta)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2)) '@types/lodash-es': specifier: ^4.17.9 version: 4.17.9 @@ -249,7 +249,7 @@ importers: version: 1.0.0 contro-max: specifier: ^0.1.2 - version: 0.1.2(typescript@5.2.2) + version: 0.1.2(typescript@5.5.0-beta) crypto-browserify: specifier: ^3.12.0 version: 3.12.0 @@ -264,7 +264,7 @@ importers: version: 8.50.0 eslint-config-zardoy: specifier: ^0.2.17 - version: 0.2.17(eslint-plugin-react-hooks@4.6.0(eslint@8.50.0))(eslint-plugin-react@7.34.1(eslint@8.50.0))(eslint@8.50.0)(typescript@5.2.2) + version: 0.2.17(eslint-plugin-react-hooks@4.6.0(eslint@8.50.0))(eslint-plugin-react@7.34.1(eslint@8.50.0))(eslint@8.50.0)(typescript@5.5.0-beta) events: specifier: ^3.3.0 version: 3.3.0 @@ -323,11 +323,11 @@ importers: specifier: ^2.0.12 version: 2.0.12 typescript: - specifier: ^5.2.2 - version: 5.2.2 + specifier: 5.5.0-beta + version: 5.5.0-beta use-typed-event-listener: specifier: ^4.0.2 - version: 4.0.2(react@18.2.0)(typescript@5.2.2) + version: 4.0.2(react@18.2.0)(typescript@5.5.0-beta) vitest: specifier: ^0.34.6 version: 0.34.6(terser@5.19.2) @@ -7996,8 +7996,8 @@ packages: typedarray@0.0.6: resolution: {integrity: sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==} - typescript@5.2.2: - resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==} + typescript@5.5.0-beta: + resolution: {integrity: sha512-FRg3e/aQg3olEG3ff8YjHOERsO4IM0m4qGrsE4UMvILaq4TdDZ6gQX4+2Rq9SjTpfSe/ebwiHcsjm/7FfWWQ6Q==} engines: {node: '>=14.17'} hasBin: true @@ -10214,15 +10214,15 @@ snapshots: core-js: 3.32.1 regenerator-runtime: 0.13.11 - '@joshwooding/vite-plugin-react-docgen-typescript@0.2.1(typescript@5.2.2)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2))': + '@joshwooding/vite-plugin-react-docgen-typescript@0.2.1(typescript@5.5.0-beta)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2))': dependencies: glob: 7.2.3 glob-promise: 4.2.2(glob@7.2.3) magic-string: 0.27.0 - react-docgen-typescript: 2.2.2(typescript@5.2.2) + react-docgen-typescript: 2.2.2(typescript@5.5.0-beta) vite: 4.5.3(@types/node@20.8.0)(terser@5.19.2) optionalDependencies: - typescript: 5.2.2 + typescript: 5.5.0-beta '@jridgewell/gen-mapping@0.3.3': dependencies: @@ -10957,7 +10957,7 @@ snapshots: - encoding - supports-color - '@storybook/builder-vite@7.4.6(encoding@0.1.13)(typescript@5.2.2)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2))': + '@storybook/builder-vite@7.4.6(encoding@0.1.13)(typescript@5.5.0-beta)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2))': dependencies: '@storybook/channels': 7.4.6 '@storybook/client-logger': 7.4.6 @@ -10980,7 +10980,7 @@ snapshots: rollup: 3.29.4 vite: 4.5.3(@types/node@20.8.0)(terser@5.19.2) optionalDependencies: - typescript: 5.2.2 + typescript: 5.5.0-beta transitivePeerDependencies: - encoding - supports-color @@ -11264,12 +11264,12 @@ snapshots: react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - '@storybook/react-vite@7.4.6(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(rollup@2.79.1)(typescript@5.2.2)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2))': + '@storybook/react-vite@7.4.6(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(rollup@2.79.1)(typescript@5.5.0-beta)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2))': dependencies: - '@joshwooding/vite-plugin-react-docgen-typescript': 0.2.1(typescript@5.2.2)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2)) + '@joshwooding/vite-plugin-react-docgen-typescript': 0.2.1(typescript@5.5.0-beta)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2)) '@rollup/pluginutils': 5.0.5(rollup@2.79.1) - '@storybook/builder-vite': 7.4.6(encoding@0.1.13)(typescript@5.2.2)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2)) - '@storybook/react': 7.4.6(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(typescript@5.2.2) + '@storybook/builder-vite': 7.4.6(encoding@0.1.13)(typescript@5.5.0-beta)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2)) + '@storybook/react': 7.4.6(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(typescript@5.5.0-beta) '@vitejs/plugin-react': 3.1.0(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2)) ast-types: 0.14.2 magic-string: 0.30.4 @@ -11285,7 +11285,7 @@ snapshots: - typescript - vite-plugin-glimmerx - '@storybook/react@7.4.6(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(typescript@5.2.2)': + '@storybook/react@7.4.6(encoding@0.1.13)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(typescript@5.5.0-beta)': dependencies: '@storybook/client-logger': 7.4.6 '@storybook/core-client': 7.4.6 @@ -11311,7 +11311,7 @@ snapshots: type-fest: 2.19.0 util-deprecate: 1.0.2 optionalDependencies: - typescript: 5.2.2 + typescript: 5.5.0-beta transitivePeerDependencies: - encoding - supports-color @@ -11354,9 +11354,9 @@ snapshots: '@types/express': 4.17.18 file-system-cache: 2.3.0 - '@storybook/web-components-vite@7.4.6(encoding@0.1.13)(lit@2.8.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(typescript@5.2.2)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2))': + '@storybook/web-components-vite@7.4.6(encoding@0.1.13)(lit@2.8.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(typescript@5.5.0-beta)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2))': dependencies: - '@storybook/builder-vite': 7.4.6(encoding@0.1.13)(typescript@5.2.2)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2)) + '@storybook/builder-vite': 7.4.6(encoding@0.1.13)(typescript@5.5.0-beta)(vite@4.5.3(@types/node@20.8.0)(terser@5.19.2)) '@storybook/core-server': 7.4.6(encoding@0.1.13) '@storybook/node-logger': 7.4.6 '@storybook/web-components': 7.4.6(encoding@0.1.13)(lit@2.8.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) @@ -11674,13 +11674,13 @@ snapshots: '@types/node': 20.11.19 optional: true - '@typescript-eslint/eslint-plugin@6.1.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0)(typescript@5.2.2)': + '@typescript-eslint/eslint-plugin@6.1.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta))(eslint@8.50.0)(typescript@5.5.0-beta)': dependencies: '@eslint-community/regexpp': 4.8.0 - '@typescript-eslint/parser': 6.7.3(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/parser': 6.7.3(eslint@8.50.0)(typescript@5.5.0-beta) '@typescript-eslint/scope-manager': 6.1.0 - '@typescript-eslint/type-utils': 6.1.0(eslint@8.50.0)(typescript@5.2.2) - '@typescript-eslint/utils': 6.1.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/type-utils': 6.1.0(eslint@8.50.0)(typescript@5.5.0-beta) + '@typescript-eslint/utils': 6.1.0(eslint@8.50.0)(typescript@5.5.0-beta) '@typescript-eslint/visitor-keys': 6.1.0 debug: 4.3.4(supports-color@8.1.1) eslint: 8.50.0 @@ -11689,22 +11689,22 @@ snapshots: natural-compare: 1.4.0 natural-compare-lite: 1.4.0 semver: 7.5.4 - ts-api-utils: 1.0.3(typescript@5.2.2) + ts-api-utils: 1.0.3(typescript@5.5.0-beta) optionalDependencies: - typescript: 5.2.2 + typescript: 5.5.0-beta transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2)': + '@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta)': dependencies: '@typescript-eslint/scope-manager': 6.7.3 '@typescript-eslint/types': 6.7.3 - '@typescript-eslint/typescript-estree': 6.7.3(typescript@5.2.2) + '@typescript-eslint/typescript-estree': 6.7.3(typescript@5.5.0-beta) '@typescript-eslint/visitor-keys': 6.7.3 debug: 4.3.4(supports-color@8.1.1) eslint: 8.50.0 optionalDependencies: - typescript: 5.2.2 + typescript: 5.5.0-beta transitivePeerDependencies: - supports-color @@ -11718,15 +11718,15 @@ snapshots: '@typescript-eslint/types': 6.7.3 '@typescript-eslint/visitor-keys': 6.7.3 - '@typescript-eslint/type-utils@6.1.0(eslint@8.50.0)(typescript@5.2.2)': + '@typescript-eslint/type-utils@6.1.0(eslint@8.50.0)(typescript@5.5.0-beta)': dependencies: - '@typescript-eslint/typescript-estree': 6.1.0(typescript@5.2.2) - '@typescript-eslint/utils': 6.1.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/typescript-estree': 6.1.0(typescript@5.5.0-beta) + '@typescript-eslint/utils': 6.1.0(eslint@8.50.0)(typescript@5.5.0-beta) debug: 4.3.4(supports-color@8.1.1) eslint: 8.50.0 - ts-api-utils: 1.0.3(typescript@5.2.2) + ts-api-utils: 1.0.3(typescript@5.5.0-beta) optionalDependencies: - typescript: 5.2.2 + typescript: 5.5.0-beta transitivePeerDependencies: - supports-color @@ -11734,7 +11734,7 @@ snapshots: '@typescript-eslint/types@6.7.3': {} - '@typescript-eslint/typescript-estree@6.1.0(typescript@5.2.2)': + '@typescript-eslint/typescript-estree@6.1.0(typescript@5.5.0-beta)': dependencies: '@typescript-eslint/types': 6.1.0 '@typescript-eslint/visitor-keys': 6.1.0 @@ -11742,13 +11742,13 @@ snapshots: globby: 11.1.0 is-glob: 4.0.3 semver: 7.6.0 - ts-api-utils: 1.0.3(typescript@5.2.2) + ts-api-utils: 1.0.3(typescript@5.5.0-beta) optionalDependencies: - typescript: 5.2.2 + typescript: 5.5.0-beta transitivePeerDependencies: - supports-color - '@typescript-eslint/typescript-estree@6.7.3(typescript@5.2.2)': + '@typescript-eslint/typescript-estree@6.7.3(typescript@5.5.0-beta)': dependencies: '@typescript-eslint/types': 6.7.3 '@typescript-eslint/visitor-keys': 6.7.3 @@ -11756,20 +11756,20 @@ snapshots: globby: 11.1.0 is-glob: 4.0.3 semver: 7.6.0 - ts-api-utils: 1.0.3(typescript@5.2.2) + ts-api-utils: 1.0.3(typescript@5.5.0-beta) optionalDependencies: - typescript: 5.2.2 + typescript: 5.5.0-beta transitivePeerDependencies: - supports-color - '@typescript-eslint/utils@6.1.0(eslint@8.50.0)(typescript@5.2.2)': + '@typescript-eslint/utils@6.1.0(eslint@8.50.0)(typescript@5.5.0-beta)': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@8.50.0) '@types/json-schema': 7.0.12 '@types/semver': 7.5.3 '@typescript-eslint/scope-manager': 6.1.0 '@typescript-eslint/types': 6.1.0 - '@typescript-eslint/typescript-estree': 6.1.0(typescript@5.2.2) + '@typescript-eslint/typescript-estree': 6.1.0(typescript@5.5.0-beta) eslint: 8.50.0 semver: 7.6.0 transitivePeerDependencies: @@ -12802,13 +12802,13 @@ snapshots: content-type@1.0.5: {} - contro-max@0.1.2(typescript@5.2.2): + contro-max@0.1.2(typescript@5.5.0-beta): dependencies: emittery: 0.10.2 lodash-es: 4.17.21 optionalDependencies: react: 18.2.0 - use-typed-event-listener: 4.0.2(react@18.2.0)(typescript@5.2.2) + use-typed-event-listener: 4.0.2(react@18.2.0)(typescript@5.5.0-beta) transitivePeerDependencies: - typescript @@ -13664,34 +13664,34 @@ snapshots: eslint-plugin-react: 7.34.1(eslint@8.50.0) eslint-plugin-react-hooks: 4.6.0(eslint@8.50.0) - eslint-config-xo-typescript@1.0.1(@typescript-eslint/eslint-plugin@6.1.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0)(typescript@5.2.2))(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0)(typescript@5.2.2): + eslint-config-xo-typescript@1.0.1(@typescript-eslint/eslint-plugin@6.1.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta))(eslint@8.50.0)(typescript@5.5.0-beta))(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta))(eslint@8.50.0)(typescript@5.5.0-beta): dependencies: - '@typescript-eslint/eslint-plugin': 6.1.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0)(typescript@5.2.2) - '@typescript-eslint/parser': 6.7.3(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/eslint-plugin': 6.1.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta))(eslint@8.50.0)(typescript@5.5.0-beta) + '@typescript-eslint/parser': 6.7.3(eslint@8.50.0)(typescript@5.5.0-beta) eslint: 8.50.0 - typescript: 5.2.2 + typescript: 5.5.0-beta eslint-config-xo@0.43.1(eslint@8.50.0): dependencies: confusing-browser-globals: 1.0.11 eslint: 8.50.0 - eslint-config-zardoy@0.2.17(eslint-plugin-react-hooks@4.6.0(eslint@8.50.0))(eslint-plugin-react@7.34.1(eslint@8.50.0))(eslint@8.50.0)(typescript@5.2.2): + eslint-config-zardoy@0.2.17(eslint-plugin-react-hooks@4.6.0(eslint@8.50.0))(eslint-plugin-react@7.34.1(eslint@8.50.0))(eslint@8.50.0)(typescript@5.5.0-beta): dependencies: '@rushstack/eslint-patch': 1.4.0 - '@typescript-eslint/eslint-plugin': 6.1.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0)(typescript@5.2.2) - '@typescript-eslint/parser': 6.7.3(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/eslint-plugin': 6.1.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta))(eslint@8.50.0)(typescript@5.5.0-beta) + '@typescript-eslint/parser': 6.7.3(eslint@8.50.0)(typescript@5.5.0-beta) eslint: 8.50.0 eslint-config-prettier: 8.10.0(eslint@8.50.0) eslint-config-xo: 0.43.1(eslint@8.50.0) eslint-config-xo-react: 0.27.0(eslint-plugin-react-hooks@4.6.0(eslint@8.50.0))(eslint-plugin-react@7.34.1(eslint@8.50.0))(eslint@8.50.0) - eslint-config-xo-typescript: 1.0.1(@typescript-eslint/eslint-plugin@6.1.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0)(typescript@5.2.2))(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0)(typescript@5.2.2) + eslint-config-xo-typescript: 1.0.1(@typescript-eslint/eslint-plugin@6.1.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta))(eslint@8.50.0)(typescript@5.5.0-beta))(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta))(eslint@8.50.0)(typescript@5.5.0-beta) eslint-plugin-eslint-comments: 3.2.0(eslint@8.50.0) - eslint-plugin-import: 2.27.5(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0) + eslint-plugin-import: 2.27.5(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta))(eslint@8.50.0) eslint-plugin-node: 11.1.0(eslint@8.50.0) eslint-plugin-sonarjs: 0.19.0(eslint@8.50.0) eslint-plugin-unicorn: 48.0.0(eslint@8.50.0) - typescript: 5.2.2 + typescript: 5.5.0-beta transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack @@ -13707,11 +13707,11 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-module-utils@2.8.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint@8.50.0): + eslint-module-utils@2.8.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta))(eslint-import-resolver-node@0.3.9)(eslint@8.50.0): dependencies: debug: 3.2.7(supports-color@8.1.1) optionalDependencies: - '@typescript-eslint/parser': 6.7.3(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/parser': 6.7.3(eslint@8.50.0)(typescript@5.5.0-beta) eslint: 8.50.0 eslint-import-resolver-node: 0.3.9 transitivePeerDependencies: @@ -13729,7 +13729,7 @@ snapshots: eslint: 8.50.0 ignore: 5.2.4 - eslint-plugin-import@2.27.5(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2))(eslint@8.50.0): + eslint-plugin-import@2.27.5(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta))(eslint@8.50.0): dependencies: array-includes: 3.1.7 array.prototype.flat: 1.3.2 @@ -13738,7 +13738,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.50.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.2.2))(eslint-import-resolver-node@0.3.9)(eslint@8.50.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.7.3(eslint@8.50.0)(typescript@5.5.0-beta))(eslint-import-resolver-node@0.3.9)(eslint@8.50.0) has: 1.0.3 is-core-module: 2.13.0 is-glob: 4.0.3 @@ -13748,7 +13748,7 @@ snapshots: semver: 6.3.1 tsconfig-paths: 3.14.2 optionalDependencies: - '@typescript-eslint/parser': 6.7.3(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/parser': 6.7.3(eslint@8.50.0)(typescript@5.5.0-beta) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack @@ -16791,9 +16791,9 @@ snapshots: react: 18.2.0 react-dom: 18.2.0(react@18.2.0) - react-docgen-typescript@2.2.2(typescript@5.2.2): + react-docgen-typescript@2.2.2(typescript@5.5.0-beta): dependencies: - typescript: 5.2.2 + typescript: 5.5.0-beta react-docgen@6.0.0-alpha.3: dependencies: @@ -17968,9 +17968,9 @@ snapshots: dependencies: utf8-byte-length: 1.0.4 - ts-api-utils@1.0.3(typescript@5.2.2): + ts-api-utils@1.0.3(typescript@5.5.0-beta): dependencies: - typescript: 5.2.2 + typescript: 5.5.0-beta ts-dedent@2.2.0: {} @@ -18092,7 +18092,7 @@ snapshots: typedarray@0.0.6: {} - typescript@5.2.2: {} + typescript@5.5.0-beta: {} ua-parser-js@1.0.37: {} @@ -18267,13 +18267,13 @@ snapshots: dependencies: react: 18.2.0 - use-typed-event-listener@4.0.2(react@18.2.0)(typescript@5.2.2): + use-typed-event-listener@4.0.2(react@18.2.0)(typescript@5.5.0-beta): dependencies: '@babel/runtime': 7.22.11 react: 18.2.0 use-deep-compare: 1.1.0(react@18.2.0) optionalDependencies: - typescript: 5.2.2 + typescript: 5.5.0-beta utf8-byte-length@1.0.4: {} diff --git a/prismarine-viewer/viewer/lib/worldDataEmitter.ts b/prismarine-viewer/viewer/lib/worldDataEmitter.ts index 6743e3372..f4ce96750 100644 --- a/prismarine-viewer/viewer/lib/worldDataEmitter.ts +++ b/prismarine-viewer/viewer/lib/worldDataEmitter.ts @@ -186,8 +186,8 @@ export class WorldDataEmitter extends EventEmitter { const positions = generateSpiralMatrix(this.viewDistance).map(([x, z]) => { const pos = new Vec3((botX + x) * 16, 0, (botZ + z) * 16) if (!this.loadedChunks[`${pos.x},${pos.z}`]) return pos - return undefined! - }).filter(Boolean) + return undefined + }).filter(a => !!a) this.lastPos.update(pos) await this._loadChunks(positions) } else { diff --git a/src/inventoryWindows.ts b/src/inventoryWindows.ts index 3345b6cde..d9fda1c74 100644 --- a/src/inventoryWindows.ts +++ b/src/inventoryWindows.ts @@ -389,9 +389,9 @@ const upJei = (search: string) => { search = search.toLowerCase() // todo fix pre flat const matchedSlots = loadedData.itemsArray.map(x => { - if (!x.displayName.toLowerCase().includes(search)) return null! + if (!x.displayName.toLowerCase().includes(search)) return null return new PrismarineItem(x.id, 1) - }).filter(Boolean) + }).filter(a => a !== null) lastWindow.pwindow.win.jeiSlotsPage = 0 lastWindow.pwindow.win.jeiSlots = mapSlots(matchedSlots) } diff --git a/src/react/MessageFormatted.tsx b/src/react/MessageFormatted.tsx index 95ab064c5..e9a0641a4 100644 --- a/src/react/MessageFormatted.tsx +++ b/src/react/MessageFormatted.tsx @@ -78,7 +78,7 @@ export const MessagePart = ({ part, ...props }: { part: MessageFormatPart } & Co underlined && messageFormatStylesMap.underlined, strikethrough && messageFormatStylesMap.strikethrough, obfuscated && messageFormatStylesMap.obfuscated - ].filter(Boolean) + ].filter(a => a !== false && a !== undefined).filter(Boolean) return {text} } diff --git a/src/react/SoundMuffler.tsx b/src/react/SoundMuffler.tsx index 4f162940e..869abc1cf 100644 --- a/src/react/SoundMuffler.tsx +++ b/src/react/SoundMuffler.tsx @@ -42,16 +42,16 @@ export default () => { Last World Played {Object.entries(lastPlayedSounds.lastServerPlayed).map(([key, value]) => { - if (!showMuted && mutedSounds.includes(key)) return null as never + if (!showMuted && mutedSounds.includes(key)) return null return [key, value.count] as const - }).filter(Boolean).sort((a, b) => b[1] - a[1]).slice(0, 20).map(([key, count]) => { + }).filter(a => !!a).sort((a, b) => b[1] - a[1]).slice(0, 20).map(([key, count]) => { return {count} })} Last Client Played {lastPlayedSounds.lastClientPlayed.map((key) => { - if (!showMuted && mutedSounds.includes(key)) return null as never + if (!showMuted && mutedSounds.includes(key)) return null return })} From cf83844281217f4ec52b8f62855844511bd7343e Mon Sep 17 00:00:00 2001 From: Vitaly Date: Fri, 26 Apr 2024 09:44:47 +0300 Subject: [PATCH 52/56] fix annoying f3 issue --- src/react/MobileTopButtons.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/react/MobileTopButtons.tsx b/src/react/MobileTopButtons.tsx index c4acb0282..c686bb0ba 100644 --- a/src/react/MobileTopButtons.tsx +++ b/src/react/MobileTopButtons.tsx @@ -40,6 +40,7 @@ export default () => { }}>S
{ document.dispatchEvent(new KeyboardEvent('keydown', { code: 'F3' })) + document.dispatchEvent(new KeyboardEvent('keyup', { code: 'F3' })) }} { ...longPressEvent }>F3
{ e.stopPropagation() From b9aa44907100a7c3a136da6c39d26cfb46a1ab45 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 27 Apr 2024 15:51:06 +0300 Subject: [PATCH 53/56] fix ios hotbar, fix item name display, fix item select, fix inv open --- src/botUtils.ts | 2 +- src/react/HotbarRenderApp.tsx | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/botUtils.ts b/src/botUtils.ts index 5dacbf4fa..a76f889b3 100644 --- a/src/botUtils.ts +++ b/src/botUtils.ts @@ -114,6 +114,6 @@ const blockToItemRemaps = { } export const getItemFromBlock = (block: import('prismarine-block').Block) => { - const item = loadedData.items[blockToItemRemaps[block.name] ?? block.name] + const item = loadedData.itemsByName[blockToItemRemaps[block.name] ?? block.name] return item } diff --git a/src/react/HotbarRenderApp.tsx b/src/react/HotbarRenderApp.tsx index 2e7ee1d18..e747c4e38 100644 --- a/src/react/HotbarRenderApp.tsx +++ b/src/react/HotbarRenderApp.tsx @@ -19,7 +19,7 @@ const ItemName = ({ itemKey }: { itemKey: string }) => { const defaultStyle: React.CSSProperties = { position: 'fixed', - bottom: `calc(var(--safe-area-inset-bottom) + ${bot ? bot.game.gameMode === 'creative' ? '35px' : '50px' : '50px'})`, + bottom: `calc(env(safe-area-inset-bottom) + ${bot ? bot.game.gameMode === 'creative' ? '35px' : '50px' : '50px'})`, left: 0, right: 0, fontSize: 10, @@ -117,7 +117,7 @@ export default () => { canvasManager.canvas.onpointerdown = (e) => { if (!isGameActive(true)) return const pos = inv.canvasManager.getMousePos(inv.canvas, e) - if (pos.x > canvasManager.canvas.width - 30) { + if (canvasManager.canvas.width - pos.x < 35 * inv.canvasManager.scale) { openPlayerInventory() } } @@ -135,7 +135,10 @@ export default () => { const heldItemChanged = () => { inv.inventory.activeHotbarSlot = bot.quickBarSlot - if (!bot.inventory.slots?.[bot.quickBarSlot + 36]) return + if (!bot.inventory.slots?.[bot.quickBarSlot + 36]) { + setItemKey('') + return + } const item = bot.inventory.slots[bot.quickBarSlot + 36]! const itemNbt = item.nbt ? JSON.stringify(item.nbt) : '' setItemKey(`${item.displayName}_split_${item.type}_split_${item.metadata}_split_${itemNbt}`) @@ -199,17 +202,15 @@ export default () => { return - -
- +
} From 6615984966ee22670965bbbacb418f30818833fa Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 27 Apr 2024 16:04:52 +0300 Subject: [PATCH 54/56] fix water rendering TODO still need to be correctly mapped to block named water instead --- prismarine-viewer/viewer/lib/mesher/world.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prismarine-viewer/viewer/lib/mesher/world.ts b/prismarine-viewer/viewer/lib/mesher/world.ts index 50616f823..63263809d 100644 --- a/prismarine-viewer/viewer/lib/mesher/world.ts +++ b/prismarine-viewer/viewer/lib/mesher/world.ts @@ -114,6 +114,8 @@ export class World { } const block = this.blockCache[stateId] + if (block.name === 'flowing_water') block.name = 'water' + if (block.name === 'flowing_lava') block.name = 'lava' // block.position = loc // it overrides position of all currently loaded blocks block.biome = this.biomeCache[column.getBiome(locInChunk)] ?? this.biomeCache[1] ?? this.biomeCache[0] if (block.name === 'redstone_ore') block.transparent = false From a504d3f5aa9b830ea47db577f2cb593e328bd236 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 27 Apr 2024 16:11:38 +0300 Subject: [PATCH 55/56] disable some useless warnings --- src/loadSave.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/loadSave.ts b/src/loadSave.ts index 655fbea88..c332e670d 100644 --- a/src/loadSave.ts +++ b/src/loadSave.ts @@ -85,8 +85,10 @@ export const loadSave = async (root = '/world') => { const qs = new URLSearchParams(window.location.search) version = qs.get('mapVersion') ?? levelDat.Version?.Name if (!version) { - const newVersion = disablePrompts ? '1.8.8' : prompt(`In 1.8 and before world save doesn't contain version info, please enter version you want to use to load the world.\nSupported versions ${supportedVersions.join(', ')}`, '1.8.8') - if (!newVersion) return + // const newVersion = disablePrompts ? '1.8.8' : prompt(`In 1.8 and before world save doesn't contain version info, please enter version you want to use to load the world.\nSupported versions ${supportedVersions.join(', ')}`, '1.8.8') + // if (!newVersion) return + // todo detect world load issues + const newVersion = '1.8.8' version = newVersion } const lastSupportedVersion = supportedVersions.at(-1)! @@ -110,7 +112,7 @@ export const loadSave = async (root = '/world') => { isFlat = levelDat.generatorName === 'flat' } if (!isFlat && levelDat.generatorName !== 'default' && levelDat.generatorName !== 'customized') { - warnings.push(`Generator ${levelDat.generatorName} may not be supported yet`) + // warnings.push(`Generator ${levelDat.generatorName} may not be supported yet, be careful of new chunks writes`) } const playerUuid = nameToMcOfflineUUID(options.localUsername) @@ -150,7 +152,7 @@ export const loadSave = async (root = '/world') => { if (!fsState.isReadonly && !fsState.inMemorySave && !disablePrompts) { // todo allow also to ctrl+s - alert('Note: the world is saved only on /save or disconnect! Ensure you have backup!') + alert('Note: the world is saved on interval, /save or disconnect! Ensure you have backup and be careful of new chunks writes!') } // improve compatibility with community saves From 9322e09a836a0d896ccaa0e5aa8ebd48e31f34f2 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 27 Apr 2024 22:55:25 +0300 Subject: [PATCH 56/56] fix: "modern" controls now correctly works with flying fix: right stick button on gamepad now toggles sneaking --- src/controls.ts | 13 +++++++++++-- src/react/HotbarRenderApp.tsx | 4 +++- src/react/TouchAreasControls.tsx | 29 ++++++++++++++++++++++------- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/controls.ts b/src/controls.ts index 734a2a6d6..264050829 100644 --- a/src/controls.ts +++ b/src/controls.ts @@ -32,7 +32,8 @@ export const contro = new ControMax({ jump: ['Space', 'A'], inventory: ['KeyE', 'X'], drop: ['KeyQ', 'B'], - sneak: ['ShiftLeft', 'Right Stick'], + sneak: ['ShiftLeft'], + toggleSneakOrDown: [null, 'Right Stick'], sprint: ['ControlLeft', 'Left Stick'], nextHotbarSlot: [null, 'Left Bumper'], prevHotbarSlot: [null, 'Right Bumper'], @@ -152,7 +153,7 @@ const uiCommand = (command: Command) => { } } -export const setSneaking = (state: boolean) => { +const setSneaking = (state: boolean) => { gameAdditionalState.isSneaking = state bot.setControlState('sneak', state) } @@ -178,6 +179,14 @@ const onTriggerOrReleased = (command: Command, pressed: boolean) => { if (pressed) { setSprinting(pressed) } + break + case 'general.toggleSneakOrDown': + if (gameAdditionalState.isFlying) { + setSneaking(pressed) + } else if (pressed) { + setSneaking(!gameAdditionalState.isSneaking) + } + break case 'general.attackDestroy': document.dispatchEvent(new MouseEvent(pressed ? 'mousedown' : 'mouseup', { button: 0 })) diff --git a/src/react/HotbarRenderApp.tsx b/src/react/HotbarRenderApp.tsx index e747c4e38..5b32e3ccf 100644 --- a/src/react/HotbarRenderApp.tsx +++ b/src/react/HotbarRenderApp.tsx @@ -108,13 +108,14 @@ export default () => { } setSize() watchUnloadForCleanup(subscribe(currentScaling, setSize)) + inv.canvas.style.pointerEvents = 'auto' container.current.appendChild(inv.canvas) const upHotbarItems = () => { if (!viewer.world.downloadedTextureImage && !viewer.world.customTexturesDataUrl) return upInventoryItems(true, inv) } - canvasManager.canvas.onpointerdown = (e) => { + canvasManager.canvas.onclick = (e) => { if (!isGameActive(true)) return const pos = inv.canvasManager.getMousePos(inv.canvas, e) if (canvasManager.canvas.width - pos.x < 35 * inv.canvasManager.scale) { @@ -209,6 +210,7 @@ export default () => { display: 'flex', justifyContent: 'center', zIndex: hasModals ? 1 : 8, + pointerEvents: 'none', bottom: 'env(safe-area-inset-bottom)' }} /> diff --git a/src/react/TouchAreasControls.tsx b/src/react/TouchAreasControls.tsx index e2a3fd873..f56db0471 100644 --- a/src/react/TouchAreasControls.tsx +++ b/src/react/TouchAreasControls.tsx @@ -1,6 +1,6 @@ -import { CSSProperties, PointerEvent, PointerEventHandler, useEffect, useRef, useState } from 'react' +import { CSSProperties, PointerEvent, useEffect, useRef } from 'react' import { proxy, ref, useSnapshot } from 'valtio' -import { contro, setSneaking } from '../controls' +import { contro } from '../controls' import worldInteractions from '../worldInteractions' import PixelartIcon from './PixelartIcon' import Button from './Button' @@ -56,6 +56,7 @@ export default ({ touchActive, setupActive, buttonsPositions, closeButtonsSetup const joystickInner = useRef(null) const { pointer } = useSnapshot(joystickPointer) + // const { isFlying, isSneaking } = useSnapshot(gameAdditionalState) const newButtonPositions = { ...buttonsPositions } const buttonProps = (name: ButtonName) => { @@ -72,7 +73,10 @@ export default ({ touchActive, setupActive, buttonsPositions, closeButtonsSetup document.dispatchEvent(new MouseEvent('mouseup', { button: 2 })) }, sneak () { - setSneaking(!bot.getControlState('sneak')) + void contro.emit('trigger', { + command: 'general.toggleSneakOrDown', + schema: null as any, + }) active = bot.getControlState('sneak') }, break () { @@ -81,14 +85,22 @@ export default ({ touchActive, setupActive, buttonsPositions, closeButtonsSetup active = true }, jump () { - bot.setControlState('jump', true) - active = true + void contro.emit('trigger', { + command: 'general.jump', + schema: null as any, + }) + active = bot.controlState.jump } } const holdUp = { action () { }, sneak () { + void contro.emit('release', { + command: 'general.toggleSneakOrDown', + schema: null as any, + }) + active = bot.getControlState('sneak') }, break () { document.dispatchEvent(new MouseEvent('mouseup', { button: 0 })) @@ -96,8 +108,11 @@ export default ({ touchActive, setupActive, buttonsPositions, closeButtonsSetup active = false }, jump () { - bot.setControlState('jump', false) - active = false + void contro.emit('release', { + command: 'general.jump', + schema: null as any, + }) + active = bot.controlState.jump } }