Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
actions._setState({
compilationOutput: {
success: false,
loading: false,
compiledModules
}
})
throw "Compilation error(s)!"
}
const indexHtml = getFile(state, "/index.html")
if (!indexHtml) {
throw new Error("No index.html found in files")
}
logEvent(debug ? "debug" : "run", {
event_category: "project",
event_label: debug ? "DebugProject" : "RunProject"
})
const iframeSource = indexHtml.content
.replace(
``,
``
)
.replace(
``,
`<style>body { background-color: white; }</style>`
) //
actions._setState({
compilationOutput: {
saveProject: () => (state, actions): Promise => {
checkOpen(state)
if (state.status === "read-only") {
throw new Error(`Status should not be read-only.`)
}
if (state.status === "editing") {
let toSave = state.project
if (toSave.details !== state.original.details) {
logEvent("rename_project", {
event_category: "project",
event_label: "Rename"
})
const name = normalize(toSave.details.name)
toSave = {
details: {
...toSave.details,
name,
hidden: name === "",
searches: getSearches(name)
},
files: toSave.files
}
}
return actions._projects.save(toSave).then(project => {
// TODO recompute searches and stuff
.then(results => {
logEvent("search", {
event_category: "project",
event_label: "Search"
})
const hasNext = results.length > search.resultsPerPage
actions.update({ name, status: "success", results, hasNext })
return actions.getState()[name]
})
.catch(e => {
.then(() => {
logEvent("login", {
event_category: "users",
event_label: eventLabel
})
onUserChanged(auth.currentUser, null)
resolve()
})
.catch(e => {
openEmbedModal: () => {
logEvent("screen_view", { screen_name: "Embed modal" })
return { embedModal: true }
},
closeEmbedModal: () => {
actions.users.getCurrentUser().then(user => {
const owner = getProjectOwner(user)
const newProject = copyProject(project, owner)
actions.editor.open(newProject)
replace("/projects/" + newProject.details.id)
logEvent("fork_project", {
event_category: "project",
event_label: "Fork"
})
})
)
.then(() => {
actions.hideSignUpModal()
logEvent("signup", {
event_category: "users",
event_label: "SignupEmail"
})
onUserChanged(auth.currentUser, null)
resolve()
})
.catch(e => {
.then(project => {
actions.editor.open(project)
replace("/projects/" + project.details.id)
logEvent("create_project", {
event_category: "project",
event_label: "Create" + template + "ProjectFromIndex"
})
})
)
.then(project => {
actions._setState({
project,
original: project,
status: "editing"
})
replace(`/projects/${project.details.id}`)
logEvent("fork_project", {
event_category: "project",
event_label: "Fork"
})
})
},
showPane: (paneShown: boolean) => {
if (paneShown == true) {
logEvent("debug", {
event_category: "project",
event_label: "ToggleDebug"
})
}
return { paneShown }
},
setValueDisplay: (valueDisplay: api.ValueDisplay) => {