-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from CodinGame/improve-asset-management
Improve asset management
- Loading branch information
Showing
5 changed files
with
98 additions
and
43 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 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
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,7 @@ | ||
let assetUrls: Record<string, string | (() => string)> = {} | ||
export function registerAssets (assets: Record<string, string | (() => string)>): void { | ||
assetUrls = { | ||
...assetUrls, | ||
...assets | ||
} | ||
} | ||
import { FileAccess } from 'vs/base/common/network' | ||
|
||
function toUrl (name: string): string | undefined { | ||
let url = assetUrls[name] | ||
if (typeof url === 'function') { | ||
url = url() | ||
export function registerAssets (assets: Record<string, string | (() => string)>): void { | ||
for (const [moduleId, url] of Object.entries(assets)) { | ||
FileAccess.registerAppResourcePathUrl(moduleId, url) | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
return new URL(url ?? '', globalThis.location?.href ?? import.meta.url).toString() | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(globalThis as any).monacoRequire = { | ||
toUrl | ||
} |
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