@@ -170,6 +170,22 @@ class RemoteAuthoritiesImpl {
170170
171171export const RemoteAuthorities = new RemoteAuthoritiesImpl ( ) ;
172172
173+ /**
174+ * A string pointing to a path inside the app. It should not begin with ./ or ../
175+ */
176+ export type AppResourcePath = (
177+ `a${string } ` | `b${string } ` | `c${string } ` | `d${string } ` | `e${string } ` | `f${string } `
178+ | `g${string } ` | `h${string } ` | `i${string } ` | `j${string } ` | `k${string } ` | `l${string } `
179+ | `m${string } ` | `n${string } ` | `o${string } ` | `p${string } ` | `q${string } ` | `r${string } `
180+ | `s${string } ` | `t${string } ` | `u${string } ` | `v${string } ` | `w${string } ` | `x${string } `
181+ | `y${string } ` | `z${string } `
182+ ) ;
183+
184+ export const builtinExtensionsPath : AppResourcePath = 'vs/../../extensions' ;
185+ export const nodeModulesPath : AppResourcePath = 'vs/../../node_modules' ;
186+ export const nodeModulesAsarPath : AppResourcePath = 'vs/../../node_modules.asar' ;
187+ export const nodeModulesAsarUnpackedPath : AppResourcePath = 'vs/../../node_modules.asar.unpacked' ;
188+
173189class FileAccessImpl {
174190
175191 private static readonly FALLBACK_AUTHORITY = 'vscode-app' ;
@@ -181,9 +197,9 @@ class FileAccessImpl {
181197 * **Note:** use `dom.ts#asCSSUrl` whenever the URL is to be used in CSS context.
182198 */
183199 asBrowserUri ( uri : URI ) : URI ;
184- asBrowserUri ( moduleId : string , moduleIdToUrl : { toUrl ( moduleId : string ) : string } ) : URI ;
185- asBrowserUri ( uriOrModule : URI | string , moduleIdToUrl ?: { toUrl ( moduleId : string ) : string } ) : URI {
186- const uri = this . toUri ( uriOrModule , moduleIdToUrl ) ;
200+ asBrowserUri ( moduleId : AppResourcePath | '' ) : URI ;
201+ asBrowserUri ( uriOrModule : URI | AppResourcePath | '' ) : URI {
202+ const uri = this . toUri ( uriOrModule ) ;
187203
188204 // Handle remote URIs via `RemoteAuthorities`
189205 if ( uri . scheme === Schemas . vscodeRemote ) {
@@ -221,9 +237,9 @@ class FileAccessImpl {
221237 * is responsible for loading.
222238 */
223239 asFileUri ( uri : URI ) : URI ;
224- asFileUri ( moduleId : string , moduleIdToUrl : { toUrl ( moduleId : string ) : string } ) : URI ;
225- asFileUri ( uriOrModule : URI | string , moduleIdToUrl ?: { toUrl ( moduleId : string ) : string } ) : URI {
226- const uri = this . toUri ( uriOrModule , moduleIdToUrl ) ;
240+ asFileUri ( moduleId : AppResourcePath | '' ) : URI ;
241+ asFileUri ( uriOrModule : URI | AppResourcePath | '' ) : URI {
242+ const uri = this . toUri ( uriOrModule ) ;
227243
228244 // Only convert the URI if it is `vscode-file:` scheme
229245 if ( uri . scheme === Schemas . vscodeFileResource ) {
@@ -241,12 +257,12 @@ class FileAccessImpl {
241257 return uri ;
242258 }
243259
244- private toUri ( uriOrModule : URI | string , moduleIdToUrl ?: { toUrl ( moduleId : string ) : string } ) : URI {
260+ private toUri ( uriOrModule : URI | string ) : URI {
245261 if ( URI . isUri ( uriOrModule ) ) {
246262 return uriOrModule ;
247263 }
248264
249- return URI . parse ( moduleIdToUrl ! . toUrl ( uriOrModule ) ) ;
265+ return URI . parse ( require . toUrl ( uriOrModule ) ) ;
250266 }
251267}
252268
0 commit comments