lean4monaco 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +1 -3
  2. package/dist/vscode-lean4/vscode-lean4/src/leanclient.js +3 -1
  3. package/dist/vscode-lean4/vscode-lean4/src/utils/clientProvider.js +0 -2
  4. package/dist/vscode-lean4/vscode-lean4/src/utils/depInstaller.d.ts +81 -0
  5. package/dist/vscode-lean4/vscode-lean4/src/utils/depInstaller.js +372 -0
  6. package/dist/vscode-lean4/vscode-lean4/src/utils/projectInfo.js +33 -32
  7. package/package.json +5 -2
  8. package/dist/JuliaMono-Regular.ttf +0 -0
  9. package/dist/lean4-infoview/codicon.ttf +0 -0
  10. package/dist/lean4-infoview/esm-shims/react-dom.d.ts +0 -5
  11. package/dist/lean4-infoview/esm-shims/react-jsx-runtime.d.ts +0 -5
  12. package/dist/lean4-infoview/esm-shims/react.d.ts +0 -5
  13. package/dist/lean4-infoview/index.css +0 -4161
  14. package/dist/lean4-infoview/index.d.ts +0 -16
  15. package/dist/lean4-infoview/index.development.js +0 -37312
  16. package/dist/lean4-infoview/index.production.min.js +0 -1528
  17. package/dist/lean4-infoview/infoview/collapsing.d.ts +0 -12
  18. package/dist/lean4-infoview/infoview/contexts.d.ts +0 -10
  19. package/dist/lean4-infoview/infoview/editorConnection.d.ts +0 -22
  20. package/dist/lean4-infoview/infoview/errors.d.ts +0 -14
  21. package/dist/lean4-infoview/infoview/event.d.ts +0 -33
  22. package/dist/lean4-infoview/infoview/goalLocation.d.ts +0 -61
  23. package/dist/lean4-infoview/infoview/goals.d.ts +0 -46
  24. package/dist/lean4-infoview/infoview/info.d.ts +0 -18
  25. package/dist/lean4-infoview/infoview/infos.d.ts +0 -2
  26. package/dist/lean4-infoview/infoview/interactiveCode.d.ts +0 -19
  27. package/dist/lean4-infoview/infoview/main.d.ts +0 -13
  28. package/dist/lean4-infoview/infoview/messages.d.ts +0 -19
  29. package/dist/lean4-infoview/infoview/rpcSessions.d.ts +0 -11
  30. package/dist/lean4-infoview/infoview/serverVersion.d.ts +0 -10
  31. package/dist/lean4-infoview/infoview/tooltips.d.ts +0 -32
  32. package/dist/lean4-infoview/infoview/traceExplorer.d.ts +0 -11
  33. package/dist/lean4-infoview/infoview/userWidget.d.ts +0 -39
  34. package/dist/lean4-infoview/infoview/util.d.ts +0 -144
  35. package/dist/lean4-infoview/loader.d.ts +0 -20
  36. package/dist/lean4-infoview/loader.development.js +0 -1006
  37. package/dist/lean4-infoview/loader.production.min.js +0 -1
  38. package/dist/lean4-infoview/react-dom.development.js +0 -30537
  39. package/dist/lean4-infoview/react-dom.production.min.js +0 -21
  40. package/dist/lean4-infoview/react-jsx-runtime.development.js +0 -1362
  41. package/dist/lean4-infoview/react-jsx-runtime.production.min.js +0 -1
  42. package/dist/lean4-infoview/react.development.js +0 -2823
  43. package/dist/lean4-infoview/react.production.min.js +0 -1
  44. package/dist/monaco-lean4/vscode-lean4/package.json +0 -944
  45. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.d.ts +0 -9
  46. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationFeature.js +0 -20
  47. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationHoverProvider.d.ts +0 -12
  48. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationHoverProvider.js +0 -40
  49. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.d.ts +0 -20
  50. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/AbbreviationRewriterFeature.js +0 -79
  51. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationConfig.d.ts +0 -13
  52. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationConfig.js +0 -29
  53. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.d.ts +0 -28
  54. package/dist/monaco-lean4/vscode-lean4/src/abbreviation/VSCodeAbbreviationRewriter.js +0 -124
  55. package/dist/monaco-lean4/vscode-lean4/src/config.d.ts +0 -33
  56. package/dist/monaco-lean4/vscode-lean4/src/config.js +0 -119
  57. package/dist/monaco-lean4/vscode-lean4/src/diagnostics/setupNotifs.d.ts +0 -27
  58. package/dist/monaco-lean4/vscode-lean4/src/diagnostics/setupNotifs.js +0 -133
  59. package/dist/monaco-lean4/vscode-lean4/src/infoview.d.ts +0 -69
  60. package/dist/monaco-lean4/vscode-lean4/src/infoview.js +0 -711
  61. package/dist/monaco-lean4/vscode-lean4/src/leanclient.d.ts +0 -67
  62. package/dist/monaco-lean4/vscode-lean4/src/leanclient.js +0 -443
  63. package/dist/monaco-lean4/vscode-lean4/src/rpc.d.ts +0 -16
  64. package/dist/monaco-lean4/vscode-lean4/src/rpc.js +0 -102
  65. package/dist/monaco-lean4/vscode-lean4/src/taskgutter.d.ts +0 -11
  66. package/dist/monaco-lean4/vscode-lean4/src/taskgutter.js +0 -130
  67. package/dist/monaco-lean4/vscode-lean4/src/utils/batch.d.ts +0 -37
  68. package/dist/monaco-lean4/vscode-lean4/src/utils/batch.js +0 -203
  69. package/dist/monaco-lean4/vscode-lean4/src/utils/clientProvider.d.ts +0 -41
  70. package/dist/monaco-lean4/vscode-lean4/src/utils/clientProvider.js +0 -205
  71. package/dist/monaco-lean4/vscode-lean4/src/utils/converters.d.ts +0 -16
  72. package/dist/monaco-lean4/vscode-lean4/src/utils/converters.js +0 -129
  73. package/dist/monaco-lean4/vscode-lean4/src/utils/elan.d.ts +0 -3
  74. package/dist/monaco-lean4/vscode-lean4/src/utils/elan.js +0 -4
  75. package/dist/monaco-lean4/vscode-lean4/src/utils/envPath.d.ts +0 -21
  76. package/dist/monaco-lean4/vscode-lean4/src/utils/envPath.js +0 -53
  77. package/dist/monaco-lean4/vscode-lean4/src/utils/exturi.d.ts +0 -35
  78. package/dist/monaco-lean4/vscode-lean4/src/utils/exturi.js +0 -136
  79. package/dist/monaco-lean4/vscode-lean4/src/utils/fsHelper.d.ts +0 -17
  80. package/dist/monaco-lean4/vscode-lean4/src/utils/fsHelper.js +0 -36
  81. package/dist/monaco-lean4/vscode-lean4/src/utils/leanInstaller.d.ts +0 -37
  82. package/dist/monaco-lean4/vscode-lean4/src/utils/leanInstaller.js +0 -210
  83. package/dist/monaco-lean4/vscode-lean4/src/utils/logger.d.ts +0 -7
  84. package/dist/monaco-lean4/vscode-lean4/src/utils/logger.js +0 -20
  85. package/dist/monaco-lean4/vscode-lean4/src/utils/notifs.d.ts +0 -24
  86. package/dist/monaco-lean4/vscode-lean4/src/utils/notifs.js +0 -110
  87. package/dist/monaco-lean4/vscode-lean4/src/utils/projectInfo.d.ts +0 -9
  88. package/dist/monaco-lean4/vscode-lean4/src/utils/projectInfo.js +0 -125
  89. package/dist/vscode.css +0 -7
