@vscode/test-web 0.0.56 → 0.0.58

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/CHANGELOG.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Changelog
2
+ ## 0.0.58
3
+ * new option `--commit` to specify the build of VS Code to use. By default the latest build is used.
4
+
2
5
  ## 0.0.37
3
6
  * new option `--testRunnerDataDir` to set the temporary folder for storing the VS Code builds used for running the tests
4
7
 
5
-
6
8
  ## 0.0.28
7
9
  * new option `--coi` to enable cross origin isolation.
8
10
 
package/README.md CHANGED
@@ -80,6 +80,7 @@ CLI options:
80
80
  | --extensionDevelopmentPath | A path pointing to an extension under development to include. |
81
81
  | --extensionTestsPath | A path to a test module to run. |
82
82
  | --quality | `insiders` (default), or `stable`. Ignored when sourcesPath is provided. |
83
+ | --commit | commitHash The servion of the server to use. Defaults to latest build version of the given quality. Ignored when sourcesPath is provided. |
83
84
  | --sourcesPath | If set, runs the server from VS Code sources located at the given path. Make sure the sources and extensions are compiled (`yarn compile` and `yarn compile-web`). |
84
85
  | --headless | If set, hides the browser. Defaults to true when an extensionTestsPath is provided, otherwise false. |
