1- import { CommandInterface , Emulators } from "emulators" ;
2- import { Terminal , Uri , Webview } from "vscode" ;
1+ import { CommandInterface , Emulators , getEmulators } from "emulators" ;
2+ import { ExtensionContext , Terminal , Uri , Webview } from "vscode" ;
33import { API , Dosbox , Jsdos } from "./vscode-dosbox-api" ;
44import * as Jszip from 'jszip' ;
5+ import { activateJSdos } from "./jsdos/main"
6+ import { CreateBundleOptions } from "./jsdos-bundle/bundle" ;
57
6-
7- class JsdosApi implements Jsdos {
8- setBundle ( bundle : Uri | Uint8Array , updateConf ?: boolean ) : void {
9- throw new Error ( "Method not implemented." ) ;
10- }
11- jszip = Jszip ;
12- updateConf ( section : string , key : string , value : string | number | boolean ) : boolean {
13- throw new Error ( "Method not implemented." ) ;
14- }
15- updateAutoexec ( context : string [ ] ) : void {
16- throw new Error ( "Method not implemented." ) ;
17- }
18- runInHost ( ) : Promise < CommandInterface > {
19- throw new Error ( "Method not implemented." ) ;
20- }
21- runInWebview ( ) : Promise < Webview > {
22- throw new Error ( "Method not implemented." ) ;
23- }
24-
25- }
26-
27- class vscodeDosboxAPI implements API {
8+ export class vscodeDosboxAPI implements API {
289 emulators : Emulators ;
29- jsdos : Jsdos = new JsdosApi ( ) ;
10+ jsdos : Jsdos ;
3011 dosbox : Dosbox ;
3112 dosboxX : Dosbox ;
32- msdosPath : string ;
33- commandPath : string ;
13+ msdosPath : string = "" ;
14+ commandPath : string = "" ;
15+ createBundle :( { sample, boxConf, mount, } : CreateBundleOptions ) => Promise < Jszip >
3416
35- constructor ( emulators ?: Emulators , msdosPath ?: string , commandPath ?: string ) {
36- // store the provided emulators object or use an empty placeholder
37- this . emulators = emulators || ( { } as Emulators ) ;
17+ constructor ( context : ExtensionContext ) {
18+ const { jsdos , createBundle } = activateJSdos ( context ) ;
19+ this . emulators = jsdos . emulators ;
3820
3921 // prefer real emulator instances when available, otherwise keep lightweight placeholders
40- this . jsdos = ( this . emulators as any ) . jsdos || ( { } as Jsdos ) ;
22+ this . jsdos = jsdos ;
23+ this . createBundle = createBundle ;
4124 this . dosbox = ( this . emulators as any ) . dosbox || ( { } as Dosbox ) ;
4225 this . dosboxX = ( this . emulators as any ) . dosboxX || ( { } as Dosbox ) ;
4326
44- this . msdosPath = msdosPath || "" ;
45- this . commandPath = commandPath || "" ;
4627 }
4728
4829 /**
@@ -100,6 +81,4 @@ class vscodeDosboxAPI implements API {
10081 return impl as unknown as Terminal ;
10182 }
10283
103- }
104-
105- export const api = new vscodeDosboxAPI ( )
84+ }
0 commit comments