diff --git a/main.typ b/main.typ new file mode 100644 index 00000000..191a4d66 --- /dev/null +++ b/main.typ @@ -0,0 +1,35 @@ +#let put(x, y, z, ..args) = { + ( + "p", + str(x), + str(y), + str(z), + ..args.pos().map(str), + ..args.named().pairs().map((u, v) => str(u) + "=" + str(v)), + ).join(" ") +} + +#html.html({ + html.head({ + html.link(rel: "stylesheet", href: "./mc-diorama.css") + html.script(src: "./mc-diorama.mjs", type: "module") + }) + html.body({ + html.main([ + = hello world + ]) + + html.elem("mc-diorama", { + html.elem("mc-camera") + html.elem( + "mc-world", + " + p 0 0 0 stone; + p 0 0 1 piston facing=up extended=false & + + p 1 0 0 redstone_block; + ", + ) + }) + }) +}) diff --git a/package-lock.json b/package-lock.json index 5df2e323..3ea55027 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,14 @@ { - "name": "wireless", - "version": "0.0.0", + "name": "mc-diorama", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "wireless", - "version": "0.0.0", + "name": "mc-diorama", + "version": "0.1.0", "devDependencies": { - "vite": "^8.1.1" + "vite": "^8.1.3" } }, "node_modules/@emnapi/core": { @@ -167,9 +167,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -187,9 +184,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -207,9 +201,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -227,9 +218,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -247,9 +235,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -267,9 +252,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -553,9 +535,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -577,9 +556,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -601,9 +577,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -625,9 +598,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ diff --git a/package.json b/package.json index c8f5f856..cd44e6d7 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,13 @@ { - "name": "wireless", - "version": "0.0.0", - "private": true, - "type": "module", - "scripts": { - "dev": "vite", - "build": "vite build", - "preview": "vite preview" - }, - "devDependencies": { - "vite": "^8.1.1" + "name": "mc-diorama", + "version": "0.1.0", + "files": [ + "dist" + ], + "module": "./dist/mc-diorama.es.js", + "exports": { + ".": { + "import": "./dist/mc-diorama.es.js" + } } } diff --git a/src/components.js b/src/components.js index 4729f03c..8a4ec7b4 100644 --- a/src/components.js +++ b/src/components.js @@ -8,7 +8,7 @@ import {SpacetimeController} from './controller.js'; window.mcEngine = new Engine(); document.body.appendChild(window.mcEngine.canvas) -export class MCWorldElement extends HTMLElement { +class MCWorldElement extends HTMLElement { connectedCallback() { if (this.world) return; // Read text content directly, allowing inline scripting @@ -17,7 +17,7 @@ export class MCWorldElement extends HTMLElement { } } -export class MCFrameElement extends HTMLElement { +class MCFrameElement extends HTMLElement { connectedCallback() { // Use a microtask to ensure children are parsed setTimeout(() => this.init(), 0); @@ -42,7 +42,7 @@ export class MCFrameElement extends HTMLElement { } } -export class MCDioramaElement extends HTMLElement { +class MCDioramaElement extends HTMLElement { connectedCallback() { setTimeout(() => this.init(), 0); } diff --git a/src/lib.js b/src/lib.js new file mode 100644 index 00000000..36b65876 --- /dev/null +++ b/src/lib.js @@ -0,0 +1,2 @@ +import './components.js'; +import './components.css'; \ No newline at end of file diff --git a/src/texture.js b/src/texture.js index 558a8476..548fe7a1 100644 --- a/src/texture.js +++ b/src/texture.js @@ -54,10 +54,10 @@ export class TextureHandler { const drawMissing = () => { const half = this.cellSize / 2; - this.ctx.fillStyle = '#33333366'; // Gray + this.ctx.fillStyle = '#666666FF'; // Gray this.ctx.fillRect(pos.x, pos.y, half, half); this.ctx.fillRect(pos.x + half, pos.y + half, half, half); - this.ctx.fillStyle = '#00000066'; // Black + this.ctx.fillStyle = '#333333FF'; // Black this.ctx.fillRect(pos.x + half, pos.y, half, half); this.ctx.fillRect(pos.x, pos.y + half, half, half); }; diff --git a/src/world.js b/src/world.js index baabe6d0..2b53687c 100644 --- a/src/world.js +++ b/src/world.js @@ -36,7 +36,7 @@ export class World { capturedInitialState = true; }; - const lines = script.split('\n').map(l => l.trim()).filter(l => l && !l.startsWith('#')); + const lines = script.split(/\n|;|(?<=&)/).map(l => l.trim()).filter(l => l && !l.startsWith('#')); let currentBatch = []; diff --git a/vite.config.js b/vite.config.js index 0c17af9b..3beb5987 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,3 +1,13 @@ -export default { - base: "/secret-knowledge/", -} +import {dirname, resolve} from 'node:path' +import {defineConfig} from 'vite' + +export default defineConfig({ + build: { + lib: { + entry: resolve(import.meta.dirname, 'src/lib.js'), + name: 'mc-diorama', + fileName: 'mc-diorama', + formats: ['es'] + } + } +}); \ No newline at end of file