@@ -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 ) ,
@@ -390,6 +393,8 @@ export function useStore(
390
393
deserialize,
391
394
getFiles,
392
395
setFiles,
396
+
397
+ resourceLinks,
393
398
} )
394
399
return store
395
400
}
@@ -415,6 +420,20 @@ export interface SFCOptions {
415
420
template ?: Partial < SFCTemplateCompileOptions >
416
421
}
417
422
423
+ export type ResourceLinkConfigs = {
424
+ esModuleShims ?: string
425
+ vueCompilerUrl ?: ( version : string ) => string
426
+ typescriptLib ?: ( version : string ) => string
427
+ // for monaco
428
+ pkgLatestVersionUrl ?: ( pkgName : string ) => string
429
+ pkgDirUrl ?: ( pkgName : string , pkgVersion : string , pkgPath : string ) => string
430
+ pkgFileTextUrl ?: (
431
+ pkgName : string ,
432
+ pkgVersion : string | undefined ,
433
+ pkgPath : string ,
434
+ ) => string
435
+ }
436
+
418
437
export type StoreState = ToRefs < {
419
438
files : Record < string , File >
420
439
activeFilename : string
@@ -445,6 +464,9 @@ export type StoreState = ToRefs<{
445
464
/** \{ dependencyName: version \} */
446
465
dependencyVersion : Record < string , string >
447
466
reloadLanguageTools ?: ( ( ) => void ) | undefined
467
+
468
+ /** Custom online resources */
469
+ resourceLinks ?: ResourceLinkConfigs
448
470
} >
449
471
450
472
export interface ReplStore extends UnwrapRef < StoreState > {
@@ -468,6 +490,8 @@ export interface ReplStore extends UnwrapRef<StoreState> {
468
490
deserialize ( serializedState : string , checkBuiltinImportMap ?: boolean ) : void
469
491
getFiles ( ) : Record < string , string >
470
492
setFiles ( newFiles : Record < string , string > , mainFile ?: string ) : Promise < void >
493
+ /** Custom online resources */
494
+ resourceLinks ?: ResourceLinkConfigs
471
495
}
472
496
473
497
export type Store = Pick <
@@ -493,6 +517,7 @@ export type Store = Pick<
493
517
| 'renameFile'
494
518
| 'getImportMap'
495
519
| 'getTsConfig'
520
+ | 'resourceLinks'
496
521
>
497
522
498
523
export class File {
0 commit comments