@@ -29,6 +29,7 @@ import {
2929import { buildProjectPackage , summarizeProjectPackaging } from "../shared/projectPackaging.js" ;
3030import { buildEditorExperienceLayer , summarizeEditorExperienceLayer } from "../shared/editorExperienceLayer.js" ;
3131import { buildDebugVisualizationLayer , summarizeDebugVisualizationLayer } from "../shared/debugVisualizationLayer.js" ;
32+ import { registerToolBootContract } from "../shared/toolBootContract.js" ;
3233
3334const SAMPLE_DIRECTORY_PATH = "./samples/" ;
3435const SAMPLE_MANIFEST_PATH = "./samples/sample-manifest.json" ;
@@ -1836,24 +1837,47 @@ class ParallaxEditorApp {
18361837 }
18371838}
18381839
1839- const initialDocument = createInitialParallaxDocument ( ) ;
1840- const app = new ParallaxEditorApp ( initialDocument ) ;
1841- app . init ( document ) ;
1842- app . applyProjectSystemState = function applyProjectSystemState ( snapshot ) {
1843- const nextDocument = sanitizeParallaxDocument ( snapshot ?. documentModel ) ;
1844- this . documentModel = nextDocument ;
1845- this . assetRegistry = snapshot ?. assetRegistry && typeof snapshot . assetRegistry === "object"
1846- ? sanitizeAssetRegistry ( snapshot . assetRegistry )
1847- : createAssetRegistry ( { projectId : nextDocument ?. map ?. name || "parallax-project" } ) ;
1848- this . selectedLayerId = typeof snapshot ?. selectedLayerId === "string" && nextDocument . layers . some ( ( layer ) => layer . id === snapshot . selectedLayerId )
1849- ? snapshot . selectedLayerId
1850- : nextDocument . layers [ 0 ] ?. id || "" ;
1851- this . cameraX = Number . isFinite ( Number ( snapshot ?. cameraX ) ) ? Number ( snapshot . cameraX ) : 0 ;
1852- this . cameraY = Number . isFinite ( Number ( snapshot ?. cameraY ) ) ? Number ( snapshot . cameraY ) : 0 ;
1853- this . resolveAssetRefsFromRegistry ( ) ;
1854- this . invalidateImageCache ( ) ;
1855- this . syncInputsFromDocument ( ) ;
1856- this . renderAll ( ) ;
1857- this . updateStatus ( `Project state loaded for ${ this . documentModel . map . name } .` ) ;
1858- } ;
1859- window . parallaxSceneStudioApp = app ;
1840+ let parallaxSceneStudioApp = null ;
1841+
1842+ function bootParallaxSceneStudio ( ) {
1843+ if ( parallaxSceneStudioApp ) {
1844+ window . parallaxSceneStudioApp = parallaxSceneStudioApp ;
1845+ return parallaxSceneStudioApp ;
1846+ }
1847+
1848+ const initialDocument = createInitialParallaxDocument ( ) ;
1849+ const app = new ParallaxEditorApp ( initialDocument ) ;
1850+ app . init ( document ) ;
1851+ app . applyProjectSystemState = function applyProjectSystemState ( snapshot ) {
1852+ const nextDocument = sanitizeParallaxDocument ( snapshot ?. documentModel ) ;
1853+ this . documentModel = nextDocument ;
1854+ this . assetRegistry = snapshot ?. assetRegistry && typeof snapshot . assetRegistry === "object"
1855+ ? sanitizeAssetRegistry ( snapshot . assetRegistry )
1856+ : createAssetRegistry ( { projectId : nextDocument ?. map ?. name || "parallax-project" } ) ;
1857+ this . selectedLayerId = typeof snapshot ?. selectedLayerId === "string" && nextDocument . layers . some ( ( layer ) => layer . id === snapshot . selectedLayerId )
1858+ ? snapshot . selectedLayerId
1859+ : nextDocument . layers [ 0 ] ?. id || "" ;
1860+ this . cameraX = Number . isFinite ( Number ( snapshot ?. cameraX ) ) ? Number ( snapshot . cameraX ) : 0 ;
1861+ this . cameraY = Number . isFinite ( Number ( snapshot ?. cameraY ) ) ? Number ( snapshot . cameraY ) : 0 ;
1862+ this . resolveAssetRefsFromRegistry ( ) ;
1863+ this . invalidateImageCache ( ) ;
1864+ this . syncInputsFromDocument ( ) ;
1865+ this . renderAll ( ) ;
1866+ this . updateStatus ( `Project state loaded for ${ this . documentModel . map . name } .` ) ;
1867+ } ;
1868+ parallaxSceneStudioApp = app ;
1869+ window . parallaxSceneStudioApp = parallaxSceneStudioApp ;
1870+ return parallaxSceneStudioApp ;
1871+ }
1872+
1873+ registerToolBootContract ( "parallax-editor" , {
1874+ init : bootParallaxSceneStudio ,
1875+ destroy ( ) {
1876+ return true ;
1877+ } ,
1878+ getApi ( ) {
1879+ return window . parallaxSceneStudioApp || null ;
1880+ }
1881+ } ) ;
1882+
1883+ bootParallaxSceneStudio ( ) ;
0 commit comments