custom-electron-titlebar 3.2.6 → 3.2.10

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 (239) hide show
  1. package/.github/FUNDING.yml +1 -0
  2. package/README.md +15 -24
  3. package/_config.yml +1 -0
  4. package/{lib → build}/browser/browser.d.ts +0 -0
  5. package/{lib → build}/browser/browser.js +0 -0
  6. package/{lib → build}/browser/browser.js.map +0 -0
  7. package/{lib → build}/browser/event.d.ts +0 -0
  8. package/{lib → build}/browser/event.js +2 -1
  9. package/{lib → build}/browser/event.js.map +1 -1
  10. package/{lib → build}/browser/iframe.d.ts +0 -0
  11. package/{lib → build}/browser/iframe.js +0 -0
  12. package/{lib → build}/browser/iframe.js.map +0 -0
  13. package/{lib → build}/browser/keyboardEvent.d.ts +0 -0
  14. package/{lib → build}/browser/keyboardEvent.js +0 -0
  15. package/{lib → build}/browser/keyboardEvent.js.map +0 -0
  16. package/{lib → build}/browser/mouseEvent.d.ts +0 -0
  17. package/{lib → build}/browser/mouseEvent.js +0 -0
  18. package/{lib → build}/browser/mouseEvent.js.map +0 -0
  19. package/{lib → build}/common/arrays.d.ts +0 -0
  20. package/{lib → build}/common/arrays.js +0 -0
  21. package/{lib → build}/common/arrays.js.map +0 -0
  22. package/{lib → build}/common/async.d.ts +0 -0
  23. package/{lib → build}/common/async.js +0 -0
  24. package/{lib → build}/common/async.js.map +0 -0
  25. package/{lib → build}/common/charCode.d.ts +0 -0
  26. package/{lib → build}/common/charCode.js +0 -0
  27. package/{lib → build}/common/charCode.js.map +0 -0
  28. package/{lib → build}/common/color.d.ts +0 -0
  29. package/{lib → build}/common/color.js +0 -0
  30. package/{lib → build}/common/color.js.map +0 -0
  31. package/{lib → build}/common/dom.d.ts +0 -0
  32. package/{lib → build}/common/dom.js +16 -14
  33. package/build/common/dom.js.map +1 -0
  34. package/{lib → build}/common/event.d.ts +0 -0
  35. package/{lib → build}/common/event.js +1 -1
  36. package/build/common/event.js.map +1 -0
  37. package/{lib → build}/common/iterator.d.ts +0 -0
  38. package/{lib → build}/common/iterator.js +0 -0
  39. package/{lib → build}/common/iterator.js.map +0 -0
  40. package/{lib → build}/common/keyCodes.d.ts +0 -0
  41. package/{lib → build}/common/keyCodes.js +0 -0
  42. package/{lib → build}/common/keyCodes.js.map +0 -0
  43. package/{lib → build}/common/lifecycle.d.ts +0 -0
  44. package/{lib → build}/common/lifecycle.js +0 -0
  45. package/{lib → build}/common/lifecycle.js.map +0 -0
  46. package/{lib → build}/common/linkedList.d.ts +0 -0
  47. package/{lib → build}/common/linkedList.js +0 -0
  48. package/{lib → build}/common/linkedList.js.map +0 -0
  49. package/{lib → build}/common/platform.d.ts +0 -0
  50. package/{lib → build}/common/platform.js +0 -0
  51. package/{lib → build}/common/platform.js.map +0 -0
  52. package/{lib → build}/index.d.ts +0 -0
  53. package/{lib → build}/index.js +0 -0
  54. package/{lib → build}/index.js.map +0 -0
  55. package/{lib → build}/menu/menu.d.ts +0 -0
  56. package/{lib → build}/menu/menu.js +38 -38
  57. package/build/menu/menu.js.map +1 -0
  58. package/{lib → build}/menu/menuitem.d.ts +10 -2
  59. package/{lib → build}/menu/menuitem.js +70 -34
  60. package/build/menu/menuitem.js.map +1 -0
  61. package/{lib → build}/menubar.d.ts +0 -0
  62. package/{lib → build}/menubar.js +29 -30
  63. package/build/menubar.js.map +1 -0
  64. package/{lib → build}/themebar.d.ts +0 -0
  65. package/{lib → build}/themebar.js +2 -2
  66. package/build/themebar.js.map +1 -0
  67. package/{lib → build}/titlebar.d.ts +0 -0
  68. package/{lib → build}/titlebar.js +61 -58
  69. package/build/titlebar.js.map +1 -0
  70. package/package.json +13 -7
  71. package/lib/common/dom.js.map +0 -1
  72. package/lib/common/enableNativeMenuCommands.d.ts +0 -1
  73. package/lib/common/enableNativeMenuCommands.js +0 -32
  74. package/lib/common/enableNativeMenuCommands.js.map +0 -1
  75. package/lib/common/event.js.map +0 -1
  76. package/lib/main.d.ts +0 -1
  77. package/lib/main.js +0 -14
  78. package/lib/main.js.map +0 -1
  79. package/lib/menu/menu.js.map +0 -1
  80. package/lib/menu/menuitem.js.map +0 -1
  81. package/lib/menubar.js.map +0 -1
  82. package/lib/themebar.js.map +0 -1
  83. package/lib/titlebar.js.map +0 -1
  84. package/lib/vs/base/browser/browser.js +0 -150
  85. package/lib/vs/base/browser/canIUse.js +0 -58
  86. package/lib/vs/base/browser/codicons.js +0 -37
  87. package/lib/vs/base/browser/contextmenu.js +0 -9
  88. package/lib/vs/base/browser/dnd.js +0 -113
  89. package/lib/vs/base/browser/dom.js +0 -1417
  90. package/lib/vs/base/browser/event.js +0 -36
  91. package/lib/vs/base/browser/fastDomNode.js +0 -265
  92. package/lib/vs/base/browser/formattedTextRenderer.js +0 -248
  93. package/lib/vs/base/browser/globalMouseMoveMonitor.js +0 -137
  94. package/lib/vs/base/browser/history.js +0 -9
  95. package/lib/vs/base/browser/iframe.js +0 -126
  96. package/lib/vs/base/browser/keyboardEvent.js +0 -599
  97. package/lib/vs/base/browser/mouseEvent.js +0 -155
  98. package/lib/vs/base/browser/touch.js +0 -315
  99. package/lib/vs/base/browser/ui/actionbar/actionViewItems.js +0 -397
  100. package/lib/vs/base/browser/ui/actionbar/actionbar.js +0 -583
  101. package/lib/vs/base/browser/ui/checkbox/checkbox.js +0 -251
  102. package/lib/vs/base/browser/ui/codicons/codiconLabel.js +0 -31
  103. package/lib/vs/base/browser/ui/codicons/codiconStyles.js +0 -47
  104. package/lib/vs/base/browser/ui/contextview/contextview.js +0 -367
  105. package/lib/vs/base/browser/ui/dropdown/dropdown.js +0 -256
  106. package/lib/vs/base/browser/ui/dropdown/dropdownActionViewItem.js +0 -120
  107. package/lib/vs/base/browser/ui/keybindingLabel/keybindingLabel.js +0 -118
  108. package/lib/vs/base/browser/ui/list/list.js +0 -54
  109. package/lib/vs/base/browser/ui/list/listPaging.js +0 -322
  110. package/lib/vs/base/browser/ui/list/listView.js +0 -1388
  111. package/lib/vs/base/browser/ui/list/listWidget.js +0 -1709
  112. package/lib/vs/base/browser/ui/list/rangeMap.js +0 -223
  113. package/lib/vs/base/browser/ui/list/rowCache.js +0 -113
  114. package/lib/vs/base/browser/ui/list/splice.js +0 -23
  115. package/lib/vs/base/browser/ui/menu/menu.js +0 -1371
  116. package/lib/vs/base/browser/ui/menu/menubar.js +0 -1139
  117. package/lib/vs/base/browser/ui/scrollbar/abstractScrollbar.js +0 -278
  118. package/lib/vs/base/browser/ui/scrollbar/horizontalScrollbar.js +0 -115
  119. package/lib/vs/base/browser/ui/scrollbar/scrollableElement.js +0 -646
  120. package/lib/vs/base/browser/ui/scrollbar/scrollableElementOptions.js +0 -9
  121. package/lib/vs/base/browser/ui/scrollbar/scrollbarArrow.js +0 -106
  122. package/lib/vs/base/browser/ui/scrollbar/scrollbarState.js +0 -184
  123. package/lib/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.js +0 -116
  124. package/lib/vs/base/browser/ui/scrollbar/verticalScrollbar.js +0 -114
  125. package/lib/vs/base/browser/ui/selectBox/selectBox.js +0 -85
  126. package/lib/vs/base/browser/ui/selectBox/selectBoxCustom.js +0 -985
  127. package/lib/vs/base/browser/ui/selectBox/selectBoxNative.js +0 -188
  128. package/lib/vs/base/browser/ui/toolbar/toolbar.js +0 -206
  129. package/lib/vs/base/browser/ui/widget.js +0 -69
  130. package/lib/vs/base/common/actions.js +0 -224
  131. package/lib/vs/base/common/amd.js +0 -31
  132. package/lib/vs/base/common/arrays.js +0 -641
  133. package/lib/vs/base/common/assert.js +0 -21
  134. package/lib/vs/base/common/async.js +0 -966
  135. package/lib/vs/base/common/buffer.js +0 -250
  136. package/lib/vs/base/common/cache.js +0 -40
  137. package/lib/vs/base/common/cancellation.js +0 -146
  138. package/lib/vs/base/common/charCode.js +0 -9
  139. package/lib/vs/base/common/codicon.js +0 -136
  140. package/lib/vs/base/common/codicons.js +0 -1378
  141. package/lib/vs/base/common/collections.js +0 -133
  142. package/lib/vs/base/common/color.js +0 -716
  143. package/lib/vs/base/common/comparers.js +0 -280
  144. package/lib/vs/base/common/console.js +0 -142
  145. package/lib/vs/base/common/date.js +0 -113
  146. package/lib/vs/base/common/decorators.js +0 -169
  147. package/lib/vs/base/common/errorMessage.js +0 -93
  148. package/lib/vs/base/common/errors.js +0 -213
  149. package/lib/vs/base/common/errorsWithActions.js +0 -28
  150. package/lib/vs/base/common/event.js +0 -873
  151. package/lib/vs/base/common/extpath.js +0 -401
  152. package/lib/vs/base/common/filters.js +0 -948
  153. package/lib/vs/base/common/functional.js +0 -28
  154. package/lib/vs/base/common/fuzzyScorer.js +0 -811
  155. package/lib/vs/base/common/glob.js +0 -696
  156. package/lib/vs/base/common/hash.js +0 -359
  157. package/lib/vs/base/common/history.js +0 -116
  158. package/lib/vs/base/common/htmlContent.js +0 -162
  159. package/lib/vs/base/common/idGenerator.js +0 -25
  160. package/lib/vs/base/common/iterator.js +0 -118
  161. package/lib/vs/base/common/json.js +0 -1624
  162. package/lib/vs/base/common/jsonEdit.js +0 -272
  163. package/lib/vs/base/common/jsonErrorMessages.js +0 -69
  164. package/lib/vs/base/common/jsonFormatter.js +0 -316
  165. package/lib/vs/base/common/jsonSchema.js +0 -9
  166. package/lib/vs/base/common/keyCodes.js +0 -591
  167. package/lib/vs/base/common/keybindingLabels.js +0 -231
  168. package/lib/vs/base/common/keybindingParser.js +0 -142
  169. package/lib/vs/base/common/labels.js +0 -430
  170. package/lib/vs/base/common/lazy.js +0 -71
  171. package/lib/vs/base/common/lifecycle.js +0 -308
  172. package/lib/vs/base/common/linkedList.js +0 -152
  173. package/lib/vs/base/common/linkedText.js +0 -73
  174. package/lib/vs/base/common/map.js +0 -1108
  175. package/lib/vs/base/common/marshalling.js +0 -80
  176. package/lib/vs/base/common/mime.js +0 -321
  177. package/lib/vs/base/common/navigator.js +0 -50
  178. package/lib/vs/base/common/network.js +0 -160
  179. package/lib/vs/base/common/normalization.js +0 -78
  180. package/lib/vs/base/common/numbers.js +0 -55
  181. package/lib/vs/base/common/objects.js +0 -268
  182. package/lib/vs/base/common/paging.js +0 -190
  183. package/lib/vs/base/common/parsers.js +0 -78
  184. package/lib/vs/base/common/path.js +0 -1550
  185. package/lib/vs/base/common/platform.js +0 -245
  186. package/lib/vs/base/common/process.js +0 -52
  187. package/lib/vs/base/common/processes.js +0 -32
  188. package/lib/vs/base/common/range.js +0 -79
  189. package/lib/vs/base/common/resourceTree.js +0 -185
  190. package/lib/vs/base/common/resources.js +0 -421
  191. package/lib/vs/base/common/scanCode.js +0 -1472
  192. package/lib/vs/base/common/scrollable.js +0 -397
  193. package/lib/vs/base/common/search.js +0 -55
  194. package/lib/vs/base/common/sequence.js +0 -64
  195. package/lib/vs/base/common/severity.js +0 -55
  196. package/lib/vs/base/common/skipList.js +0 -234
  197. package/lib/vs/base/common/stopwatch.js +0 -45
  198. package/lib/vs/base/common/stream.js +0 -418
  199. package/lib/vs/base/common/strings.js +0 -1283
  200. package/lib/vs/base/common/styler.js +0 -9
  201. package/lib/vs/base/common/types.js +0 -296
  202. package/lib/vs/base/common/uint.js +0 -46
  203. package/lib/vs/base/common/uri.js +0 -756
  204. package/lib/vs/base/common/uriIpc.js +0 -154
  205. package/lib/vs/base/common/uuid.js +0 -70
  206. package/lib/vs/nls.mock.js +0 -31
  207. package/lib/vs/platform/actions/browser/menuEntryActionViewItem.js +0 -342
  208. package/lib/vs/platform/actions/common/actions.js +0 -456
  209. package/lib/vs/platform/actions/common/menuService.js +0 -194
  210. package/lib/vs/platform/clipboard/browser/clipboardService.js +0 -99
  211. package/lib/vs/platform/clipboard/common/clipboardService.js +0 -14
  212. package/lib/vs/platform/contextkey/common/contextkey.js +0 -1210
  213. package/lib/vs/platform/contextkey/common/contextkeys.js +0 -23
  214. package/lib/vs/platform/contextview/browser/contextView.js +0 -15
  215. package/lib/vs/platform/contextview/browser/contextViewService.js +0 -96
  216. package/lib/vs/platform/environment/common/argv.js +0 -9
  217. package/lib/vs/platform/environment/common/environment.js +0 -15
  218. package/lib/vs/platform/instantiation/common/descriptors.js +0 -25
  219. package/lib/vs/platform/instantiation/common/extensions.js +0 -26
  220. package/lib/vs/platform/instantiation/common/graph.js +0 -93
  221. package/lib/vs/platform/instantiation/common/instantiation.js +0 -84
  222. package/lib/vs/platform/instantiation/common/instantiationService.js +0 -361
  223. package/lib/vs/platform/instantiation/common/serviceCollection.js +0 -39
  224. package/lib/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -73
  225. package/lib/vs/platform/keybinding/common/keybinding.js +0 -14
  226. package/lib/vs/platform/keybinding/common/keybindingResolver.js +0 -391
  227. package/lib/vs/platform/keybinding/common/keybindingsRegistry.js +0 -229
  228. package/lib/vs/platform/keybinding/common/resolvedKeybindingItem.js +0 -47
  229. package/lib/vs/platform/keybinding/common/usLayoutResolvedKeybinding.js +0 -160
  230. package/lib/vs/platform/layout/browser/layoutService.js +0 -14
  231. package/lib/vs/platform/menubar/common/menubar.js +0 -34
  232. package/lib/vs/platform/registry/common/platform.js +0 -38
  233. package/lib/vs/platform/theme/browser/checkbox.js +0 -32
  234. package/lib/vs/platform/theme/common/colorRegistry.js +0 -1154
  235. package/lib/vs/platform/theme/common/styler.js +0 -290
  236. package/lib/vs/platform/theme/common/theme.js +0 -21
  237. package/lib/vs/platform/theme/common/themeService.js +0 -176
  238. package/lib/vs/platform/theme/common/tokenClassificationRegistry.js +0 -540
  239. package/lib/vs/platform/theme/test/common/testThemeService.js +0 -98
