UNPKG

@zerospacegg/iolin

Version:

Pure TypeScript implementation of ZeroSpace game data processing (PKL-free)

63 lines 2.53 kB
"use strict"; /** * Universal - Minimal base class for all game objects * Provides core identity properties that both entities and children need */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Universal = void 0; class Universal { constructor() { // Unlock system properties - every entity can participate in unlock relationships this.unlocked = true; // Whether this entity is currently unlocked (default unlocked) this.unlockedBy = []; // What entities this unlocks (what this enables) } /** Runtime class name hierarchy for frontend dynamic imports */ get className() { const hierarchy = []; let currentConstructor = this.constructor; // Walk up the prototype chain until we hit Universal while (currentConstructor) { hierarchy.push(currentConstructor.name); if (currentConstructor.name === "Universal") break; currentConstructor = Object.getPrototypeOf(currentConstructor); } return hierarchy; } /** First class name for backward compatibility */ get firstClassName() { return this.constructor.name; } /** Canonical URL path for this entity on zerospace.gg */ get zsggPath() { return `https://zerospace.gg/library/${this.id}/`; } /** * Normalize indentation from template literals * Simple text normalization - markdown processing happens in the frontend */ normalizeText(value) { if (!value) { return undefined; } // Split into lines first, preserving the template literal structure const lines = value.split(/\r?\n/); // Find minimum indentation (ignoring empty and whitespace-only lines) const contentLines = lines.filter(line => line.trim().length > 0); if (contentLines.length === 0) { return ""; } const minIndent = Math.min(...contentLines.map(line => line.match(/^\s*/)?.[0].length ?? 0)); // Remove common indentation, preserving empty/whitespace-only lines as empty const normalizedLines = lines.map(line => { if (line.trim().length === 0) { return ''; } return line.slice(minIndent); }); // Trim at the end to remove leading/trailing whitespace from template literal structure return normalizedLines.join('\n').trim(); } } exports.Universal = Universal; //# sourceMappingURL=universal.js.map