cspell-lib 8.8.4 → 8.9.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/dist/esm/Settings/DefaultSettings.js +1 -1
- package/dist/esm/util/url.d.ts +1 -14
- package/dist/esm/util/url.js +6 -68
- package/package.json +17 -16
|
@@ -67,7 +67,7 @@ const definedDefaultRegExpExcludeList = [
|
|
|
67
67
|
'UnicodeRef',
|
|
68
68
|
'UUID',
|
|
69
69
|
];
|
|
70
|
-
// This bit of copying is done to have the
|
|
70
|
+
// This bit of copying is done to have the compiler ensure that the defaults exist.
|
|
71
71
|
const defaultRegExpExcludeList = definedDefaultRegExpExcludeList;
|
|
72
72
|
export const _defaultSettingsBasis = Object.freeze(createCSpellSettingsInternal({
|
|
73
73
|
id: 'static_defaults',
|
package/dist/esm/util/url.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Convert a URL into a string. If it is a file URL, convert it to a path.
|
|
3
|
-
* @param url - URL
|
|
4
|
-
* @returns path or href
|
|
5
|
-
*/
|
|
6
|
-
export declare function toFilePathOrHref(url: URL | string): string;
|
|
1
|
+
export { addTrailingSlash, isDataURL, isFileURL, isUrlLike as isURLLike, toFileURL as resolveFileWithURL, toFileDirURL, toFilePathOrHref, toURL, } from '@cspell/url';
|
|
7
2
|
/**
|
|
8
3
|
* This is a URL that can be used for searching for modules.
|
|
9
4
|
* @returns URL for the source directory
|
|
@@ -16,15 +11,7 @@ export declare function getSourceDirectoryUrl(): URL;
|
|
|
16
11
|
*/
|
|
17
12
|
export declare function relativeTo(path: string, relativeTo?: URL | string): URL;
|
|
18
13
|
export declare function cwdURL(): URL;
|
|
19
|
-
export declare function resolveFileWithURL(file: string | URL, relativeToURL: URL): URL;
|
|
20
|
-
export declare function normalizePathSlashesForUrl(filePath: string, sep?: string | RegExp): string;
|
|
21
14
|
export declare function toFileUrl(file: string | URL): URL;
|
|
22
|
-
export declare function toFileDirUrl(dir: string | URL): URL;
|
|
23
|
-
export declare function addTrailingSlash(url: URL): URL;
|
|
24
|
-
export declare function toURL(href: string | URL, relativeTo?: string | URL): URL;
|
|
25
15
|
export declare function fileURLOrPathToPath(filenameOrURL: string | URL): string;
|
|
26
|
-
export declare function isURLLike(url: string | URL): boolean;
|
|
27
|
-
export declare function isFileURL(url: string | URL): boolean;
|
|
28
|
-
export declare function isDataURL(url: string | URL): boolean;
|
|
29
16
|
export declare function windowsDriveLetterToUpper(absoluteFilePath: string): string;
|
|
30
17
|
//# sourceMappingURL=url.d.ts.map
|
package/dist/esm/util/url.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import {
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { toFilePathOrHref, toFileURL } from '@cspell/url';
|
|
3
4
|
import { srcDirectory } from '../../lib-cjs/pkg-info.cjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Convert a URL into a string. If it is a file URL, convert it to a path.
|
|
7
|
-
* @param url - URL
|
|
8
|
-
* @returns path or href
|
|
9
|
-
*/
|
|
10
|
-
export function toFilePathOrHref(url) {
|
|
11
|
-
return fileURLOrPathToPath(url);
|
|
12
|
-
}
|
|
5
|
+
export { addTrailingSlash, isDataURL, isFileURL, isUrlLike as isURLLike, toFileURL as resolveFileWithURL, toFileDirURL, toFilePathOrHref, toURL, } from '@cspell/url';
|
|
13
6
|
/**
|
|
14
7
|
* This is a URL that can be used for searching for modules.
|
|
15
8
|
* @returns URL for the source directory
|
|
@@ -24,71 +17,16 @@ export function getSourceDirectoryUrl() {
|
|
|
24
17
|
* @returns a URL
|
|
25
18
|
*/
|
|
26
19
|
export function relativeTo(path, relativeTo) {
|
|
27
|
-
return
|
|
20
|
+
return toFileURL(path, relativeTo ?? cwdURL());
|
|
28
21
|
}
|
|
29
22
|
export function cwdURL() {
|
|
30
23
|
return pathToFileURL('./');
|
|
31
24
|
}
|
|
32
|
-
export function resolveFileWithURL(file, relativeToURL) {
|
|
33
|
-
if (file instanceof URL)
|
|
34
|
-
return file;
|
|
35
|
-
if (isURLLike(file))
|
|
36
|
-
return toURL(file);
|
|
37
|
-
const isRelativeToFile = isFileURL(relativeToURL);
|
|
38
|
-
if (isRelativeToFile && path.isAbsolute(file)) {
|
|
39
|
-
return pathToFileURL(file);
|
|
40
|
-
}
|
|
41
|
-
if (isRelativeToFile) {
|
|
42
|
-
const rootURL = new URL('.', relativeToURL);
|
|
43
|
-
const root = fileURLToPath(rootURL);
|
|
44
|
-
const suffix = file === '.' || file == '..' || file.endsWith('/') || file.endsWith(path.sep) ? '/' : '';
|
|
45
|
-
const filePath = path.resolve(root, file);
|
|
46
|
-
return pathToFileURL(filePath + suffix);
|
|
47
|
-
}
|
|
48
|
-
return relativeTo(file, relativeToURL);
|
|
49
|
-
}
|
|
50
|
-
export function normalizePathSlashesForUrl(filePath, sep = /[/\\]/g) {
|
|
51
|
-
return filePath
|
|
52
|
-
.replace(/^([a-z]:)/i, '/$1')
|
|
53
|
-
.split(sep)
|
|
54
|
-
.join('/');
|
|
55
|
-
}
|
|
56
25
|
export function toFileUrl(file) {
|
|
57
|
-
|
|
58
|
-
return file;
|
|
59
|
-
return resolveFileWithURL(file, cwdURL());
|
|
60
|
-
}
|
|
61
|
-
export function toFileDirUrl(dir) {
|
|
62
|
-
return addTrailingSlash(toFileUrl(dir));
|
|
63
|
-
}
|
|
64
|
-
export function addTrailingSlash(url) {
|
|
65
|
-
if (url.pathname.endsWith('/'))
|
|
66
|
-
return url;
|
|
67
|
-
const urlWithSlash = new URL(url.href);
|
|
68
|
-
urlWithSlash.pathname += '/';
|
|
69
|
-
return urlWithSlash;
|
|
70
|
-
}
|
|
71
|
-
export function toURL(href, relativeTo) {
|
|
72
|
-
return href instanceof URL ? href : new URL(href, relativeTo);
|
|
26
|
+
return toFileURL(file, cwdURL());
|
|
73
27
|
}
|
|
74
28
|
export function fileURLOrPathToPath(filenameOrURL) {
|
|
75
|
-
return
|
|
76
|
-
}
|
|
77
|
-
function toFilePath(url) {
|
|
78
|
-
return windowsDriveLetterToUpper(fileURLToPath(url));
|
|
79
|
-
}
|
|
80
|
-
export function isURLLike(url) {
|
|
81
|
-
return url instanceof URL || isUrlRegExp.test(url);
|
|
82
|
-
}
|
|
83
|
-
export function isFileURL(url) {
|
|
84
|
-
return isUrlWithProtocol(url, 'file');
|
|
85
|
-
}
|
|
86
|
-
export function isDataURL(url) {
|
|
87
|
-
return isUrlWithProtocol(url, 'data');
|
|
88
|
-
}
|
|
89
|
-
function isUrlWithProtocol(url, protocol) {
|
|
90
|
-
protocol = protocol.endsWith(':') ? protocol : protocol + ':';
|
|
91
|
-
return url instanceof URL ? url.protocol === protocol : url.startsWith(protocol);
|
|
29
|
+
return toFilePathOrHref(filenameOrURL);
|
|
92
30
|
}
|
|
93
31
|
export function windowsDriveLetterToUpper(absoluteFilePath) {
|
|
94
32
|
return absoluteFilePath.replace(/^([a-z]):\\/, (s) => s.toUpperCase());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-lib",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.0",
|
|
4
4
|
"description": "A library of useful functions used across various cspell tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -59,20 +59,21 @@
|
|
|
59
59
|
},
|
|
60
60
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@cspell/cspell-bundled-dicts": "8.
|
|
63
|
-
"@cspell/cspell-pipe": "8.
|
|
64
|
-
"@cspell/cspell-resolver": "8.
|
|
65
|
-
"@cspell/cspell-types": "8.
|
|
66
|
-
"@cspell/dynamic-import": "8.
|
|
67
|
-
"@cspell/strong-weak-map": "8.
|
|
62
|
+
"@cspell/cspell-bundled-dicts": "8.9.0",
|
|
63
|
+
"@cspell/cspell-pipe": "8.9.0",
|
|
64
|
+
"@cspell/cspell-resolver": "8.9.0",
|
|
65
|
+
"@cspell/cspell-types": "8.9.0",
|
|
66
|
+
"@cspell/dynamic-import": "8.9.0",
|
|
67
|
+
"@cspell/strong-weak-map": "8.9.0",
|
|
68
|
+
"@cspell/url": "8.9.0",
|
|
68
69
|
"clear-module": "^4.1.2",
|
|
69
70
|
"comment-json": "^4.2.3",
|
|
70
|
-
"cspell-config-lib": "8.
|
|
71
|
-
"cspell-dictionary": "8.
|
|
72
|
-
"cspell-glob": "8.
|
|
73
|
-
"cspell-grammar": "8.
|
|
74
|
-
"cspell-io": "8.
|
|
75
|
-
"cspell-trie-lib": "8.
|
|
71
|
+
"cspell-config-lib": "8.9.0",
|
|
72
|
+
"cspell-dictionary": "8.9.0",
|
|
73
|
+
"cspell-glob": "8.9.0",
|
|
74
|
+
"cspell-grammar": "8.9.0",
|
|
75
|
+
"cspell-io": "8.9.0",
|
|
76
|
+
"cspell-trie-lib": "8.9.0",
|
|
76
77
|
"env-paths": "^3.0.0",
|
|
77
78
|
"fast-equals": "^5.0.1",
|
|
78
79
|
"gensequence": "^7.0.0",
|
|
@@ -86,19 +87,19 @@
|
|
|
86
87
|
"node": ">=18"
|
|
87
88
|
},
|
|
88
89
|
"devDependencies": {
|
|
89
|
-
"@cspell/dict-cpp": "^5.1.
|
|
90
|
+
"@cspell/dict-cpp": "^5.1.10",
|
|
90
91
|
"@cspell/dict-csharp": "^4.0.2",
|
|
91
92
|
"@cspell/dict-css": "^4.0.12",
|
|
92
93
|
"@cspell/dict-fa-ir": "^4.0.0",
|
|
93
94
|
"@cspell/dict-fr-fr": "^2.2.2",
|
|
94
95
|
"@cspell/dict-html": "^4.0.5",
|
|
95
96
|
"@cspell/dict-nl-nl": "^2.3.0",
|
|
96
|
-
"@cspell/dict-python": "^4.1
|
|
97
|
+
"@cspell/dict-python": "^4.2.1",
|
|
97
98
|
"@types/configstore": "^6.0.2",
|
|
98
99
|
"configstore": "^6.0.0",
|
|
99
100
|
"cspell-dict-nl-nl": "^1.1.2",
|
|
100
101
|
"leaked-handles": "^5.2.0",
|
|
101
102
|
"lorem-ipsum": "^2.0.8"
|
|
102
103
|
},
|
|
103
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "33c513cf848a61fb1ebcea1b9c67505a31447411"
|
|
104
105
|
}
|