@@ -170,6 +170,22 @@ class RemoteAuthoritiesImpl {
170
170
171
171
export const RemoteAuthorities = new RemoteAuthoritiesImpl ( ) ;
172
172
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
+
173
189
class FileAccessImpl {
174
190
175
191
private static readonly FALLBACK_AUTHORITY = 'vscode-app' ;
@@ -181,9 +197,9 @@ class FileAccessImpl {
181
197
* **Note:** use `dom.ts#asCSSUrl` whenever the URL is to be used in CSS context.
182
198
*/
183
199
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 ) ;
187
203
188
204
// Handle remote URIs via `RemoteAuthorities`
189
205
if ( uri . scheme === Schemas . vscodeRemote ) {
@@ -221,9 +237,9 @@ class FileAccessImpl {
221
237
* is responsible for loading.
222
238
*/
223
239
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 ) ;
227
243
228
244
// Only convert the URI if it is `vscode-file:` scheme
229
245
if ( uri . scheme === Schemas . vscodeFileResource ) {
@@ -241,12 +257,12 @@ class FileAccessImpl {
241
257
return uri ;
242
258
}
243
259
244
- private toUri ( uriOrModule : URI | string , moduleIdToUrl ?: { toUrl ( moduleId : string ) : string } ) : URI {
260
+ private toUri ( uriOrModule : URI | string ) : URI {
245
261
if ( URI . isUri ( uriOrModule ) ) {
246
262
return uriOrModule ;
247
263
}
248
264
249
- return URI . parse ( moduleIdToUrl ! . toUrl ( uriOrModule ) ) ;
265
+ return URI . parse ( require . toUrl ( uriOrModule ) ) ;
250
266
}
251
267
}
252
268
0 commit comments