@@ -43,6 +43,14 @@ export class BridgeJSPlayground {
43
43
this . copyButton = /** @type {HTMLButtonElement } */ ( document . getElementById ( 'copyButton' ) ) ;
44
44
/** @type {HTMLButtonElement } */
45
45
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' ) ) ;
46
54
}
47
55
48
56
/**
@@ -55,43 +63,53 @@ export class BridgeJSPlayground {
55
63
}
56
64
57
65
try {
66
+ this . showProgress ( 'Starting…' , 5 ) ;
58
67
// Initialize editor system
59
68
await this . editorSystem . init ( ) ;
69
+ this . setProgress ( 'Editor ready' , 30 ) ;
60
70
61
71
// Initialize BridgeJS
62
72
await this . initializeBridgeJS ( ) ;
73
+ this . setProgress ( 'BridgeJS ready' , 70 ) ;
63
74
64
75
// Set up event listeners
65
76
this . setupEventListeners ( ) ;
66
77
67
78
// Check for shared code in URL
79
+ this . setProgress ( 'Checking shared code…' , 80 ) ;
68
80
const sharedCode = await CodeShareManager . extractCodeFromUrl ( ) ;
69
81
if ( sharedCode ) {
70
82
this . editorSystem . setInputs ( sharedCode ) ;
71
83
} else {
72
84
// Load sample code
73
85
this . editorSystem . setInputs ( sampleCode ) ;
74
86
}
75
-
87
+ this . setProgress ( 'Finalizing…' , 95 ) ;
76
88
this . isInitialized = true ;
77
89
console . log ( 'BridgeJS Playground initialized successfully' ) ;
90
+ this . setProgress ( 'Ready' , 100 ) ;
91
+ setTimeout ( ( ) => this . hideProgress ( ) , 400 ) ;
78
92
} catch ( error ) {
79
93
console . error ( 'Failed to initialize BridgeJS Playground:' , error ) ;
80
94
this . showError ( 'Failed to initialize application: ' + error . message ) ;
95
+ this . hideProgress ( ) ;
81
96
}
82
97
}
83
98
84
99
// Initialize BridgeJS
85
100
async initializeBridgeJS ( ) {
86
101
try {
87
102
// Import the BridgeJS module
103
+ this . setProgress ( 'Loading BridgeJS…' , 50 ) ;
88
104
const { init } = await import ( "../../.build/plugins/PackageToJS/outputs/Package/index.js" ) ;
89
105
const virtualHost = await this . createTS2SkeletonFactory ( ) ;
106
+ this . setProgress ( 'Preparing TypeScript host…' , 60 ) ;
90
107
const { exports } = await init ( {
91
108
getImports : ( ) => ( {
92
109
createTS2Skeleton : ( ) => this . createTS2Skeleton ( virtualHost )
93
110
} )
94
111
} ) ;
112
+ this . setProgress ( 'Creating runtime…' , 65 ) ;
95
113
this . playBridgeJS = new exports . PlayBridgeJS ( ) ;
96
114
console . log ( 'BridgeJS initialized successfully' ) ;
97
115
} catch ( error ) {
@@ -284,4 +302,42 @@ export class BridgeJSPlayground {
284
302
hideError ( ) {
285
303
this . errorDisplay . classList . remove ( 'show' ) ;
286
304
}
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
+ }
287
343
}
0 commit comments