1- import * as Bluebird from 'bluebird' ;
21import * as path from 'path' ;
32import * as fs from 'fs-extra' ;
43
@@ -18,13 +17,13 @@ class UbisoftLauncher implements types.IGameStore {
1817 public name : string = STORE_NAME ;
1918 public priority : number = STORE_PRIORITY ;
2019 private mClientPath : Promise < string > ;
21- private mCache : Bluebird < types . IGameStoreEntry [ ] > ;
20+ private mCache : Promise < types . IGameStoreEntry [ ] > ;
2221
2322 constructor ( ) {
2423 if ( process . platform === 'win32' ) {
2524 // Windows implementation (existing Uplay functionality)
2625 try {
27- import ( 'winapi-bindings' ) . then ( ( winapi ) => {
26+ Promise . resolve ( import ( 'winapi-bindings' ) ) . then ( ( winapi ) => {
2827 const uplayPath = winapi . RegGetValue ( 'HKEY_LOCAL_MACHINE' ,
2928 'SOFTWARE\\WOW6432Node\\Ubisoft\\Launcher' , 'InstallDir' ) ;
3029 this . mClientPath = Promise . resolve ( path . join ( uplayPath . value as string , 'UbisoftConnect.exe' ) ) ;
@@ -38,9 +37,9 @@ class UbisoftLauncher implements types.IGameStore {
3837 }
3938 } else if ( process . platform === 'darwin' ) {
4039 // macOS implementation
41- this . mClientPath = this . findMacOSUbisoftPath ( ) . catch ( ( err ) => {
40+ this . mClientPath = Promise . resolve ( this . findMacOSUbisoftPath ( ) ) . catch ( ( err ) => {
4241 log ( 'info' , 'Ubisoft launcher not found on macOS' , { error : err . message } ) ;
43- return Promise . resolve ( undefined ) ;
42+ return undefined ;
4443 } ) ;
4544 } else {
4645 log ( 'info' , 'Ubisoft launcher not found' , { error : 'unsupported platform' } ) ;
@@ -51,7 +50,7 @@ class UbisoftLauncher implements types.IGameStore {
5150 /**
5251 * Find Ubisoft Connect on macOS
5352 */
54- private async findMacOSUbisoftPath ( ) : Promise < string > {
53+ private async findMacOSUbisoftPath ( ) : globalThis . Promise < string > {
5554 // Check standard installation paths
5655 const possiblePaths = [
5756 '/Applications/Ubisoft Connect.app' ,
@@ -62,17 +61,17 @@ class UbisoftLauncher implements types.IGameStore {
6261 try {
6362 const stat = await fs . stat ( appPath ) ;
6463 if ( stat . isDirectory ( ) ) {
65- return Promise . resolve ( appPath ) ;
64+ return appPath ;
6665 }
6766 } catch ( err ) {
6867 // Continue to next path
6968 }
7069 }
7170
72- return Promise . reject ( new Error ( 'Ubisoft Connect not found on macOS' ) ) ;
71+ throw new Error ( 'Ubisoft Connect not found on macOS' ) ;
7372 }
7473
75- public launchGame ( appInfo : any , api ?: types . IExtensionApi ) : Bluebird < void > {
74+ public launchGame ( appInfo : any , api ?: types . IExtensionApi ) : Promise < void > {
7675 const appId = ( ( typeof ( appInfo ) === 'object' ) && ( 'appId' in appInfo ) )
7776 ? appInfo . appId : appInfo . toString ( ) ;
7877
@@ -85,31 +84,31 @@ class UbisoftLauncher implements types.IGameStore {
8584 // need to change this in the future to allow game extensions to choose the executable
8685 // they want to launch.
8786 const posixPath = `ubisoft://launch/${ appId } /0` ;
88- return util . opn ( posixPath ) . catch ( err => Bluebird . resolve ( ) ) ;
87+ return util . opn ( posixPath ) . catch ( ( ) => Promise . resolve ( ) ) ;
8988 }
9089
91- public allGames ( ) : Bluebird < types . IGameStoreEntry [ ] > {
90+ public allGames ( ) : Promise < types . IGameStoreEntry [ ] > {
9291 if ( this . mCache === undefined ) {
9392 this . mCache = this . getGameEntries ( ) ;
9493 }
9594 return this . mCache ;
9695 }
9796
98- public reloadGames ( ) : Bluebird < void > {
97+ public reloadGames ( ) : Promise < void > {
9998 this . mCache = this . getGameEntries ( ) ;
100- return Bluebird . resolve ( ) ;
99+ return Promise . resolve ( ) ;
101100 }
102101
103- public findByName ( appName : string ) : Bluebird < types . IGameStoreEntry > {
102+ public findByName ( appName : string ) : Promise < types . IGameStoreEntry > {
104103 const re = new RegExp ( '^' + appName + '$' ) ;
105104 return this . allGames ( )
106105 . then ( entries => entries . find ( entry => re . test ( entry . name ) ) )
107106 . then ( entry => ( entry === undefined )
108- ? Bluebird . reject ( new types . GameEntryNotFound ( appName , STORE_ID ) )
109- : Bluebird . resolve ( entry ) ) ;
107+ ? Promise . reject ( new types . GameEntryNotFound ( appName , STORE_ID ) )
108+ : Promise . resolve ( entry ) ) ;
110109 }
111110
112- public findByAppId ( appId : string | string [ ] ) : Bluebird < types . IGameStoreEntry > {
111+ public findByAppId ( appId : string | string [ ] ) : Promise < types . IGameStoreEntry > {
113112 const matcher = Array . isArray ( appId )
114113 ? ( entry : types . IGameStoreEntry ) => ( appId . includes ( entry . appid ) )
115114 : ( entry : types . IGameStoreEntry ) => ( appId === entry . appid ) ;
@@ -118,33 +117,33 @@ class UbisoftLauncher implements types.IGameStore {
118117 . then ( entries => {
119118 const gameEntry = entries . find ( matcher ) ;
120119 if ( gameEntry === undefined ) {
121- return Bluebird . reject (
120+ return Promise . reject (
122121 new types . GameEntryNotFound ( Array . isArray ( appId ) ? appId . join ( ', ' ) : appId , STORE_ID ) ) ;
123122 } else {
124- return Bluebird . resolve ( gameEntry ) ;
123+ return Promise . resolve ( gameEntry ) ;
125124 }
126125 } ) ;
127126 }
128127
129- public getGameStorePath ( ) : Bluebird < string > {
128+ public getGameStorePath ( ) : Promise < string > {
130129 return ( ! ! this . mClientPath )
131- ? Bluebird . resolve ( this . mClientPath ) . then ( x => x )
132- : Bluebird . resolve ( undefined ) ;
130+ ? Promise . resolve ( this . mClientPath ) . then ( x => x )
131+ : Promise . resolve ( undefined ) ;
133132 }
134133
135- private getGameEntries ( ) : Bluebird < types . IGameStoreEntry [ ] > {
134+ private getGameEntries ( ) : Promise < types . IGameStoreEntry [ ] > {
136135 if ( process . platform === 'win32' ) {
137- return Bluebird . resolve ( this . getGameEntriesWindows ( ) ) . then ( x => x ) ;
136+ return Promise . resolve ( this . getGameEntriesWindows ( ) ) . then ( x => x ) ;
138137 } else if ( process . platform === 'darwin' ) {
139- return Bluebird . resolve ( this . getGameEntriesMacOS ( ) ) . then ( x => x ) ;
138+ return Promise . resolve ( this . getGameEntriesMacOS ( ) ) . then ( x => x ) ;
140139 } else {
141- return Bluebird . resolve ( [ ] ) ;
140+ return Promise . resolve ( [ ] ) ;
142141 }
143142 }
144143
145144 private getGameEntriesWindows ( ) : Promise < types . IGameStoreEntry [ ] > {
146145 return ( ! ! this . mClientPath )
147- ? import ( 'winapi-bindings' ) . then ( ( winapi ) => {
146+ ? Promise . resolve ( import ( 'winapi-bindings' ) ) . then ( ( winapi ) => {
148147 return new Promise < types . IGameStoreEntry [ ] > ( ( resolve , reject ) => {
149148 try {
150149 winapi . WithRegOpen ( 'HKEY_LOCAL_MACHINE' ,
@@ -185,7 +184,7 @@ class UbisoftLauncher implements types.IGameStore {
185184 : Promise . resolve ( [ ] ) ;
186185 }
187186
188- private async getGameEntriesMacOS ( ) : Promise < types . IGameStoreEntry [ ] > {
187+ private async getGameEntriesMacOS ( ) : globalThis . Promise < types . IGameStoreEntry [ ] > {
189188 try {
190189 // On macOS, Ubisoft Connect stores data in ~/Library/Application Support/Ubisoft/Ubisoft Game Launcher
191190 const homeDir = process . env . HOME || '' ;
@@ -278,7 +277,7 @@ class UbisoftLauncher implements types.IGameStore {
278277 return gameNames [ gameId ] || `Ubisoft Game ${ gameId } ` ;
279278 }
280279
281- private async findGameInstallationPath ( gameId : string ) : Promise < string | null > {
280+ private async findGameInstallationPath ( gameId : string ) : globalThis . Promise < string | null > {
282281 try {
283282 // Check common installation paths
284283 const homeDir = process . env . HOME || '' ;
@@ -338,4 +337,5 @@ function main(context: types.IExtensionContext) {
338337 return true ;
339338}
340339
340+ export { UbisoftLauncher } ;
341341export default main ;
0 commit comments