wip vite lib, typst markup

This commit is contained in:
2026-07-07 22:49:09 -04:00
parent a787981f57
commit e4a3bd0ce2
8 changed files with 71 additions and 55 deletions

35
main.typ Normal file
View File

@@ -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;
",
)
})
})
})

40
package-lock.json generated
View File

@@ -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": [

View File

@@ -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"
}
}
}

View File

@@ -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);
}

2
src/lib.js Normal file
View File

@@ -0,0 +1,2 @@
import './components.js';
import './components.css';

View File

@@ -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);
};

View File

@@ -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 = [];

View File

@@ -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']
}
}
});