Compare commits

..

No commits in common. "ade44717e4de4a41c9fcad4193e7aceb9916e6a7" and "77b5fe003ec271a9fa879be35a533fd9c9cfccd0" have entirely different histories.

2 changed files with 15 additions and 21 deletions

View file

@ -71,7 +71,6 @@ export const promisedRequest = async ({
url,
payload,
formData,
cache,
credentials,
headers = {},
}) => {
@ -88,10 +87,6 @@ export const promisedRequest = async ({
options.headers['Content-Type'] = 'application/json'
}
if (cache) {
options.cache = cache
}
if (formData || payload) {
options.body = formData || JSON.stringify(payload)
}

View file

@ -2,8 +2,6 @@ import sum from 'hash-sum'
import localforage from 'localforage'
import { chunk, throttle } from 'lodash'
import { promisedRequest } from 'src/api/helpers.js'
import { getCssRules } from '../theme_data/css_utils.js'
import { getEngineChecksum, init } from '../theme_data/theme_data_3.service.js'
@ -302,7 +300,7 @@ export const applyStyleConfig = (input) => {
adoptStyleSheets()
}
export const getResourcesIndex = async (url, parser = x => x) => {
export const getResourcesIndex = async (url, parser = JSON.parse) => {
const cache = 'no-store'
const customUrl = url.replace(/\.(\w+)$/, '.custom.$1')
let builtin
@ -316,15 +314,14 @@ export const getResourcesIndex = async (url, parser = x => x) => {
return [
k,
() =>
promisedRequest({
url: v,
cache,
})
.then(({ data: text }) => parser(text))
.catch((e) => {
console.error(e)
return null
}),
window
.fetch(v, { cache })
.then((data) => data.text())
.then((text) => parser(text))
.catch((e) => {
console.error(e)
return null
}),
]
} else {
console.error(`Unknown resource format - ${k} is a ${typeof v}`)
@ -334,16 +331,18 @@ export const getResourcesIndex = async (url, parser = x => x) => {
}
try {
const { data: builtinData } = await promisedRequest({ url, cache })
builtin = resourceTransform(builtinData)
const builtinData = await window.fetch(url, { cache })
const builtinResources = await builtinData.json()
builtin = resourceTransform(builtinResources)
} catch {
builtin = []
console.warn(`Builtin resources at ${url} unavailable`)
}
try {
const { data: customData } = await promisedRequest({ url: customUrl, cache })
custom = resourceTransform(customData)
const customData = await window.fetch(customUrl, { cache })
const customResources = await customData.json()
custom = resourceTransform(customResources)
} catch {
custom = []
console.warn(`Custom resources at ${customUrl} unavailable`)