@@ -48,6 +48,7 @@ export function useStore(
48
48
typescriptVersion = ref ( 'latest' ) ,
49
49
dependencyVersion = ref ( Object . create ( null ) ) ,
50
50
reloadLanguageTools = ref ( ) ,
51
+ resourceLinks = undefined ,
51
52
} : Partial < StoreState > = { } ,
52
53
serializedState ?: string ,
53
54
) : ReplStore {
@@ -92,7 +93,9 @@ export function useStore(
92
93
vueVersion ,
93
94
async ( version ) => {
94
95
if ( version ) {
95
- const compilerUrl = `https://cdn.jsdelivr.net/npm/@vue/compiler-sfc@${ version } /dist/compiler-sfc.esm-browser.js`
96
+ const compilerUrl =
97
+ resourceLinks ?. value ?. vueCompilerUrl ?.( version ) ||
98
+ `https://cdn.jsdelivr.net/npm/@vue/compiler-sfc@${ version } /dist/compiler-sfc.esm-browser.js`
96
99
loading . value = true
97
100
compiler . value = await import ( /* @vite -ignore */ compilerUrl ) . finally (
98
101
( ) => ( loading . value = false ) ,
@@ -389,6 +392,8 @@ export function useStore(
389
392
deserialize,
390
393
getFiles,
391
394
setFiles,
395
+
396
+ resourceLinks,
392
397
} )
393
398
return store
394
399
}
@@ -414,6 +419,21 @@ export interface SFCOptions {
414
419
template ?: Partial < SFCTemplateCompileOptions >
415
420
}
416
421
422
+ export type ResourceLinkConfigs = {
423
+ esModuleShims ?: string
424
+ vueCompilerUrl ?: ( version : string ) => string
425
+ typescriptLib ?: ( version : string ) => string
426
+ // for monaco
427
+ pkgLatestVersionUrl ?: ( pkgName : string ) => string
428
+ pkgDirUrl ?: ( pkgName : string , pkgVersion : string , pkgPath : string ) => string
429
+ pkgFileTextUrl ?: (
430
+ path : string ,
431
+ pkgName : string ,
432
+ pkgVersion : string | undefined ,
433
+ pkgPath : string ,
434
+ ) => string
435
+ }
436
+
417
437
export type StoreState = ToRefs < {
418
438
files : Record < string , File >
419
439
activeFilename : string
@@ -440,6 +460,9 @@ export type StoreState = ToRefs<{
440
460
/** \{ dependencyName: version \} */
441
461
dependencyVersion : Record < string , string >
442
462
reloadLanguageTools ?: ( ( ) => void ) | undefined
463
+
464
+ /** Custom online resources */
465
+ resourceLinks ?: ResourceLinkConfigs
443
466
} >
444
467
445
468
export interface ReplStore extends UnwrapRef < StoreState > {
@@ -463,6 +486,8 @@ export interface ReplStore extends UnwrapRef<StoreState> {
463
486
deserialize ( serializedState : string , checkBuiltinImportMap ?: boolean ) : void
464
487
getFiles ( ) : Record < string , string >
465
488
setFiles ( newFiles : Record < string , string > , mainFile ?: string ) : Promise < void >
489
+ /** Custom online resources */
490
+ resourceLinks ?: ResourceLinkConfigs
466
491
}
467
492
468
493
export type Store = Pick <
@@ -487,6 +512,7 @@ export type Store = Pick<
487
512
| 'renameFile'
488
513
| 'getImportMap'
489
514
| 'getTsConfig'
515
+ | 'resourceLinks'
490
516
>
491
517
492
518
export class File {
0 commit comments