MCPcopy Create free account
hub / github.com/SplootCode/splootcode / RuntimeStateManager

Class RuntimeStateManager

packages/runtime-python/src/runtime/index.ts:18–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16`
17
18class RuntimeStateManager {
19 private parentWindowDomain: string | null
20 private parentWindowDomainRegex: string
21 private RuntimeWorker: new () => Worker
22 private AutocompleteWorker: new () => Worker
23 private workerManager: WorkerManager
24 private autocompleteWorkerManager: AutocompleteWorkerManager
25 private workspace: Map<string, FileSpec>
26 private envVars: Map<string, string>
27 private initialFilesLoaded: boolean
28 private stdinPromiseResolve: null | ((s: string) => void)
29 private fetchHandler: FetchHandler
30 private runType: RunType
31 private eventData: HTTPRequestAWSEvent | null
32 private stliteApp: any
33 private staticURLS: StaticURLs
34
35 private dependencies: Dependency[] | null
36
37 constructor(
38 parentWindowDomainRegex: string,
39 RuntimeWorker: new () => Worker,
40 AutocompleteWorker: new () => Worker,
41 fetchHandler: FetchHandler,
42 staticURLS: StaticURLs
43 ) {
44 this.parentWindowDomain = null
45 this.parentWindowDomainRegex = parentWindowDomainRegex
46 this.RuntimeWorker = RuntimeWorker
47 this.AutocompleteWorker = AutocompleteWorker
48 this.initialFilesLoaded = false
49 this.workspace = new Map()
50 this.envVars = new Map()
51 this.fetchHandler = fetchHandler
52 this.eventData = null
53 this.stliteApp = null
54 this.staticURLS = staticURLS
55 }
56
57 sendToParent = (payload: EditorMessage) => {
58 if (this.parentWindowDomain) {
59 parent.postMessage(payload, this.parentWindowDomain)
60 } else if (payload.type === 'heartbeat') {
61 // Only allow heartbeat messages to go to any origin.
62 parent.postMessage(payload, '*')
63 }
64 }
65
66 getTerminalInput = async () => {
67 const promise = new Promise<string>((resolve) => {
68 this.stdinPromiseResolve = resolve
69 })
70 this.sendToParent({ type: 'stdin' })
71 return promise
72 }
73
74 handleStdinInput = (text: string) => {
75 if (this.stdinPromiseResolve) {

Callers

nothing calls this directly

Calls 14

initializeStliteMethod · 0.95
addFilesToWorkspaceMethod · 0.95
setEnvironmentVarsMethod · 0.95
sameDepencenciesFunction · 0.90
postMessageMethod · 0.80
reloadDependenciesMethod · 0.80
loadDependenciesMethod · 0.80
generateTextCodeMethod · 0.80
rerunMethod · 0.80
sendParseTreesMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected