@@ -144,16 +144,36 @@ <h2 onclick="toggleInstructions()">
144144 <!-- Sample queries -->
145145 < script src ="./queries.js "> </ script >
146146
147- <!-- Graph Plugin - DEV MODE (load source files directly) -->
147+ <!-- Graph Plugin: Load from source in dev, or from dist in production -->
148148 < script type ="module ">
149- // Import all source modules
150- import GraphPlugin from '../src/GraphPlugin.js' ;
151-
152- // Register plugin with YASGUI
153- if ( window . Yasgui && window . Yasgui . Yasr ) {
154- window . Yasgui . Yasr . registerPlugin ( 'Graph' , GraphPlugin ) ;
155- } else {
156- console . error ( 'YASGUI not loaded' ) ;
149+ // Try to load from source (development mode)
150+ let pluginLoaded = false ;
151+ try {
152+ const { default : GraphPlugin } = await import ( '../src/GraphPlugin.js' ) ;
153+ if ( window . Yasgui && window . Yasgui . Yasr ) {
154+ window . Yasgui . Yasr . registerPlugin ( 'Graph' , GraphPlugin ) ;
155+ pluginLoaded = true ;
156+ console . log ( 'Graph Plugin loaded from source (dev mode)' ) ;
157+ }
158+ } catch ( error ) {
159+ console . log ( 'Source not available, loading from bundle (production mode)' ) ;
160+ }
161+
162+ // Fall back to bundle if source didn't work
163+ if ( ! pluginLoaded ) {
164+ const script = document . createElement ( 'script' ) ;
165+ script . src = './dist/yasgui-graph-plugin.min.js' ;
166+ await new Promise ( ( resolve , reject ) => {
167+ script . onload = ( ) => {
168+ console . log ( 'Graph Plugin loaded from bundle' ) ;
169+ resolve ( ) ;
170+ } ;
171+ script . onerror = ( ) => {
172+ console . error ( 'Failed to load Graph Plugin bundle' ) ;
173+ reject ( ) ;
174+ } ;
175+ document . head . appendChild ( script ) ;
176+ } ) ;
157177 }
158178
159179 // Initialize YASGUI after plugin is registered
0 commit comments