package/README.md CHANGED
@@ -109,7 +109,7 @@ export default {
109
109
  For Vite dev mode to work properly, the following plugin is necessary:
110
110
 
111
111
  ```
112
- npm install -D 'https://gitpkg.vercel.app/hhu-adam/lean4monaco/esbuild-import-meta-url-plugin?main'
112
+ npm install --save-dev '@codingame/esbuild-import-meta-url-plugin'
113
113
  ```
114
114
 
115
115
  ```ts
@@ -126,8 +126,6 @@ export default {
126
126
  }
127
127
  ```
128
128
 
129
- This could be replaced by `npm install --save-dev @codingame/esbuild-import-meta-url-plugin` when this PR is accepted: https://github.com/CodinGame/esbuild-import-meta-url-plugin/pull/5
130
-
131
129
  #### infoview
132
130
 
133
131
  Moreover, the infoview javascript files need to be served:
@@ -313,7 +313,9 @@ export class LeanClient {
313
313
  return true;
314
314
  }
315
315
  if (this.folderUri.scheme === 'file' && uri.scheme === 'file') {
316
- return uri.isInFolder(this.folderUri);
316
+ // lean4monaco: To avoid file system issues, we let any client manage any file:
317
+ return true;
318
+ // return uri.isInFolder(this.folderUri)
317
319
  }
318
320
  return false;
319
321
  }
@@ -168,8 +168,6 @@ export class LeanClientProvider {
168
168
  bestCandidate = candidate;
169
169
  }
170
170
  }
171
- // lean4monaco: Due to issues with Windows file paths, we assume for now that there is only one client.
172
- return this.getClients()[0];
173
171
  return bestCandidate;
174
172
  }