85
86
  | --permission | Permission granted to the opened browser: e.g. `clipboard-read`, `clipboard-write`. See [full list of options](https://playwright.dev/docs/api/class-browsercontext#browser-context-grant-permissions). Argument can be provided multiple times. |
@@ -0,0 +1,49 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+
6
+ import header from "@tony.ganchev/eslint-plugin-header";
7
+ import tsParser from "@typescript-eslint/parser";
8
+ import path from "node:path";
9
+ import { fileURLToPath } from "node:url";
10
+ import js from "@eslint/js";
11
+ import { FlatCompat } from "@eslint/eslintrc";
12
+
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = path.dirname(__filename);
15
+ const compat = new FlatCompat({
16
+ baseDirectory: __dirname,
17
+ recommendedConfig: js.configs.recommended,
18
+ allConfig: js.configs.all
19
+ });
20
+
21
+ export default [{
22
+ ignores: ["**/*.d.ts", "**/*.test.ts", "**/*.js", "sample/**/*.*"],
23
+ }, ...compat.extends("plugin:@typescript-eslint/recommended"), {
24
+ plugins: {
25
+ header,
26
+ },
27
+
28
+ languageOptions: {
29
+ parser: tsParser,
30
+ ecmaVersion: 2018,
31
+ sourceType: "module",
32
+ },
33
+
34
+ rules: {
35
+ "@typescript-eslint/no-use-before-define": "off",
36
+ "@typescript-eslint/explicit-function-return-type": "off",
37
+ "@typescript-eslint/no-explicit-any": "off",
38
+ "@typescript-eslint/no-non-null-assertion": "off",
39
+ "@typescript-eslint/explicit-module-boundary-types": "off",
40
+ "@typescript-eslint/no-unused-vars": "off",
41
+ "@typescript-eslint/no-var-requires": "error",
42
+
43
+ "header/header": [
44
+ 2,
45
+ "block",
46
+ ["---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------"],
47
+ ],
48
+ },
49
+ }];
@@ -4,7 +4,7 @@
4
4
  /* 1 */
5
5
  /***/ ((__unused_webpack_module, exports) => {
6
6
 
7
- (()=>{"use strict";var e={};(()=>{var r=e;Object.defineProperty(r,"__esModule",{value:!0}),r.getErrorStatusDescription=r.xhr=r.configure=void 0,r.configure=(e,r)=>{},r.xhr=async e=>{const r=new Headers;if(e.headers)for(const t in e.headers){const o=e.headers[t];Array.isArray(o)?o.forEach((e=>r.set(t,e))):r.set(t,o)}e.user&&e.password&&r.set("Authorization","Basic "+btoa(e.user+":"+e.password));const t={method:e.type,redirect:e.followRedirects>0?"follow":"manual",mode:"cors",headers:r};if(e.data&&(t.body=e.data),e.token){const r=new AbortController;e.token.isCancellationRequested&&r.abort(),e.token.onCancellationRequested((()=>{r.abort()})),t.signal=r.signal}const o=new Request(e.url,t),s=await fetch(o),a={};s.headers.forEach(((e,r)=>{a[r]=e}));const n=await s.arrayBuffer();return new class{constructor(){this.status=s.status,this.headers=a}get responseText(){return(new TextDecoder).decode(n)}get body(){return new Uint8Array(n)}}},r.getErrorStatusDescription=function(e){return String(e)}})();var r=exports;for(var t in e)r[t]=e[t];e.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
7
+ (()=>{"use strict";var e={};(()=>{var r=e;Object.defineProperty(r,"__esModule",{value:!0}),r.xhr=r.configure=void 0,r.getErrorStatusDescription=function(e){return String(e)},r.configure=(e,r)=>{},r.xhr=async e=>{const r=new Headers;if(e.headers)for(const t in e.headers){const o=e.headers[t];Array.isArray(o)?o.forEach((e=>r.set(t,e))):r.set(t,o)}e.user&&e.password&&r.set("Authorization","Basic "+btoa(e.user+":"+e.password));const t={method:e.type,redirect:e.followRedirects>0?"follow":"manual",mode:"cors",headers:r};if(e.data&&(t.body=e.data),e.token){const r=new AbortController;e.token.isCancellationRequested&&r.abort(),e.token.onCancellationRequested((()=>{r.abort()})),t.signal=r.signal}const o=new Request(e.url,t),s=await fetch(o),a={};s.headers.forEach(((e,r)=>{a[r]=e}));const n=await s.arrayBuffer();return new class{constructor(){this.status=s.status,this.headers=a}get responseText(){return(new TextDecoder).decode(n)}get body(){return new Uint8Array(n)}}}})();var r=exports;for(var t in e)r[t]=e[t];e.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
8
8
 
9
9
  /***/ }),
10
10
  /* 2 */
@@ -35,14 +35,13 @@ function modifiedFileStat(stats, size) {
35
35
  return Promise.resolve({ type: stats.type, ctime: stats.ctime, mtime: Date.now(), size: size ?? stats.size });
36
36
  }
37
37
  class MemFileSystemProvider {
38
+ scheme;
39
+ root;
40
+ extensionUri;
38
41
  constructor(scheme, root, extensionUri) {
39
42
  this.scheme = scheme;
40
43
  this.root = root;
41
44
  this.extensionUri = extensionUri;
42
- // --- manage file events
43
- this._onDidChangeFile = new vscode_1.EventEmitter();
44
- this.onDidChangeFile = this._onDidChangeFile.event;
45
- this._bufferedChanges = [];
46
45
  }
47
46
  // --- manage file metadata
48
47
  async stat(resource) {
@@ -131,12 +130,14 @@ class MemFileSystemProvider {
131
130
  // Pattern is always blank: https://github.com/microsoft/vscode/issues/200892
132
131
  const glob = pattern ? new minimatch_1.Minimatch(pattern) : undefined;
133
132
  const result = [];
134
- const dive = async (currentDirectory, pathSegments = []) => {
135
- for (const [name, entry] of await currentDirectory.entries) {
133
+ const dive = async (folderUri) => {
134
+ const directory = await this._lookupAsDirectory(folderUri, false);
135
+ for (const [name, entry] of await directory.entries) {
136
+ /* support options.includes && options.excludes */
136
137
  if (typeof options.maxResults !== 'undefined' && result.length >= options.maxResults) {
137
138
  break;
138
139
  }
139
- const uri = vscode_1.Uri.joinPath(this.extensionUri, ...pathSegments, entry.name);
140
+ const uri = vscode_1.Uri.joinPath(folderUri, entry.name);
140
141
  if (entry.type === vscode_1.FileType.File) {
141
142
  const toMatch = uri.toString();
142
143
  // Pattern is always blank: https://github.com/microsoft/vscode/issues/200892
@@ -145,11 +146,11 @@ class MemFileSystemProvider {
145
146
  }
146
147
  }
147
148
  else if (entry.type === vscode_1.FileType.Directory) {
148
- await dive(entry, [...pathSegments, name]);
149
+ await dive(uri);
149
150
  }
150
151
  }
151
152
  };
152
- await dive(this.root);
153
+ await dive(options.folder);
153
154
  return result;
154
155
  }
155
156
  async _lookup(uri, silent) {
@@ -204,6 +205,11 @@ class MemFileSystemProvider {
204
205
  const dirname = vscode_uri_1.Utils.dirname(uri);
205
206
  return this._lookupAsDirectory(dirname, false);
206
207
  }
208
+ // --- manage file events
209
+ _onDidChangeFile = new vscode_1.EventEmitter();
210
+ onDidChangeFile = this._onDidChangeFile.event;
211
+ _bufferedChanges = [];
212
+ _fireSoonHandle;
207
213
  watch(resource, opts) {
208
214
  // ignore, fires for all changes...
209
215
  return vscode_1.Disposable.from();
@@ -2615,11 +2621,16 @@ function activate(context) {
2615
2621
  }
2616
2622
  exports.activate = activate;
2617
2623
  class ServerBackedFile {
2624
+ _serverRoot;
2625
+ pathSegments;
2626
+ name;
2627
+ type = vscode_1.FileType.File;
2628
+ _stats;
2629
+ _content;
2618
2630
  constructor(_serverRoot, pathSegments, name) {
2619
2631
  this._serverRoot = _serverRoot;
2620
2632
  this.pathSegments = pathSegments;
2621
2633
  this.name = name;
2622
- this.type = vscode_1.FileType.File;
2623
2634
  }
2624
2635
  get stats() {
2625
2636
  if (this._stats === undefined) {
@@ -2641,11 +2652,16 @@ class ServerBackedFile {
2641
2652
  }
2642
2653
  }
2643
2654
  class ServerBackedDirectory {
2655
+ _serverRoot;
2656
+ pathSegments;
2657
+ name;
2658
+ type = vscode_1.FileType.Directory;
2659
+ _stats;
2660
+ _entries;
2644
2661
  constructor(_serverRoot, pathSegments, name) {
2645
2662
  this._serverRoot = _serverRoot;
2646
2663
  this.pathSegments = pathSegments;
2647
2664
  this.name = name;
2648
- this.type = vscode_1.FileType.Directory;
2649
2665
  }
2650
2666
  get stats() {
2651
2667
  if (this._stats === undefined) {
@@ -9,14 +9,14 @@
9
9
  "version": "0.0.1",
10
10
  "license": "MIT",
11
11
  "devDependencies": {
12
- "@types/vscode": "^1.90.0",
13
- "minimatch": "9.0.5",
12
+ "@types/vscode": "^1.92.0",
13
+ "minimatch": "10.0.1",
14
14
  "path-browserify": "^1.0.1",
15
15
  "process": "^0.11.10",
16
- "request-light": "^0.7.0",
16
+ "request-light": "^0.8.0",
17
17
  "ts-loader": "^9.5.1",
18
18
  "vscode-uri": "^3.0.8",
19
- "webpack": "^5.92.1",
19
+ "webpack": "^5.94.0",
20
20
  "webpack-cli": "^5.1.4"
21
21
  },
22
22
  "engines": {
@@ -91,28 +91,6 @@
91
91
  "@jridgewell/sourcemap-codec": "^1.4.14"
92
92
  }
93
93
  },
94
- "node_modules/@types/eslint": {
95
- "version": "7.28.0",
96
- "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.28.0.tgz",
97
- "integrity": "sha512-07XlgzX0YJUn4iG1ocY4IX9DzKSmMGUs6ESKlxWhZRaa0fatIWaHWUVapcuGa8r5HFnTqzj+4OCjd5f7EZ/i/A==",
98
- "dev": true,
99
- "license": "MIT",
100
- "dependencies": {
101
- "@types/estree": "*",
102
- "@types/json-schema": "*"
103
- }
104
- },
105
- "node_modules/@types/eslint-scope": {
106
- "version": "3.7.3",
107
- "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.3.tgz",
108
- "integrity": "sha512-PB3ldyrcnAicT35TWPs5IcwKD8S333HMaa2VVv4+wdvebJkjWuW/xESoB8IwRcog8HYVYamb1g/R31Qv5Bx03g==",
109
- "dev": true,
110
- "license": "MIT",
111
- "dependencies": {
112
- "@types/eslint": "*",
113
- "@types/estree": "*"
114
- }
115
- },
116
94
  "node_modules/@types/estree": {
117
95
  "version": "1.0.5",
118
96
  "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
@@ -136,9 +114,9 @@
136
114
  }
137
115
  },
138
116
  "node_modules/@types/vscode": {
139
- "version": "1.90.0",
140
- "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.90.0.tgz",
141
- "integrity": "sha512-oT+ZJL7qHS9Z8bs0+WKf/kQ27qWYR3trsXpq46YDjFqBsMLG4ygGGjPaJ2tyrH0wJzjOEmDyg9PDJBBhWg9pkQ==",
117
+ "version": "1.92.0",
118
+ "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.92.0.tgz",
119
+ "integrity": "sha512-DcZoCj17RXlzB4XJ7IfKdPTcTGDLYvTOcTNkvtjXWF+K2TlKzHHkBEXNWQRpBIXixNEUgx39cQeTFunY0E2msw==",
142
120
  "dev": true
143
121
  },
144
122
  "node_modules/@webassemblyjs/ast": {
@@ -596,9 +574,9 @@
596
574
  "dev": true
597
575
  },
598
576
  "node_modules/enhanced-resolve": {
599
- "version": "5.17.0",
600
- "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.0.tgz",
601
- "integrity": "sha512-dwDPwZL0dmye8Txp2gzFmA6sxALaSvdRDjPH0viLcKrtlOL3tw62nWWweVD1SdILDTJrbrL6tdWVN58Wo6U3eA==",
577
+ "version": "5.17.1",
578
+ "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz",
579
+ "integrity": "sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==",
602
580
  "dev": true,
603
581
  "dependencies": {
604
582
  "graceful-fs": "^4.2.4",
@@ -958,14 +936,13 @@
958
936
  "dev": true
959
937
  },
960
938
  "node_modules/micromatch": {
961
- "version": "4.0.4",
962
- "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz",
963
- "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==",
939
+ "version": "4.0.8",
940
+ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
941
+ "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
964
942
  "dev": true,
965
- "license": "MIT",
966
943
  "dependencies": {
967
- "braces": "^3.0.1",
968
- "picomatch": "^2.2.3"
944
+ "braces": "^3.0.3",
945
+ "picomatch": "^2.3.1"
969
946
  },
970
947
  "engines": {
971
948
  "node": ">=8.6"
@@ -995,15 +972,15 @@
995
972
  }
996
973
  },
997
974
  "node_modules/minimatch": {
998
- "version": "9.0.5",
999
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
1000
- "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
975
+ "version": "10.0.1",
976
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz",
977
+ "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==",
1001
978
  "dev": true,
1002
979
  "dependencies": {
1003
980
  "brace-expansion": "^2.0.1"
1004
981
  },
1005
982
  "engines": {
1006
- "node": ">=16 || 14 >=14.17"
983
+ "node": "20 || >=22"
1007
984
  },
1008
985
  "funding": {
1009
986
  "url": "https://github.com/sponsors/isaacs"
@@ -1102,11 +1079,10 @@
1102
1079
  "dev": true
1103
1080
  },
1104
1081
  "node_modules/picomatch": {
1105
- "version": "2.3.0",
1106
- "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz",
1107
- "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==",
1082
+ "version": "2.3.1",
1083
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
1084
+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
1108
1085
  "dev": true,
1109
- "license": "MIT",
1110
1086
  "engines": {
1111
1087
  "node": ">=8.6"
1112
1088
  },
@@ -1170,11 +1146,10 @@
1170
1146
  }
1171
1147
  },
1172
1148
  "node_modules/request-light": {
1173
- "version": "0.7.0",
1174
- "resolved": "https://registry.npmjs.org/request-light/-/request-light-0.7.0.tgz",
1175
- "integrity": "sha512-lMbBMrDoxgsyO+yB3sDcrDuX85yYt7sS8BfQd11jtbW/z5ZWgLZRcEGLsLoYw7I0WSUGQBs8CC8ScIxkTX1+6Q==",
1176
- "dev": true,
1177
- "license": "MIT"
1149
+ "version": "0.8.0",
1150
+ "resolved": "https://registry.npmjs.org/request-light/-/request-light-0.8.0.tgz",
1151
+ "integrity": "sha512-bH6E4PMmsEXYrLX6Kr1vu+xI3HproB1vECAwaPSJeroLE1kpWE3HR27uB4icx+6YORu1ajqBJXxuedv8ZQg5Lw==",
1152
+ "dev": true
1178
1153
  },
1179
1154
  "node_modules/resolve": {
1180
1155
  "version": "1.22.1",
@@ -1550,12 +1525,11 @@
1550
1525
  }
1551
1526
  },
1552
1527
  "node_modules/webpack": {
1553
- "version": "5.92.1",
1554
- "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.92.1.tgz",
1555
- "integrity": "sha512-JECQ7IwJb+7fgUFBlrJzbyu3GEuNBcdqr1LD7IbSzwkSmIevTm8PF+wej3Oxuz/JFBUZ6O1o43zsPkwm1C4TmA==",
1528
+ "version": "5.94.0",
1529
+ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.94.0.tgz",
1530
+ "integrity": "sha512-KcsGn50VT+06JH/iunZJedYGUJS5FGjow8wb9c0v5n1Om8O1g4L6LjtfxwlXIATopoQu+vOXXa7gYisWxCoPyg==",
1556
1531
  "dev": true,
1557
1532
  "dependencies": {
1558
- "@types/eslint-scope": "^3.7.3",
1559
1533
  "@types/estree": "^1.0.5",
1560
1534
  "@webassemblyjs/ast": "^1.12.1",
1561
1535
  "@webassemblyjs/wasm-edit": "^1.12.1",
@@ -1564,7 +1538,7 @@
1564
1538
  "acorn-import-attributes": "^1.9.5",
1565
1539
  "browserslist": "^4.21.10",
1566
1540
  "chrome-trace-event": "^1.0.2",
1567
- "enhanced-resolve": "^5.17.0",
1541
+ "enhanced-resolve": "^5.17.1",
1568
1542
  "es-module-lexer": "^1.2.1",
1569
1543
  "eslint-scope": "5.1.1",
1570
1544
  "events": "^3.2.0",
@@ -17,7 +17,8 @@
17
17
  "onSearch:vscode-test-web"
18
18
  ],
19
19
  "enabledApiProposals": [
20
- "fileSearchProvider"
20
+ "fileSearchProvider",
21
+ "textSearchProvider"
21
22
  ],
22
23
  "contributes": {
23
24
  "resourceLabelFormatters": [
@@ -39,14 +40,14 @@
39
40
  "package-web": "webpack --mode production --devtool hidden-source-map"
40
41
  },
41
42
  "devDependencies": {
42
- "@types/vscode": "^1.90.0",
43
- "minimatch": "9.0.5",
43
+ "@types/vscode": "^1.92.0",
44
+ "minimatch": "10.0.1",
44
45
  "ts-loader": "^9.5.1",
45
- "webpack": "^5.92.1",
46
+ "webpack": "^5.94.0",
46
47
  "webpack-cli": "^5.1.4",
47
48
  "process": "^0.11.10",
48
49
  "path-browserify": "^1.0.1",
49
- "request-light": "^0.7.0",
50
+ "request-light": "^0.8.0",
50
51
  "vscode-uri": "^3.0.8"
51
52
  }
52
53
  }
@@ -0,0 +1,2 @@
1
+ {
2
+ }
@@ -0,0 +1,207 @@
1
+ define("vscode-web-browser-main", ["require", "exports", "./workbench.api"], function (require, exports, workbench_api_1) {
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ class WorkspaceProvider {
5
+ workspace;
6
+ payload;
7
+ static QUERY_PARAM_EMPTY_WINDOW = 'ew';
8
+ static QUERY_PARAM_FOLDER = 'folder';
9
+ static QUERY_PARAM_WORKSPACE = 'workspace';
10
+ static QUERY_PARAM_PAYLOAD = 'payload';
11
+ static create(config) {
12
+ let foundWorkspace = false;
13
+ let workspace;
14
+ let payload = Object.create(null);
15
+ const query = new URL(document.location.href).searchParams;
16
+ query.forEach((value, key) => {
17
+ switch (key) {
18
+ case WorkspaceProvider.QUERY_PARAM_FOLDER:
19
+ workspace = { folderUri: workbench_api_1.URI.parse(value) };
20
+ foundWorkspace = true;
21
+ break;
22
+ case WorkspaceProvider.QUERY_PARAM_WORKSPACE:
23
+ workspace = { workspaceUri: workbench_api_1.URI.parse(value) };
24
+ foundWorkspace = true;
25
+ break;
26
+ case WorkspaceProvider.QUERY_PARAM_EMPTY_WINDOW:
27
+ workspace = undefined;
28
+ foundWorkspace = true;
29
+ break;
30
+ case WorkspaceProvider.QUERY_PARAM_PAYLOAD:
31
+ try {
32
+ payload = JSON.parse(value);
33
+ }
34
+ catch (error) {
35
+ console.error(error);
36
+ }
37
+ break;
38
+ }
39
+ });
40
+ if (!foundWorkspace) {
41
+ if (config.folderUri) {
42
+ workspace = { folderUri: workbench_api_1.URI.revive(config.folderUri) };
43
+ }
44
+ else if (config.workspaceUri) {
45
+ workspace = { workspaceUri: workbench_api_1.URI.revive(config.workspaceUri) };
46
+ }
47
+ }
48
+ return new WorkspaceProvider(workspace, payload);
49
+ }
50
+ trusted = true;
51
+ constructor(workspace, payload) {
52
+ this.workspace = workspace;
53
+ this.payload = payload;
54
+ }
55
+ async open(workspace, options) {
56
+ if (options?.reuse && !options.payload && this.isSame(this.workspace, workspace)) {
57
+ return true;
58
+ }
59
+ const targetHref = this.createTargetUrl(workspace, options);
60
+ if (targetHref) {
61
+ if (options?.reuse) {
62
+ window.location.href = targetHref;
63
+ return true;
64
+ }
65
+ else {
66
+ return !!window.open(targetHref);
67
+ }
68
+ }
69
+ return false;
70
+ }
71
+ createTargetUrl(workspace, options) {
72
+ let targetHref = undefined;
73
+ if (!workspace) {
74
+ targetHref = `${document.location.origin}${document.location.pathname}?${WorkspaceProvider.QUERY_PARAM_EMPTY_WINDOW}=true`;
75
+ }
76
+ else if ('folderUri' in workspace) {
77
+ const queryParamFolder = encodeURIComponent(workspace.folderUri.toString(true));
78
+ targetHref = `${document.location.origin}${document.location.pathname}?${WorkspaceProvider.QUERY_PARAM_FOLDER}=${queryParamFolder}`;
79
+ }
80
+ else if ('workspaceUri' in workspace) {
81
+ const queryParamWorkspace = encodeURIComponent(workspace.workspaceUri.toString(true));
82
+ targetHref = `${document.location.origin}${document.location.pathname}?${WorkspaceProvider.QUERY_PARAM_WORKSPACE}=${queryParamWorkspace}`;
83
+ }
84
+ if (options?.payload) {
85
+ targetHref += `&${WorkspaceProvider.QUERY_PARAM_PAYLOAD}=${encodeURIComponent(JSON.stringify(options.payload))}`;
86
+ }
87
+ return targetHref;
88
+ }
89
+ isSame(workspaceA, workspaceB) {
90
+ if (!workspaceA || !workspaceB) {
91
+ return workspaceA === workspaceB;
92
+ }
93
+ if ('folderUri' in workspaceA && 'folderUri' in workspaceB) {
94
+ return this.isEqualURI(workspaceA.folderUri, workspaceB.folderUri);
95
+ }
96
+ if ('workspaceUri' in workspaceA && 'workspaceUri' in workspaceB) {
97
+ return this.isEqualURI(workspaceA.workspaceUri, workspaceB.workspaceUri);
98
+ }
99
+ return false;
100
+ }
101
+ isEqualURI(a, b) {
102
+ return a.scheme === b.scheme && a.authority === b.authority && a.path === b.path;
103
+ }
104
+ }
105
+ class LocalStorageURLCallbackProvider {
106
+ _callbackRoute;
107
+ static REQUEST_ID = 0;
108
+ static QUERY_KEYS = [
109
+ 'scheme',
110
+ 'authority',
111
+ 'path',
112
+ 'query',
113
+ 'fragment'
114
+ ];
115
+ _onCallback = new workbench_api_1.Emitter();
116
+ onCallback = this._onCallback.event;
117
+ pendingCallbacks = new Set();
118
+ lastTimeChecked = Date.now();
119
+ checkCallbacksTimeout = undefined;
120
+ onDidChangeLocalStorageDisposable;
121
+ constructor(_callbackRoute) {
122
+ this._callbackRoute = _callbackRoute;
123
+ }
124
+ create(options = {}) {
125
+ const id = ++LocalStorageURLCallbackProvider.REQUEST_ID;
126
+ const queryParams = [`vscode-reqid=${id}`];
127
+ for (const key of LocalStorageURLCallbackProvider.QUERY_KEYS) {
128
+ const value = options[key];
129
+ if (value) {
130
+ queryParams.push(`vscode-${key}=${encodeURIComponent(value)}`);
131
+ }
132
+ }
133
+ if (!(options.authority === 'vscode.github-authentication' && options.path === '/dummy')) {
134
+ const key = `vscode-web.url-callbacks[${id}]`;
135
+ localStorage.removeItem(key);
136
+ this.pendingCallbacks.add(id);
137
+ this.startListening();
138
+ }
139
+ return workbench_api_1.URI.parse(window.location.href).with({ path: this._callbackRoute, query: queryParams.join('&') });
140
+ }
141
+ startListening() {
142
+ if (this.onDidChangeLocalStorageDisposable) {
143
+ return;
144
+ }
145
+ const fn = () => this.onDidChangeLocalStorage();
146
+ window.addEventListener('storage', fn);
147
+ this.onDidChangeLocalStorageDisposable = { dispose: () => window.removeEventListener('storage', fn) };
148
+ }
149
+ stopListening() {
150
+ this.onDidChangeLocalStorageDisposable?.dispose();
151
+ this.onDidChangeLocalStorageDisposable = undefined;
152
+ }
153
+ async onDidChangeLocalStorage() {
154
+ const ellapsed = Date.now() - this.lastTimeChecked;
155
+ if (ellapsed > 1000) {
156
+ this.checkCallbacks();
157
+ }
158
+ else if (this.checkCallbacksTimeout === undefined) {
159
+ this.checkCallbacksTimeout = setTimeout(() => {
160
+ this.checkCallbacksTimeout = undefined;
161
+ this.checkCallbacks();
162
+ }, 1000 - ellapsed);
163
+ }
164
+ }
165
+ checkCallbacks() {
166
+ let pendingCallbacks;
167
+ for (const id of this.pendingCallbacks) {
168
+ const key = `vscode-web.url-callbacks[${id}]`;
169
+ const result = localStorage.getItem(key);
170
+ if (result !== null) {
171
+ try {
172
+ this._onCallback.fire(workbench_api_1.URI.revive(JSON.parse(result)));
173
+ }
174
+ catch (error) {
175
+ console.error(error);
176
+ }
177
+ pendingCallbacks = pendingCallbacks ?? new Set(this.pendingCallbacks);
178
+ pendingCallbacks.delete(id);
179
+ localStorage.removeItem(key);
180
+ }
181
+ }
182
+ if (pendingCallbacks) {
183
+ this.pendingCallbacks = pendingCallbacks;
184
+ if (this.pendingCallbacks.size === 0) {
185
+ this.stopListening();
186
+ }
187
+ }
188
+ this.lastTimeChecked = Date.now();
189
+ }
190
+ dispose() {
191
+ this._onCallback.dispose();
192
+ }
193
+ }
194
+ (function () {
195
+ const configElement = window.document.getElementById('vscode-workbench-web-configuration');
196
+ const configElementAttribute = configElement ? configElement.getAttribute('data-settings') : undefined;
197
+ if (!configElement || !configElementAttribute) {
198
+ throw new Error('Missing web configuration element');
199
+ }
200
+ const config = JSON.parse(configElementAttribute);
201
+ (0, workbench_api_1.create)(window.document.body, {
202
+ ...config,
203
+ workspaceProvider: WorkspaceProvider.create(config),
204
+ urlCallbackProvider: new LocalStorageURLCallbackProvider(config.callbackRoute)
205
+ });
206
+ })();
207
+ });