many improvements on VM and tooling
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"name": "@prometeu/sdk",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"types": "types/index.d.ts"
|
||||
}
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
export const Audio = audio;
|
||||
export type Audio = Prometeu.Audio;
|
||||
@@ -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;
|
||||
},
|
||||
};
|
||||
@@ -1,2 +0,0 @@
|
||||
export const Fs = fs;
|
||||
export type Fs = Prometeu.Fs;
|
||||
@@ -1 +0,0 @@
|
||||
export type Gfx = Prometeu.Gfx;
|
||||
@@ -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";
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
|
||||
export const Pad: Prometeu.Pad = pad;
|
||||
export const Touch: Prometeu.Touch = touch;
|
||||
@@ -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,
|
||||
}
|
||||
@@ -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.",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -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
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user