@codingame/monaco-vscode-output-service-override 1.82.4-next.1 → 1.82.5-next.0

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.
package/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { default } from 'vscode/service-override/output'
1
+ export { default } from './output.js';
package/index.js CHANGED
@@ -1 +1 @@
1
- export { default } from 'vscode/service-override/output'
1
+ export { default } from 'vscode/service-override/output';
package/output.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { IEditorOverrideServices } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
2
+ import { LogLevel } from 'vscode/vscode/vs/platform/log/common/log';
3
+
4
+ declare function getServiceOverride(logLevel?: LogLevel): IEditorOverrideServices;
5
+
6
+ export { getServiceOverride as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-output-service-override",
3
- "version": "1.82.4-next.1",
3
+ "version": "1.82.5-next.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,7 +18,7 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@1.82.4-next.1",
21
+ "vscode": "npm:@codingame/monaco-vscode-api@1.82.5-next.0",
22
22
  "monaco-editor": "0.43.0"
23
23
  },
24
24
  "exports": {
@@ -0,0 +1,131 @@
1
+ import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
2
+ import * as extpath from 'monaco-editor/esm/vs/base/common/extpath.js';
3
+ import * as resources from 'monaco-editor/esm/vs/base/common/resources.js';
4
+ import * as strings from 'monaco-editor/esm/vs/base/common/strings.js';
5
+ import { Range } from 'monaco-editor/esm/vs/editor/common/core/range.js';
6
+ import { isWindows } from 'monaco-editor/esm/vs/base/common/platform.js';
7
+ import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
8
+
9
+ class OutputLinkComputer {
10
+ constructor(ctx, createData) {
11
+ this.ctx = ctx;
12
+ this.patterns = ( new Map());
13
+ this.computePatterns(createData);
14
+ }
15
+ computePatterns(createData) {
16
+ const workspaceFolders = ( createData.workspaceFolders
17
+ .sort((resourceStrA, resourceStrB) => resourceStrB.length - resourceStrA.length)
18
+ .map(resourceStr => ( URI.parse(resourceStr))));
19
+ for (const workspaceFolder of workspaceFolders) {
20
+ const patterns = OutputLinkComputer.createPatterns(workspaceFolder);
21
+ this.patterns.set(workspaceFolder, patterns);
22
+ }
23
+ }
24
+ getModel(uri) {
25
+ const models = this.ctx.getMirrorModels();
26
+ return models.find(model => ( model.uri.toString()) === uri);
27
+ }
28
+ computeLinks(uri) {
29
+ const model = this.getModel(uri);
30
+ if (!model) {
31
+ return [];
32
+ }
33
+ const links = [];
34
+ const lines = strings.splitLines(model.getValue());
35
+ for (const [folderUri, folderPatterns] of this.patterns) {
36
+ const resourceCreator = {
37
+ toResource: (folderRelativePath) => {
38
+ if (typeof folderRelativePath === 'string') {
39
+ return resources.joinPath(folderUri, folderRelativePath);
40
+ }
41
+ return null;
42
+ }
43
+ };
44
+ for (let i = 0, len = lines.length; i < len; i++) {
45
+ links.push(...OutputLinkComputer.detectLinks(lines[i], i + 1, folderPatterns, resourceCreator));
46
+ }
47
+ }
48
+ return links;
49
+ }
50
+ static createPatterns(workspaceFolder) {
51
+ const patterns = [];
52
+ const workspaceFolderPath = workspaceFolder.scheme === Schemas.file ? workspaceFolder.fsPath : workspaceFolder.path;
53
+ const workspaceFolderVariants = [workspaceFolderPath];
54
+ if (isWindows && workspaceFolder.scheme === Schemas.file) {
55
+ workspaceFolderVariants.push(extpath.toSlashes(workspaceFolderPath));
56
+ }
57
+ for (const workspaceFolderVariant of workspaceFolderVariants) {
58
+ const validPathCharacterPattern = '[^\\s\\(\\):<>"]';
59
+ const validPathCharacterOrSpacePattern = `(?:${validPathCharacterPattern}| ${validPathCharacterPattern})`;
60
+ const pathPattern = `${validPathCharacterOrSpacePattern}+\\.${validPathCharacterPattern}+`;
61
+ const strictPathPattern = `${validPathCharacterPattern}+`;
62
+ patterns.push(( new RegExp(
63
+ strings.escapeRegExpCharacters(workspaceFolderVariant) + `(${pathPattern}) on line ((\\d+)(, column (\\d+))?)`,
64
+ 'gi'
65
+ )));
66
+ patterns.push(( new RegExp(
67
+ strings.escapeRegExpCharacters(workspaceFolderVariant) + `(${pathPattern}):line ((\\d+)(, column (\\d+))?)`,
68
+ 'gi'
69
+ )));
70
+ patterns.push(( new RegExp(
71
+ strings.escapeRegExpCharacters(workspaceFolderVariant) + `(${pathPattern})(\\s?\\((\\d+)(,(\\d+))?)\\)`,
72
+ 'gi'
73
+ )));
74
+ patterns.push(( new RegExp(
75
+ strings.escapeRegExpCharacters(workspaceFolderVariant) + `(${strictPathPattern})(:(\\d+))?(:(\\d+))?`,
76
+ 'gi'
77
+ )));
78
+ }
79
+ return patterns;
80
+ }
81
+ static detectLinks(line, lineIndex, patterns, resourceCreator) {
82
+ const links = [];
83
+ patterns.forEach(pattern => {
84
+ pattern.lastIndex = 0;
85
+ let match;
86
+ let offset = 0;
87
+ while ((match = pattern.exec(line)) !== null) {
88
+ const folderRelativePath = strings.rtrim(match[1], '.').replace(/\\/g, '/');
89
+ let resourceString;
90
+ try {
91
+ const resource = resourceCreator.toResource(folderRelativePath);
92
+ if (resource) {
93
+ resourceString = ( resource.toString());
94
+ }
95
+ }
96
+ catch (error) {
97
+ continue;
98
+ }
99
+ if (match[3]) {
100
+ const lineNumber = match[3];
101
+ if (match[5]) {
102
+ const columnNumber = match[5];
103
+ resourceString = strings.format('{0}#{1},{2}', resourceString, lineNumber, columnNumber);
104
+ }
105
+ else {
106
+ resourceString = strings.format('{0}#{1}', resourceString, lineNumber);
107
+ }
108
+ }
109
+ const fullMatch = strings.rtrim(match[0], '.');
110
+ const index = line.indexOf(fullMatch, offset);
111
+ offset = index + fullMatch.length;
112
+ const linkRange = {
113
+ startColumn: index + 1,
114
+ startLineNumber: lineIndex,
115
+ endColumn: index + 1 + fullMatch.length,
116
+ endLineNumber: lineIndex
117
+ };
118
+ if (( links.some(link => Range.areIntersectingOrTouching(link.range, linkRange)))) {
119
+ return;
120
+ }
121
+ links.push({
122
+ range: linkRange,
123
+ url: resourceString
124
+ });
125
+ }
126
+ });
127
+ return links;
128
+ }
129
+ }
130
+
131
+ export { OutputLinkComputer };
package/worker.js CHANGED
@@ -1 +1 @@
1
- import 'vscode/workers/outputLinkComputer.worker'
1
+ import './workers/outputLinkComputer.worker.js';
@@ -0,0 +1,4 @@
1
+ import { initialize } from 'monaco-editor/esm/vs/editor/editor.worker.js';
2
+ import { OutputLinkComputer } from '../vscode/src/vs/workbench/contrib/output/common/outputLinkComputer.js';
3
+
4
+ initialize((ctx, createData) => new OutputLinkComputer(ctx, createData));