Fix circular dep

This commit is contained in:
Pierre Jacquier
2025-02-12 15:34:38 -05:00
parent b6101ae154
commit 93c872a747
2 changed files with 23 additions and 20 deletions

View File

@ -1,5 +1,3 @@
import { VITE_KC_KCL_SAMPLES_REF } from 'env'
export const APP_NAME = 'Modeling App'
/** Search string in new project names to increment as an index */
export const INDEX_IDENTIFIER = '$n'
@ -107,7 +105,8 @@ export const MAKE_TOAST_MESSAGES = {
/** The URL for the KCL samples manifest files */
export const KCL_SAMPLES_MANIFEST_URLS = {
remote: `https://raw.githubusercontent.com/KittyCAD/kcl-samples/${VITE_KC_KCL_SAMPLES_REF}/manifest.json`,
// TODO: enable remote fetching again, maybe?
// remote: `https://raw.githubusercontent.com/KittyCAD/kcl-samples/${VITE_KC_KCL_SAMPLES_REF}/manifest.json`,
localFallback: '/kcl-samples-manifest-fallback.json',
} as const

View File

@ -10,23 +10,27 @@ export type KclSamplesManifestItem = {
}
export async function getKclSamplesManifest() {
let response = await fetch(KCL_SAMPLES_MANIFEST_URLS.remote)
if (!response.ok) {
console.warn(
'Failed to fetch latest remote KCL samples manifest, falling back to local:',
response.statusText
)
response = await fetch(
(isDesktop() ? '.' : '') + KCL_SAMPLES_MANIFEST_URLS.localFallback
)
if (!response.ok) {
console.error(
'Failed to fetch fallback KCL samples manifest:',
response.statusText
)
return []
}
}
// TODO: enable remote fetching again, maybe?
// let response = await fetch(KCL_SAMPLES_MANIFEST_URLS.remote)
// if (!response.ok) {
// console.warn(
// 'Failed to fetch latest remote KCL samples manifest, falling back to local:',
// response.statusText
// )
// response = await fetch(
// (isDesktop() ? '.' : '') + KCL_SAMPLES_MANIFEST_URLS.localFallback
// )
// if (!response.ok) {
// console.error(
// 'Failed to fetch fallback KCL samples manifest:',
// response.statusText
// )
// return []
// }
// }
const response = await fetch(
(isDesktop() ? '.' : '') + KCL_SAMPLES_MANIFEST_URLS.localFallback
)
return response.json().then((manifest) => {
return manifest as KclSamplesManifestItem[]
})