175
173
  getClients() {
@@ -0,0 +1,81 @@
1
+ import { Disposable, OutputChannel } from 'vscode';
2
+ import { ExecutionResult } from './batch';
3
+ import { NotificationSeverity, StickyInput, StickyNotificationOptions } from './notifs';
4
+ export type LinuxPackageManager = {
5
+ kind: 'Apt';
6
+ isPkExecAvailable: boolean;
7
+ } | {
8
+ kind: 'Dnf';
9
+ isPkExecAvailable: boolean;
10
+ } | {
11
+ kind: 'Other';
12
+ };
13
+ export type DependencyInstallationMethod = {
14
+ kind: 'Automatic';
15
+ shell: 'Windows' | 'Unix';
16
+ script: string;
17
+ manualBackupScript: string | undefined;
18
+ pathExtensions: string[];
19
+ } | {
20
+ kind: 'Manual';
21
+ script: string | undefined;
22
+ };
23
+ export type MissingDependencyInstallationProcedure = {
24
+ kind: 'Linux';
25
+ isGitAvailable: boolean;
26
+ isCurlAvailable: boolean;
27
+ packageManager: LinuxPackageManager;
28
+ } | {
29
+ kind: 'MacOS';
30
+ isGitAvailable: boolean;
31
+ isCurlAvailable: true;
32
+ } | {
33
+ kind: 'Windows';
34
+ isGitAvailable: boolean;
35
+ isCurlAvailable: true;
36
+ isWinGetAvailable: boolean;
37
+ } | {
38
+ kind: 'Other';
39
+ isGitAvailable: boolean;
40
+ isCurlAvailable: boolean;
41
+ };
42
+ export type DependencyInstallationProcedure = {
43
+ kind: 'AllDepsInstalled';
44
+ } | (MissingDependencyInstallationProcedure & {
45
+ method: DependencyInstallationMethod;
46
+ });
47
+ export type DependencyInstallationResult = {
48
+ kind: 'Success';
49
+ } | {
50
+ kind: 'Error';
51
+ result: ExecutionResult;
52
+ } | {
53
+ kind: 'Cancelled';
54
+ } | {
55
+ kind: 'PendingInstall';
56
+ };
57
+ export declare function depInstallationLocations(): string[];
58
+ export declare class DepInstaller implements Disposable {
59
+ readonly outputChannel: OutputChannel;
60
+ private pendingInstall;
61
+ private diagnoser;
62
+ private subscriptions;
63
+ constructor(outputChannel: OutputChannel);
64
+ displayInstallDependenciesPrompt(severity: NotificationSeverity, reason: string | undefined): Promise<'Success' | 'PendingInstall' | 'Failure'>;
65
+ displayStickyInstallDependenciesPrompt(severity: NotificationSeverity, reason: string | undefined, options: StickyNotificationOptions<string>, otherItems?: StickyInput<string>[]): Promise<Disposable>;
66
+ private installMissingDepsAndDisplayNotification;
67
+ installMissingDeps(p: MissingDependencyInstallationProcedure & {
68
+ method: DependencyInstallationMethod;
69
+ }): Promise<DependencyInstallationResult>;
70
+ private addDepsToProcessEnv;
71
+ determineDependencyInstallationProcedure(): Promise<DependencyInstallationProcedure>;
72
+ private determineMissingDependencyInstallationProcedure;
73
+ private runCommand;
74
+ dispose(): void;
75
+ }
76
+ export declare function missingDepsSentence(p: MissingDependencyInstallationProcedure): string;
77
+ export declare function sentenceJoin(entries: string[]): string;
78
+ export declare function missingDeps(p: MissingDependencyInstallationProcedure): string[];
79
+ export declare function unsuccessfulDependencyInstallationPrompt(p: MissingDependencyInstallationProcedure & {
80
+ method: DependencyInstallationMethod;
81
+ }): string;
@@ -0,0 +1,372 @@
1
+ import * as os from 'os';
2
+ import path from 'path';
3
+ import { commands, Disposable, env } from 'vscode';
4
+ import { SetupDiagnoser } from '../diagnostics/setupDiagnoser';
5
+ import { batchExecuteWithProgress, displayModalResultError, ExecutionExitCode, } from './batch';
6
+ import { addToProcessEnvPATH } from './envPath';
7
+ import { displayModalNotification, displayNotification, displayNotificationWithInput, displayStickyNotificationWithOptionalInput, } from './notifs';
8
+ const gitInstallDir = path.join('c:', 'Program Files', 'Git', 'cmd');
9
+ export function depInstallationLocations() {
10
+ switch (os.type()) {
11
+ case 'Linux':
12
+ // Installation locations of Git and curl should already be in PATH on most Linux systems
13
+ return [];
14
+ case 'Darwin':
15
+ // MacOS ships with a dummy executable for Git that is already in the PATH, which is replaced
16
+ // with the real executable when Apple Command Line Tools is installed.
17
+ return [];
18
+ case 'Windows_NT':
19
+ return [gitInstallDir];
20
+ }
21
+ return [];
22
+ }
23
+ const windowsRawGitInstallScript = `$gitInstallerUrl = "https://github.com/git-for-windows/git/releases/download/v2.50.1.windows.1/Git-2.50.1-64-bit.exe"
24
+ $installDir = "%TEMP%\\lean4-vscode-extension"
25
+ $gitInstallerLoc = "$installDir\\GitInstaller.exe"
26
+ New-Item -ItemType Directory -Path $installDir -Force
27
+ Invoke-WebRequest -Uri $gitInstallerUrl -OutFile $gitInstallerLoc
28
+ & $gitInstallerLoc /VERYSILENT /NORESTART /SP-
29
+ exit $LASTEXITCODE`;
30
+ const macOsInstallScript = `set -e
31
+ touch "/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress"
32
+ aclt_label="$(/usr/sbin/softwareupdate -l |
33
+ grep -B 1 -E 'Command Line Tools' |
34
+ awk -F'*' '/^ *\\*/ {print $2}' |
35
+ sed -e 's/^ *Label: //' -e 's/^ *//' |
36
+ sort -V |
37
+ tail -n1 |
38
+ tr -d '\n')"
39
+ /usr/sbin/softwareupdate -i "$aclt_label"`;
40
+ export class DepInstaller {
41
+ outputChannel;
42
+ pendingInstall = false;
43
+ diagnoser;
44
+ subscriptions = [];
45
+ constructor(outputChannel) {
46
+ this.outputChannel = outputChannel;
47
+ this.diagnoser = new SetupDiagnoser({
48
+ channel: outputChannel,
49
+ cwdUri: undefined,
50
+ context: 'Dependency Installation',
51
+ });
52
+ this.subscriptions.push(commands.registerCommand('lean4.setup.installDeps', () => this.displayInstallDependenciesPrompt('Information', undefined)));
53
+ }
54
+ async displayInstallDependenciesPrompt(severity, reason) {
55
+ const p = await this.determineDependencyInstallationProcedure();
56
+ if (p.kind === 'AllDepsInstalled') {
57
+ displayNotification('Information', 'All dependencies of Lean (Git and curl) are already installed.');
58
+ return 'Success';
59
+ }
60
+ if (p.method.kind === 'Manual') {
61
+ await displayManualInstallationPrompt(severity, reason, p);
62
+ return 'Failure';
63
+ }
64
+ const choice = await displayNotificationWithInput(severity, installDependenciesPrompt(reason, p), ['Proceed']);
65
+ if (choice !== 'Proceed') {
66
+ return 'Failure';
67
+ }
68
+ return await this.installMissingDepsAndDisplayNotification(p);
69
+ }
70
+ async displayStickyInstallDependenciesPrompt(severity, reason, options, otherItems = []) {
71
+ const p = await this.determineDependencyInstallationProcedure();
72
+ if (p.kind === 'AllDepsInstalled') {
73
+ displayNotification('Information', 'All dependencies of Lean (Git and curl) are already installed.');
74
+ return Disposable.from();
75
+ }
76
+ if (p.method.kind === 'Manual') {
77
+ return await displayStickyManualInstallationPrompt(severity, reason, p, options, otherItems);
78
+ }
79
+ const installDepsItem = {
80
+ input: 'Install Dependencies',
81
+ continueDisplaying: false,
82
+ action: async () => {
83
+ await this.installMissingDepsAndDisplayNotification(p);
84
+ },
85
+ };
86
+ return displayStickyNotificationWithOptionalInput(severity, installDependenciesPrompt(reason, p), options, [
87
+ installDepsItem,
88
+ ...otherItems,
89
+ ]);
90
+ }
91
+ async installMissingDepsAndDisplayNotification(p) {
92
+ const r = await this.installMissingDeps(p);
93
+ switch (r.kind) {
94
+ case 'Success':
95
+ displayNotification('Information', 'Dependency installation successful!');
96
+ return 'Success';
97
+ case 'Error':
98
+ await displayModalResultError(r.result, unsuccessfulDependencyInstallationPrompt(p));
99
+ return 'Failure';
100
+ case 'Cancelled':
101
+ return 'Failure';
102
+ case 'PendingInstall':
103
+ return 'PendingInstall';
104
+ }
105
+ }
106
+ async installMissingDeps(p) {
107
+ if (p.method.kind === 'Manual') {
108
+ throw new Error('got manual installation method in `installMissingDeps`');
109
+ }
110
+ if (this.pendingInstall) {
111
+ displayNotification('Error', 'Dependencies are already being installed.');
112
+ return { kind: 'PendingInstall' };
113
+ }
114
+ this.pendingInstall = true;
115
+ try {
116
+ const installationResult = await this.runCommand(p.method.script, [], 'Installing missing dependencies', p.method.shell);
117
+ switch (installationResult.exitCode) {
118
+ case ExecutionExitCode.Success:
119
+ this.addDepsToProcessEnv(p.method);
120
+ return { kind: 'Success' };
121
+ case ExecutionExitCode.CannotLaunch:
122
+ case ExecutionExitCode.ExecutionError:
123
+ return { kind: 'Error', result: installationResult };
124
+ case ExecutionExitCode.Cancelled:
125
+ return { kind: 'Cancelled' };
126
+ }
127
+ }
128
+ finally {
129
+ this.pendingInstall = false;
130
+ }
131
+ }
132
+ addDepsToProcessEnv(method) {
133
+ if (method.kind !== 'Automatic') {
134
+ return;
135
+ }
136
+ for (const pathExt of method.pathExtensions) {
137
+ addToProcessEnvPATH(pathExt);
138
+ }
139
+ }
140
+ async determineDependencyInstallationProcedure() {
141
+ const p = await this.determineMissingDependencyInstallationProcedure();
142
+ if (p === undefined) {
143
+ return { kind: 'AllDepsInstalled' };
144
+ }
145
+ return { ...p, method: dependencyInstallationMethod(p) };
146
+ }
147
+ async determineMissingDependencyInstallationProcedure() {
148
+ const isCurlAvailable = await this.diagnoser.checkCurlAvailable();
149
+ const isGitAvailable = await this.diagnoser.checkGitAvailable();
150
+ if (isCurlAvailable && isGitAvailable) {
151
+ return undefined;
152
+ }
153
+ switch (os.type()) {
154
+ case 'Linux':
155
+ const isAptAvailable = await this.diagnoser.checkAptGetAvailable();
156
+ if (isAptAvailable) {
157
+ const isPkExecAvailable = await this.diagnoser.checkPkExecAvailable();
158
+ return {
159
+ kind: 'Linux',
160
+ isCurlAvailable,
161
+ isGitAvailable,
162
+ packageManager: { kind: 'Apt', isPkExecAvailable },
163
+ };
164
+ }
165
+ const isDnfAvailable = await this.diagnoser.checkDnfAvailable();
166
+ if (isDnfAvailable) {
167
+ const isPkExecAvailable = await this.diagnoser.checkPkExecAvailable();
168
+ return {
169
+ kind: 'Linux',
170
+ isCurlAvailable,
171
+ isGitAvailable,
172
+ packageManager: { kind: 'Dnf', isPkExecAvailable },
173
+ };
174
+ }
175
+ return {
176
+ kind: 'Linux',
177
+ isCurlAvailable,
178
+ isGitAvailable,
179
+ packageManager: { kind: 'Other' },
180
+ };
181
+ case 'Darwin':
182
+ return {
183
+ kind: 'MacOS',
184
+ isCurlAvailable: true,
185
+ isGitAvailable,
186
+ };
187
+ case 'Windows_NT':
188
+ const isWinGetAvailable = await this.diagnoser.checkWinGetAvailable();
189
+ return {
190
+ kind: 'Windows',
191
+ isCurlAvailable: true,
192
+ isGitAvailable,
193
+ isWinGetAvailable,
194
+ };
195
+ }
196
+ return {
197
+ kind: 'Other',
198
+ isCurlAvailable,
199
+ isGitAvailable,
200
+ };
201
+ }
202
+ async runCommand(executablePath, args, title, shell) {
203
+ const options = {
204
+ allowCancellation: true,
205
+ channel: this.outputChannel,
206
+ shell,
207
+ };
208
+ return batchExecuteWithProgress(executablePath, args, 'Dependency Installation', title, options);
209
+ }
210
+ dispose() {
211
+ for (const s of this.subscriptions) {
212
+ s.dispose();
213
+ }
214
+ }
215
+ }
216
+ function dependencyInstallationMethod(p) {
217
+ switch (p.kind) {
218
+ case 'Linux':
219
+ switch (p.packageManager.kind) {
220
+ case 'Apt':
221
+ const manualAptScript = `sudo apt update && sudo apt install ${missingDeps(p).join(' ')}`;
222
+ if (!p.packageManager.isPkExecAvailable) {
223
+ return {
224
+ kind: 'Manual',
225
+ script: manualAptScript,
226
+ };
227
+ }
228
+ return {
229
+ kind: 'Automatic',
230
+ shell: 'Unix',
231
+ // `ulimit -Sn 1024`: https://github.com/microsoft/vscode/issues/237427
232
+ script: `ulimit -Sn 1024; pkexec bash -c 'export DEBIAN_FRONTEND=noninteractive; apt-get update -y && apt-get install -y ${missingDeps(p).join(' ')}'`,
233
+ manualBackupScript: manualAptScript,
234
+ pathExtensions: [],
235
+ };
236
+ case 'Dnf':
237
+ const manualDnfScript = `sudo dnf install ${missingDeps(p).join(' ')}`;
238
+ if (!p.packageManager.isPkExecAvailable) {
239
+ return {
240
+ kind: 'Manual',
241
+ script: manualDnfScript,
242
+ };
243
+ }
244
+ return {
245
+ kind: 'Automatic',
246
+ shell: 'Unix',
247
+ script: `pkexec dnf install -y ${missingDeps(p).join(' ')}`,
248
+ manualBackupScript: manualDnfScript,
249
+ pathExtensions: [],
250
+ };
251
+ case 'Other':
252
+ return {
253
+ kind: 'Manual',
254
+ script: undefined,
255
+ };
256
+ }
257
+ case 'MacOS':
258
+ return {
259
+ kind: 'Automatic',
260
+ shell: 'Unix',
261
+ script: macOsInstallScript,
262
+ manualBackupScript: macOsInstallScript,
263
+ pathExtensions: [],
264
+ };
265
+ case 'Windows':
266
+ if (!p.isWinGetAvailable) {
267
+ return {
268
+ kind: 'Automatic',
269
+ shell: 'Windows',
270
+ script: windowsRawGitInstallScript,
271
+ manualBackupScript: undefined,
272
+ pathExtensions: [gitInstallDir],
273
+ };
274
+ }
275
+ const windowsWingetGitInstallScript = 'winget install -e --id Git.Git --silent --accept-package-agreements --accept-source-agreements --disable-interactivity';
276
+ return {
277
+ kind: 'Automatic',
278
+ shell: 'Windows',
279
+ script: windowsWingetGitInstallScript,
280
+ manualBackupScript: windowsWingetGitInstallScript,
281
+ pathExtensions: [gitInstallDir],
282
+ };
283
+ case 'Other':
284
+ return {
285
+ kind: 'Manual',
286
+ script: undefined,
287
+ };
288
+ }
289
+ }
290
+ async function displayManualInstallationPrompt(severity, reason, p) {
291
+ let reasonPrefix = '';
292
+ if (reason !== undefined) {
293
+ reasonPrefix = `${reason} `;
294
+ }
295
+ if (p.method.script === undefined) {
296
+ await displayModalNotification(severity, `${reasonPrefix}Please install ${missingDepsSentence(p)} and restart VS Code.`);
297
+ return;
298
+ }
299
+ const prompt = `${reasonPrefix}Please install ${missingDepsSentence(p)} from a terminal using the script below and restart VS Code.\n\n${p.method.script}`;
300
+ const copyToClipboardInput = 'Copy Script to Clipboard';
301
+ const choice = await displayNotificationWithInput('Information', prompt, [copyToClipboardInput], 'Close');
302
+ if (choice === copyToClipboardInput) {
303
+ await env.clipboard.writeText(p.method.script);
304
+ }
305
+ }
306
+ async function displayStickyManualInstallationPrompt(severity, reason, p, options, otherItems = []) {
307
+ let reasonPrefix = '';
308
+ if (reason !== undefined) {
309
+ reasonPrefix = `${reason} `;
310
+ }
311
+ const script = p.method.script;
312
+ if (script === undefined) {
313
+ await displayModalNotification(severity, `${reasonPrefix}Please install ${missingDepsSentence(p)} and restart VS Code.`);
314
+ return Disposable.from();
315
+ }
316
+ const prompt = `${reasonPrefix}Please install ${missingDepsSentence(p)} from a [terminal](command:workbench.action.terminal.new) using the script below and restart VS Code.\n\n${script}`;
317
+ const copyToClipboardItem = {
318
+ input: 'Copy Script to Clipboard',
319
+ continueDisplaying: true,
320
+ action: async () => {
321
+ await env.clipboard.writeText(script);
322
+ },
323
+ };
324
+ return displayStickyNotificationWithOptionalInput(severity, prompt, options, [copyToClipboardItem, ...otherItems]);
325
+ }
326
+ export function missingDepsSentence(p) {
327
+ return sentenceJoin(missingDeps(p).map(d => '`' + d + '`'));
328
+ }
329
+ export function sentenceJoin(entries) {
330
+ if (entries.length === 0) {
331
+ throw new Error('Cannot join empty array.');
332
+ }
333
+ if (entries.length === 1) {
334
+ return entries[0];
335
+ }
336
+ if (entries.length === 2) {
337
+ return `${entries[0]} and ${entries[1]}`;
338
+ }
339
+ return `${entries.slice(0, entries.length - 1).join(', ')} and ${entries[entries.length - 1]}`;
340
+ }
341
+ export function missingDeps(p) {
342
+ const missingDeps = [];
343
+ if (!p.isGitAvailable) {
344
+ missingDeps.push('git');
345
+ }
346
+ if (!p.isCurlAvailable) {
347
+ missingDeps.push('curl');
348
+ }
349
+ return missingDeps;
350
+ }
351
+ function installDependenciesPrompt(reason, p) {
352
+ if (p.method.kind === 'Manual') {
353
+ throw new Error('cannot display installDependenciesPrompt for manual installation');
354
+ }
355
+ let reasonPrefix = '';
356
+ if (reason !== undefined) {
357
+ reasonPrefix = `${reason} `;
358
+ }
359
+ return `${reasonPrefix}Do you wish to install ${missingDepsSentence(p)}?`;
360
+ }
361
+ export function unsuccessfulDependencyInstallationPrompt(p) {
362
+ if (p.method.kind === 'Manual') {
363
+ throw new Error('cannot display unsuccessfulDependencyInstallationPrompt for manual installation');
364
+ }
365
+ if (p.method.manualBackupScript === undefined) {
366
+ return `Installation of ${missingDepsSentence(p)} unsuccessful.`;
367
+ }
368
+ return `Installation of ${missingDepsSentence(p)} unsuccessful.
369
+ If you are unable to figure out the issue from the command output below, you can also try running the following manual installation script from a terminal:
370
+
371
+ ${p.method.manualBackupScript}`;
372
+ }
@@ -1,6 +1,6 @@
1
1
  import * as fs from 'fs';
2
2
  import path from 'path';
3
- import { FileUri, isWorkspaceFolder, UntitledUri } from './exturi';
3
+ import { FileUri, UntitledUri } from './exturi';
4
4
  import { dirExists, fileExists } from './fsHelper';
5
5
  // Detect lean4 root directory (works for both lean4 repo and nightly distribution)
6
6
  export async function isCoreLean4Directory(path) {
@@ -26,57 +26,58 @@ export async function findLeanProjectRootInfo(uri) {
26
26
  if (uri.scheme === 'untitled') {
27
27
  return { kind: 'Success', projectRootUri: new UntitledUri(), toolchainUri: undefined };
28
28
  }
29
- let path = uri;
29
+ // lean4monaco: Prevent filesystem access:
30
+ return { kind: 'Success', projectRootUri: uri.join('..'), toolchainUri: undefined };
31
+ /*
32
+ let path = uri
30
33
  try {
31
34
  if ((await fs.promises.stat(path.fsPath)).isFile()) {
32
- path = uri.join('..');
35
+ path = uri.join('..')
33
36
  }
37
+ } catch (e) {
38
+ return { kind: 'FileNotFound' }
34
39
  }
35
- catch (e) {
36
- return { kind: 'FileNotFound' };
37
- }
38
- let bestFolder = path;
39
- let bestLeanToolchain;
40
+
41
+ let bestFolder = path
42
+ let bestLeanToolchain: FileUri | undefined
40
43
  while (true) {
41
- const leanToolchain = path.join('lean-toolchain');
42
- const lakefileLean = path.join('lakefile.lean');
43
- const lakefileToml = path.join('lakefile.toml');
44
+ const leanToolchain = path.join('lean-toolchain')
45
+ const lakefileLean = path.join('lakefile.lean')
46
+ const lakefileToml = path.join('lakefile.toml')
44
47
  if (await fileExists(leanToolchain.fsPath)) {
45
- bestFolder = path;
46
- bestLeanToolchain = leanToolchain;
47
- }
48
- else if (await isCoreLean4Directory(path)) {
49
- bestFolder = path;
50
- bestLeanToolchain = undefined;
48
+ bestFolder = path
49
+ bestLeanToolchain = leanToolchain
50
+ } else if (await isCoreLean4Directory(path)) {
51
+ bestFolder = path
52
+ bestLeanToolchain = undefined
51
53
  // Stop searching in case users accidentally created a lean-toolchain file above the core directory
52
- break;
53
- }
54
- else if (await fileExists(lakefileLean.fsPath)) {
55
- return { kind: 'LakefileWithoutToolchain', projectRootUri: path, lakefileUri: lakefileLean };
56
- }
57
- else if (await fileExists(lakefileToml.fsPath)) {
58
- return { kind: 'LakefileWithoutToolchain', projectRootUri: path, lakefileUri: lakefileToml };
54
+ break
55
+ } else if (await fileExists(lakefileLean.fsPath)) {
56
+ return { kind: 'LakefileWithoutToolchain', projectRootUri: path, lakefileUri: lakefileLean }
57
+ } else if (await fileExists(lakefileToml.fsPath)) {
58
+ return { kind: 'LakefileWithoutToolchain', projectRootUri: path, lakefileUri: lakefileToml }
59
59
  }
60
60
  if (isWorkspaceFolder(path)) {
61
61
  if (bestLeanToolchain === undefined) {
62
62
  // If we haven't found a toolchain yet, prefer the workspace folder as the project scope for the file,
63
63
  // but keep looking in case there is a lean-toolchain above the workspace folder
64
64
  // (New users sometimes accidentally open sub-folders of projects)
65
- bestFolder = path;
66
- }
67
- else {
65
+ bestFolder = path
66
+ } else {
68
67
  // Stop looking above the barrier if we have a toolchain. This is necessary for the nested lean-toolchain setup of core.
69
- break;
68
+ break
70
69
  }
71
70
  }
72
- const parent = path.join('..');
71
+ const parent = path.join('..')
73
72
  if (parent.equals(path)) {
74
73
  // no project file found.
75
- break;
74
+ break
76
75
  }
77
- path = parent;
76
+ path = parent
78
77
  }
79
- return { kind: 'Success', projectRootUri: bestFolder, toolchainUri: bestLeanToolchain };
78
+
79
+ return { kind: 'Success', projectRootUri: bestFolder, toolchainUri: bestLeanToolchain }
80
+ */
80
81
  }
81
82
  export async function findLeanProjectInfo(uri) {
82
83
  const info = await findLeanProjectRootInfo(uri);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lean4monaco",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Monaco Editor support for the Lean 4 theorem prover.",
5
5
  "keywords": [
6
6
  "lean",
@@ -39,7 +39,10 @@
39
39
  "watch:copyfiles": "nodemon --watch ./src --exec \"npm run build:copyfiles\"",
40
40
  "build:copyfiles": "cd src && copyfiles \"**/*.json\" \"**/*.css\" \"**/*.ttf\" \"**/*.otf\" \"**/*.svg\" ../dist/",
41
41
  "build": "tsc && webpack && npm run build:copyfiles",
42
- "test": "npm run demo:setup && concurrently --hide 0 --kill-others \"npm start\" \"wait-on http://localhost:5173 && cypress run\" -n server,cypress -s command-cypress"
42
+ "test:bare": "wait-on http://localhost:5173 && cypress run",
43
+ "test": "npm run demo:setup && concurrently --hide 0 --kill-others \"npm start\" \"npm run test:bare\" -n server,cypress -s command-cypress",
44
+ "test:windows:bare": "wait-on http://localhost:5173 && CYPRESS_USER_AGENT_OS=\"Windows NT 10.0; Win64; x64\" cypress run --browser chromium",
45
+ "test:windows": "npm run demo:setup && concurrently --hide 0 --kill-others \"npm start\" \"npm run test:windows:bare\" -n server,cypress -s command-cypress"
43
46
  },
44
47
  "dependencies": {
45
48
  "@leanprover/infoview": "~0.8.5",
Binary file
Binary file
@@ -1,5 +0,0 @@
1
- /** @module See `rollup.config.js` for what this file does. */
2
- import * as ReactDOM from 'react-dom';
3
- import { createPortal, createRoot, findDOMNode, flushSync, hydrate, hydrateRoot, render, unmountComponentAtNode, unstable_batchedUpdates, unstable_renderSubtreeIntoContainer, version, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } from 'react-dom';
4
- export default ReactDOM;
5
- export { __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, createPortal, createRoot, findDOMNode, flushSync, hydrate, hydrateRoot, render, unmountComponentAtNode, unstable_batchedUpdates, unstable_renderSubtreeIntoContainer, version, };
@@ -1,5 +0,0 @@
1
- /** @module See `rollup.config.js` for what this file does. */
2
- import * as Jsx from 'react/jsx-runtime';
3
- import { Fragment, jsx, jsxs } from 'react/jsx-runtime';
4
- export default Jsx;
5
- export { Fragment, jsx, jsxs };
@@ -1,5 +0,0 @@
1
- /** @module See `rollup.config.js` for what this file does. */
2
- import * as React from 'react';
3
- export default React;
4
- import { Children, cloneElement, Component, createContext, createElement, createFactory, createRef, forwardRef, Fragment, isValidElement, lazy, memo, Profiler, PureComponent, startTransition, StrictMode, Suspense, unstable_act, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition, version, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED } from 'react';
5
- export { Children, Component, Fragment, Profiler, PureComponent, StrictMode, Suspense, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, cloneElement, createContext, createElement, createFactory, createRef, forwardRef, isValidElement, lazy, memo, startTransition, unstable_act, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition, version, };