2021-10-15 05:39:56 -04:00
|
|
|
import {
|
|
|
|
createContext,
|
|
|
|
useCallback,
|
|
|
|
useContext,
|
|
|
|
useEffect,
|
|
|
|
useMemo,
|
|
|
|
useState,
|
|
|
|
} from 'react'
|
2021-04-19 08:38:03 -04:00
|
|
|
import PropTypes from 'prop-types'
|
2021-10-08 06:09:41 -04:00
|
|
|
import useScopeValue from '../hooks/use-scope-value'
|
2021-11-03 10:30:41 -04:00
|
|
|
import useScopeValueSetterOnly from '../hooks/use-scope-value-setter-only'
|
2021-10-15 05:39:56 -04:00
|
|
|
import usePersistedState from '../hooks/use-persisted-state'
|
|
|
|
import useAbortController from '../hooks/use-abort-controller'
|
|
|
|
import DocumentCompiler from '../../features/pdf-preview/util/compiler'
|
2022-01-10 08:59:22 -05:00
|
|
|
import { send, sendMBSampled } from '../../infrastructure/event-tracking'
|
2021-10-15 05:39:56 -04:00
|
|
|
import {
|
|
|
|
buildLogEntryAnnotations,
|
|
|
|
handleOutputFiles,
|
|
|
|
} from '../../features/pdf-preview/util/output-files'
|
|
|
|
import { useIdeContext } from './ide-context'
|
|
|
|
import { useProjectContext } from './project-context'
|
|
|
|
import { useEditorContext } from './editor-context'
|
2021-04-19 08:38:03 -04:00
|
|
|
|
|
|
|
export const CompileContext = createContext()
|
|
|
|
|
|
|
|
CompileContext.Provider.propTypes = {
|
|
|
|
value: PropTypes.shape({
|
2021-10-15 05:39:56 -04:00
|
|
|
autoCompile: PropTypes.bool.isRequired,
|
|
|
|
clearingCache: PropTypes.bool.isRequired,
|
2021-10-08 05:51:04 -04:00
|
|
|
clsiServerId: PropTypes.string,
|
2021-10-15 05:39:56 -04:00
|
|
|
codeCheckFailed: PropTypes.bool.isRequired,
|
|
|
|
compiling: PropTypes.bool.isRequired,
|
|
|
|
draft: PropTypes.bool.isRequired,
|
|
|
|
error: PropTypes.string,
|
|
|
|
fileList: PropTypes.object,
|
|
|
|
hasChanges: PropTypes.bool.isRequired,
|
2021-10-21 06:31:51 -04:00
|
|
|
highlights: PropTypes.arrayOf(PropTypes.object),
|
2021-04-19 08:38:03 -04:00
|
|
|
logEntries: PropTypes.object,
|
2021-11-15 07:50:42 -05:00
|
|
|
logEntryAnnotations: PropTypes.object,
|
2021-10-08 05:51:04 -04:00
|
|
|
pdfDownloadUrl: PropTypes.string,
|
|
|
|
pdfUrl: PropTypes.string,
|
2021-10-21 06:31:51 -04:00
|
|
|
pdfViewer: PropTypes.string,
|
|
|
|
position: PropTypes.object,
|
2021-10-15 05:39:56 -04:00
|
|
|
rawLog: PropTypes.string,
|
|
|
|
setAutoCompile: PropTypes.func.isRequired,
|
|
|
|
setDraft: PropTypes.func.isRequired,
|
2021-10-15 05:52:07 -04:00
|
|
|
setError: PropTypes.func.isRequired,
|
2021-10-15 05:39:56 -04:00
|
|
|
setHasLintingError: PropTypes.func.isRequired, // only for storybook
|
2021-10-21 06:31:51 -04:00
|
|
|
setHighlights: PropTypes.func.isRequired,
|
|
|
|
setPosition: PropTypes.func.isRequired,
|
2021-10-15 05:39:56 -04:00
|
|
|
setShowLogs: PropTypes.func.isRequired,
|
|
|
|
setStopOnValidationError: PropTypes.func.isRequired,
|
|
|
|
showLogs: PropTypes.bool.isRequired,
|
|
|
|
stopOnValidationError: PropTypes.bool.isRequired,
|
2021-04-27 03:52:58 -04:00
|
|
|
uncompiled: PropTypes.bool,
|
2021-10-15 05:39:56 -04:00
|
|
|
validationIssues: PropTypes.object,
|
2021-10-20 04:45:10 -04:00
|
|
|
firstRenderDone: PropTypes.func,
|
2021-11-30 09:54:14 -05:00
|
|
|
cleanupCompileResult: PropTypes.func,
|
2021-04-27 03:52:58 -04:00
|
|
|
}),
|
2021-04-19 08:38:03 -04:00
|
|
|
}
|
|
|
|
|
2021-06-16 05:32:38 -04:00
|
|
|
export function CompileProvider({ children }) {
|
2021-10-15 05:39:56 -04:00
|
|
|
const ide = useIdeContext()
|
|
|
|
|
|
|
|
const { hasPremiumCompile, isProjectOwner } = useEditorContext()
|
|
|
|
|
2022-01-10 10:47:10 -05:00
|
|
|
const { _id: projectId, rootDocId } = useProjectContext()
|
2021-10-15 05:39:56 -04:00
|
|
|
|
|
|
|
// whether a compile is in progress
|
|
|
|
const [compiling, setCompiling] = useState(false)
|
|
|
|
|
2021-10-08 05:51:04 -04:00
|
|
|
// the log entries parsed from the compile output log
|
2021-11-03 10:30:41 -04:00
|
|
|
const [logEntries, setLogEntries] = useScopeValueSetterOnly('pdf.logEntries')
|
2021-10-08 05:51:04 -04:00
|
|
|
|
|
|
|
// annotations for display in the editor, built from the log entries
|
2021-11-15 07:50:42 -05:00
|
|
|
const [logEntryAnnotations, setLogEntryAnnotations] = useScopeValue(
|
|
|
|
'pdf.logEntryAnnotations'
|
|
|
|
)
|
2021-10-08 05:51:04 -04:00
|
|
|
|
2021-10-21 06:31:51 -04:00
|
|
|
// the PDF viewer
|
|
|
|
const [pdfViewer] = useScopeValue('settings.pdfViewer')
|
|
|
|
|
2021-10-08 05:51:04 -04:00
|
|
|
// the URL for downloading the PDF
|
2022-01-10 05:23:05 -05:00
|
|
|
const [pdfDownloadUrl, setPdfDownloadUrl] =
|
|
|
|
useScopeValueSetterOnly('pdf.downloadUrl')
|
2021-10-08 05:51:04 -04:00
|
|
|
|
|
|
|
// the URL for loading the PDF in the preview pane
|
2021-11-03 10:30:41 -04:00
|
|
|
const [pdfUrl, setPdfUrl] = useScopeValueSetterOnly('pdf.url')
|
2021-10-08 05:51:04 -04:00
|
|
|
|
|
|
|
// the project is considered to be "uncompiled" if a doc has changed since the last compile started
|
2021-10-21 11:29:27 -04:00
|
|
|
const [uncompiled, setUncompiled] = useScopeValue('pdf.uncompiled')
|
2021-10-08 05:51:04 -04:00
|
|
|
|
|
|
|
// the id of the CLSI server which ran the compile
|
2021-10-21 06:31:51 -04:00
|
|
|
const [clsiServerId, setClsiServerId] = useState()
|
2021-10-08 05:51:04 -04:00
|
|
|
|
2021-10-15 05:39:56 -04:00
|
|
|
// data received in response to a compile request
|
|
|
|
const [data, setData] = useState()
|
|
|
|
|
2021-10-20 04:45:10 -04:00
|
|
|
// callback to be invoked for PdfJsMetrics
|
|
|
|
const [firstRenderDone, setFirstRenderDone] = useState()
|
|
|
|
|
2021-10-15 05:39:56 -04:00
|
|
|
// whether the project has been compiled yet
|
|
|
|
const [compiledOnce, setCompiledOnce] = useState(false)
|
|
|
|
|
|
|
|
// whether the cache is being cleared
|
|
|
|
const [clearingCache, setClearingCache] = useState(false)
|
|
|
|
|
|
|
|
// whether the logs should be visible
|
|
|
|
const [showLogs, setShowLogs] = useState(false)
|
|
|
|
|
|
|
|
// an error that occurred
|
|
|
|
const [error, setError] = useState()
|
|
|
|
|
|
|
|
// the list of files that can be downloaded
|
|
|
|
const [fileList, setFileList] = useState()
|
|
|
|
|
|
|
|
// the raw contents of the log file
|
|
|
|
const [rawLog, setRawLog] = useState()
|
|
|
|
|
|
|
|
// validation issues from CLSI
|
|
|
|
const [validationIssues, setValidationIssues] = useState()
|
|
|
|
|
2021-10-21 06:31:51 -04:00
|
|
|
// areas to highlight on the PDF, from synctex
|
|
|
|
const [highlights, setHighlights] = useState()
|
|
|
|
|
|
|
|
// scroll position of the PDF
|
|
|
|
const [position, setPosition] = usePersistedState(`pdf.position.${projectId}`)
|
|
|
|
|
2021-10-15 05:39:56 -04:00
|
|
|
// whether autocompile is switched on
|
2021-12-21 08:45:38 -05:00
|
|
|
const [autoCompile, setAutoCompile] = usePersistedState(
|
2021-10-15 05:39:56 -04:00
|
|
|
`autocompile_enabled:${projectId}`,
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
)
|
|
|
|
|
|
|
|
// whether the compile should run in draft mode
|
|
|
|
const [draft, setDraft] = usePersistedState(`draft:${projectId}`, false, true)
|
|
|
|
|
|
|
|
// whether compiling should be prevented if there are linting errors
|
|
|
|
const [stopOnValidationError, setStopOnValidationError] = usePersistedState(
|
|
|
|
`stop_on_validation_error:${projectId}`,
|
|
|
|
true,
|
|
|
|
true
|
|
|
|
)
|
|
|
|
|
|
|
|
// the Document currently open in the editor
|
|
|
|
const [currentDoc] = useScopeValue('editor.sharejs_doc')
|
|
|
|
|
|
|
|
// whether the editor linter found errors
|
|
|
|
const [hasLintingError, setHasLintingError] = useScopeValue('hasLintingError')
|
|
|
|
|
|
|
|
// whether syntax validation is enabled globally
|
|
|
|
const [syntaxValidation] = useScopeValue('settings.syntaxValidation')
|
|
|
|
|
|
|
|
// the timestamp that a doc was last changed or saved
|
|
|
|
const [changedAt, setChangedAt] = useState(0)
|
|
|
|
|
|
|
|
const { signal } = useAbortController()
|
|
|
|
|
2021-11-03 10:30:41 -04:00
|
|
|
const cleanupCompileResult = useCallback(() => {
|
|
|
|
setPdfUrl(null)
|
|
|
|
setPdfDownloadUrl(null)
|
|
|
|
setLogEntries(null)
|
|
|
|
setLogEntryAnnotations({})
|
|
|
|
}, [setPdfUrl, setPdfDownloadUrl, setLogEntries, setLogEntryAnnotations])
|
|
|
|
|
2021-10-15 05:39:56 -04:00
|
|
|
// the document compiler
|
|
|
|
const [compiler] = useState(() => {
|
|
|
|
return new DocumentCompiler({
|
2022-01-10 10:47:10 -05:00
|
|
|
projectId,
|
|
|
|
rootDocId,
|
2021-10-15 05:39:56 -04:00
|
|
|
setChangedAt,
|
|
|
|
setCompiling,
|
|
|
|
setData,
|
2021-10-20 04:45:10 -04:00
|
|
|
setFirstRenderDone,
|
2021-10-15 05:39:56 -04:00
|
|
|
setError,
|
2021-11-03 10:30:41 -04:00
|
|
|
cleanupCompileResult,
|
2021-10-15 05:39:56 -04:00
|
|
|
signal,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
// keep currentDoc in sync with the compiler
|
|
|
|
useEffect(() => {
|
|
|
|
compiler.currentDoc = currentDoc
|
|
|
|
}, [compiler, currentDoc])
|
|
|
|
|
|
|
|
// keep draft setting in sync with the compiler
|
|
|
|
useEffect(() => {
|
|
|
|
compiler.draft = draft
|
|
|
|
}, [compiler, draft])
|
|
|
|
|
|
|
|
// pass the "uncompiled" value up into the scope for use outside this context provider
|
|
|
|
useEffect(() => {
|
2021-10-21 04:10:25 -04:00
|
|
|
if (window.showNewPdfPreview) {
|
|
|
|
setUncompiled(changedAt > 0)
|
|
|
|
}
|
2021-10-15 05:39:56 -04:00
|
|
|
}, [setUncompiled, changedAt])
|
|
|
|
|
|
|
|
// always compile the PDF once after opening the project, after the doc has loaded
|
|
|
|
useEffect(() => {
|
|
|
|
if (!compiledOnce && currentDoc) {
|
|
|
|
setCompiledOnce(true)
|
|
|
|
compiler.compile({ isAutoCompileOnLoad: true })
|
|
|
|
}
|
|
|
|
}, [compiledOnce, currentDoc, compiler])
|
|
|
|
|
|
|
|
// handle the data returned from a compile request
|
|
|
|
// note: this should _only_ run when `data` changes,
|
|
|
|
// the other dependencies must all be static
|
|
|
|
useEffect(() => {
|
|
|
|
if (data) {
|
|
|
|
if (data.clsiServerId) {
|
|
|
|
setClsiServerId(data.clsiServerId) // set in scope, for PdfSynctexController
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.outputFiles) {
|
|
|
|
handleOutputFiles(projectId, data).then(result => {
|
|
|
|
setLogEntryAnnotations(
|
|
|
|
buildLogEntryAnnotations(result.logEntries.all, ide.fileTreeManager)
|
|
|
|
)
|
2021-11-08 06:15:24 -05:00
|
|
|
if (data.status === 'success') {
|
|
|
|
setPdfDownloadUrl(result.pdfDownloadUrl)
|
|
|
|
setPdfUrl(result.pdfUrl)
|
|
|
|
}
|
2021-10-15 05:39:56 -04:00
|
|
|
setLogEntries(result.logEntries)
|
|
|
|
setFileList(result.fileList)
|
|
|
|
setRawLog(result.log)
|
|
|
|
|
|
|
|
// sample compile stats for real users
|
|
|
|
if (!window.user.alphaProgram && data.status === 'success') {
|
|
|
|
sendMBSampled(
|
|
|
|
'compile-result',
|
|
|
|
{
|
|
|
|
errors: result.logEntries.errors.length,
|
|
|
|
warnings: result.logEntries.warnings.length,
|
|
|
|
typesetting: result.logEntries.typesetting.length,
|
|
|
|
newPdfPreview: true, // TODO: is this useful?
|
|
|
|
},
|
|
|
|
0.01
|
|
|
|
)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (data.status) {
|
|
|
|
case 'success':
|
|
|
|
setError(undefined)
|
|
|
|
setShowLogs(false)
|
|
|
|
break
|
|
|
|
|
|
|
|
case 'clsi-maintenance':
|
|
|
|
case 'compile-in-progress':
|
|
|
|
case 'exited':
|
|
|
|
case 'failure':
|
|
|
|
case 'project-too-large':
|
|
|
|
case 'rate-limited':
|
|
|
|
case 'terminated':
|
|
|
|
case 'too-recently-compiled':
|
|
|
|
setError(data.status)
|
|
|
|
break
|
|
|
|
|
|
|
|
case 'timedout':
|
|
|
|
setError('timedout')
|
|
|
|
|
|
|
|
if (!hasPremiumCompile && isProjectOwner) {
|
|
|
|
send(
|
|
|
|
'subscription-funnel',
|
|
|
|
'editor-click-feature',
|
|
|
|
'compile-timeout'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
break
|
|
|
|
|
|
|
|
case 'autocompile-backoff':
|
|
|
|
if (!data.options.isAutoCompileOnLoad) {
|
|
|
|
setError('autocompile-disabled')
|
|
|
|
setAutoCompile(false)
|
|
|
|
}
|
|
|
|
break
|
|
|
|
|
|
|
|
case 'unavailable':
|
|
|
|
setError('clsi-unavailable')
|
|
|
|
break
|
|
|
|
|
|
|
|
case 'validation-problems':
|
|
|
|
setError('validation-problems')
|
|
|
|
setValidationIssues(data.validationProblems)
|
|
|
|
break
|
|
|
|
|
|
|
|
default:
|
|
|
|
setError('error')
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [
|
|
|
|
data,
|
|
|
|
ide,
|
|
|
|
hasPremiumCompile,
|
|
|
|
isProjectOwner,
|
|
|
|
projectId,
|
|
|
|
setAutoCompile,
|
|
|
|
setClsiServerId,
|
|
|
|
setLogEntries,
|
|
|
|
setLogEntryAnnotations,
|
|
|
|
setPdfDownloadUrl,
|
|
|
|
setPdfUrl,
|
|
|
|
])
|
|
|
|
|
|
|
|
// switch to logs if there's an error
|
|
|
|
useEffect(() => {
|
|
|
|
if (error) {
|
|
|
|
setShowLogs(true)
|
|
|
|
}
|
|
|
|
}, [error])
|
|
|
|
|
|
|
|
// whether there has been an autocompile linting error, if syntax validation is switched on
|
|
|
|
const autoCompileLintingError = Boolean(
|
|
|
|
autoCompile && syntaxValidation && hasLintingError
|
|
|
|
)
|
|
|
|
|
|
|
|
const codeCheckFailed = stopOnValidationError && autoCompileLintingError
|
|
|
|
|
|
|
|
// the project is available for auto-compiling
|
2021-10-21 06:31:51 -04:00
|
|
|
const canAutoCompile = Boolean(autoCompile && !codeCheckFailed)
|
|
|
|
|
|
|
|
// show that the project has pending changes
|
|
|
|
const hasChanges = Boolean(canAutoCompile && uncompiled && compiledOnce)
|
2021-10-15 05:39:56 -04:00
|
|
|
|
|
|
|
// call the debounced autocompile function if the project is available for auto-compiling and it has changed
|
|
|
|
useEffect(() => {
|
2021-10-21 06:31:51 -04:00
|
|
|
if (canAutoCompile) {
|
|
|
|
if (changedAt > 0) {
|
|
|
|
compiler.debouncedAutoCompile()
|
|
|
|
}
|
2021-10-15 05:39:56 -04:00
|
|
|
} else {
|
|
|
|
compiler.debouncedAutoCompile.cancel()
|
|
|
|
}
|
|
|
|
}, [compiler, canAutoCompile, changedAt])
|
|
|
|
|
|
|
|
// cancel debounced recompile on unmount
|
|
|
|
useEffect(() => {
|
|
|
|
return () => {
|
|
|
|
compiler.debouncedAutoCompile.cancel()
|
|
|
|
}
|
|
|
|
}, [compiler])
|
|
|
|
|
|
|
|
// start a compile manually
|
2021-11-30 09:54:14 -05:00
|
|
|
const startCompile = useCallback(
|
|
|
|
options => {
|
|
|
|
compiler.compile(options)
|
|
|
|
},
|
|
|
|
[compiler]
|
|
|
|
)
|
2021-10-15 05:39:56 -04:00
|
|
|
|
|
|
|
// stop a compile manually
|
|
|
|
const stopCompile = useCallback(() => {
|
|
|
|
compiler.stopCompile()
|
|
|
|
}, [compiler])
|
|
|
|
|
|
|
|
// clear the compile cache
|
|
|
|
const clearCache = useCallback(() => {
|
|
|
|
setClearingCache(true)
|
|
|
|
|
2021-12-07 04:49:18 -05:00
|
|
|
return compiler
|
|
|
|
.clearCache()
|
|
|
|
.then(() => {
|
|
|
|
setFileList(undefined)
|
|
|
|
setPdfDownloadUrl(undefined)
|
|
|
|
setPdfUrl(undefined)
|
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
setClearingCache(false)
|
|
|
|
})
|
|
|
|
}, [compiler, setPdfDownloadUrl, setPdfUrl])
|
2021-10-15 05:39:56 -04:00
|
|
|
|
|
|
|
// clear the cache then run a compile, triggered by a menu item
|
|
|
|
const recompileFromScratch = useCallback(() => {
|
|
|
|
clearCache().then(() => {
|
|
|
|
compiler.compile()
|
|
|
|
})
|
|
|
|
}, [clearCache, compiler])
|
|
|
|
|
2021-10-08 05:51:04 -04:00
|
|
|
const value = useMemo(
|
|
|
|
() => ({
|
2021-10-15 05:39:56 -04:00
|
|
|
autoCompile,
|
|
|
|
clearCache,
|
|
|
|
clearingCache,
|
2021-10-08 05:51:04 -04:00
|
|
|
clsiServerId,
|
2021-10-15 05:39:56 -04:00
|
|
|
codeCheckFailed,
|
|
|
|
compiling,
|
|
|
|
draft,
|
|
|
|
error,
|
|
|
|
fileList,
|
|
|
|
hasChanges,
|
2021-10-21 06:31:51 -04:00
|
|
|
highlights,
|
2021-11-15 07:50:42 -05:00
|
|
|
logEntryAnnotations,
|
2021-10-08 05:51:04 -04:00
|
|
|
logEntries,
|
|
|
|
pdfDownloadUrl,
|
|
|
|
pdfUrl,
|
2021-10-21 06:31:51 -04:00
|
|
|
pdfViewer,
|
|
|
|
position,
|
2021-10-15 05:39:56 -04:00
|
|
|
rawLog,
|
|
|
|
recompileFromScratch,
|
|
|
|
setAutoCompile,
|
|
|
|
setCompiling,
|
|
|
|
setDraft,
|
2021-10-15 05:52:07 -04:00
|
|
|
setError,
|
2021-10-15 05:39:56 -04:00
|
|
|
setHasLintingError, // only for stories
|
2021-10-21 06:31:51 -04:00
|
|
|
setHighlights,
|
|
|
|
setPosition,
|
2021-10-15 05:39:56 -04:00
|
|
|
setShowLogs,
|
|
|
|
setStopOnValidationError,
|
|
|
|
showLogs,
|
|
|
|
startCompile,
|
|
|
|
stopCompile,
|
|
|
|
stopOnValidationError,
|
2021-10-08 05:51:04 -04:00
|
|
|
uncompiled,
|
2021-10-15 05:39:56 -04:00
|
|
|
validationIssues,
|
2021-10-20 04:45:10 -04:00
|
|
|
firstRenderDone,
|
2021-11-30 09:54:14 -05:00
|
|
|
setChangedAt,
|
|
|
|
cleanupCompileResult,
|
2021-10-08 05:51:04 -04:00
|
|
|
}),
|
|
|
|
[
|
2021-10-15 05:39:56 -04:00
|
|
|
autoCompile,
|
|
|
|
clearCache,
|
|
|
|
clearingCache,
|
2021-10-08 05:51:04 -04:00
|
|
|
clsiServerId,
|
2021-10-15 05:39:56 -04:00
|
|
|
codeCheckFailed,
|
|
|
|
compiling,
|
|
|
|
draft,
|
|
|
|
error,
|
|
|
|
fileList,
|
|
|
|
hasChanges,
|
2021-10-21 06:31:51 -04:00
|
|
|
highlights,
|
2021-10-08 05:51:04 -04:00
|
|
|
logEntries,
|
2021-11-15 07:50:42 -05:00
|
|
|
logEntryAnnotations,
|
2021-10-21 06:31:51 -04:00
|
|
|
position,
|
2021-10-08 05:51:04 -04:00
|
|
|
pdfDownloadUrl,
|
|
|
|
pdfUrl,
|
2021-10-21 06:31:51 -04:00
|
|
|
pdfViewer,
|
2021-10-15 05:39:56 -04:00
|
|
|
rawLog,
|
|
|
|
recompileFromScratch,
|
|
|
|
setAutoCompile,
|
|
|
|
setDraft,
|
2021-10-15 05:52:07 -04:00
|
|
|
setError,
|
2021-11-03 10:30:41 -04:00
|
|
|
setHasLintingError, // only for stories
|
2021-10-21 06:31:51 -04:00
|
|
|
setHighlights,
|
|
|
|
setPosition,
|
2021-10-15 05:39:56 -04:00
|
|
|
setStopOnValidationError,
|
|
|
|
showLogs,
|
|
|
|
startCompile,
|
|
|
|
stopCompile,
|
|
|
|
stopOnValidationError,
|
2021-10-08 05:51:04 -04:00
|
|
|
uncompiled,
|
2021-10-15 05:39:56 -04:00
|
|
|
validationIssues,
|
2021-10-20 04:45:10 -04:00
|
|
|
firstRenderDone,
|
2021-11-30 09:54:14 -05:00
|
|
|
setChangedAt,
|
|
|
|
cleanupCompileResult,
|
2021-10-08 05:51:04 -04:00
|
|
|
]
|
|
|
|
)
|
2021-04-19 08:38:03 -04:00
|
|
|
|
|
|
|
return (
|
2021-06-16 05:32:38 -04:00
|
|
|
<CompileContext.Provider value={value}>{children}</CompileContext.Provider>
|
2021-04-19 08:38:03 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
CompileProvider.propTypes = {
|
|
|
|
children: PropTypes.any,
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useCompileContext(propTypes) {
|
|
|
|
const data = useContext(CompileContext)
|
|
|
|
PropTypes.checkPropTypes(propTypes, data, 'data', 'CompileContext.Provider')
|
|
|
|
return data
|
|
|
|
}
|