@@ -48,6 +48,7 @@ export function useStore(
4848 typescriptVersion = ref ( 'latest' ) ,
4949 dependencyVersion = ref ( Object . create ( null ) ) ,
5050 reloadLanguageTools = ref ( ) ,
51+ resourceLinks = undefined ,
5152 } : Partial < StoreState > = { } ,
5253 serializedState ?: string ,
5354) : ReplStore {
@@ -92,7 +93,9 @@ export function useStore(
9293 vueVersion ,
9394 async ( version ) => {
9495 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`
9699 loading . value = true
97100 compiler . value = await import ( /* @vite -ignore */ compilerUrl ) . finally (
98101 ( ) => ( loading . value = false ) ,
@@ -390,6 +393,8 @@ export function useStore(
390393 deserialize,
391394 getFiles,
392395 setFiles,
396+
397+ resourceLinks,
393398 } )
394399 return store
395400}
@@ -415,6 +420,20 @@ export interface SFCOptions {
415420 template ?: Partial < SFCTemplateCompileOptions >
416421}
417422
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+
418437export type StoreState = ToRefs < {
419438 files : Record < string , File >
420439 activeFilename : string
@@ -445,6 +464,9 @@ export type StoreState = ToRefs<{
445464 /** \{ dependencyName: version \} */
446465 dependencyVersion : Record < string , string >
447466 reloadLanguageTools ?: ( ( ) => void ) | undefined
467+
468+ /** Custom online resources */
469+ resourceLinks ?: ResourceLinkConfigs
448470} >
449471
450472export interface ReplStore extends UnwrapRef < StoreState > {
@@ -468,6 +490,8 @@ export interface ReplStore extends UnwrapRef<StoreState> {
468490 deserialize ( serializedState : string , checkBuiltinImportMap ?: boolean ) : void
469491 getFiles ( ) : Record < string , string >
470492 setFiles ( newFiles : Record < string , string > , mainFile ?: string ) : Promise < void >
493+ /** Custom online resources */
494+ resourceLinks ?: ResourceLinkConfigs
471495}
472496
473497export type Store = Pick <
@@ -493,6 +517,7 @@ export type Store = Pick<
493517 | 'renameFile'
494518 | 'getImportMap'
495519 | 'getTsConfig'
520+ | 'resourceLinks'
496521>
497522
498523export class File {
0 commit comments