@@ -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,20 @@ 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
+ pkgName : string ,
431
+ pkgVersion : string | undefined ,
432
+ pkgPath : string ,
433
+ ) => string
434
+ }
435
+
417
436
export type StoreState = ToRefs < {
418
437
files : Record < string , File >
419
438
activeFilename : string
@@ -440,6 +459,9 @@ export type StoreState = ToRefs<{
440
459
/** \{ dependencyName: version \} */
441
460
dependencyVersion : Record < string , string >
442
461
reloadLanguageTools ?: ( ( ) => void ) | undefined
462
+
463
+ /** Custom online resources */
464
+ resourceLinks ?: ResourceLinkConfigs
443
465
} >
444
466
445
467
export interface ReplStore extends UnwrapRef < StoreState > {
@@ -463,6 +485,8 @@ export interface ReplStore extends UnwrapRef<StoreState> {
463
485
deserialize ( serializedState : string , checkBuiltinImportMap ?: boolean ) : void
464
486
getFiles ( ) : Record < string , string >
465
487
setFiles ( newFiles : Record < string , string > , mainFile ?: string ) : Promise < void >
488
+ /** Custom online resources */
489
+ resourceLinks ?: ResourceLinkConfigs
466
490
}
467
491
468
492
export type Store = Pick <
@@ -487,6 +511,7 @@ export type Store = Pick<
487
511
| 'renameFile'
488
512
| 'getImportMap'
489
513
| 'getTsConfig'
514
+ | 'resourceLinks'
490
515
>
491
516
492
517
export class File {
0 commit comments