Skip to content

Commit 4415c70

Browse files
committed
docs: resource links config
1 parent 9f58e42 commit 4415c70

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,73 @@ const store = useStore(
132132
<Sandbox :store="store" />
133133
</template>
134134
```
135+
136+
<details>
137+
<summary>Configuration options for resource links. (replace CDN resources)</summary>
138+
139+
```ts
140+
export type ResourceLinkConfigs = {
141+
/** URL for ES Module Shims. */
142+
esModuleShims?: string
143+
/** Function that generates the Vue compiler URL based on the version. */
144+
vueCompilerUrl?: (version: string) => string
145+
/** Function that generates the TypeScript library URL based on the version. */
146+
typescriptLib?: (version: string) => string
147+
148+
/** [monaco] Function that generates a URL to fetch the latest version of a package. */
149+
pkgLatestVersionUrl?: (pkgName: string) => string
150+
/** [monaco] Function that generates a URL to browse a package directory. */
151+
pkgDirUrl?: (pkgName: string, pkgVersion: string, pkgPath: string) => string
152+
/** [monaco] Function that generates a URL to fetch the content of a file from a package. */
153+
pkgFileTextUrl?: (
154+
pkgName: string,
155+
pkgVersion: string | undefined,
156+
pkgPath: string,
157+
) => string
158+
}
159+
```
160+
161+
**unpkg**
162+
163+
```ts
164+
const store = useStore({
165+
resourceLinks: ref({
166+
esModuleShims:
167+
'https://unpkg.com/[email protected]/dist/es-module-shims.wasm.js',
168+
vueCompilerUrl: (version) =>
169+
`https://unpkg.com/@vue/compiler-sfc@${version}/dist/compiler-sfc.esm-browser.js`,
170+
typescriptLib: (version) =>
171+
`https://unpkg.com/typescript@${version}/lib/typescript.js`,
172+
pkgLatestVersionUrl: (pkgName) =>
173+
`https://unpkg.com/${pkgName}@latest/package.json`,
174+
pkgDirUrl: (pkgName, pkgVersion, pkgPath) =>
175+
`https://unpkg.com/${pkgName}@${pkgVersion}/${pkgPath}/?meta`,
176+
pkgFileTextUrl: (pkgName, pkgVersion, pkgPath) =>
177+
`https://unpkg.com/${pkgName}@${pkgVersion || 'latest'}/${pkgPath}`,
178+
}),
179+
})
180+
```
181+
182+
**npmmirror**
183+
184+
```ts
185+
const store = useStore({
186+
resourceLinks: ref({
187+
esModuleShims:
188+
'https://registry.npmmirror.com/es-module-shims/1.5.18/files/dist/es-module-shims.wasm.js',
189+
vueCompilerUrl: (version) =>
190+
`https://registry.npmmirror.com/@vue/compiler-sfc/${version}/files/dist/compiler-sfc.esm-browser.js`,
191+
typescriptLib: (version) =>
192+
`https://registry.npmmirror.com/typescript/${version}/files/lib/typescript.js`,
193+
194+
pkgLatestVersionUrl: (pkgName) =>
195+
`https://registry.npmmirror.com/${pkgName}/latest/files/package.json`,
196+
pkgDirUrl: (pkgName, pkgVersion, pkgPath) =>
197+
`https://registry.npmmirror.com/${pkgName}/${pkgVersion}/files/${pkgPath}/?meta`,
198+
pkgFileTextUrl: (pkgName, pkgVersion, pkgPath) =>
199+
`https://registry.npmmirror.com/${pkgName}/${pkgVersion || 'latest'}/files/${pkgPath}`,
200+
}),
201+
})
202+
```
203+
204+
</details>

0 commit comments

Comments
 (0)