-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jupyter): Rework comm creation to make it compatible w/ other ext…
…ensions
- Loading branch information
1 parent
b625a33
commit 77b08c7
Showing
9 changed files
with
1,280 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { URLExt } from '@jupyterlab/coreutils'; | ||
import { ServerConnection } from '@jupyterlab/services'; | ||
|
||
async function getExtensionLocation(): Promise<{ | ||
endpoint: string; | ||
www: string; | ||
}> { | ||
let www = ''; | ||
let endpoint = ''; | ||
|
||
const settings = ServerConnection.makeSettings(); | ||
endpoint = URLExt.join(settings.baseUrl, 'trame-jupyter-server'); | ||
const requestUrl = URLExt.join( | ||
settings.baseUrl, | ||
'trame-jupyter-server', | ||
'location' | ||
); | ||
let response: Response; | ||
try { | ||
response = await ServerConnection.makeRequest(requestUrl, {}, settings); | ||
} catch (error) { | ||
throw new ServerConnection.NetworkError(error as any); | ||
} | ||
|
||
const data: any = await response.text(); | ||
|
||
if (data.length > 0) { | ||
try { | ||
www = JSON.parse(data).www; | ||
} catch (error) { | ||
console.log('Not a JSON response body.', response); | ||
} | ||
} | ||
|
||
if (!response.ok) { | ||
throw new ServerConnection.ResponseError(response, data.message || data); | ||
} | ||
|
||
return { endpoint, www }; | ||
} | ||
|
||
export { getExtensionLocation }; |
Oops, something went wrong.