MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / Monogatari

Class Monogatari

src/monogatari.ts:158–2495  ·  view source on GitHub ↗

* Every Monogatari Game is composed mainly of the following items: * * Actions: The list of capabilities a Monogatari script can run. * * Components: The list of screens and other HTML elements available in the game. * * State: The current state of the game, this simple object contains the cur

Source from the content-addressed store, hash-verified

156 *
157 */
158class Monogatari {
159
160 /**
161 * Returns the class typed as VisualNovelEngine.
162 * This enables type-safe access while allowing external users to extend
163 * the VisualNovelEngine interface via declaration merging.
164 *
165 * @internal
166 */
167 private static asEngine(): VisualNovelEngine {
168 return this as unknown as VisualNovelEngine;
169 }
170
171 static _languageMetadata: Record<string, { code: string; icon: string }> = {};
172 static _events: Record<string, unknown> = {};
173
174 static _selector = '#monogatari';
175
176 static _actions: StaticAction[] = [];
177 static _components: StaticComponent[] = [];
178 static _translations: Record<string, Record<string, string>> = {};
179 static _script: Record<string, unknown> = {};
180 static _characters: Record<string, Character> = {};
181 static _storage: Record<string, unknown> = {};
182
183 // Web Audio API context for audio playback with effects
184 static audioContext: AudioContext | undefined;
185
186 // Asset caches for decoded audio and images
187 static _audioBufferCache: Map<string, AudioBuffer> = new Map();
188 static _imageCache: Map<string, HTMLImageElement> = new Map();
189
190 // Persistent audio buffer storage
191 static _audioBufferSpace: Space | null = null;
192
193 // Save screenshot storage (IndexedDB, out-of-line keys; holds raw Blobs)
194 static _screenshotSpace: Space | null = null;
195
196 // Track IndexedDB availability: null = not checked, true = available, false = unavailable
197 static _indexedDBAvailable: boolean | null = null;
198
199 // Whether the developer has overridden the default onSaveScreenshot callback
200 static _hasCustomSaveScreenshot = false;
201
202 // Screenshot of the game screen captured when the save screen is opened, before
203 // the game screen is hidden. Consumed by saveTo() for manual-save thumbnails.
204 static _pendingScreenshot: Promise<Blob | null> | null = null;
205
206 static Storage: StorageInterface = new Space () as unknown as StorageInterface;
207
208 // Read a stored screenshot Blob into a data-URL string for display.
209 private static _blobToDataURL (blob: Blob): Promise<string> {
210 return new Promise ((resolve, reject) => {
211 const reader = new FileReader ();
212 reader.onload = () => resolve (reader.result as string);
213 reader.onerror = () => reject (reader.error ?? new Error ('Failed to read screenshot blob'));
214 reader.readAsDataURL (blob);
215 });

Callers

nothing calls this directly

Calls 5

screenshotSpaceMethod · 0.80
_blobToDataURLMethod · 0.80
setMethod · 0.65
getMethod · 0.65
removeMethod · 0.65

Tested by

no test coverage detected