many improvements on VM and tooling

This commit is contained in:
2026-03-24 13:40:20 +00:00
parent 31080ea40d
commit 5caa3e112e
36 changed files with 5261 additions and 558 deletions
+1
View File
@@ -1,6 +1,7 @@
{
"name": "@prometeu/sdk",
"version": "0.1.0",
"type": "module",
"main": "src/index.ts",
"types": "types/index.d.ts"
}
-2
View File
@@ -1,2 +0,0 @@
export const Audio = audio;
export type Audio = Prometeu.Audio;
-25
View File
@@ -1,25 +0,0 @@
export type Color565 = Prometeu.Color565;
function clamp8(n: number): number {
return n < 0 ? 0 : n > 255 ? 255 : n | 0;
}
export const Color: Prometeu.Color = {
black: 0x0000 as Color565,
white: 0xffff as Color565,
red: 0xf800 as Color565,
green: 0x07e0 as Color565,
blue: 0x001f as Color565,
yellow: 0xffe0 as Color565,
cyan: 0x07ff as Color565,
magenta: 0xf81f as Color565,
indigo: 0x4810 as Color565,
rgb(r: number, g: number, b: number): Color565 {
r = clamp8(r); g = clamp8(g); b = clamp8(b);
const r5 = (r >> 3) & 0x1f;
const g6 = (g >> 2) & 0x3f;
const b5 = (b >> 3) & 0x1f;
return ((r5 << 11) | (g6 << 5) | b5) as Color565;
},
};
-2
View File
@@ -1,2 +0,0 @@
export const Fs = fs;
export type Fs = Prometeu.Fs;
-1
View File
@@ -1 +0,0 @@
export type Gfx = Prometeu.Gfx;
-8
View File
@@ -1,8 +0,0 @@
export { Color } from "./color";
export { Pad, Touch } from "./input";
export { Gfx } from "./gfx";
export { System } from "./system";
export { Audio } from "./audio";
export { Fs } from "./fs";
export { Log, LogLevel } from "./log";
export type { Color565 } from "./color";
-4
View File
@@ -1,4 +0,0 @@
export const Pad: Prometeu.Pad = pad;
export const Touch: Prometeu.Touch = touch;
-11
View File
@@ -1,11 +0,0 @@
export const Log = log;
export type Log = Prometeu.Log;
export enum LogLevel {
Trace = 0,
Debug = 1,
Info = 2,
Warn = 3,
Error = 4,
Fatal = 5,
}
-2
View File
@@ -1,2 +0,0 @@
export const System = system;
export type System = Prometeu.System;
@@ -0,0 +1,57 @@
export function createPrometeuEslintConfig({ tsParser, tseslint }) {
if (!tsParser || !tseslint) {
throw new Error(
"createPrometeuEslintConfig requires { tsParser, tseslint } provided by the project (root node_modules).",
);
}
return [
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: tsParser,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
},
plugins: {
"@typescript-eslint": tseslint,
},
rules: {
"@typescript-eslint/no-unused-vars": [
"warn",
{
varsIgnorePattern: "^(frame)$",
},
],
"@typescript-eslint/typedef": [
"error",
{
variableDeclaration: false,
variableDeclarationIgnoreFunction: false,
parameter: true,
propertyDeclaration: true,
memberVariableDeclaration: true,
arrowParameter: true,
},
],
"no-restricted-syntax": [
"error",
{
selector: "TSUnionType:not(:has(TSNullKeyword))",
message:
"Union types are not allowed in Prometeu code style (exception: T | null).",
},
{
selector: "TSUnionType:has(TSUndefinedKeyword)",
message:
"Use null (T | null) instead of undefined (T | undefined) in Prometeu code style.",
},
],
},
},
];
}
+17 -1
View File
@@ -1,4 +1,20 @@
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"exactOptionalPropertyTypes": true,
"useUnknownInCatchVariables": true,
"noUncheckedIndexedAccess": true,
"forceConsistentCasingInFileNames": true
}
}
}
+2 -2
View File
@@ -40,6 +40,7 @@ declare global {
drawCircle(x: number, y: number, r: number, color: Color565): void;
drawDisc(x: number, y: number, r: number, borderColor: Color565, fillColor: Color565): void;
drawSquare(x: number, y: number, w: number, h: number, borderColor: Color565, fillColor: Color565): void;
drawText(x: number, y: number, s: string, color: Color565): void;
setSprite(assetName: string, id: number, x: number, y: number, tileId: number, paletteId: number, active: boolean, flipX: boolean, flipY: boolean, priority: number): void;
}
@@ -86,14 +87,13 @@ declare global {
}
}
export const color: Prometeu.Color;
export const pad: Prometeu.Pad;
export const touch: Prometeu.Touch;
export const gfx: Prometeu.Gfx;
export const audio: Prometeu.Audio;
export const fs: Prometeu.Fs;
export const log: Prometeu.Log;
export const color: Prometeu.Color;
export const system: Prometeu.System;
}