@@ -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 ) ,
@@ -389,6 +392,8 @@ export function useStore(
389392 deserialize,
390393 getFiles,
391394 setFiles,
395+
396+ resourceLinks,
392397 } )
393398 return store
394399}
@@ -414,6 +419,20 @@ export interface SFCOptions {
414419 template ?: Partial < SFCTemplateCompileOptions >
415420}
416421
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+
417436export type StoreState = ToRefs < {
418437 files : Record < string , File >
419438 activeFilename : string
@@ -440,6 +459,9 @@ export type StoreState = ToRefs<{
440459 /** \{ dependencyName: version \} */
441460 dependencyVersion : Record < string , string >
442461 reloadLanguageTools ?: ( ( ) => void ) | undefined
462+
463+ /** Custom online resources */
464+ resourceLinks ?: ResourceLinkConfigs
443465} >
444466
445467export interface ReplStore extends UnwrapRef < StoreState > {
@@ -463,6 +485,8 @@ export interface ReplStore extends UnwrapRef<StoreState> {
463485 deserialize ( serializedState : string , checkBuiltinImportMap ?: boolean ) : void
464486 getFiles ( ) : Record < string , string >
465487 setFiles ( newFiles : Record < string , string > , mainFile ?: string ) : Promise < void >
488+ /** Custom online resources */
489+ resourceLinks ?: ResourceLinkConfigs
466490}
467491
468492export type Store = Pick <
@@ -487,6 +511,7 @@ export type Store = Pick<
487511 | 'renameFile'
488512 | 'getImportMap'
489513 | 'getTsConfig'
514+ | 'resourceLinks'
490515>
491516
492517export class File {
0 commit comments