@@ -43,6 +43,14 @@ export class BridgeJSPlayground {
4343 this . copyButton = /** @type {HTMLButtonElement } */ ( document . getElementById ( 'copyButton' ) ) ;
4444 /** @type {HTMLButtonElement } */
4545 this . closeShareDialogButton = /** @type {HTMLButtonElement } */ ( document . getElementById ( 'closeShareDialog' ) ) ;
46+
47+ // Progress UI elements
48+ /** @type {HTMLDivElement | null } */
49+ this . progressBar = /** @type {HTMLDivElement } */ ( document . getElementById ( 'progressBar' ) ) ;
50+ /** @type {HTMLDivElement | null } */
51+ this . progressFill = /** @type {HTMLDivElement } */ ( document . getElementById ( 'progressFill' ) ) ;
52+ /** @type {HTMLDivElement | null } */
53+ this . progressLabel = /** @type {HTMLDivElement } */ ( document . getElementById ( 'progressLabel' ) ) ;
4654 }
4755
4856 /**
@@ -55,43 +63,53 @@ export class BridgeJSPlayground {
5563 }
5664
5765 try {
66+ this . showProgress ( 'Starting…' , 5 ) ;
5867 // Initialize editor system
5968 await this . editorSystem . init ( ) ;
69+ this . setProgress ( 'Editor ready' , 30 ) ;
6070
6171 // Initialize BridgeJS
6272 await this . initializeBridgeJS ( ) ;
73+ this . setProgress ( 'BridgeJS ready' , 70 ) ;
6374
6475 // Set up event listeners
6576 this . setupEventListeners ( ) ;
6677
6778 // Check for shared code in URL
79+ this . setProgress ( 'Checking shared code…' , 80 ) ;
6880 const sharedCode = await CodeShareManager . extractCodeFromUrl ( ) ;
6981 if ( sharedCode ) {
7082 this . editorSystem . setInputs ( sharedCode ) ;
7183 } else {
7284 // Load sample code
7385 this . editorSystem . setInputs ( sampleCode ) ;
7486 }
75-
87+ this . setProgress ( 'Finalizing…' , 95 ) ;
7688 this . isInitialized = true ;
7789 console . log ( 'BridgeJS Playground initialized successfully' ) ;
90+ this . setProgress ( 'Ready' , 100 ) ;
91+ setTimeout ( ( ) => this . hideProgress ( ) , 400 ) ;
7892 } catch ( error ) {
7993 console . error ( 'Failed to initialize BridgeJS Playground:' , error ) ;
8094 this . showError ( 'Failed to initialize application: ' + error . message ) ;
95+ this . hideProgress ( ) ;
8196 }
8297 }
8398
8499 // Initialize BridgeJS
85100 async initializeBridgeJS ( ) {
86101 try {
87102 // Import the BridgeJS module
103+ this . setProgress ( 'Loading BridgeJS…' , 50 ) ;
88104 const { init } = await import ( "../../.build/plugins/PackageToJS/outputs/Package/index.js" ) ;
89105 const virtualHost = await this . createTS2SkeletonFactory ( ) ;
106+ this . setProgress ( 'Preparing TypeScript host…' , 60 ) ;
90107 const { exports } = await init ( {
91108 getImports : ( ) => ( {
92109 createTS2Skeleton : ( ) => this . createTS2Skeleton ( virtualHost )
93110 } )
94111 } ) ;
112+ this . setProgress ( 'Creating runtime…' , 65 ) ;
95113 this . playBridgeJS = new exports . PlayBridgeJS ( ) ;
96114 console . log ( 'BridgeJS initialized successfully' ) ;
97115 } catch ( error ) {
@@ -284,4 +302,42 @@ export class BridgeJSPlayground {
284302 hideError ( ) {
285303 this . errorDisplay . classList . remove ( 'show' ) ;
286304 }
305+
306+ /**
307+ * Shows progress bar.
308+ * @param {string } label
309+ * @param {number } percent
310+ */
311+ showProgress ( label , percent ) {
312+ if ( this . progressBar ) {
313+ this . progressBar . classList . add ( 'show' ) ;
314+ this . progressBar . classList . remove ( 'hidden' ) ;
315+ }
316+ this . setProgress ( label , percent ) ;
317+ }
318+
319+ /**
320+ * Updates progress label and percentage.
321+ * @param {string } label
322+ * @param {number } percent
323+ */
324+ setProgress ( label , percent ) {
325+ if ( this . progressLabel ) {
326+ this . progressLabel . textContent = label ;
327+ }
328+ if ( this . progressFill ) {
329+ const clamped = Math . max ( 0 , Math . min ( 100 , Number ( percent ) || 0 ) ) ;
330+ this . progressFill . style . width = clamped + '%' ;
331+ }
332+ }
333+
334+ /**
335+ * Hides progress bar.
336+ */
337+ hideProgress ( ) {
338+ if ( this . progressBar ) {
339+ this . progressBar . classList . remove ( 'show' ) ;
340+ this . progressBar . classList . add ( 'hidden' ) ;
341+ }
342+ }
287343}
0 commit comments