@@ -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,21 @@ 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+ path : string ,
431+ pkgName : string ,
432+ pkgVersion : string | undefined ,
433+ pkgPath : string ,
434+ ) => string
435+ }
436+
417437export type StoreState = ToRefs < {
418438 files : Record < string , File >
419439 activeFilename : string
@@ -440,6 +460,9 @@ export type StoreState = ToRefs<{
440460 /** \{ dependencyName: version \} */
441461 dependencyVersion : Record < string , string >
442462 reloadLanguageTools ?: ( ( ) => void ) | undefined
463+
464+ /** Custom online resources */
465+ resourceLinks ?: ResourceLinkConfigs
443466} >
444467
445468export interface ReplStore extends UnwrapRef < StoreState > {
@@ -463,6 +486,8 @@ export interface ReplStore extends UnwrapRef<StoreState> {
463486 deserialize ( serializedState : string , checkBuiltinImportMap ?: boolean ) : void
464487 getFiles ( ) : Record < string , string >
465488 setFiles ( newFiles : Record < string , string > , mainFile ?: string ) : Promise < void >
489+ /** Custom online resources */
490+ resourceLinks ?: ResourceLinkConfigs
466491}
467492
468493export type Store = Pick <
@@ -487,6 +512,7 @@ export type Store = Pick<
487512 | 'renameFile'
488513 | 'getImportMap'
489514 | 'getTsConfig'
515+ | 'resourceLinks'
490516>
491517
492518export class File {
0 commit comments