local-compile-context.tsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. import {
  2. FC,
  3. createContext,
  4. useCallback,
  5. useContext,
  6. useEffect,
  7. useMemo,
  8. useRef,
  9. useState,
  10. } from 'react'
  11. import useScopeValue from '../hooks/use-scope-value'
  12. import useScopeValueSetterOnly from '../hooks/use-scope-value-setter-only'
  13. import usePersistedState from '../hooks/use-persisted-state'
  14. import useAbortController from '../hooks/use-abort-controller'
  15. import DocumentCompiler from '../../features/pdf-preview/util/compiler'
  16. import {
  17. send,
  18. sendMB,
  19. sendMBOnce,
  20. sendMBSampled,
  21. } from '../../infrastructure/event-tracking'
  22. import {
  23. buildLogEntryAnnotations,
  24. buildRuleCounts,
  25. handleLogFiles,
  26. handleOutputFiles,
  27. } from '../../features/pdf-preview/util/output-files'
  28. import { useIdeContext } from './ide-context'
  29. import { useProjectContext } from './project-context'
  30. import { useEditorContext } from './editor-context'
  31. import { buildFileList } from '../../features/pdf-preview/util/file-list'
  32. import { useLayoutContext } from './layout-context'
  33. import { useUserContext } from './user-context'
  34. import { useFileTreeData } from '@/shared/context/file-tree-data-context'
  35. import { useFileTreePathContext } from '@/features/file-tree/contexts/file-tree-path'
  36. import { useUserSettingsContext } from '@/shared/context/user-settings-context'
  37. import { useSplitTestContext } from '@/shared/context/split-test-context'
  38. type PdfFile = Record<string, any>
  39. export type CompileContext = {
  40. autoCompile: boolean
  41. clearingCache: boolean
  42. clsiServerId?: string
  43. codeCheckFailed: boolean
  44. compiling: boolean
  45. deliveryLatencies: Record<string, any>
  46. draft: boolean
  47. error?: string
  48. fileList?: Record<string, any>
  49. hasChanges: boolean
  50. highlights?: Record<string, any>[]
  51. isProjectOwner: boolean
  52. logEntries?: Record<string, any>
  53. logEntryAnnotations?: Record<string, any>
  54. pdfDownloadUrl?: string
  55. pdfFile?: PdfFile
  56. pdfUrl?: string
  57. pdfViewer?: string
  58. position?: Record<string, any>
  59. rawLog?: string
  60. setAutoCompile: (value: boolean) => void
  61. setDraft: (value: any) => void
  62. setError: (value: any) => void
  63. setHasLintingError: (value: any) => void // only for storybook
  64. setHighlights: (value: any) => void
  65. setPosition: (value: any) => void
  66. setShowCompileTimeWarning: (value: any) => void
  67. setShowLogs: (value: boolean) => void
  68. toggleLogs: () => void
  69. setStopOnFirstError: (value: boolean) => void
  70. setStopOnValidationError: (value: boolean) => void
  71. showCompileTimeWarning: boolean
  72. showLogs: boolean
  73. showNewCompileTimeoutUI?: string
  74. showFasterCompilesFeedbackUI: boolean
  75. stopOnFirstError: boolean
  76. stopOnValidationError: boolean
  77. stoppedOnFirstError: boolean
  78. uncompiled?: boolean
  79. validationIssues?: Record<string, any>
  80. firstRenderDone: () => void
  81. cleanupCompileResult?: () => void
  82. animateCompileDropdownArrow: boolean
  83. editedSinceCompileStarted: boolean
  84. lastCompileOptions: any
  85. setAnimateCompileDropdownArrow: (value: boolean) => void
  86. recompileFromScratch: () => void
  87. setCompiling: (value: boolean) => void
  88. startCompile: (options?: any) => void
  89. stopCompile: () => void
  90. setChangedAt: (value: any) => void
  91. clearCache: () => void
  92. syncToEntry: (value: any) => void
  93. }
  94. export const LocalCompileContext = createContext<CompileContext | undefined>(
  95. undefined
  96. )
  97. export const LocalCompileProvider: FC = ({ children }) => {
  98. const ide = useIdeContext()
  99. const { hasPremiumCompile, isProjectOwner } = useEditorContext()
  100. const {
  101. _id: projectId,
  102. rootDocId,
  103. showNewCompileTimeoutUI,
  104. } = useProjectContext()
  105. const { pdfPreviewOpen } = useLayoutContext()
  106. const { features } = useUserContext()
  107. const { fileTreeData } = useFileTreeData()
  108. const { findEntityByPath } = useFileTreePathContext()
  109. // whether a compile is in progress
  110. const [compiling, setCompiling] = useState(false)
  111. // whether to show the compile time warning
  112. const [showCompileTimeWarning, setShowCompileTimeWarning] = useState(false)
  113. // the log entries parsed from the compile output log
  114. const [logEntries, setLogEntries] = useScopeValueSetterOnly('pdf.logEntries')
  115. // annotations for display in the editor, built from the log entries
  116. const [logEntryAnnotations, setLogEntryAnnotations] = useScopeValue(
  117. 'pdf.logEntryAnnotations'
  118. )
  119. // the PDF viewer and whether syntax validation is enabled globally
  120. const { userSettings } = useUserSettingsContext()
  121. const { pdfViewer, syntaxValidation } = userSettings
  122. // the URL for downloading the PDF
  123. const [, setPdfDownloadUrl] =
  124. useScopeValueSetterOnly<string>('pdf.downloadUrl')
  125. // the URL for loading the PDF in the preview pane
  126. const [, setPdfUrl] = useScopeValueSetterOnly<string>('pdf.url')
  127. // low level details for metrics
  128. const [pdfFile, setPdfFile] = useState<PdfFile | undefined>()
  129. useEffect(() => {
  130. setPdfDownloadUrl(pdfFile?.pdfDownloadUrl)
  131. setPdfUrl(pdfFile?.pdfUrl)
  132. }, [pdfFile, setPdfDownloadUrl, setPdfUrl])
  133. // the project is considered to be "uncompiled" if a doc has changed, or finished saving, since the last compile started.
  134. const [uncompiled, setUncompiled] = useScopeValue('pdf.uncompiled')
  135. // whether a doc has been edited since the last compile started
  136. const [editedSinceCompileStarted, setEditedSinceCompileStarted] =
  137. useState(false)
  138. // the id of the CLSI server which ran the compile
  139. const [clsiServerId, setClsiServerId] = useState()
  140. // data received in response to a compile request
  141. const [data, setData] = useState<Record<string, any>>()
  142. // the rootDocId used in the most recent compile request, which may not be the
  143. // same as the project rootDocId. This is used to calculate correct paths when
  144. // parsing the compile logs
  145. const lastCompileRootDocId = data?.rootDocId
  146. // callback to be invoked for PdfJsMetrics
  147. const [firstRenderDone, setFirstRenderDone] = useState(() => () => {})
  148. // latencies of compile/pdf download/rendering
  149. const [deliveryLatencies, setDeliveryLatencies] = useState({})
  150. // whether the project has been compiled yet
  151. const [compiledOnce, setCompiledOnce] = useState(false)
  152. // whether the cache is being cleared
  153. const [clearingCache, setClearingCache] = useState(false)
  154. // whether the logs should be visible
  155. const [showLogs, setShowLogs] = useState(false)
  156. // whether the faster compiles feedback UI should be displayed
  157. const [showFasterCompilesFeedbackUI, setShowFasterCompilesFeedbackUI] =
  158. useState(false)
  159. // whether the compile dropdown arrow should be animated
  160. const [animateCompileDropdownArrow, setAnimateCompileDropdownArrow] =
  161. useState(false)
  162. const toggleLogs = useCallback(() => {
  163. setShowLogs(prev => {
  164. if (!prev) {
  165. sendMBOnce('ide-open-logs-once')
  166. }
  167. return !prev
  168. })
  169. }, [setShowLogs])
  170. // an error that occurred
  171. const [error, setError] = useState<string>()
  172. // the list of files that can be downloaded
  173. const [fileList, setFileList] = useState<Record<string, any[]>>()
  174. // the raw contents of the log file
  175. const [rawLog, setRawLog] = useState<string>()
  176. // validation issues from CLSI
  177. const [validationIssues, setValidationIssues] = useState()
  178. // areas to highlight on the PDF, from synctex
  179. const [highlights, setHighlights] = useState()
  180. // scroll position of the PDF
  181. const [position, setPosition] = usePersistedState(`pdf.position.${projectId}`)
  182. // whether autocompile is switched on
  183. const [autoCompile, setAutoCompile] = usePersistedState(
  184. `autocompile_enabled:${projectId}`,
  185. false,
  186. true
  187. )
  188. // whether the compile should run in draft mode
  189. const [draft, setDraft] = usePersistedState(`draft:${projectId}`, false, true)
  190. // whether compiling should stop on first error
  191. const [stopOnFirstError, setStopOnFirstError] = usePersistedState(
  192. `stop_on_first_error:${projectId}`,
  193. false,
  194. true
  195. )
  196. // whether the last compiles stopped on first error
  197. const [stoppedOnFirstError, setStoppedOnFirstError] = useState(false)
  198. // whether compiling should be prevented if there are linting errors
  199. const [stopOnValidationError, setStopOnValidationError] = usePersistedState(
  200. `stop_on_validation_error:${projectId}`,
  201. true,
  202. true
  203. )
  204. // the Document currently open in the editor
  205. const [currentDoc] = useScopeValue('editor.sharejs_doc')
  206. // whether the editor linter found errors
  207. const [hasLintingError, setHasLintingError] = useScopeValue('hasLintingError')
  208. // the timestamp that a doc was last changed
  209. const [changedAt, setChangedAt] = useState(0)
  210. const { signal } = useAbortController()
  211. const cleanupCompileResult = useCallback(() => {
  212. setPdfFile(undefined)
  213. setLogEntries(null)
  214. setLogEntryAnnotations({})
  215. }, [setPdfFile, setLogEntries, setLogEntryAnnotations])
  216. const compilingRef = useRef(false)
  217. useEffect(() => {
  218. compilingRef.current = compiling
  219. }, [compiling])
  220. const _buildLogEntryAnnotations = useCallback(
  221. entries =>
  222. buildLogEntryAnnotations(entries, fileTreeData, lastCompileRootDocId),
  223. [fileTreeData, lastCompileRootDocId]
  224. )
  225. const buildLogEntryAnnotationsRef = useRef(_buildLogEntryAnnotations)
  226. useEffect(() => {
  227. buildLogEntryAnnotationsRef.current = _buildLogEntryAnnotations
  228. }, [_buildLogEntryAnnotations])
  229. // the document compiler
  230. const [compiler] = useState(() => {
  231. return new DocumentCompiler({
  232. projectId,
  233. setChangedAt,
  234. setCompiling,
  235. setData,
  236. setFirstRenderDone,
  237. setDeliveryLatencies,
  238. setError,
  239. cleanupCompileResult,
  240. compilingRef,
  241. signal,
  242. })
  243. })
  244. // keep currentDoc in sync with the compiler
  245. useEffect(() => {
  246. compiler.currentDoc = currentDoc
  247. }, [compiler, currentDoc])
  248. // keep the project rootDocId in sync with the compiler
  249. useEffect(() => {
  250. compiler.projectRootDocId = rootDocId
  251. }, [compiler, rootDocId])
  252. // keep draft setting in sync with the compiler
  253. useEffect(() => {
  254. compiler.setOption('draft', draft)
  255. }, [compiler, draft])
  256. // keep stop on first error setting in sync with the compiler
  257. useEffect(() => {
  258. compiler.setOption('stopOnFirstError', stopOnFirstError)
  259. }, [compiler, stopOnFirstError])
  260. useEffect(() => {
  261. setUncompiled(changedAt > 0)
  262. }, [setUncompiled, changedAt])
  263. useEffect(() => {
  264. setEditedSinceCompileStarted(changedAt > 0)
  265. }, [setEditedSinceCompileStarted, changedAt])
  266. // always compile the PDF once after opening the project, after the doc has loaded
  267. useEffect(() => {
  268. if (!compiledOnce && currentDoc) {
  269. setCompiledOnce(true)
  270. compiler.compile({ isAutoCompileOnLoad: true })
  271. }
  272. }, [compiledOnce, currentDoc, compiler])
  273. useEffect(() => {
  274. const compileTimeWarningEnabled =
  275. features?.compileTimeout !== undefined && features.compileTimeout <= 60
  276. if (compileTimeWarningEnabled && compiling && isProjectOwner) {
  277. const timeout = window.setTimeout(() => {
  278. setShowCompileTimeWarning(true)
  279. }, 30000)
  280. return () => {
  281. window.clearTimeout(timeout)
  282. }
  283. }
  284. }, [compiling, isProjectOwner, features])
  285. const { splitTestVariants } = useSplitTestContext()
  286. // handle the data returned from a compile request
  287. // note: this should _only_ run when `data` changes,
  288. // the other dependencies must all be static
  289. useEffect(() => {
  290. const abortController = new AbortController()
  291. if (data) {
  292. if (data.clsiServerId) {
  293. setClsiServerId(data.clsiServerId) // set in scope, for PdfSynctexController
  294. }
  295. setShowFasterCompilesFeedbackUI(
  296. Boolean(data.showFasterCompilesFeedbackUI)
  297. )
  298. if (data.outputFiles) {
  299. const outputFiles = new Map()
  300. for (const outputFile of data.outputFiles) {
  301. outputFiles.set(outputFile.path, outputFile)
  302. }
  303. // set the PDF context
  304. if (data.status === 'success') {
  305. setPdfFile(handleOutputFiles(outputFiles, projectId, data))
  306. }
  307. setFileList(
  308. buildFileList(outputFiles, data.clsiServerId, data.compileGroup)
  309. )
  310. // handle log files
  311. // asynchronous (TODO: cancel on new compile?)
  312. setLogEntryAnnotations(null)
  313. setLogEntries(null)
  314. setRawLog(undefined)
  315. handleLogFiles(outputFiles, data, abortController.signal).then(
  316. (result: Record<string, any>) => {
  317. setRawLog(result.log)
  318. setLogEntries(result.logEntries)
  319. setLogEntryAnnotations(
  320. buildLogEntryAnnotationsRef.current(result.logEntries.all)
  321. )
  322. // sample compile stats for real users
  323. if (!window.user.alphaProgram) {
  324. if (['success', 'stopped-on-first-error'].includes(data.status)) {
  325. sendMBSampled(
  326. 'compile-result',
  327. {
  328. errors: result.logEntries.errors.length,
  329. warnings: result.logEntries.warnings.length,
  330. typesetting: result.logEntries.typesetting.length,
  331. newPdfPreview: true, // TODO: is this useful?
  332. stopOnFirstError: data.options.stopOnFirstError,
  333. },
  334. 0.01
  335. )
  336. }
  337. if (splitTestVariants['compile-log-events'] === 'enabled') {
  338. sendMB('compile-log-entries', {
  339. status: data.status,
  340. stopOnFirstError: data.options.stopOnFirstError,
  341. isAutoCompileOnLoad: !!data.options.isAutoCompileOnLoad,
  342. isAutoCompileOnChange: !!data.options.isAutoCompileOnChange,
  343. ...buildRuleCounts(result.logEntries.all),
  344. })
  345. }
  346. }
  347. }
  348. )
  349. }
  350. switch (data.status) {
  351. case 'success':
  352. setError(undefined)
  353. setShowLogs(false)
  354. break
  355. case 'stopped-on-first-error':
  356. setError(undefined)
  357. setShowLogs(true)
  358. break
  359. case 'clsi-maintenance':
  360. case 'compile-in-progress':
  361. case 'exited':
  362. case 'failure':
  363. case 'project-too-large':
  364. case 'rate-limited':
  365. case 'terminated':
  366. case 'too-recently-compiled':
  367. setError(data.status)
  368. break
  369. case 'timedout':
  370. setError('timedout')
  371. if (!hasPremiumCompile && isProjectOwner) {
  372. send(
  373. 'subscription-funnel',
  374. 'editor-click-feature',
  375. 'compile-timeout'
  376. )
  377. }
  378. break
  379. case 'autocompile-backoff':
  380. if (!data.options.isAutoCompileOnLoad) {
  381. setError('autocompile-disabled')
  382. setAutoCompile(false)
  383. }
  384. break
  385. case 'unavailable':
  386. setError('clsi-unavailable')
  387. break
  388. case 'validation-problems':
  389. setError('validation-problems')
  390. setValidationIssues(data.validationProblems)
  391. break
  392. default:
  393. setError('error')
  394. break
  395. }
  396. setStoppedOnFirstError(data.status === 'stopped-on-first-error')
  397. }
  398. return () => {
  399. abortController.abort()
  400. }
  401. }, [
  402. data,
  403. ide,
  404. hasPremiumCompile,
  405. isProjectOwner,
  406. projectId,
  407. setAutoCompile,
  408. setClsiServerId,
  409. setLogEntries,
  410. setLogEntryAnnotations,
  411. setPdfFile,
  412. splitTestVariants,
  413. ])
  414. // switch to logs if there's an error
  415. useEffect(() => {
  416. if (error) {
  417. setShowLogs(true)
  418. }
  419. }, [error])
  420. // whether there has been an autocompile linting error, if syntax validation is switched on
  421. const autoCompileLintingError = Boolean(
  422. autoCompile && syntaxValidation && hasLintingError
  423. )
  424. const codeCheckFailed = stopOnValidationError && autoCompileLintingError
  425. // the project is available for auto-compiling
  426. // (autocompile is enabled, the PDF preview is open, and the code check (if enabled) hasn't failed)
  427. const canAutoCompile = Boolean(
  428. autoCompile && pdfPreviewOpen && !codeCheckFailed
  429. )
  430. // show that the project has pending changes
  431. const hasChanges = Boolean(canAutoCompile && uncompiled && compiledOnce)
  432. // call the debounced autocompile function if the project is available for auto-compiling and it has changed
  433. useEffect(() => {
  434. if (canAutoCompile) {
  435. if (changedAt > 0) {
  436. compiler.debouncedAutoCompile()
  437. }
  438. } else {
  439. compiler.debouncedAutoCompile.cancel()
  440. }
  441. }, [compiler, canAutoCompile, changedAt])
  442. // cancel debounced recompile on unmount
  443. useEffect(() => {
  444. return () => {
  445. compiler.debouncedAutoCompile.cancel()
  446. }
  447. }, [compiler])
  448. // start a compile manually
  449. const startCompile = useCallback(
  450. options => {
  451. compiler.compile(options)
  452. },
  453. [compiler]
  454. )
  455. // stop a compile manually
  456. const stopCompile = useCallback(() => {
  457. compiler.stopCompile()
  458. }, [compiler])
  459. // clear the compile cache
  460. const clearCache = useCallback(() => {
  461. setClearingCache(true)
  462. return compiler
  463. .clearCache()
  464. .then(() => {
  465. setFileList(undefined)
  466. setPdfFile(undefined)
  467. })
  468. .finally(() => {
  469. setClearingCache(false)
  470. })
  471. }, [compiler])
  472. const syncToEntry = useCallback(
  473. entry => {
  474. const result = findEntityByPath(entry.file)
  475. if (result && result.type === 'doc') {
  476. ide.editorManager.openDocId(result.entity._id, {
  477. gotoLine: entry.line ?? undefined,
  478. gotoColumn: entry.column ?? undefined,
  479. })
  480. }
  481. },
  482. [findEntityByPath, ide.editorManager]
  483. )
  484. // clear the cache then run a compile, triggered by a menu item
  485. const recompileFromScratch = useCallback(() => {
  486. clearCache().then(() => {
  487. compiler.compile()
  488. })
  489. }, [clearCache, compiler])
  490. // After a compile, the compiler sets `data.options` to the options that were
  491. // used for that compile.
  492. const lastCompileOptions = useMemo(() => data?.options || {}, [data])
  493. const value = useMemo(
  494. () => ({
  495. animateCompileDropdownArrow,
  496. autoCompile,
  497. clearCache,
  498. clearingCache,
  499. clsiServerId,
  500. codeCheckFailed,
  501. compiling,
  502. deliveryLatencies,
  503. draft,
  504. editedSinceCompileStarted,
  505. error,
  506. fileList,
  507. hasChanges,
  508. highlights,
  509. isProjectOwner,
  510. lastCompileOptions,
  511. logEntryAnnotations,
  512. logEntries,
  513. pdfDownloadUrl: pdfFile?.pdfDownloadUrl,
  514. pdfFile,
  515. pdfUrl: pdfFile?.pdfUrl,
  516. pdfViewer,
  517. position,
  518. rawLog,
  519. recompileFromScratch,
  520. setAnimateCompileDropdownArrow,
  521. setAutoCompile,
  522. setCompiling,
  523. setDraft,
  524. setError,
  525. setHasLintingError, // only for stories
  526. setHighlights,
  527. setPosition,
  528. showCompileTimeWarning,
  529. setShowCompileTimeWarning,
  530. setShowLogs,
  531. toggleLogs,
  532. setStopOnFirstError,
  533. setStopOnValidationError,
  534. showLogs,
  535. showNewCompileTimeoutUI,
  536. showFasterCompilesFeedbackUI,
  537. startCompile,
  538. stopCompile,
  539. stopOnFirstError,
  540. stopOnValidationError,
  541. stoppedOnFirstError,
  542. uncompiled,
  543. validationIssues,
  544. firstRenderDone,
  545. setChangedAt,
  546. cleanupCompileResult,
  547. syncToEntry,
  548. }),
  549. [
  550. animateCompileDropdownArrow,
  551. autoCompile,
  552. clearCache,
  553. clearingCache,
  554. clsiServerId,
  555. codeCheckFailed,
  556. compiling,
  557. deliveryLatencies,
  558. draft,
  559. editedSinceCompileStarted,
  560. error,
  561. fileList,
  562. hasChanges,
  563. highlights,
  564. isProjectOwner,
  565. lastCompileOptions,
  566. logEntries,
  567. logEntryAnnotations,
  568. position,
  569. pdfFile,
  570. pdfViewer,
  571. rawLog,
  572. recompileFromScratch,
  573. setAnimateCompileDropdownArrow,
  574. setAutoCompile,
  575. setDraft,
  576. setError,
  577. setHasLintingError, // only for stories
  578. setHighlights,
  579. setPosition,
  580. setShowCompileTimeWarning,
  581. setStopOnFirstError,
  582. setStopOnValidationError,
  583. showCompileTimeWarning,
  584. showLogs,
  585. showNewCompileTimeoutUI,
  586. showFasterCompilesFeedbackUI,
  587. startCompile,
  588. stopCompile,
  589. stopOnFirstError,
  590. stopOnValidationError,
  591. stoppedOnFirstError,
  592. uncompiled,
  593. validationIssues,
  594. firstRenderDone,
  595. setChangedAt,
  596. cleanupCompileResult,
  597. setShowLogs,
  598. toggleLogs,
  599. syncToEntry,
  600. ]
  601. )
  602. return (
  603. <LocalCompileContext.Provider value={value}>
  604. {children}
  605. </LocalCompileContext.Provider>
  606. )
  607. }
  608. export function useLocalCompileContext() {
  609. const context = useContext(LocalCompileContext)
  610. if (!context) {
  611. throw new Error(
  612. 'useLocalCompileContext is only available inside LocalCompileProvider'
  613. )
  614. }
  615. return context
  616. }