cspell-lib 5.19.4 → 5.19.7

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.
@@ -0,0 +1,5 @@
1
+ export declare class PatternRegExp extends RegExp {
2
+ constructor(pattern: RegExp | string);
3
+ toJSON(): string;
4
+ }
5
+ //# sourceMappingURL=PatternRegExp.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PatternRegExp = void 0;
4
+ class PatternRegExp extends RegExp {
5
+ constructor(pattern) {
6
+ super(pattern);
7
+ }
8
+ toJSON() {
9
+ return this.toString();
10
+ }
11
+ }
12
+ exports.PatternRegExp = PatternRegExp;
13
+ //# sourceMappingURL=PatternRegExp.js.map
@@ -1,4 +1,6 @@
1
1
  import { CSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef';
2
+ export declare const _defaultSettingsBasis: Readonly<CSpellSettingsInternal>;
2
3
  export declare const _defaultSettings: Readonly<CSpellSettingsInternal>;
3
- export declare function getDefaultSettings(): CSpellSettingsInternal;
4
+ export declare function getDefaultSettings(useDefaultDictionaries?: boolean): CSpellSettingsInternal;
5
+ export declare function getDefaultBundledSettings(): CSpellSettingsInternal;
4
6
  //# sourceMappingURL=DefaultSettings.d.ts.map
@@ -23,8 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getDefaultSettings = exports._defaultSettings = void 0;
26
+ exports.getDefaultBundledSettings = exports.getDefaultSettings = exports._defaultSettings = exports._defaultSettingsBasis = void 0;
27
27
  const CSpellSettingsInternalDef_1 = require("../Models/CSpellSettingsInternalDef");
28
+ const PatternRegExp_1 = require("../Models/PatternRegExp");
28
29
  const resolveFile_1 = require("../util/resolveFile");
29
30
  const configLoader_1 = require("./configLoader");
30
31
  const index_1 = require("./index");
@@ -34,9 +35,9 @@ const defaultConfigFileModuleRef = '@cspell/cspell-bundled-dicts/cspell-default.
34
35
  // Do not use require.resolve because webpack will mess it up.
35
36
  const defaultConfigFile = resolveConfigModule(defaultConfigFileModuleRef);
36
37
  const regExpSpellCheckerDisable = [
37
- RegPat.regExSpellingGuardBlock,
38
- RegPat.regExSpellingGuardLine,
39
- RegPat.regExSpellingGuardNext,
38
+ new PatternRegExp_1.PatternRegExp(RegPat.regExSpellingGuardBlock),
39
+ new PatternRegExp_1.PatternRegExp(RegPat.regExSpellingGuardLine),
40
+ new PatternRegExp_1.PatternRegExp(RegPat.regExSpellingGuardNext),
40
41
  ];
41
42
  // cspell:ignore filetypes
42
43
  const predefinedPatterns = [
@@ -71,7 +72,7 @@ const predefinedPatterns = [
71
72
  { name: 'CStyleComment', pattern: RegPat.regExCStyleComments },
72
73
  { name: 'Everything', pattern: '.*' },
73
74
  ];
74
- const defaultRegExpPatterns = [...predefinedPatterns];
75
+ const defaultRegExpPatterns = [...predefinedPatterns].map(normalizePattern);
75
76
  const definedDefaultRegExpExcludeList = [
76
77
  'SpellCheckerDisable',
77
78
  'SpellCheckerIgnoreInDocSetting',
@@ -92,11 +93,28 @@ const definedDefaultRegExpExcludeList = [
92
93
  ];
93
94
  // This bit of copying is done to have the complier ensure that the defaults exist.
94
95
  const defaultRegExpExcludeList = definedDefaultRegExpExcludeList;
95
- exports._defaultSettings = Object.freeze((0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({
96
+ exports._defaultSettingsBasis = Object.freeze((0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({
96
97
  id: 'static_defaults',
97
98
  language: 'en',
98
99
  name: 'Static Defaults',
99
100
  enabled: true,
101
+ enabledLanguageIds: [],
102
+ maxNumberOfProblems: 100,
103
+ numSuggestions: 10,
104
+ suggestionsTimeout: 500,
105
+ suggestionNumChanges: 3,
106
+ words: [],
107
+ userWords: [],
108
+ ignorePaths: [],
109
+ allowCompoundWords: false,
110
+ patterns: defaultRegExpPatterns,
111
+ ignoreRegExpList: [],
112
+ languageSettings: [],
113
+ source: { name: 'defaultSettings' },
114
+ reporters: [],
115
+ }));
116
+ exports._defaultSettings = Object.freeze((0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({
117
+ ...exports._defaultSettingsBasis,
100
118
  enabledLanguageIds: [
101
119
  'ada',
102
120
  'csharp',
@@ -123,23 +141,15 @@ exports._defaultSettings = Object.freeze((0, CSpellSettingsInternalDef_1.createC
123
141
  'shellscript',
124
142
  'toml',
125
143
  ],
126
- maxNumberOfProblems: 100,
127
- numSuggestions: 10,
128
- suggestionsTimeout: 500,
129
- suggestionNumChanges: 3,
130
- words: [],
131
- userWords: [],
132
- ignorePaths: [],
133
- allowCompoundWords: false,
134
- patterns: defaultRegExpPatterns,
135
144
  ignoreRegExpList: defaultRegExpExcludeList,
136
145
  languageSettings: LanguageSettings.getDefaultLanguageSettings(),
137
- source: { name: 'defaultSettings' },
138
- reporters: [],
139
146
  }));
140
147
  const getSettings = (function () {
141
148
  let settings = undefined;
142
- return function () {
149
+ return function (useDefaultDictionaries) {
150
+ if (!useDefaultDictionaries) {
151
+ return exports._defaultSettingsBasis;
152
+ }
143
153
  if (!settings) {
144
154
  const jsonSettings = (0, configLoader_1.readSettings)(defaultConfigFile);
145
155
  settings = (0, index_1.mergeSettings)(exports._defaultSettings, jsonSettings);
@@ -156,8 +166,22 @@ const getSettings = (function () {
156
166
  function resolveConfigModule(configModuleName) {
157
167
  return (0, resolveFile_1.resolveFile)(configModuleName, __dirname).filename;
158
168
  }
159
- function getDefaultSettings() {
160
- return getSettings();
169
+ function normalizePattern(pat) {
170
+ const { name, pattern, description } = pat;
171
+ if (!(pattern instanceof RegExp))
172
+ return pat;
173
+ return {
174
+ name,
175
+ pattern: new PatternRegExp_1.PatternRegExp(pattern),
176
+ description,
177
+ };
178
+ }
179
+ function getDefaultSettings(useDefaultDictionaries = true) {
180
+ return getSettings(useDefaultDictionaries);
161
181
  }
162
182
  exports.getDefaultSettings = getDefaultSettings;
183
+ function getDefaultBundledSettings() {
184
+ return getDefaultSettings();
185
+ }
186
+ exports.getDefaultBundledSettings = getDefaultBundledSettings;
163
187
  //# sourceMappingURL=DefaultSettings.js.map
@@ -1,6 +1,6 @@
1
1
  export { clearCachedSettingsFiles, defaultConfigFilenames, defaultFileName, extractImportErrors, getCachedFileSize, getGlobalSettings, loadConfig, loadPnP, loadPnPSync, readRawSettings, readSettings, readSettingsFiles, searchForConfig, sectionCSpell, } from './configLoader';
2
2
  export { calcOverrideSettings, checkFilenameMatchesGlob, currentSettingsFileVersion, ENV_CSPELL_GLOB_ROOT, extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, } from './CSpellSettingsServer';
3
3
  export type { ConfigurationDependencies, ImportFileRefWithError } from './CSpellSettingsServer';
4
- export { getDefaultSettings } from './DefaultSettings';
4
+ export { getDefaultSettings, getDefaultBundledSettings } from './DefaultSettings';
5
5
  export { ImportError } from './ImportError';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ImportError = exports.getDefaultSettings = exports.mergeSettings = exports.mergeInDocSettings = exports.getSources = exports.finalizeSettings = exports.extractDependencies = exports.ENV_CSPELL_GLOB_ROOT = exports.currentSettingsFileVersion = exports.checkFilenameMatchesGlob = exports.calcOverrideSettings = exports.sectionCSpell = exports.searchForConfig = exports.readSettingsFiles = exports.readSettings = exports.readRawSettings = exports.loadPnPSync = exports.loadPnP = exports.loadConfig = exports.getGlobalSettings = exports.getCachedFileSize = exports.extractImportErrors = exports.defaultFileName = exports.defaultConfigFilenames = exports.clearCachedSettingsFiles = void 0;
3
+ exports.ImportError = exports.getDefaultBundledSettings = exports.getDefaultSettings = exports.mergeSettings = exports.mergeInDocSettings = exports.getSources = exports.finalizeSettings = exports.extractDependencies = exports.ENV_CSPELL_GLOB_ROOT = exports.currentSettingsFileVersion = exports.checkFilenameMatchesGlob = exports.calcOverrideSettings = exports.sectionCSpell = exports.searchForConfig = exports.readSettingsFiles = exports.readSettings = exports.readRawSettings = exports.loadPnPSync = exports.loadPnP = exports.loadConfig = exports.getGlobalSettings = exports.getCachedFileSize = exports.extractImportErrors = exports.defaultFileName = exports.defaultConfigFilenames = exports.clearCachedSettingsFiles = void 0;
4
4
  var configLoader_1 = require("./configLoader");
5
5
  Object.defineProperty(exports, "clearCachedSettingsFiles", { enumerable: true, get: function () { return configLoader_1.clearCachedSettingsFiles; } });
6
6
  Object.defineProperty(exports, "defaultConfigFilenames", { enumerable: true, get: function () { return configLoader_1.defaultConfigFilenames; } });
@@ -28,6 +28,7 @@ Object.defineProperty(exports, "mergeInDocSettings", { enumerable: true, get: fu
28
28
  Object.defineProperty(exports, "mergeSettings", { enumerable: true, get: function () { return CSpellSettingsServer_1.mergeSettings; } });
29
29
  var DefaultSettings_1 = require("./DefaultSettings");
30
30
  Object.defineProperty(exports, "getDefaultSettings", { enumerable: true, get: function () { return DefaultSettings_1.getDefaultSettings; } });
31
+ Object.defineProperty(exports, "getDefaultBundledSettings", { enumerable: true, get: function () { return DefaultSettings_1.getDefaultBundledSettings; } });
31
32
  var ImportError_1 = require("./ImportError");
32
33
  Object.defineProperty(exports, "ImportError", { enumerable: true, get: function () { return ImportError_1.ImportError; } });
33
34
  //# sourceMappingURL=index.js.map
@@ -54,7 +54,7 @@ class SpellingDictionaryCollection {
54
54
  return this._suggest(word, suggestOptions);
55
55
  }
56
56
  _suggest(word, suggestOptions) {
57
- const { numSuggestions = (0, Settings_1.getDefaultSettings)().numSuggestions || SpellingDictionaryMethods_1.defaultNumSuggestions, numChanges, ignoreCase, includeTies, timeout, } = suggestOptions;
57
+ const { numSuggestions = (0, Settings_1.getDefaultSettings)(false).numSuggestions || SpellingDictionaryMethods_1.defaultNumSuggestions, numChanges, ignoreCase, includeTies, timeout, } = suggestOptions;
58
58
  const prefixNoCase = cspell_trie_lib_1.CASE_INSENSITIVE_PREFIX;
59
59
  const filter = (word, _cost) => {
60
60
  return ((ignoreCase || word[0] !== prefixNoCase) &&
@@ -97,7 +97,7 @@ class SpellingDictionaryFromTrie {
97
97
  return this._suggest(word, suggestOptions);
98
98
  }
99
99
  _suggest(word, suggestOptions) {
100
- const { numSuggestions = (0, Settings_1.getDefaultSettings)().numSuggestions || SpellingDictionaryMethods_1.defaultNumSuggestions, numChanges, includeTies, ignoreCase, timeout, } = suggestOptions;
100
+ const { numSuggestions = (0, Settings_1.getDefaultSettings)(false).numSuggestions || SpellingDictionaryMethods_1.defaultNumSuggestions, numChanges, includeTies, ignoreCase, timeout, } = suggestOptions;
101
101
  function filter(_word) {
102
102
  return true;
103
103
  }
@@ -35,6 +35,7 @@ async function* suggestionsForWords(words, options, settings = {}) {
35
35
  }
36
36
  exports.suggestionsForWords = suggestionsForWords;
37
37
  async function suggestionsForWord(word, options, settings = {}) {
38
+ var _a;
38
39
  const { languageId, locale: language, strict = true, numChanges = 4, numSuggestions = 8, includeTies = true, includeDefaultConfig = true, dictionaries, } = options || {};
39
40
  const ignoreCase = !strict;
40
41
  async function determineDictionaries(config) {
@@ -56,7 +57,9 @@ async function suggestionsForWord(word, options, settings = {}) {
56
57
  };
57
58
  }
58
59
  await (0, SpellingDictionary_1.refreshDictionaryCache)();
59
- const config = includeDefaultConfig ? (0, Settings_1.mergeSettings)((0, Settings_1.getDefaultSettings)(), (0, Settings_1.getGlobalSettings)(), settings) : settings;
60
+ const config = includeDefaultConfig
61
+ ? (0, Settings_1.mergeSettings)((0, Settings_1.getDefaultSettings)((_a = settings.loadDefaultConfiguration) !== null && _a !== void 0 ? _a : true), (0, Settings_1.getGlobalSettings)(), settings)
62
+ : settings;
60
63
  const { dictionaryCollection, allDictionaryCollection } = await determineDictionaries(config);
61
64
  const opts = { ignoreCase, numChanges, numSuggestions, includeTies };
62
65
  const suggestionsByDictionary = dictionaryCollection.dictionaries.map((dict) => dict.suggest(word, opts).map((r) => ({ ...r, dictName: dict.name })));
@@ -41,11 +41,11 @@ const TextDocumentSettings_1 = require("../Settings/TextDocumentSettings");
41
41
  * @param settings - The near final settings. Should already be the combination of all configuration files.
42
42
  */
43
43
  function determineTextDocumentSettings(doc, settings) {
44
- var _a;
44
+ var _a, _b;
45
45
  const filename = doc.uri.fsPath;
46
- const settingsWithDefaults = (0, Settings_1.mergeSettings)((0, Settings_1.getDefaultSettings)(), (0, Settings_1.getGlobalSettings)(), settings);
46
+ const settingsWithDefaults = (0, Settings_1.mergeSettings)((0, Settings_1.getDefaultSettings)((_a = settings.loadDefaultConfiguration) !== null && _a !== void 0 ? _a : true), (0, Settings_1.getGlobalSettings)(), settings);
47
47
  const fileSettings = (0, Settings_1.calcOverrideSettings)(settingsWithDefaults, filename);
48
- const languageIds = ((_a = fileSettings === null || fileSettings === void 0 ? void 0 : fileSettings.languageId) === null || _a === void 0 ? void 0 : _a.length)
48
+ const languageIds = ((_b = fileSettings === null || fileSettings === void 0 ? void 0 : fileSettings.languageId) === null || _b === void 0 ? void 0 : _b.length)
49
49
  ? fileSettings.languageId
50
50
  : doc.languageId
51
51
  ? doc.languageId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell-lib",
3
- "version": "5.19.4",
3
+ "version": "5.19.7",
4
4
  "description": "A library of useful functions used across various cspell tools.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -48,17 +48,17 @@
48
48
  },
49
49
  "homepage": "https://github.com/streetsidesoftware/cspell#readme",
50
50
  "dependencies": {
51
- "@cspell/cspell-bundled-dicts": "^5.19.4",
52
- "@cspell/cspell-pipe": "^5.19.4",
53
- "@cspell/cspell-types": "^5.19.4",
51
+ "@cspell/cspell-bundled-dicts": "^5.19.7",
52
+ "@cspell/cspell-pipe": "^5.19.7",
53
+ "@cspell/cspell-types": "^5.19.7",
54
54
  "clear-module": "^4.1.2",
55
55
  "comment-json": "^4.2.2",
56
56
  "configstore": "^5.0.1",
57
57
  "cosmiconfig": "^7.0.1",
58
- "cspell-glob": "^5.19.4",
59
- "cspell-io": "^5.19.4",
60
- "cspell-trie-lib": "^5.19.4",
61
- "fast-equals": "^3.0.0",
58
+ "cspell-glob": "^5.19.7",
59
+ "cspell-io": "^5.19.7",
60
+ "cspell-trie-lib": "^5.19.7",
61
+ "fast-equals": "^3.0.1",
62
62
  "find-up": "^5.0.0",
63
63
  "fs-extra": "^10.0.1",
64
64
  "gensequence": "^3.1.1",
@@ -78,7 +78,7 @@
78
78
  "@cspell/dict-fa-ir": "^2.0.0",
79
79
  "@cspell/dict-fr-fr": "^2.0.1",
80
80
  "@cspell/dict-html": "^1.1.9",
81
- "@cspell/dict-nl-nl": "^2.2.3",
81
+ "@cspell/dict-nl-nl": "^2.2.4",
82
82
  "@cspell/dict-python": "^2.0.6",
83
83
  "@types/configstore": "^5.0.1",
84
84
  "@types/fs-extra": "^9.0.13",
@@ -89,8 +89,8 @@
89
89
  "lorem-ipsum": "^2.0.4",
90
90
  "rimraf": "^3.0.2",
91
91
  "rollup": "^2.70.1",
92
- "rollup-plugin-dts": "^4.2.0",
92
+ "rollup-plugin-dts": "^4.2.1",
93
93
  "ts-jest": "^27.1.4"
94
94
  },
95
- "gitHead": "9f7e77c95eb1e8fabf53c5b74b7418b2d114ef02"
95
+ "gitHead": "1d33cd1b61250f8c4c5c2c218ec43675614784ca"
96
96
  }