@@ -1,756 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Licensed under the MIT License. See License.txt in the project root for license information.
5
- *--------------------------------------------------------------------------------------------*/
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.uriToFsPath = exports.URI = void 0;
11
-
12
- const platform_1 = require("./platform");
13
-
14
- const paths = require("./path");
15
-
16
- const _schemePattern = /^\w[\w\d+.-]*$/;
17
- const _singleSlashStart = /^\//;
18
- const _doubleSlashStart = /^\/\//;
19
-
20
- function _validateUri(ret, _strict) {
21
- // scheme, must be set
22
- if (!ret.scheme && _strict) {
23
- throw new Error(`[UriError]: Scheme is missing: {scheme: "", authority: "${ret.authority}", path: "${ret.path}", query: "${ret.query}", fragment: "${ret.fragment}"}`);
24
- } // scheme, https://tools.ietf.org/html/rfc3986#section-3.1
25
- // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
26
-
27
-
28
- if (ret.scheme && !_schemePattern.test(ret.scheme)) {
29
- throw new Error('[UriError]: Scheme contains illegal characters.');
30
- } // path, http://tools.ietf.org/html/rfc3986#section-3.3
31
- // If a URI contains an authority component, then the path component
32
- // must either be empty or begin with a slash ("/") character. If a URI
33
- // does not contain an authority component, then the path cannot begin
34
- // with two slash characters ("//").
35
-
36
-
37
- if (ret.path) {
38
- if (ret.authority) {
39
- if (!_singleSlashStart.test(ret.path)) {
40
- throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character');
41
- }
42
- } else {
43
- if (_doubleSlashStart.test(ret.path)) {
44
- throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")');
45
- }
46
- }
47
- }
48
- } // for a while we allowed uris *without* schemes and this is the migration
49
- // for them, e.g. an uri without scheme and without strict-mode warns and falls
50
- // back to the file-scheme. that should cause the least carnage and still be a
51
- // clear warning
52
-
53
-
54
- function _schemeFix(scheme, _strict) {
55
- if (!scheme && !_strict) {
56
- return 'file';
57
- }
58
-
59
- return scheme;
60
- } // implements a bit of https://tools.ietf.org/html/rfc3986#section-5
61
-
62
-
63
- function _referenceResolution(scheme, path) {
64
- // the slash-character is our 'default base' as we don't
65
- // support constructing URIs relative to other URIs. This
66
- // also means that we alter and potentially break paths.
67
- // see https://tools.ietf.org/html/rfc3986#section-5.1.4
68
- switch (scheme) {
69
- case 'https':
70
- case 'http':
71
- case 'file':
72
- if (!path) {
73
- path = _slash;
74
- } else if (path[0] !== _slash) {
75
- path = _slash + path;
76
- }
77
-
78
- break;
79
- }
80
-
81
- return path;
82
- }
83
-
84
- const _empty = '';
85
- const _slash = '/';
86
- const _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
87
- /**
88
- * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
89
- * This class is a simple parser which creates the basic component parts
90
- * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
91
- * and encoding.
92
- *
93
- * ```txt
94
- * foo://example.com:8042/over/there?name=ferret#nose
95
- * \_/ \______________/\_________/ \_________/ \__/
96
- * | | | | |
97
- * scheme authority path query fragment
98
- * | _____________________|__
99
- * / \ / \
100
- * urn:example:animal:ferret:nose
101
- * ```
102
- */
103
-
104
- class URI {
105
- /**
106
- * @internal
107
- */
108
- constructor(schemeOrData, authority, path, query, fragment, _strict = false) {
109
- if (typeof schemeOrData === 'object') {
110
- this.scheme = schemeOrData.scheme || _empty;
111
- this.authority = schemeOrData.authority || _empty;
112
- this.path = schemeOrData.path || _empty;
113
- this.query = schemeOrData.query || _empty;
114
- this.fragment = schemeOrData.fragment || _empty; // no validation because it's this URI
115
- // that creates uri components.
116
- // _validateUri(this);
117
- } else {
118
- this.scheme = _schemeFix(schemeOrData, _strict);
119
- this.authority = authority || _empty;
120
- this.path = _referenceResolution(this.scheme, path || _empty);
121
- this.query = query || _empty;
122
- this.fragment = fragment || _empty;
123
-
124
- _validateUri(this, _strict);
125
- }
126
- }
127
-
128
- static isUri(thing) {
129
- if (thing instanceof URI) {
130
- return true;
131
- }
132
-
133
- if (!thing) {
134
- return false;
135
- }
136
-
137
- return typeof thing.authority === 'string' && typeof thing.fragment === 'string' && typeof thing.path === 'string' && typeof thing.query === 'string' && typeof thing.scheme === 'string' && typeof thing.fsPath === 'function' && typeof thing.with === 'function' && typeof thing.toString === 'function';
138
- } // ---- filesystem path -----------------------
139
-
140
- /**
141
- * Returns a string representing the corresponding file system path of this URI.
142
- * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
143
- * platform specific path separator.
144
- *
145
- * * Will *not* validate the path for invalid characters and semantics.
146
- * * Will *not* look at the scheme of this URI.
147
- * * The result shall *not* be used for display purposes but for accessing a file on disk.
148
- *
149
- *
150
- * The *difference* to `URI#path` is the use of the platform specific separator and the handling
151
- * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
152
- *
153
- * ```ts
154
- const u = URI.parse('file://server/c$/folder/file.txt')
155
- u.authority === 'server'
156
- u.path === '/shares/c$/file.txt'
157
- u.fsPath === '\\server\c$\folder\file.txt'
158
- ```
159
- *
160
- * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
161
- * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
162
- * with URIs that represent files on disk (`file` scheme).
163
- */
164
-
165
-
166
- get fsPath() {
167
- // if (this.scheme !== 'file') {
168
- // console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
169
- // }
170
- return uriToFsPath(this, false);
171
- } // ---- modify to new -------------------------
172
-
173
-
174
- with(change) {
175
- if (!change) {
176
- return this;
177
- }
178
-
179
- let {
180
- scheme,
181
- authority,
182
- path,
183
- query,
184
- fragment
185
- } = change;
186
-
187
- if (scheme === undefined) {
188
- scheme = this.scheme;
189
- } else if (scheme === null) {
190
- scheme = _empty;
191
- }
192
-
193
- if (authority === undefined) {
194
- authority = this.authority;
195
- } else if (authority === null) {
196
- authority = _empty;
197
- }
198
-
199
- if (path === undefined) {
200
- path = this.path;
201
- } else if (path === null) {
202
- path = _empty;
203
- }
204
-
205
- if (query === undefined) {
206
- query = this.query;
207
- } else if (query === null) {
208
- query = _empty;
209
- }
210
-
211
- if (fragment === undefined) {
212
- fragment = this.fragment;
213
- } else if (fragment === null) {
214
- fragment = _empty;
215
- }
216
-
217
- if (scheme === this.scheme && authority === this.authority && path === this.path && query === this.query && fragment === this.fragment) {
218
- return this;
219
- }
220
-
221
- return new Uri(scheme, authority, path, query, fragment);
222
- } // ---- parse & validate ------------------------
223
-
224
- /**
225
- * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
226
- * `file:///usr/home`, or `scheme:with/path`.
227
- *
228
- * @param value A string which represents an URI (see `URI#toString`).
229
- */
230
-
231
-
232
- static parse(value, _strict = false) {
233
- const match = _regexp.exec(value);
234
-
235
- if (!match) {
236
- return new Uri(_empty, _empty, _empty, _empty, _empty);
237
- }
238
-
239
- return new Uri(match[2] || _empty, percentDecode(match[4] || _empty), percentDecode(match[5] || _empty), percentDecode(match[7] || _empty), percentDecode(match[9] || _empty), _strict);
240
- }
241
- /**
242
- * Creates a new URI from a file system path, e.g. `c:\my\files`,
243
- * `/usr/home`, or `\\server\share\some\path`.
244
- *
245
- * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
246
- * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
247
- * `URI.parse('file://' + path)` because the path might contain characters that are
248
- * interpreted (# and ?). See the following sample:
249
- * ```ts
250
- const good = URI.file('/coding/c#/project1');
251
- good.scheme === 'file';
252
- good.path === '/coding/c#/project1';
253
- good.fragment === '';
254
- const bad = URI.parse('file://' + '/coding/c#/project1');
255
- bad.scheme === 'file';
256
- bad.path === '/coding/c'; // path is now broken
257
- bad.fragment === '/project1';
258
- ```
259
- *
260
- * @param path A file system path (see `URI#fsPath`)
261
- */
262
-
263
-
264
- static file(path) {
265
- let authority = _empty; // normalize to fwd-slashes on windows,
266
- // on other systems bwd-slashes are valid
267
- // filename character, eg /f\oo/ba\r.txt
268
-
269
- if (platform_1.isWindows) {
270
- path = path.replace(/\\/g, _slash);
271
- } // check for authority as used in UNC shares
272
- // or use the path as given
273
-
274
-
275
- if (path[0] === _slash && path[1] === _slash) {
276
- const idx = path.indexOf(_slash, 2);
277
-
278
- if (idx === -1) {
279
- authority = path.substring(2);
280
- path = _slash;
281
- } else {
282
- authority = path.substring(2, idx);
283
- path = path.substring(idx) || _slash;
284
- }
285
- }
286
-
287
- return new Uri('file', authority, path, _empty, _empty);
288
- }
289
-
290
- static from(components) {
291
- return new Uri(components.scheme, components.authority, components.path, components.query, components.fragment);
292
- }
293
- /**
294
- * Join a URI path with path fragments and normalizes the resulting path.
295
- *
296
- * @param uri The input URI.
297
- * @param pathFragment The path fragment to add to the URI path.
298
- * @returns The resulting URI.
299
- */
300
-
301
-
302
- static joinPath(uri, ...pathFragment) {
303
- if (!uri.path) {
304
- throw new Error(`[UriError]: cannot call joinPaths on URI without path`);
305
- }
306
-
307
- let newPath;
308
-
309
- if (platform_1.isWindows && uri.scheme === 'file') {
310
- newPath = URI.file(paths.win32.join(uriToFsPath(uri, true), ...pathFragment)).path;
311
- } else {
312
- newPath = paths.posix.join(uri.path, ...pathFragment);
313
- }
314
-
315
- return uri.with({
316
- path: newPath
317
- });
318
- } // ---- printing/externalize ---------------------------
319
-
320
- /**
321
- * Creates a string representation for this URI. It's guaranteed that calling
322
- * `URI.parse` with the result of this function creates an URI which is equal
323
- * to this URI.
324
- *
325
- * * The result shall *not* be used for display purposes but for externalization or transport.
326
- * * The result will be encoded using the percentage encoding and encoding happens mostly
327
- * ignore the scheme-specific encoding rules.
328
- *
329
- * @param skipEncoding Do not encode the result, default is `false`
330
- */
331
-
332
-
333
- toString(skipEncoding = false) {
334
- return _asFormatted(this, skipEncoding);
335
- }
336
-
337
- toJSON() {
338
- return this;
339
- }
340
-
341
- static revive(data) {
342
- if (!data) {
343
- return data;
344
- } else if (data instanceof URI) {
345
- return data;
346
- } else {
347
- const result = new Uri(data);
348
- result._formatted = data.external;
349
- result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null;
350
- return result;
351
- }
352
- }
353
-
354
- }
355
-
356
- exports.URI = URI;
357
-
358
- const _pathSepMarker = platform_1.isWindows ? 1 : undefined; // This class exists so that URI is compatibile with vscode.Uri (API).
359
-
360
-
361
- class Uri extends URI {
362
- constructor() {
363
- super(...arguments);
364
- this._formatted = null;
365
- this._fsPath = null;
366
- }
367
-
368
- get fsPath() {
369
- if (!this._fsPath) {
370
- this._fsPath = uriToFsPath(this, false);
371
- }
372
-
373
- return this._fsPath;
374
- }
375
-
376
- toString(skipEncoding = false) {
377
- if (!skipEncoding) {
378
- if (!this._formatted) {
379
- this._formatted = _asFormatted(this, false);
380
- }
381
-
382
- return this._formatted;
383
- } else {
384
- // we don't cache that
385
- return _asFormatted(this, true);
386
- }
387
- }
388
-
389
- toJSON() {
390
- const res = {
391
- $mid: 1
392
- }; // cached state
393
-
394
- if (this._fsPath) {
395
- res.fsPath = this._fsPath;
396
- res._sep = _pathSepMarker;
397
- }
398
-
399
- if (this._formatted) {
400
- res.external = this._formatted;
401
- } // uri components
402
-
403
-
404
- if (this.path) {
405
- res.path = this.path;
406
- }
407
-
408
- if (this.scheme) {
409
- res.scheme = this.scheme;
410
- }
411
-
412
- if (this.authority) {
413
- res.authority = this.authority;
414
- }
415
-
416
- if (this.query) {
417
- res.query = this.query;
418
- }
419
-
420
- if (this.fragment) {
421
- res.fragment = this.fragment;
422
- }
423
-
424
- return res;
425
- }
426
-
427
- } // reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2
428
-
429
-
430
- const encodeTable = {
431
- [58
432
- /* Colon */
433
- ]: '%3A',
434
- [47
435
- /* Slash */
436
- ]: '%2F',
437
- [63
438
- /* QuestionMark */
439
- ]: '%3F',
440
- [35
441
- /* Hash */
442
- ]: '%23',
443
- [91
444
- /* OpenSquareBracket */
445
- ]: '%5B',
446
- [93
447
- /* CloseSquareBracket */
448
- ]: '%5D',
449
- [64
450
- /* AtSign */
451
- ]: '%40',
452
- [33
453
- /* ExclamationMark */
454
- ]: '%21',
455
- [36
456
- /* DollarSign */
457
- ]: '%24',
458
- [38
459
- /* Ampersand */
460
- ]: '%26',
461
- [39
462
- /* SingleQuote */
463
- ]: '%27',
464
- [40
465
- /* OpenParen */
466
- ]: '%28',
467
- [41
468
- /* CloseParen */
469
- ]: '%29',
470
- [42
471
- /* Asterisk */
472
- ]: '%2A',
473
- [43
474
- /* Plus */
475
- ]: '%2B',
476
- [44
477
- /* Comma */
478
- ]: '%2C',
479
- [59
480
- /* Semicolon */
481
- ]: '%3B',
482
- [61
483
- /* Equals */
484
- ]: '%3D',
485
- [32
486
- /* Space */
487
- ]: '%20'
488
- };
489
-
490
- function encodeURIComponentFast(uriComponent, allowSlash) {
491
- let res = undefined;
492
- let nativeEncodePos = -1;
493
-
494
- for (let pos = 0; pos < uriComponent.length; pos++) {
495
- const code = uriComponent.charCodeAt(pos); // unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3
496
-
497
- if (code >= 97
498
- /* a */
499
- && code <= 122
500
- /* z */
501
- || code >= 65
502
- /* A */
503
- && code <= 90
504
- /* Z */
505
- || code >= 48
506
- /* Digit0 */
507
- && code <= 57
508
- /* Digit9 */
509
- || code === 45
510
- /* Dash */
511
- || code === 46
512
- /* Period */
513
- || code === 95
514
- /* Underline */
515
- || code === 126
516
- /* Tilde */
517
- || allowSlash && code === 47
518
- /* Slash */
519
- ) {
520
- // check if we are delaying native encode
521
- if (nativeEncodePos !== -1) {
522
- res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
523
- nativeEncodePos = -1;
524
- } // check if we write into a new string (by default we try to return the param)
525
-
526
-
527
- if (res !== undefined) {
528
- res += uriComponent.charAt(pos);
529
- }
530
- } else {
531
- // encoding needed, we need to allocate a new string
532
- if (res === undefined) {
533
- res = uriComponent.substr(0, pos);
534
- } // check with default table first
535
-
536
-
537
- const escaped = encodeTable[code];
538
-
539
- if (escaped !== undefined) {
540
- // check if we are delaying native encode
541
- if (nativeEncodePos !== -1) {
542
- res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
543
- nativeEncodePos = -1;
544
- } // append escaped variant to result
545
-
546
-
547
- res += escaped;
548
- } else if (nativeEncodePos === -1) {
549
- // use native encode only when needed
550
- nativeEncodePos = pos;
551
- }
552
- }
553
- }
554
-
555
- if (nativeEncodePos !== -1) {
556
- res += encodeURIComponent(uriComponent.substring(nativeEncodePos));
557
- }
558
-
559
- return res !== undefined ? res : uriComponent;
560
- }
561
-
562
- function encodeURIComponentMinimal(path) {
563
- let res = undefined;
564
-
565
- for (let pos = 0; pos < path.length; pos++) {
566
- const code = path.charCodeAt(pos);
567
-
568
- if (code === 35
569
- /* Hash */
570
- || code === 63
571
- /* QuestionMark */
572
- ) {
573
- if (res === undefined) {
574
- res = path.substr(0, pos);
575
- }
576
-
577
- res += encodeTable[code];
578
- } else {
579
- if (res !== undefined) {
580
- res += path[pos];
581
- }
582
- }
583
- }
584
-
585
- return res !== undefined ? res : path;
586
- }
587
- /**
588
- * Compute `fsPath` for the given uri
589
- */
590
-
591
-
592
- function uriToFsPath(uri, keepDriveLetterCasing) {
593
- let value;
594
-
595
- if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
596
- // unc path: file://shares/c$/far/boo
597
- value = `//${uri.authority}${uri.path}`;
598
- } else if (uri.path.charCodeAt(0) === 47
599
- /* Slash */
600
- && (uri.path.charCodeAt(1) >= 65
601
- /* A */
602
- && uri.path.charCodeAt(1) <= 90
603
- /* Z */
604
- || uri.path.charCodeAt(1) >= 97
605
- /* a */
606
- && uri.path.charCodeAt(1) <= 122
607
- /* z */
608
- ) && uri.path.charCodeAt(2) === 58
609
- /* Colon */
610
- ) {
611
- if (!keepDriveLetterCasing) {
612
- // windows drive letter: file:///c:/far/boo
613
- value = uri.path[1].toLowerCase() + uri.path.substr(2);
614
- } else {
615
- value = uri.path.substr(1);
616
- }
617
- } else {
618
- // other path
619
- value = uri.path;
620
- }
621
-
622
- if (platform_1.isWindows) {
623
- value = value.replace(/\//g, '\\');
624
- }
625
-
626
- return value;
627
- }
628
-
629
- exports.uriToFsPath = uriToFsPath;
630
- /**
631
- * Create the external version of a uri
632
- */
633
-
634
- function _asFormatted(uri, skipEncoding) {
635
- const encoder = !skipEncoding ? encodeURIComponentFast : encodeURIComponentMinimal;
636
- let res = '';
637
- let {
638
- scheme,
639
- authority,
640
- path,
641
- query,
642
- fragment
643
- } = uri;
644
-
645
- if (scheme) {
646
- res += scheme;
647
- res += ':';
648
- }
649
-
650
- if (authority || scheme === 'file') {
651
- res += _slash;
652
- res += _slash;
653
- }
654
-
655
- if (authority) {
656
- let idx = authority.indexOf('@');
657
-
658
- if (idx !== -1) {
659
- // <user>@<auth>
660
- const userinfo = authority.substr(0, idx);
661
- authority = authority.substr(idx + 1);
662
- idx = userinfo.indexOf(':');
663
-
664
- if (idx === -1) {
665
- res += encoder(userinfo, false);
666
- } else {
667
- // <user>:<pass>@<auth>
668
- res += encoder(userinfo.substr(0, idx), false);
669
- res += ':';
670
- res += encoder(userinfo.substr(idx + 1), false);
671
- }
672
-
673
- res += '@';
674
- }
675
-
676
- authority = authority.toLowerCase();
677
- idx = authority.indexOf(':');
678
-
679
- if (idx === -1) {
680
- res += encoder(authority, false);
681
- } else {
682
- // <auth>:<port>
683
- res += encoder(authority.substr(0, idx), false);
684
- res += authority.substr(idx);
685
- }
686
- }
687
-
688
- if (path) {
689
- // lower-case windows drive letters in /C:/fff or C:/fff
690
- if (path.length >= 3 && path.charCodeAt(0) === 47
691
- /* Slash */
692
- && path.charCodeAt(2) === 58
693
- /* Colon */
694
- ) {
695
- const code = path.charCodeAt(1);
696
-
697
- if (code >= 65
698
- /* A */
699
- && code <= 90
700
- /* Z */
701
- ) {
702
- path = `/${String.fromCharCode(code + 32)}:${path.substr(3)}`; // "/c:".length === 3
703
- }
704
- } else if (path.length >= 2 && path.charCodeAt(1) === 58
705
- /* Colon */
706
- ) {
707
- const code = path.charCodeAt(0);
708
-
709
- if (code >= 65
710
- /* A */
711
- && code <= 90
712
- /* Z */
713
- ) {
714
- path = `${String.fromCharCode(code + 32)}:${path.substr(2)}`; // "/c:".length === 3
715
- }
716
- } // encode the rest of the path
717
-
718
-
719
- res += encoder(path, true);
720
- }
721
-
722
- if (query) {
723
- res += '?';
724
- res += encoder(query, false);
725
- }
726
-
727
- if (fragment) {
728
- res += '#';
729
- res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment;
730
- }
731
-
732
- return res;
733
- } // --- decode
734
-
735
-
736
- function decodeURIComponentGraceful(str) {
737
- try {
738
- return decodeURIComponent(str);
739
- } catch {
740
- if (str.length > 3) {
741
- return str.substr(0, 3) + decodeURIComponentGraceful(str.substr(3));
742
- } else {
743
- return str;
744
- }
745
- }
746
- }
747
-
748
- const _rEncodedAsHex = /(%[0-9A-Za-z][0-9A-Za-z])+/g;
749
-
750
- function percentDecode(str) {
751
- if (!str.match(_rEncodedAsHex)) {
752
- return str;
753
- }
754
-
755
- return str.replace(_rEncodedAsHex, match => decodeURIComponentGraceful(match));
756
- }