Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b26171948 | ||
|
|
529738fea6 | ||
|
|
8735adc3ae | ||
|
|
f6c1aaa5b9 | ||
|
|
4e856b17f9 | ||
|
|
3617098951 | ||
|
|
919d3b25dd | ||
|
|
a32800e751 |
@@ -1,8 +1,23 @@
|
||||
node_modules/
|
||||
.svelte-kit/
|
||||
dist/
|
||||
build/
|
||||
node_modules
|
||||
|
||||
# Output
|
||||
.output
|
||||
.vercel
|
||||
.netlify
|
||||
.wrangler
|
||||
/.svelte-kit
|
||||
/build
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
*.log
|
||||
Thumbs.db
|
||||
|
||||
# Env
|
||||
.env
|
||||
.env.local
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.test
|
||||
|
||||
# Vite
|
||||
vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
strict-peer-dependencies=false
|
||||
auto-install-peers=true
|
||||
public-hoist-pattern[]=*svelte*
|
||||
public-hoist-pattern[]=*vite*
|
||||
engine-strict=true
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 ChaosMaker
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
||||
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,3 +1,5 @@
|
||||
# ʃɪˈmædʒɪk
|
||||
|
||||
# sv
|
||||
|
||||
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
|
||||
@@ -15,7 +17,7 @@ To recreate this project with the same configuration:
|
||||
|
||||
```sh
|
||||
# recreate this project
|
||||
pnpm dlx sv@1.1.1 create --template minimal --types ts --install pnpm demo
|
||||
npx sv@1.1.1 create --template minimal --types ts --install npm ./
|
||||
```
|
||||
|
||||
## Adding features
|
||||
@@ -1,23 +0,0 @@
|
||||
node_modules
|
||||
|
||||
# Output
|
||||
.output
|
||||
.vercel
|
||||
.netlify
|
||||
.wrangler
|
||||
/.svelte-kit
|
||||
/build
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Env
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
!.env.test
|
||||
|
||||
# Vite
|
||||
vite.config.js.timestamp-*
|
||||
vite.config.ts.timestamp-*
|
||||
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"name": "demo",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"prepare": "svelte-kit sync || echo ''",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"shimejic": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/adapter-auto": "^8.0.0",
|
||||
"@sveltejs/kit": "^3.0.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|
||||
"svelte": "^5.57.1",
|
||||
"svelte-check": "^4.6.0",
|
||||
"typescript": "^6.0.3",
|
||||
"vite": "^8.3.0"
|
||||
},
|
||||
"imports": {
|
||||
"#lib": "./src/lib/index.js",
|
||||
"#lib/*": "./src/lib/*"
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="text-scale" content="scale" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"extends": ["../../tsconfig.base.json", "$app/tsconfig"],
|
||||
"compilerOptions": {
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"sourceMap": true,
|
||||
"strict": true,
|
||||
"moduleResolution": "bundler"
|
||||
},
|
||||
"include": ["src", "vite.config.ts"]
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import adapter from '@sveltejs/adapter-auto';
|
||||
import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
sveltekit({
|
||||
compilerOptions: {
|
||||
// Force runes mode for the project, except for libraries. Can be removed in svelte 6.
|
||||
runes: ({ filename }) =>
|
||||
filename.split(/[/\\]/).includes('node_modules') ? undefined : true
|
||||
},
|
||||
|
||||
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
||||
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
||||
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
|
||||
adapter: adapter()
|
||||
})
|
||||
]
|
||||
});
|
||||
@@ -1,18 +1,38 @@
|
||||
{
|
||||
"name": "shimejic-mono",
|
||||
"name": "shimejic",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "pnpm --filter demo dev",
|
||||
"build": "pnpm -r build",
|
||||
"check": "pnpm -r check"
|
||||
"dev": "vite dev",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"prepare": "svelte-kit sync || echo ''",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"author": "gornodox",
|
||||
"packageManager": "pnpm@12.14.0",
|
||||
"devDependencies": {
|
||||
"typescript": "catalog:"
|
||||
"@sveltejs/adapter-auto": "^8.0.0",
|
||||
"@sveltejs/kit": "^3.0.0",
|
||||
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|
||||
"svelte": "^5.57.1",
|
||||
"svelte-check": "^4.6.0",
|
||||
"typescript": "^6.0.3",
|
||||
"vite": "^8.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"tailwindcss": "^4.3.3"
|
||||
},
|
||||
"imports": {
|
||||
"#lib": "./src/lib/index.js",
|
||||
"#lib/*": "./src/lib/*"
|
||||
},
|
||||
"exports": {
|
||||
".": "./src/lib/shimejic/index.ts",
|
||||
"./core": "./src/lib/shimejic/core/index.ts",
|
||||
"./systems": "./src/lib/shimejic/systems/index.ts",
|
||||
"./features": "./src/lib/shimejic/features/index.ts",
|
||||
"./svelte": "./src/lib/shimejic/svelte/index.ts"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"name": "shimejic-packer",
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
"bin": {
|
||||
"shimejic-pack": "./dist/cli.js"
|
||||
},
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
"check": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"shimejic": "workspace:*",
|
||||
"sharp": "^0.33.0",
|
||||
"cac": "^6.7.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "catalog:",
|
||||
"@types/node": "^22.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import { cac } from "cac";
|
||||
import { pack } from "./index.js";
|
||||
|
||||
const cli = cac("shimejic-pack");
|
||||
|
||||
cli.command("<input>", "Path to character asset folder")
|
||||
.option("-o, --output <path>", "Output directory (default: ./dist)")
|
||||
.option("-c, --config <path>", "Overrides JSON (default: <input>/character.config.json)")
|
||||
.option("--dry-run", "Report without writing files")
|
||||
.option("--verbose", "Verbose output")
|
||||
.action(async (input: string, options: Record<string, unknown>) => {
|
||||
try {
|
||||
const result = await pack({
|
||||
input,
|
||||
output: (options.output as string | undefined) ?? "./dist",
|
||||
...(options.config !== undefined && { config: options.config as string }),
|
||||
...(options.dryRun !== undefined && { dryRun: Boolean(options.dryRun) }),
|
||||
});
|
||||
|
||||
if (!result.ok) {
|
||||
if (result.errors) {
|
||||
for (const err of result.errors) {
|
||||
console.error(`[error] ${err.path}: ${err.message}`);
|
||||
}
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (result.warnings && result.warnings.length > 0) {
|
||||
for (const w of result.warnings) console.warn(`[warn] ${w}`);
|
||||
}
|
||||
|
||||
console.log("shimejic-pack: not implemented yet");
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
console.error(`[fatal] ${err instanceof Error ? err.message : String(err)}`);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
cli.help();
|
||||
cli.version("0.0.1");
|
||||
cli.parse();
|
||||
@@ -1,26 +0,0 @@
|
||||
export interface PackOptions {
|
||||
/** Path to the folder containing character assets. */
|
||||
input: string;
|
||||
/** Path where atlases and character.json should be written. */
|
||||
output: string;
|
||||
/** Path to overrides JSON. Defaults to `<input>/character.config.json` if present. */
|
||||
config?: string;
|
||||
/** Max atlas dimension in pixels. Default 2048. */
|
||||
maxAtlasSize?: number;
|
||||
/** Report what would be done without writing files. */
|
||||
dryRun?: boolean;
|
||||
}
|
||||
|
||||
export interface PackResult {
|
||||
ok: boolean;
|
||||
/** Populated on success. */
|
||||
characterConfig?: unknown;
|
||||
/** Populated on failure. */
|
||||
errors?: Array<{ path: string; message: string }>;
|
||||
/** Non-fatal issues. */
|
||||
warnings?: string[];
|
||||
}
|
||||
|
||||
export async function pack(_options: PackOptions): Promise<PackResult> {
|
||||
throw new Error("shimejic-packer: not implemented yet");
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext",
|
||||
"target": "es2022",
|
||||
"types": ["node"],
|
||||
"outDir": "./dist",
|
||||
"rootDir": "./src",
|
||||
"noEmit": false,
|
||||
"allowImportingTsExtensions": false
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "shimejic",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./core": "./src/core/index.ts",
|
||||
"./systems": "./src/systems/index.ts",
|
||||
"./features": "./src/features/index.ts"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"check": "tsc --noEmit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "catalog:"
|
||||
}
|
||||
}
|
||||
@@ -1,369 +0,0 @@
|
||||
export interface FrameRegion {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
offsetX: number;
|
||||
offsetY: number;
|
||||
sourceW: number;
|
||||
sourceH: number;
|
||||
}
|
||||
|
||||
export interface AtlasDefinition {
|
||||
url: string;
|
||||
width: number;
|
||||
height: number;
|
||||
frames: Record<string, FrameRegion>;
|
||||
}
|
||||
|
||||
export interface ClipDefinition {
|
||||
atlas: string;
|
||||
frames: string[];
|
||||
framerate: number;
|
||||
loop?: boolean;
|
||||
}
|
||||
|
||||
export interface LookSectorDefinition {
|
||||
minAngle: number;
|
||||
maxAngle: number;
|
||||
minDistance: number;
|
||||
maxDistance: number;
|
||||
atlas: string;
|
||||
frames: string[];
|
||||
}
|
||||
|
||||
export interface LookDefinition {
|
||||
pivot: { x: number; y: number };
|
||||
distance: { min: number; max: number };
|
||||
hysteresis: number;
|
||||
sectors: LookSectorDefinition[];
|
||||
}
|
||||
|
||||
export interface EventDefinition {
|
||||
name: string;
|
||||
atlas: string;
|
||||
frames: string[];
|
||||
framerate: number;
|
||||
chance: number;
|
||||
interval: [number, number];
|
||||
cooldown: number;
|
||||
weight: number;
|
||||
interrupt?: "cut" | "finish";
|
||||
chatter?: ChatterCueDefinition[];
|
||||
}
|
||||
|
||||
export interface ChatterCueDefinition {
|
||||
at: number;
|
||||
unit: "frame" | "ms";
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface StateDefinition {
|
||||
base: ClipDefinition;
|
||||
enter?: ClipDefinition;
|
||||
look?: LookDefinition;
|
||||
events?: EventDefinition[];
|
||||
}
|
||||
|
||||
export interface TextDefinition {
|
||||
font: string;
|
||||
color: string;
|
||||
align: "left" | "center" | "right";
|
||||
padding: { top: number; right: number; bottom: number; left: number };
|
||||
lineHeight: number;
|
||||
wrap: boolean;
|
||||
wrapLongWords: boolean;
|
||||
speed: number;
|
||||
startFrame: number;
|
||||
}
|
||||
|
||||
export interface TimingDefinition {
|
||||
duration?: number | "auto";
|
||||
holdLast: number;
|
||||
}
|
||||
|
||||
export interface BubbleDefinition {
|
||||
atlas: string;
|
||||
frames: string[];
|
||||
framerate?: number;
|
||||
width: number;
|
||||
height: number;
|
||||
anchorX?: number;
|
||||
anchorY?: number;
|
||||
frameMode?: "loop" | "hold" | "reverse-on-dismiss";
|
||||
text?: Partial<TextDefinition>;
|
||||
}
|
||||
|
||||
export interface IconDefinition {
|
||||
atlas: string;
|
||||
frames: string[];
|
||||
}
|
||||
|
||||
export interface VoiceDefinition {
|
||||
basePitch?: number;
|
||||
formatScale?: number;
|
||||
noiseMix?: number;
|
||||
volume?: number;
|
||||
}
|
||||
|
||||
export interface CharacterConfig {
|
||||
ver: 1;
|
||||
id: string;
|
||||
initialState: string;
|
||||
spawnState?: string;
|
||||
atlases: Record<string, AtlasDefinition>;
|
||||
states: Record<string, StateDefinition>;
|
||||
bubbles: Record<string, BubbleDefinition>;
|
||||
icons?: Record<string, IconDefinition>;
|
||||
text?: Partial<TextDefinition>;
|
||||
timing?: Partial<TimingDefinition>;
|
||||
voice?: VoiceDefinition;
|
||||
}
|
||||
|
||||
export interface ValidationError {
|
||||
path: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export function validateConfig(config: unknown): ValidationError[] {
|
||||
const errors: ValidationError[] = [];
|
||||
|
||||
const push = (path: string, message: string): void => {
|
||||
errors.push({ path, message });
|
||||
};
|
||||
|
||||
if (typeof config !== "object" || config === null) {
|
||||
push("", "config must be an object");
|
||||
return errors;
|
||||
}
|
||||
|
||||
const c = config as Partial<CharacterConfig>;
|
||||
|
||||
if (c.ver !== 1) push("version", `expected 1, got ${c.ver}`);
|
||||
if (typeof c.id !== "string" || c.id.length === 0) push("id", "must be a non-empty string");
|
||||
if (typeof c.initialState !== "string") push("initialState", "must be a string");
|
||||
|
||||
if (typeof c.atlases !== "object" || c.atlases === null) {
|
||||
push("atlases", "must be an object");
|
||||
return errors;
|
||||
}
|
||||
if (typeof c.states !== "object" || c.states === null) {
|
||||
push("states", "must be an object");
|
||||
return errors;
|
||||
}
|
||||
|
||||
for (const [name, atlas] of Object.entries(c.atlases)) {
|
||||
validateAtlas(atlas, `atlases.${name}`, push);
|
||||
}
|
||||
|
||||
if (typeof c.initialState === "string" && !(c.initialState in c.states)) {
|
||||
push("initialState", `references unknown state "${c.initialState}"`);
|
||||
}
|
||||
|
||||
if (c.spawnState !== undefined) {
|
||||
if (!(c.spawnState in c.states)) {
|
||||
push("spawnState", `references unknown state "${c.spawnState}"`);
|
||||
}
|
||||
}
|
||||
|
||||
for (const [name, state] of Object.entries(c.states)) {
|
||||
validateState(state, `states.${name}`, c.atlases, push);
|
||||
}
|
||||
|
||||
if (c.bubbles) {
|
||||
for (const [name, bubble] of Object.entries(c.bubbles)) {
|
||||
validateBubble(bubble, `bubbles.${name}`, c.atlases, push);
|
||||
}
|
||||
}
|
||||
|
||||
if (c.icons) {
|
||||
for (const [name, icon] of Object.entries(c.icons)) {
|
||||
validateIcon(icon, `icons.${name}`, c.atlases, push);
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
function validateAtlas(atlas: AtlasDefinition, path: string, push: (path: string, message: string) => void): void {
|
||||
if (typeof atlas.url !== "string") push(`${path}.url`, "must be a string");
|
||||
if (typeof atlas.width !== "number" || atlas.width <= 0) {
|
||||
push(`${path}.width`, "must be a positive number");
|
||||
}
|
||||
if (typeof atlas.height !== "number" || atlas.height <= 0) {
|
||||
push(`${path}.height`, "must be a positive number");
|
||||
}
|
||||
if (typeof atlas.frames !== "object" || atlas.frames === null) {
|
||||
push(`${path}.frames`, "must be an object");
|
||||
return;
|
||||
}
|
||||
for (const [frameName, region] of Object.entries(atlas.frames)) {
|
||||
validateFrameRegion(region, `${path}.frames.${frameName}`, push);
|
||||
}
|
||||
}
|
||||
|
||||
function validateFrameRegion(region: FrameRegion, path: string, push: (path: string, message: string) => void): void {
|
||||
if (typeof region.x !== "number") push(`${path}.x`, "must be a number");
|
||||
if (typeof region.y !== "number") push(`${path}.y`, "must be a number");
|
||||
if (typeof region.w !== "number" || region.w <= 0) push(`${path}.w`, "must be a positive number");
|
||||
if (typeof region.h !== "number" || region.h <= 0) push(`${path}.h`, "must be a positive number");
|
||||
}
|
||||
|
||||
function validateClip(
|
||||
clip: ClipDefinition,
|
||||
path: string,
|
||||
atlases: Record<string, AtlasDefinition>,
|
||||
push: (path: string, message: string) => void,
|
||||
): void {
|
||||
if (typeof clip.atlas !== "string") {
|
||||
push(`${path}.atlas`, "must be a string");
|
||||
} else if (!(clip.atlas in atlases)) {
|
||||
push(`${path}.atlas`, `references unknown atlas "${clip.atlas}"`);
|
||||
} else if (Array.isArray(clip.frames)) {
|
||||
const atlas = atlases[clip.atlas];
|
||||
if (atlas !== undefined) {
|
||||
for (let i = 0; i < clip.frames.length; i++) {
|
||||
const frameName = clip.frames[i];
|
||||
if (frameName !== undefined && !(frameName in atlas.frames)) {
|
||||
push(`${path}.frames[${i}]`, `unknown frame "${frameName}" in atlas "${clip.atlas}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!Array.isArray(clip.frames) || clip.frames.length === 0) {
|
||||
push(`${path}.frames`, "must be a non-empty array");
|
||||
}
|
||||
if (typeof clip.framerate !== "number" || clip.framerate <= 0) {
|
||||
push(`${path}.framerate`, "must be a positive number");
|
||||
}
|
||||
}
|
||||
|
||||
function validateState(
|
||||
state: StateDefinition,
|
||||
path: string,
|
||||
atlases: Record<string, AtlasDefinition>,
|
||||
push: (path: string, message: string) => void,
|
||||
): void {
|
||||
if (state.base === undefined) {
|
||||
push(`${path}.base`, "is required");
|
||||
} else {
|
||||
validateClip(state.base, `${path}.base`, atlases, push);
|
||||
}
|
||||
|
||||
if (state.enter !== undefined) {
|
||||
validateClip(state.enter, `${path}.enter`, atlases, push);
|
||||
}
|
||||
|
||||
if (state.look !== undefined) {
|
||||
validateLook(state.look, `${path}.look`, state.base, atlases, push);
|
||||
}
|
||||
|
||||
if (state.events !== undefined) {
|
||||
for (let i = 0; i < state.events.length; i++) {
|
||||
const ev = state.events[i];
|
||||
if (ev === undefined) continue;
|
||||
const ep = `${path}.events[${i}]`;
|
||||
// Event clip validation reuses validateClip
|
||||
validateClip({ atlas: ev.atlas, frames: ev.frames, framerate: ev.framerate }, ep, atlases, push);
|
||||
if (typeof ev.chance !== "number" || ev.chance < 0 || ev.chance > 1) {
|
||||
push(`${ep}.chance`, "must be between 0 and 1");
|
||||
}
|
||||
if (!Array.isArray(ev.interval) || ev.interval.length !== 2) {
|
||||
push(`${ep}.interval`, "must be in the correct format [min, max]");
|
||||
} else if (ev.interval[0] > ev.interval[1]) {
|
||||
push(`${ep}.interval`, "min must be <= max");
|
||||
}
|
||||
if (typeof ev.cooldown !== "number" || ev.cooldown < 0) {
|
||||
push(`${ep}.cooldown`, "must be >= 0");
|
||||
}
|
||||
if (typeof ev.weight !== "number" || ev.weight < 0) {
|
||||
push(`${ep}.weight`, "must be >= 0");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateLook(
|
||||
look: LookDefinition,
|
||||
path: string,
|
||||
base: ClipDefinition,
|
||||
atlases: Record<string, AtlasDefinition>,
|
||||
push: (path: string, message: string) => void,
|
||||
): void {
|
||||
if (typeof look.pivot?.x !== "number" || typeof look.pivot?.y !== "number") {
|
||||
push(`${path}.pivot`, "must have numeric x and y");
|
||||
}
|
||||
if (typeof look.distance?.min !== "number" || typeof look.distance?.max !== "number") {
|
||||
push(`${path}.distance`, "must have numeric min and max");
|
||||
}
|
||||
if (typeof look.hysteresis !== "number" || look.hysteresis < 0) {
|
||||
push(`${path}.hysteresis`, "must be >= 0");
|
||||
}
|
||||
if (!Array.isArray(look.sectors)) {
|
||||
push(`${path}.sectors`, "must be an array");
|
||||
return;
|
||||
}
|
||||
|
||||
const baseFrameCount = Array.isArray(base.frames) ? base.frames.length : 0;
|
||||
|
||||
for (let i = 0; i < look.sectors.length; i++) {
|
||||
const sector = look.sectors[i];
|
||||
if (sector === undefined) continue;
|
||||
const sp = `${path}.sectors[${i}]`;
|
||||
if (typeof sector.minAngle !== "number" || typeof sector.maxAngle !== "number") {
|
||||
push(sp, "minAngle and maxAngle must be numbers");
|
||||
}
|
||||
if (sector.minDistance !== undefined || sector.maxDistance !== undefined) {
|
||||
push(sp, "minDistance and maxDistance must both be set or both be omitted");
|
||||
} else if (typeof sector.minDistance !== "number" || typeof sector.maxDistance !== "number") {
|
||||
push(sp, "minDistance and maxDistance must be numbers");
|
||||
} else if (sector.minDistance > sector.maxDistance) {
|
||||
push(sp, "minDistance must be <= maxDistance");
|
||||
}
|
||||
if (typeof sector.atlas !== "string" || !(sector.atlas in atlases)) {
|
||||
push(`${sp}.atlas`, `references unknown atlas "${sector.atlas}"`);
|
||||
continue;
|
||||
}
|
||||
if (!Array.isArray(sector.frames)) {
|
||||
push(`${sp}.frames`, "must be an array");
|
||||
continue;
|
||||
}
|
||||
const atlas = atlases[sector.atlas];
|
||||
if (atlas !== undefined) {
|
||||
for (let j = 0; j < sector.frames.length; j++) {
|
||||
const frameName = sector.frames[j];
|
||||
if (frameName !== undefined && !(frameName in atlas.frames)) {
|
||||
push(`${sp}.frames[${j}]`, `unknown frame "${frameName}"`);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (baseFrameCount > 0 && sector.frames.length !== baseFrameCount) {
|
||||
push(`${sp}.frames`, `frame count ${sector.frames.length} doesn't match base count ${baseFrameCount}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateBubble(
|
||||
bubble: BubbleDefinition,
|
||||
path: string,
|
||||
atlases: Record<string, AtlasDefinition>,
|
||||
push: (path: string, message: string) => void,
|
||||
): void {
|
||||
validateClip({ atlas: bubble.atlas, frames: bubble.frames, framerate: bubble.framerate ?? 8 }, path, atlases, push);
|
||||
if (typeof bubble.width !== "number" || bubble.width <= 0) {
|
||||
push(`${path}.width`, "must be a positive number");
|
||||
}
|
||||
if (typeof bubble.height !== "number" || bubble.height <= 0) {
|
||||
push(`${path}.height`, "must be a positive number");
|
||||
}
|
||||
}
|
||||
|
||||
function validateIcon(
|
||||
icon: IconDefinition,
|
||||
path: string,
|
||||
atlases: Record<string, AtlasDefinition>,
|
||||
push: (path: string, message: string) => void,
|
||||
): void {
|
||||
validateClip({ atlas: icon.atlas, frames: icon.frames, framerate: 1 }, path, atlases, push);
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"allowImportingTsExtensions": true,
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
packages:
|
||||
- "apps/*"
|
||||
- "packages/*"
|
||||
|
||||
allowBuilds:
|
||||
sharp: false
|
||||
esbuild: true
|
||||
|
||||
catalog:
|
||||
typescript: ^7.0.2
|
||||
@@ -0,0 +1 @@
|
||||
@import "tailwindcss";
|
||||
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="text-scale" content="scale" />
|
||||
<link rel="stylesheet" href="/src/app.css" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover" style="background-color: black">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 613 B After Width: | Height: | Size: 613 B |
|
Before Width: | Height: | Size: 620 B After Width: | Height: | Size: 620 B |
|
Before Width: | Height: | Size: 617 B After Width: | Height: | Size: 617 B |
|
Before Width: | Height: | Size: 616 B After Width: | Height: | Size: 616 B |
|
Before Width: | Height: | Size: 627 B After Width: | Height: | Size: 627 B |
|
Before Width: | Height: | Size: 618 B After Width: | Height: | Size: 618 B |
|
Before Width: | Height: | Size: 615 B After Width: | Height: | Size: 615 B |
|
Before Width: | Height: | Size: 608 B After Width: | Height: | Size: 608 B |
|
Before Width: | Height: | Size: 603 B After Width: | Height: | Size: 603 B |
|
Before Width: | Height: | Size: 609 B After Width: | Height: | Size: 609 B |
|
Before Width: | Height: | Size: 617 B After Width: | Height: | Size: 617 B |
|
Before Width: | Height: | Size: 654 B After Width: | Height: | Size: 654 B |
|
Before Width: | Height: | Size: 609 B After Width: | Height: | Size: 609 B |
|
Before Width: | Height: | Size: 608 B After Width: | Height: | Size: 608 B |
|
Before Width: | Height: | Size: 601 B After Width: | Height: | Size: 601 B |
|
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 622 B |
|
Before Width: | Height: | Size: 634 B After Width: | Height: | Size: 634 B |
|
Before Width: | Height: | Size: 620 B After Width: | Height: | Size: 620 B |
|
Before Width: | Height: | Size: 621 B After Width: | Height: | Size: 621 B |
|
Before Width: | Height: | Size: 624 B After Width: | Height: | Size: 624 B |
|
Before Width: | Height: | Size: 631 B After Width: | Height: | Size: 631 B |
|
Before Width: | Height: | Size: 632 B After Width: | Height: | Size: 632 B |
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
|
Before Width: | Height: | Size: 632 B After Width: | Height: | Size: 632 B |
|
Before Width: | Height: | Size: 631 B After Width: | Height: | Size: 631 B |
|
Before Width: | Height: | Size: 631 B After Width: | Height: | Size: 631 B |
|
Before Width: | Height: | Size: 625 B After Width: | Height: | Size: 625 B |
|
Before Width: | Height: | Size: 625 B After Width: | Height: | Size: 625 B |
|
Before Width: | Height: | Size: 621 B After Width: | Height: | Size: 621 B |
|
Before Width: | Height: | Size: 607 B After Width: | Height: | Size: 607 B |
|
Before Width: | Height: | Size: 607 B After Width: | Height: | Size: 607 B |
|
Before Width: | Height: | Size: 614 B After Width: | Height: | Size: 614 B |
|
Before Width: | Height: | Size: 601 B After Width: | Height: | Size: 601 B |
|
Before Width: | Height: | Size: 654 B After Width: | Height: | Size: 654 B |
|
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 602 B |
|
Before Width: | Height: | Size: 600 B After Width: | Height: | Size: 600 B |
|
Before Width: | Height: | Size: 611 B After Width: | Height: | Size: 611 B |
|
Before Width: | Height: | Size: 601 B After Width: | Height: | Size: 601 B |
|
Before Width: | Height: | Size: 607 B After Width: | Height: | Size: 607 B |
|
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 622 B |
|
Before Width: | Height: | Size: 648 B After Width: | Height: | Size: 648 B |
|
Before Width: | Height: | Size: 650 B After Width: | Height: | Size: 650 B |
|
Before Width: | Height: | Size: 638 B After Width: | Height: | Size: 638 B |
|
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 622 B |
|
Before Width: | Height: | Size: 658 B After Width: | Height: | Size: 658 B |
|
Before Width: | Height: | Size: 608 B After Width: | Height: | Size: 608 B |
|
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 622 B |
|
Before Width: | Height: | Size: 622 B After Width: | Height: | Size: 622 B |
|
Before Width: | Height: | Size: 620 B After Width: | Height: | Size: 620 B |
|
Before Width: | Height: | Size: 619 B After Width: | Height: | Size: 619 B |
|
Before Width: | Height: | Size: 613 B After Width: | Height: | Size: 613 B |
|
Before Width: | Height: | Size: 595 B After Width: | Height: | Size: 595 B |
|
Before Width: | Height: | Size: 593 B After Width: | Height: | Size: 593 B |
|
Before Width: | Height: | Size: 591 B After Width: | Height: | Size: 591 B |
|
Before Width: | Height: | Size: 601 B After Width: | Height: | Size: 601 B |
|
Before Width: | Height: | Size: 595 B After Width: | Height: | Size: 595 B |
|
Before Width: | Height: | Size: 592 B After Width: | Height: | Size: 592 B |
|
Before Width: | Height: | Size: 585 B After Width: | Height: | Size: 585 B |
|
Before Width: | Height: | Size: 582 B After Width: | Height: | Size: 582 B |
|
Before Width: | Height: | Size: 593 B After Width: | Height: | Size: 593 B |
|
Before Width: | Height: | Size: 594 B After Width: | Height: | Size: 594 B |
|
Before Width: | Height: | Size: 621 B After Width: | Height: | Size: 621 B |
|
Before Width: | Height: | Size: 588 B After Width: | Height: | Size: 588 B |
|
Before Width: | Height: | Size: 591 B After Width: | Height: | Size: 591 B |
|
Before Width: | Height: | Size: 583 B After Width: | Height: | Size: 583 B |
|
Before Width: | Height: | Size: 600 B After Width: | Height: | Size: 600 B |
|
Before Width: | Height: | Size: 607 B After Width: | Height: | Size: 607 B |
|
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 602 B |
|
Before Width: | Height: | Size: 602 B After Width: | Height: | Size: 602 B |
|
Before Width: | Height: | Size: 600 B After Width: | Height: | Size: 600 B |
|
Before Width: | Height: | Size: 608 B After Width: | Height: | Size: 608 B |
|
Before Width: | Height: | Size: 608 B After Width: | Height: | Size: 608 B |
|
Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 606 B |
|
Before Width: | Height: | Size: 609 B After Width: | Height: | Size: 609 B |