From b7356efbcefb9a34f0c857015ea20274f575abf6 Mon Sep 17 00:00:00 2001 From: qqq <76906216+soulless-ai@users.noreply.github.com> Date: Wed, 17 Jul 2024 04:53:26 +0500 Subject: [PATCH] feat: Add a way to view / sign books (#158) --------- Co-authored-by: soulless-ai Co-authored-by: Vitaly Turovsky --- .eslintrc.json | 1 + esbuild.mjs | 1 + scripts/buildNpmReact.ts | 4 + src/globals.d.ts | 1 + src/localServerMultiplayer.ts | 2 +- src/react/AddServerOrConnect.tsx | 1 - src/react/Book.module.css | 605 +++++++++++++++++++ src/react/Book.stories.tsx | 25 + src/react/Book.tsx | 322 ++++++++++ src/react/BookProvider.tsx | 110 ++++ src/react/MessageFormatted.tsx | 4 +- src/react/MessageFormattedString.stories.tsx | 5 +- src/react/MessageFormattedString.tsx | 16 +- src/react/PlayerListOverlayProvider.tsx | 8 +- src/react/XPBar.tsx | 7 +- src/react/book_icons/book-half.webp | Bin 0 -> 5110 bytes src/react/book_icons/book.webp | Bin 0 -> 10158 bytes src/react/book_icons/next-click.webp | Bin 0 -> 1800 bytes src/react/book_icons/next.webp | Bin 0 -> 1268 bytes src/react/book_icons/notebook.webp | Bin 0 -> 5956 bytes src/react/book_icons/prev-click.webp | Bin 0 -> 1866 bytes src/react/book_icons/prev.webp | Bin 0 -> 1298 bytes src/react/book_icons/title.webp | Bin 0 -> 3392 bytes src/react/globals.d.ts | 4 + src/react/singleplayer.module.css | 4 +- src/reactUi.tsx | 2 + src/worldInteractions.ts | 1 + 27 files changed, 1104 insertions(+), 19 deletions(-) create mode 100644 src/react/Book.module.css create mode 100644 src/react/Book.stories.tsx create mode 100644 src/react/Book.tsx create mode 100644 src/react/BookProvider.tsx create mode 100644 src/react/book_icons/book-half.webp create mode 100644 src/react/book_icons/book.webp create mode 100644 src/react/book_icons/next-click.webp create mode 100644 src/react/book_icons/next.webp create mode 100644 src/react/book_icons/notebook.webp create mode 100644 src/react/book_icons/prev-click.webp create mode 100644 src/react/book_icons/prev.webp create mode 100644 src/react/book_icons/title.webp diff --git a/.eslintrc.json b/.eslintrc.json index a91015d2..c9fa60e2 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -7,6 +7,7 @@ "rules": { "space-infix-ops": "error", "no-multi-spaces": "error", + "no-trailing-spaces": "error", "space-before-function-paren": "error", "space-in-parens": [ "error", diff --git a/esbuild.mjs b/esbuild.mjs index 1f075a62..3dfe9939 100644 --- a/esbuild.mjs +++ b/esbuild.mjs @@ -88,6 +88,7 @@ const buildOptions = { '.woff': 'dataurl', '.woff2': 'dataurl', '.ttf': 'dataurl', + '.webp': 'dataurl', }, write: false, // todo would be better to enable? diff --git a/scripts/buildNpmReact.ts b/scripts/buildNpmReact.ts index 4516f1b7..bc0fc192 100644 --- a/scripts/buildNpmReact.ts +++ b/scripts/buildNpmReact.ts @@ -53,6 +53,10 @@ fs.promises.readdir(path.resolve(__dirname, '../src/react')).then(async (files) write: false, // todo loader: { '.png': 'dataurl', + '.jpg': 'dataurl', + '.jpeg': 'dataurl', + '.webp': 'dataurl', + '.css': 'text', }, plugins: [ // on external module resolve diff --git a/src/globals.d.ts b/src/globals.d.ts index f8699f21..4abc0822 100644 --- a/src/globals.d.ts +++ b/src/globals.d.ts @@ -25,6 +25,7 @@ declare const customEvents: import('typed-emitter').default<{ gameLoaded (): void mineflayerBotCreated (): void search (q: string): void + activateItem (item: Item, slot: number, offhand: boolean): void }> declare const beforeRenderFrame: Array<() => void> diff --git a/src/localServerMultiplayer.ts b/src/localServerMultiplayer.ts index ca85c126..c8e4bc5e 100644 --- a/src/localServerMultiplayer.ts +++ b/src/localServerMultiplayer.ts @@ -52,7 +52,7 @@ export const openToWanAndCopyJoinLink = async (writeText: (text) => void, doCopy peerInstance = peer peer.on('connection', (connection) => { console.log('connection') - const serverDuplex = new CustomDuplex({}, (data) => connection.send(data)) + const serverDuplex = new CustomDuplex({}, async (data) => connection.send(data)) const client = new Client(true, localServer.options.version, undefined) client.setSocket(serverDuplex) localServer._server.emit('connection', client) diff --git a/src/react/AddServerOrConnect.tsx b/src/react/AddServerOrConnect.tsx index 535e3ee9..2c38a894 100644 --- a/src/react/AddServerOrConnect.tsx +++ b/src/react/AddServerOrConnect.tsx @@ -101,7 +101,6 @@ export default ({ onBack, onConfirm, title = 'Add a Server', initialData, parseQ }}> Account Override