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

Method init

src/monogatari.ts:2376–2479  ·  view source on GitHub ↗
(selector = '#monogatari')

Source from the content-addressed store, hash-verified

2374 }
2375
2376 static async init (selector = '#monogatari') {
2377 this._selector = selector;
2378
2379 if (typeof window.Cypress !== 'undefined') {
2380 this.setting ('ExperimentalFeatures', true);
2381 }
2382
2383 // Setup Pandora Registry for centralized error handling and lifecycle tracking
2384 this._setupRegistry ();
2385
2386 this.trigger ('willInit');
2387
2388 const storageConfigInit = this.Storage?.configuration () as { name?: string } | undefined;
2389
2390 if (!storageConfigInit || storageConfigInit.name === '') {
2391 this.setupStorage ();
2392 }
2393
2394 this.trigger ('willSetup');
2395
2396 await this.setup(selector);
2397
2398 this.trigger ('didSetup');
2399 this.trigger ('willBind');
2400
2401 await this.bind(selector);
2402
2403 this.trigger ('didBind');
2404
2405 this.ambientPlayer = new Audio ();
2406
2407 // Set the initial language translations
2408 this.localize ();
2409
2410 // Set the label in which the game will start
2411 this.state ({ label: this.setting ('Label') });
2412
2413 // Check if the orientation is correct, if it's not, show the warning
2414 // message so the player will rotate its device.
2415 if (this.setting ('Orientation') !== 'any') {
2416 const initIsMobile = Platform.mobile();
2417
2418 if (initIsMobile && Platform.orientation !== this.setting ('Orientation')) {
2419 this.alert ('orientation-warning', {
2420 message: 'OrientationWarning'
2421 });
2422 }
2423 }
2424
2425 const init: Promise<void>[] = [];
2426
2427 for (const component of this.components ()) {
2428 init.push (component.init (selector));
2429 }
2430
2431 for (const action of this.actions ()) {
2432 init.push (action.init (selector));
2433 }

Callers

nothing calls this directly

Calls 15

settingMethod · 0.95
_setupRegistryMethod · 0.95
triggerMethod · 0.95
setupStorageMethod · 0.95
setupMethod · 0.95
bindMethod · 0.95
localizeMethod · 0.95
stateMethod · 0.95
alertMethod · 0.95
componentsMethod · 0.95
actionsMethod · 0.95
globalMethod · 0.95

Tested by

no test coverage detected