Skip to content

Commit aff9a94

Browse files
committed
fixes for Windows
1 parent 426f382 commit aff9a94

7 files changed

+103
-100
lines changed

demo/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/src/LeanMonaco.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ function LeanMonacoComponent({options, numberEditors} : {options: LeanMonacoOpti
1010

1111
// You need to start one `LeanMonaco` instance once in your application using a `useEffect`
1212
useEffect(() => {
13-
const leanMonaco = new LeanMonaco()
14-
setLeanMonaco(leanMonaco)
15-
leanMonaco.setInfoviewElement(infoviewRef.current!)
13+
var _leanMonaco = new LeanMonaco()
14+
setLeanMonaco(_leanMonaco)
15+
_leanMonaco.setInfoviewElement(infoviewRef.current!)
16+
1617

1718
;(async () => {
18-
await leanMonaco.start(options)
19+
await _leanMonaco.start(options)
20+
console.debug('[demo]: leanMonaco started')
1921
})()
2022

2123
return () => {
22-
leanMonaco.dispose()
24+
_leanMonaco.dispose()
2325
}
2426
}, [options])
2527

@@ -34,7 +36,7 @@ function LeanMonacoComponent({options, numberEditors} : {options: LeanMonacoOpti
3436

3537
<div>
3638
<button onClick={(ev)=> {
37-
console.log('restarting Lean')
39+
console.log('[LeanMonaco] restarting Lean')
3840
leanMonaco?.clientProvider?.getClients().map(client => {client.restart()})
3941
}}>Restart Lean</button>
4042
</div>

demo/src/LeanMonacoEditor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ function LeanMonacoEditorComponent({fileName, value}: {fileName: string, value:
1313

1414
;(async () => {
1515
await leanMonaco!.whenReady
16+
console.debug('[demo]: starting editor')
1617
await leanMonacoEditor.start(codeviewRef.current!, fileName, value)
18+
console.debug('[demo]: editor started')
1719
})()
1820

1921
return () => {

package-lock.json

Lines changed: 59 additions & 80 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/leanmonaco.ts

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,27 @@ export type LeanMonacoOptions = {
6262
console.debug('[LeanMonaco]: starting')
6363

6464
if (LeanMonaco.activeInstance == this) {
65-
console.warn('A LeanMonaco instance cannot be started twice.')
65+
console.warn('[LeanMonaco]: A LeanMonaco instance cannot be started twice.')
6666
return
6767
}
6868
if (LeanMonaco.activeInstance) {
69-
console.warn('There can only be one active LeanMonaco instance at a time. Disposing previous instance.')
69+
console.warn('[LeanMonaco]: There can only be one active LeanMonaco instance at a time. Disposing previous instance.')
7070
LeanMonaco.activeInstance?.dispose()
7171
}
7272
LeanMonaco.activeInstance = this
7373

7474
if (! window.MonacoEnvironment) {
75+
console.debug('[LeanMonaco]: setting monaco environment')
7576
type WorkerLoader = () => Worker
7677
const workerLoaders: Partial<Record<string, WorkerLoader>> = {
77-
editorWorkerService: () => new Worker(new URL('monaco-editor/esm/vs/editor/editor.worker.js', import.meta.url), { type: 'module' }),
78-
textMateWorker: () => new Worker(new URL('@codingame/monaco-vscode-textmate-service-override/worker', import.meta.url), { type: 'module' }),
78+
editorWorkerService: () => new Worker(
79+
new URL('monaco-editor/esm/vs/editor/editor.worker.js', import.meta.url),
80+
{ type: 'module' }
81+
),
82+
textMateWorker: () => new Worker(
83+
new URL('@codingame/monaco-vscode-textmate-service-override/worker', import.meta.url),
84+
{ type: 'module' }
85+
),
7986
}
8087
window.MonacoEnvironment = {
8188
getWorker: function (moduleId, label) {
@@ -102,19 +109,22 @@ export type LeanMonacoOptions = {
102109
workspaceProvider: {
103110
trusted: true,
104111
workspace: {
105-
workspaceUri: Uri.file('/workspace.code-workspace')
112+
workspaceUri: Uri.file('/workspace.code-workspace')
106113
},
107114
async open() {
108-
return false
115+
return false
109116
}
110117
}
111118
}
112119
)
113-
120+
console.debug('[LeanMonaco]: done initializing')
114121
}
115122
await (await import('@codingame/monaco-vscode-theme-defaults-default-extension')).whenReady
116123

117-
if (this.disposed) return
124+
if (this.disposed) {
125+
console.debug('[LeanMonaco]: is disposed (A)')
126+
return
127+
}
118128

119129
this.extensionRegisterResult = registerExtension(this.getExtensionManifest(), ExtensionHostKind.LocalProcess)
120130

@@ -125,12 +135,18 @@ export type LeanMonacoOptions = {
125135

126136
await this.extensionRegisterResult.whenReady()
127137

128-
if (this.disposed) return
138+
if (this.disposed) {
139+
console.debug('[LeanMonaco]: is disposed (B)')
140+
return
141+
}
129142

130143
const themeService = await getService(IThemeService)
131144
const configurationService = await getService(IConfigurationService)
132145

133-
if (this.disposed) return
146+
if (this.disposed) {
147+
console.debug('[LeanMonaco]: is disposed (C)')
148+
return
149+
}
134150

135151
this.updateVSCodeOptions(options.vscode ?? {})
136152

@@ -206,8 +222,12 @@ export type LeanMonacoOptions = {
206222
...options.vscode
207223
})
208224

209-
if (this.disposed) return
225+
if (this.disposed) {
226+
console.debug('[LeanMonaco]: is disposed (D)')
227+
return
228+
}
210229

230+
console.info('[LeanMonaco]: is ready!')
211231
this.ready()
212232
}
213233

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"target": "ESNext",
44
"useDefineForClassFields": true,
55
"module": "ESNext",
6-
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6+
"lib": ["ES2021", "ES2021.String", "DOM", "DOM.Iterable"],
77
"skipLibCheck": true,
88

99
/* Bundler mode */

0 commit comments

Comments
 (0)