cspell-lib 9.6.0 → 9.6.2

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 (98) hide show
  1. package/dist/cspell-rpc/api.d.ts +28 -0
  2. package/dist/cspell-rpc/api.js +6 -0
  3. package/dist/cspell-rpc/client.d.ts +17 -0
  4. package/dist/cspell-rpc/client.js +20 -0
  5. package/dist/cspell-rpc/index.d.ts +7 -0
  6. package/dist/cspell-rpc/index.js +4 -0
  7. package/dist/cspell-rpc/server.d.ts +16 -0
  8. package/dist/cspell-rpc/server.js +37 -0
  9. package/dist/cspell-rpc/spellCheckFile.d.ts +2 -0
  10. package/dist/cspell-rpc/spellCheckFile.js +2 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.js +2 -0
  13. package/dist/lib/Settings/CSpellSettingsServer.d.ts +4 -2
  14. package/dist/lib/Settings/CSpellSettingsServer.js +10 -2
  15. package/dist/lib/Settings/Controller/configLoader/configLoader.js +1 -1
  16. package/dist/lib/Settings/Controller/configLoader/defaultSettings.js +1 -1
  17. package/dist/lib/Settings/Controller/configLoader/normalizeRawSettings.js +1 -1
  18. package/dist/lib/Settings/Controller/configLoader/types.d.ts +1 -1
  19. package/dist/lib/Settings/DefaultSettings.d.ts +1 -1
  20. package/dist/lib/Settings/DefaultSettings.js +1 -1
  21. package/dist/lib/Settings/InDocSettings.d.ts +0 -3
  22. package/dist/lib/Settings/InDocSettings.js +2 -3
  23. package/dist/lib/Settings/LanguageSettings.js +3 -3
  24. package/dist/lib/Settings/TextDocumentSettings.d.ts +1 -1
  25. package/dist/lib/Settings/index.d.ts +3 -1
  26. package/dist/lib/Settings/index.js +2 -1
  27. package/dist/lib/Settings/internal/CSpellSettingsInternalDef.d.ts +18 -0
  28. package/dist/lib/{Models → Settings/internal}/CSpellSettingsInternalDef.js +1 -10
  29. package/dist/lib/Settings/{DictionarySettings.d.ts → internal/DictionarySettings.d.ts} +3 -2
  30. package/dist/lib/Settings/{DictionarySettings.js → internal/DictionarySettings.js} +14 -9
  31. package/dist/lib/{Models/CSpellSettingsInternalDef.d.ts → Settings/internal/InternalDictionaryDef.d.ts} +2 -17
  32. package/dist/lib/Settings/internal/InternalDictionaryDef.js +10 -0
  33. package/dist/lib/Settings/internal/index.d.ts +6 -0
  34. package/dist/lib/Settings/internal/index.js +4 -0
  35. package/dist/lib/Settings/sanitizeSettings.d.ts +11 -0
  36. package/dist/lib/Settings/sanitizeSettings.js +254 -0
  37. package/dist/lib/Settings/util/settingsToJson.d.ts +28 -0
  38. package/dist/lib/Settings/util/settingsToJson.js +125 -0
  39. package/dist/lib/SpellingDictionary/Dictionaries.d.ts +1 -1
  40. package/dist/lib/SpellingDictionary/Dictionaries.js +1 -1
  41. package/dist/lib/SpellingDictionary/DictionaryController/DictionaryLoader.d.ts +1 -1
  42. package/dist/lib/SpellingDictionary/DictionaryController/DictionaryLoader.js +99 -20
  43. package/dist/lib/SpellingDictionary/DictionaryLoader.d.ts +1 -1
  44. package/dist/lib/index.d.ts +2 -2
  45. package/dist/lib/index.js +2 -2
  46. package/dist/lib/perf/index.d.ts +1 -1
  47. package/dist/lib/perf/index.js +1 -1
  48. package/dist/lib/spellCheckFile.d.ts +10 -0
  49. package/dist/lib/spellCheckFile.js +24 -4
  50. package/dist/lib/suggestions.js +3 -3
  51. package/dist/lib/textValidation/cleanValidationIssue.d.ts +3 -0
  52. package/dist/lib/textValidation/cleanValidationIssue.js +21 -0
  53. package/dist/lib/textValidation/determineTextDocumentSettings.d.ts +1 -1
  54. package/dist/lib/textValidation/docValidator.d.ts +4 -1
  55. package/dist/lib/textValidation/docValidator.js +18 -1
  56. package/dist/lib/textValidation/settingsToValidateOptions.d.ts +1 -1
  57. package/dist/lib/util/clone.d.ts +35 -0
  58. package/dist/lib/util/clone.js +76 -0
  59. package/dist/lib/util/memoizeLastCall.d.ts +13 -0
  60. package/dist/lib/util/{memorizeLastCall.js → memoizeLastCall.js} +2 -2
  61. package/dist/lib/util/memoizeWeak.d.ts +6 -0
  62. package/dist/lib/util/{memorizerWeak.js → memoizeWeak.js} +2 -2
  63. package/dist/lib/util/text.js +6 -4
  64. package/dist/lib/util/textRegex.d.ts +2 -2
  65. package/dist/lib/util/textRegex.js +2 -2
  66. package/dist/rpc/Future.d.ts +18 -0
  67. package/dist/rpc/Future.js +49 -0
  68. package/dist/rpc/MessagePortEvents.d.ts +56 -0
  69. package/dist/rpc/MessagePortEvents.js +94 -0
  70. package/dist/rpc/assert.d.ts +14 -0
  71. package/dist/rpc/assert.js +21 -0
  72. package/dist/rpc/client.d.ts +186 -0
  73. package/dist/rpc/client.js +364 -0
  74. package/dist/rpc/errors.d.ts +24 -0
  75. package/dist/rpc/errors.js +47 -0
  76. package/dist/rpc/index.d.ts +11 -0
  77. package/dist/rpc/index.js +6 -0
  78. package/dist/rpc/messagePort.d.ts +34 -0
  79. package/dist/rpc/messagePort.js +2 -0
  80. package/dist/rpc/models.d.ts +134 -0
  81. package/dist/rpc/models.js +2 -0
  82. package/dist/rpc/modelsHelpers.d.ts +56 -0
  83. package/dist/rpc/modelsHelpers.js +117 -0
  84. package/dist/rpc/notify.d.ts +79 -0
  85. package/dist/rpc/notify.js +135 -0
  86. package/dist/rpc/protocol.d.ts +21 -0
  87. package/dist/rpc/protocol.js +17 -0
  88. package/dist/rpc/server.d.ts +39 -0
  89. package/dist/rpc/server.js +146 -0
  90. package/dist/rpc/types.d.ts +9 -0
  91. package/dist/rpc/types.js +2 -0
  92. package/dist/rpc.d.ts +2 -0
  93. package/dist/rpc.js +2 -0
  94. package/package.json +34 -21
  95. package/dist/lib/perf/performance.d.ts +0 -16
  96. package/dist/lib/perf/performance.js +0 -34
  97. package/dist/lib/util/memorizeLastCall.d.ts +0 -13
  98. package/dist/lib/util/memorizerWeak.d.ts +0 -6
@@ -0,0 +1,28 @@
1
+ import type { spellCheckDocumentRPC } from './spellCheckFile.js';
2
+ export interface CSpellRPCApi {
3
+ spellCheckDocument: typeof spellCheckDocumentRPC;
4
+ /**
5
+ * Sleeps for the given number of milliseconds.
6
+ *
7
+ * **Note:** This is primarily for testing purposes.
8
+ *
9
+ * @param ms - The number of milliseconds to sleep.
10
+ * @returns A promise that resolves with the number of milliseconds slept.
11
+ */
12
+ sleep: (ms: number) => Promise<number>;
13
+ /**
14
+ * Returns the given message.
15
+ *
16
+ * **Note:** This is primarily for testing purposes.
17
+ *
18
+ * @param msg - The message to echo.
19
+ * @returns A promise that resolves with the given message.
20
+ */
21
+ echo: (msg: string) => Promise<string>;
22
+ }
23
+ export type CSpellRPCApiMethodNames = keyof CSpellRPCApi;
24
+ export type CSpellRPCApiEndpointNames = {
25
+ [K in CSpellRPCApiMethodNames]: K;
26
+ };
27
+ export declare const CSPELL_RPC_API_ENDPOINTS: CSpellRPCApiEndpointNames;
28
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1,6 @@
1
+ export const CSPELL_RPC_API_ENDPOINTS = {
2
+ spellCheckDocument: 'spellCheckDocument',
3
+ sleep: 'sleep',
4
+ echo: 'echo',
5
+ };
6
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1,17 @@
1
+ import type { RPCClientConfiguration, RPCClientOptions, RPCProtocol } from '../rpc/index.js';
2
+ import { RPCClient } from '../rpc/index.js';
3
+ import type { CSpellRPCApi } from './api.js';
4
+ export type { MessagePortLike } from '../rpc/index.js';
5
+ export type CSpellRPCClientOptions = RPCClientOptions;
6
+ export type CSpellRPCClientConfig = RPCClientConfiguration;
7
+ export declare class CSpellRPCClient extends RPCClient<CSpellRPCApi> {
8
+ constructor(config: CSpellRPCClientConfig);
9
+ getApi(): RPCProtocol<CSpellRPCApi>;
10
+ }
11
+ /**
12
+ * Create a CSpell RPC Client.
13
+ * @param config - Client configuration
14
+ * @returns CSpellRPCClient
15
+ */
16
+ export declare function createCSpellRPCClient(config: CSpellRPCClientConfig): CSpellRPCClient;
17
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { RPCClient } from '../rpc/index.js';
3
+ import { CSPELL_RPC_API_ENDPOINTS } from './api.js';
4
+ export class CSpellRPCClient extends RPCClient {
5
+ constructor(config) {
6
+ super({ randomUUID, ...config });
7
+ }
8
+ getApi() {
9
+ return super.getApi(Object.keys(CSPELL_RPC_API_ENDPOINTS));
10
+ }
11
+ }
12
+ /**
13
+ * Create a CSpell RPC Client.
14
+ * @param config - Client configuration
15
+ * @returns CSpellRPCClient
16
+ */
17
+ export function createCSpellRPCClient(config) {
18
+ return new CSpellRPCClient(config);
19
+ }
20
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,7 @@
1
+ export type { CSpellRPCApi } from './api.js';
2
+ export { CSPELL_RPC_API_ENDPOINTS } from './api.js';
3
+ export type { CSpellRPCClientOptions } from './client.js';
4
+ export { createCSpellRPCClient, CSpellRPCClient } from './client.js';
5
+ export type { CSpellRPCServerOptions, MessagePortLike } from './server.js';
6
+ export { createCSpellRPCServer, CSpellRPCServer } from './server.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export { CSPELL_RPC_API_ENDPOINTS } from './api.js';
2
+ export { createCSpellRPCClient, CSpellRPCClient } from './client.js';
3
+ export { createCSpellRPCServer, CSpellRPCServer } from './server.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,16 @@
1
+ import type { RPCServerConfiguration, RPCServerOptions } from '../rpc/index.js';
2
+ import { RPCServer } from '../rpc/index.js';
3
+ import type { CSpellRPCApi } from './api.js';
4
+ export type { MessagePortLike } from '../rpc/index.js';
5
+ export type CSpellRPCServerOptions = RPCServerOptions;
6
+ export type CSpellRPCServerConfig = RPCServerConfiguration;
7
+ export declare class CSpellRPCServer extends RPCServer<CSpellRPCApi> {
8
+ constructor(config: CSpellRPCServerConfig);
9
+ }
10
+ /**
11
+ * Create a CSpell RPC Server that listens on the given port.
12
+ * @param config - Server configuration.
13
+ * @returns The CSpell RPC Server.
14
+ */
15
+ export declare function createCSpellRPCServer(config: CSpellRPCServerConfig): CSpellRPCServer;
16
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1,37 @@
1
+ import { RPCServer } from '../rpc/index.js';
2
+ import { spellCheckDocumentRPC } from './spellCheckFile.js';
3
+ export class CSpellRPCServer extends RPCServer {
4
+ constructor(config) {
5
+ super(config, getCSpellRPCApi());
6
+ }
7
+ }
8
+ /**
9
+ * Create a CSpell RPC Server that listens on the given port.
10
+ * @param config - Server configuration.
11
+ * @returns The CSpell RPC Server.
12
+ */
13
+ export function createCSpellRPCServer(config) {
14
+ return new CSpellRPCServer(config);
15
+ }
16
+ /**
17
+ * Get the CSpell RPC API.
18
+ *
19
+ * @returns the api implementation.
20
+ */
21
+ function getCSpellRPCApi() {
22
+ return {
23
+ spellCheckDocument: spellCheckDocumentRPC,
24
+ sleep,
25
+ echo,
26
+ };
27
+ }
28
+ function echo(msg) {
29
+ return Promise.resolve(msg);
30
+ }
31
+ function sleep(ms) {
32
+ return new Promise((resolve) => {
33
+ const start = performance.now();
34
+ setTimeout(() => resolve(performance.now() - start), ms);
35
+ });
36
+ }
37
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1,2 @@
1
+ export { spellCheckDocumentRPC } from '../lib/spellCheckFile.js';
2
+ //# sourceMappingURL=spellCheckFile.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { spellCheckDocumentRPC } from '../lib/spellCheckFile.js';
2
+ //# sourceMappingURL=spellCheckFile.js.map
@@ -0,0 +1,2 @@
1
+ export * from './lib/index.js';
2
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './lib/index.js';
2
+ //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
- import type { AdvancedCSpellSettingsWithSourceTrace, ImportFileRef } from '@cspell/cspell-types';
2
- import type { CSpellSettingsInternal, CSpellSettingsInternalFinalized } from '../Models/CSpellSettingsInternalDef.js';
1
+ import type { AdvancedCSpellSettingsWithSourceTrace, CSpellSettings, ImportFileRef } from '@cspell/cspell-types';
3
2
  import type { OptionalOrUndefined } from '../util/types.js';
3
+ import type { CSpellSettingsInternal, CSpellSettingsInternalFinalized } from './internal/index.js';
4
4
  type CSpellSettingsWST = AdvancedCSpellSettingsWithSourceTrace;
5
5
  export type CSpellSettingsWSTO = OptionalOrUndefined<AdvancedCSpellSettingsWithSourceTrace>;
6
6
  export type CSpellSettingsI = CSpellSettingsInternal;
@@ -9,6 +9,8 @@ declare function mergeObjects(left: undefined, right: undefined): undefined;
9
9
  declare function mergeObjects<T>(left: T, right: undefined): T;
10
10
  declare function mergeObjects<T>(left: T, right: T): T;
11
11
  declare function mergeObjects<T>(left: undefined, right: T): T;
12
+ export declare function toCSpellSettingsWithSourceTrace(settings: CSpellSettingsWSTO | CSpellSettingsI): CSpellSettingsWSTO;
13
+ export declare function toCSpellSettingsWithOutSourceTrace(settings: CSpellSettingsWSTO | CSpellSettingsI): CSpellSettings;
12
14
  export declare function mergeSettings(left: CSpellSettingsWSTO | CSpellSettingsI, ...settings: (CSpellSettingsWSTO | CSpellSettingsI | undefined)[]): CSpellSettingsI;
13
15
  export declare function mergeInDocSettings(left: CSpellSettingsWSTO, ...rest: CSpellSettingsWSTO[]): CSpellSettingsWST;
14
16
  /**
@@ -1,14 +1,15 @@
1
1
  import assert from 'node:assert';
2
2
  import { onClearCache } from '../events/index.js';
3
- import { cleanCSpellSettingsInternal as csi, isCSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.js';
4
3
  import { autoResolveWeak, AutoResolveWeakCache } from '../util/AutoResolve.js';
5
4
  import { toFileUrl } from '../util/url.js';
6
5
  import * as util from '../util/util.js';
7
6
  import { configSettingsFileVersion0_1, ENV_CSPELL_GLOB_ROOT } from './constants.js';
8
- import { calcDictionaryDefsToLoad, mapDictDefsToInternal } from './DictionarySettings.js';
7
+ import { calcDictionaryDefsToLoad, mapDictDefsToInternal } from './internal/index.js';
8
+ import { cleanCSpellSettingsInternal as csi, isCSpellSettingsInternal } from './internal/index.js';
9
9
  import { mergeList, mergeListUnique } from './mergeList.js';
10
10
  import { resolvePatterns } from './patterns.js';
11
11
  import { CwdUrlResolver } from './resolveCwd.js';
12
+ import { walkToJSONObj } from './util/settingsToJson.js';
12
13
  export { stats as getMergeStats } from './mergeList.js';
13
14
  const emptyWords = [];
14
15
  Object.freeze(emptyWords);
@@ -54,6 +55,13 @@ function replaceIfNotEmpty(left = [], right = []) {
54
55
  }
55
56
  return left;
56
57
  }
58
+ export function toCSpellSettingsWithSourceTrace(settings) {
59
+ return walkToJSONObj(settings);
60
+ }
61
+ export function toCSpellSettingsWithOutSourceTrace(settings) {
62
+ const { __importRef, __imports, source: _source, ...rest } = toCSpellSettingsWithSourceTrace(settings);
63
+ return util.clean(rest);
64
+ }
57
65
  export function mergeSettings(left, ...settings) {
58
66
  const rawSettings = settings.filter(util.isDefined).reduce(merge, toInternalSettings(left));
59
67
  return util.clean(rawSettings);
@@ -7,7 +7,6 @@ import { isUrlLike, toFileURL } from 'cspell-io';
7
7
  import { URI, Utils as UriUtils } from 'vscode-uri';
8
8
  import { onClearCache } from '../../../events/index.js';
9
9
  import { getVirtualFS } from '../../../fileSystem.js';
10
- import { createCSpellSettingsInternal as csi } from '../../../Models/CSpellSettingsInternalDef.js';
11
10
  import { srcDirectory } from '../../../pkg-info.mjs';
12
11
  import { autoResolve, AutoResolveCache, autoResolveWeak } from '../../../util/AutoResolve.js';
13
12
  import { logError, logWarning } from '../../../util/logger.js';
@@ -17,6 +16,7 @@ import { addTrailingSlash, cwdURL, resolveFileWithURL, toFileDirURL, toFilePathO
17
16
  import { configSettingsFileVersion0_1, configSettingsFileVersion0_2, currentSettingsFileVersion, defaultConfigFileModuleRef, ENV_CSPELL_GLOB_ROOT, } from '../../constants.js';
18
17
  import { getMergeStats, mergeSettings, toInternalSettings } from '../../CSpellSettingsServer.js';
19
18
  import { getGlobalConfig } from '../../GlobalSettings.js';
19
+ import { createCSpellSettingsInternal as csi } from '../../internal/index.js';
20
20
  import { ImportError } from '../ImportError.js';
21
21
  import { pnpLoader } from '../pnpLoader.js';
22
22
  import { searchPlaces } from './configLocations.js';
@@ -1,5 +1,5 @@
1
- import { createCSpellSettingsInternal as csi } from '../../../Models/CSpellSettingsInternalDef.js';
2
1
  import { currentSettingsFileVersion } from '../../constants.js';
2
+ import { createCSpellSettingsInternal as csi } from '../../internal/index.js';
3
3
  export const defaultSettings = csi({
4
4
  id: 'default',
5
5
  name: 'default',
@@ -3,7 +3,7 @@ import { fileURLToPath } from 'node:url';
3
3
  import { resolveFile } from '../../../util/resolveFile.js';
4
4
  import { resolveFileWithURL, toFilePathOrHref } from '../../../util/url.js';
5
5
  import * as util from '../../../util/util.js';
6
- import { mapDictDefsToInternal } from '../../DictionarySettings.js';
6
+ import { mapDictDefsToInternal } from '../../internal/index.js';
7
7
  import { toGlobDef } from './toGlobDef.js';
8
8
  export function normalizeRawConfig(config) {
9
9
  if (typeof config.version === 'number') {
@@ -1,5 +1,5 @@
1
1
  import type { CSpellSettingsWithSourceTrace } from '@cspell/cspell-types';
2
- import type { CSpellSettingsInternal } from '../../../Models/CSpellSettingsInternalDef.js';
2
+ import type { CSpellSettingsInternal } from '../../internal/index.js';
3
3
  export type CSpellSettingsWST = CSpellSettingsWithSourceTrace;
4
4
  export type CSpellSettingsI = CSpellSettingsInternal;
5
5
  //# sourceMappingURL=types.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { CSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.js';
1
+ import type { CSpellSettingsInternal } from './internal/index.js';
2
2
  export declare const _defaultSettingsBasis: Readonly<CSpellSettingsInternal>;
3
3
  export declare const _defaultSettings: Readonly<CSpellSettingsInternal>;
4
4
  declare class DefaultSettingsLoader {
@@ -1,11 +1,11 @@
1
1
  import { parsers } from 'cspell-grammar';
2
- import { createCSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.js';
3
2
  import { PatternRegExp } from '../Models/PatternRegExp.js';
4
3
  import { srcDirectory } from '../pkg-info.mjs';
5
4
  import { resolveFile } from '../util/resolveFile.js';
6
5
  import { defaultConfigFileModuleRef } from './constants.js';
7
6
  import { readSettings } from './Controller/configLoader/index.js';
8
7
  import { mergeSettings } from './CSpellSettingsServer.js';
8
+ import { createCSpellSettingsInternal } from './internal/index.js';
9
9
  import * as LanguageSettings from './LanguageSettings.js';
10
10
  import * as RegPat from './RegExpPatterns.js';
11
11
  // Do not use require.resolve because webpack will mess it up.
@@ -31,9 +31,6 @@ interface DirectiveMatchWithParser extends PossibleMatch {
31
31
  directive: Directive;
32
32
  fn: ReducerFn;
33
33
  }
34
- export declare const regExSpellingGuardBlock: RegExp;
35
- export declare const regExSpellingGuardNext: RegExp;
36
- export declare const regExSpellingGuardLine: RegExp;
37
34
  declare function parseCompoundWords(acc: CSpellUserSettings, match: string): CSpellUserSettings;
38
35
  declare function parseWords(acc: CSpellUserSettings, match: string): CSpellUserSettings;
39
36
  declare function parseIgnoreWords(acc: CSpellUserSettings, match: string): CSpellUserSettings;
@@ -118,14 +118,12 @@ const settingParsers = [
118
118
  [/^dictionar(?:y|ies)\b(?!-)/i, parseDictionaries, 'Dictionaries'], // cspell:disable-line
119
119
  [/^LocalWords:/, (acc, m) => reduceWordList(acc, m.replaceAll(/^LocalWords:?/gi, ' '), 'words'), 'Words'],
120
120
  ];
121
- export const regExSpellingGuardBlock = /(\bc?spell(?:-?checker)?::?)\s*disable(?!-line|-next)\b[\s\S]*?((?:\1\s*enable\b)|$)/gi;
122
- export const regExSpellingGuardNext = /\bc?spell(?:-?checker)?::?\s*disable-next\b.*\s\s?.*/gi;
123
- export const regExSpellingGuardLine = /^.*\bc?spell(?:-?checker)?::?\s*disable-line\b.*/gim;
124
121
  const issueMessages = {
125
122
  unknownDirective: 'Unknown CSpell directive',
126
123
  };
127
124
  function parseSettingMatchValidation(possibleMatch) {
128
125
  const { fullDirective, offset } = possibleMatch;
126
+ regExCSpellDirectiveKey.lastIndex = 0;
129
127
  const directiveMatch = fullDirective.match(regExCSpellDirectiveKey);
130
128
  if (!directiveMatch)
131
129
  return undefined;
@@ -231,6 +229,7 @@ function parseFlagWords(acc, match) {
231
229
  }
232
230
  function parseRegEx(match) {
233
231
  const patterns = [match.replace(/^[^\s]+\s+/, '')].map((a) => {
232
+ regExMatchRegEx.lastIndex = 0;
234
233
  const m = a.match(regExMatchRegEx);
235
234
  if (m && m[0]) {
236
235
  return m[0];
@@ -16,11 +16,11 @@ function stringToList(sList) {
16
16
  .map((s) => s.trim())
17
17
  .filter((s) => !!s);
18
18
  }
19
- function memorizer(resolver) {
19
+ function memoize(resolver) {
20
20
  const cache = createAutoResolveCache();
21
21
  return (k) => cache.get(k, resolver);
22
22
  }
23
- const _normalizeLanguageId = memorizer(__normalizeLanguageId);
23
+ const _normalizeLanguageId = memoize(__normalizeLanguageId);
24
24
  function __normalizeLanguageId(langId) {
25
25
  const langIds = stringToList(langId);
26
26
  return new Set(langIds.map((a) => a.toLowerCase()));
@@ -28,7 +28,7 @@ function __normalizeLanguageId(langId) {
28
28
  export function normalizeLanguageId(langId) {
29
29
  return _normalizeLanguageId(typeof langId === 'string' ? langId : langId.join(','));
30
30
  }
31
- const _normalizeLocale = memorizer(__normalizeLocale);
31
+ const _normalizeLocale = memoize(__normalizeLocale);
32
32
  function __normalizeLocale(locale) {
33
33
  const locales = localesToList(locale);
34
34
  return new Set(locales.map((locale) => locale.toLowerCase().replaceAll(/[^a-z]/g, '')));
@@ -1,5 +1,5 @@
1
1
  import type { CSpellSettings, CSpellUserSettings } from '@cspell/cspell-types';
2
- import type { CSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.js';
2
+ import type { CSpellSettingsInternal } from './internal/index.js';
3
3
  export declare function combineTextAndLanguageSettings(settings: CSpellUserSettings, text: string | undefined, languageId: string | string[]): CSpellSettingsInternal;
4
4
  export declare function extractSettingsFromText(text: string): CSpellSettings;
5
5
  //# sourceMappingURL=TextDocumentSettings.d.ts.map
@@ -5,6 +5,8 @@ export type { CSpellConfigFile, ICSpellConfigFile } from './Controller/configLoa
5
5
  export { clearCachedSettingsFiles, createConfigLoader, defaultConfigFilenames, defaultFileName, extractImportErrors, getCachedFileSize, getDefaultConfigLoader, getGlobalSettings, getGlobalSettingsAsync, loadConfig, loadPnP, readConfigFile, readRawSettings, readSettings, readSettingsFiles, resolveConfigFileImports, resolveSettingsImports, searchForConfig, sectionCSpell, } from './Controller/configLoader/index.js';
6
6
  export { ImportError } from './Controller/ImportError.js';
7
7
  export type { ConfigurationDependencies, ImportFileRefWithError } from './CSpellSettingsServer.js';
8
- export { extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, } from './CSpellSettingsServer.js';
8
+ export { extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, toCSpellSettingsWithOutSourceTrace, } from './CSpellSettingsServer.js';
9
9
  export { defaultSettingsLoader, getDefaultBundledSettingsAsync, getDefaultSettings } from './DefaultSettings.js';
10
+ export type { CSpellSettingsInternal, CSpellSettingsInternalFinalized, DictionaryDefinitionInlineInternal, DictionaryDefinitionInternal, DictionaryDefinitionSimpleInternal, DictionaryFileDefinitionInternal, } from './internal/index.js';
11
+ export { calcDictionaryDefsToLoad, createCSpellSettingsInternal, filterDictDefsToLoad, isDictionaryDefinitionInlineInternal, isDictionaryFileDefinitionInternal, mapDictDefToInternal, } from './internal/index.js';
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -3,6 +3,7 @@ export { checkFilenameMatchesGlob } from './checkFilenameMatchesGlob.js';
3
3
  export { currentSettingsFileVersion, ENV_CSPELL_GLOB_ROOT } from './constants.js';
4
4
  export { clearCachedSettingsFiles, createConfigLoader, defaultConfigFilenames, defaultFileName, extractImportErrors, getCachedFileSize, getDefaultConfigLoader, getGlobalSettings, getGlobalSettingsAsync, loadConfig, loadPnP, readConfigFile, readRawSettings, readSettings, readSettingsFiles, resolveConfigFileImports, resolveSettingsImports, searchForConfig, sectionCSpell, } from './Controller/configLoader/index.js';
5
5
  export { ImportError } from './Controller/ImportError.js';
6
- export { extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, } from './CSpellSettingsServer.js';
6
+ export { extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, toCSpellSettingsWithOutSourceTrace, } from './CSpellSettingsServer.js';
7
7
  export { defaultSettingsLoader, getDefaultBundledSettingsAsync, getDefaultSettings } from './DefaultSettings.js';
8
+ export { calcDictionaryDefsToLoad, createCSpellSettingsInternal, filterDictDefsToLoad, isDictionaryDefinitionInlineInternal, isDictionaryFileDefinitionInternal, mapDictDefToInternal, } from './internal/index.js';
8
9
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,18 @@
1
+ import type { AdvancedCSpellSettingsWithSourceTrace, CSpellSettingsWithSourceTrace, Parser } from '@cspell/cspell-types';
2
+ import type { OptionalOrUndefined } from '../../util/types.js';
3
+ import type { DictionaryDefinitionInternal } from './InternalDictionaryDef.js';
4
+ export declare const SymbolCSpellSettingsInternal: unique symbol;
5
+ export interface CSpellSettingsInternal extends Omit<AdvancedCSpellSettingsWithSourceTrace, 'dictionaryDefinitions'> {
6
+ [SymbolCSpellSettingsInternal]: true;
7
+ dictionaryDefinitions?: DictionaryDefinitionInternal[];
8
+ }
9
+ export interface CSpellSettingsInternalFinalized extends CSpellSettingsInternal {
10
+ parserFn: Parser | undefined;
11
+ finalized: true;
12
+ ignoreRegExpList: RegExp[];
13
+ includeRegExpList: RegExp[];
14
+ }
15
+ export declare function cleanCSpellSettingsInternal(parts?: OptionalOrUndefined<Partial<CSpellSettingsInternal>>): CSpellSettingsInternal;
16
+ export declare function createCSpellSettingsInternal(parts?: OptionalOrUndefined<Partial<CSpellSettingsInternal>>): CSpellSettingsInternal;
17
+ export declare function isCSpellSettingsInternal(cs: CSpellSettingsInternal | CSpellSettingsWithSourceTrace | OptionalOrUndefined<CSpellSettingsInternal | CSpellSettingsWithSourceTrace>): cs is CSpellSettingsInternal;
18
+ //# sourceMappingURL=CSpellSettingsInternalDef.d.ts.map
@@ -1,4 +1,4 @@
1
- import { clean } from '../util/util.js';
1
+ import { clean } from '../../util/util.js';
2
2
  export const SymbolCSpellSettingsInternal = Symbol('CSpellSettingsInternal');
3
3
  export function cleanCSpellSettingsInternal(parts) {
4
4
  return parts
@@ -11,13 +11,4 @@ export function createCSpellSettingsInternal(parts) {
11
11
  export function isCSpellSettingsInternal(cs) {
12
12
  return !!cs[SymbolCSpellSettingsInternal];
13
13
  }
14
- export function isDictionaryDefinitionInlineInternal(def) {
15
- if (def.path)
16
- return false;
17
- const defInline = def;
18
- return !!(defInline.words || defInline.flagWords || defInline.ignoreWords || defInline.suggestWords);
19
- }
20
- export function isDictionaryFileDefinitionInternal(def) {
21
- return !!(def.path || def.file);
22
- }
23
14
  //# sourceMappingURL=CSpellSettingsInternalDef.js.map
@@ -1,6 +1,7 @@
1
1
  import type { DictionaryDefinition } from '@cspell/cspell-types';
2
- import type { CSpellSettingsInternal, DictionaryDefinitionInternal, DictionaryDefinitionInternalWithSource, DictionaryFileDefinitionInternalWithSource } from '../Models/CSpellSettingsInternalDef.js';
3
- import type { DictionaryReferenceCollection } from './DictionaryReferenceCollection.js';
2
+ import type { DictionaryReferenceCollection } from '../DictionaryReferenceCollection.js';
3
+ import type { CSpellSettingsInternal } from './CSpellSettingsInternalDef.js';
4
+ import type { DictionaryDefinitionInternal, DictionaryDefinitionInternalWithSource, DictionaryFileDefinitionInternalWithSource } from './InternalDictionaryDef.js';
4
5
  export type DefMapArrayItem = [string, DictionaryDefinitionInternal];
5
6
  /**
6
7
  * Combines the list of desired dictionaries with the list of dictionary
@@ -1,11 +1,11 @@
1
1
  import * as path from 'node:path';
2
2
  import { mapDictionaryInformationToWeightMap } from 'cspell-trie-lib';
3
- import { isDictionaryDefinitionInlineInternal } from '../Models/CSpellSettingsInternalDef.js';
4
- import { createAutoResolveWeakWeakCache } from '../util/AutoResolve.js';
5
- import { resolveRelativeTo } from '../util/resolveFile.js';
6
- import { toFilePathOrHref } from '../util/url.js';
7
- import { clean } from '../util/util.js';
8
- import { createDictionaryReferenceCollection } from './DictionaryReferenceCollection.js';
3
+ import { createAutoResolveWeakWeakCache } from '../../util/AutoResolve.js';
4
+ import { resolveRelativeTo } from '../../util/resolveFile.js';
5
+ import { toFilePathOrHref } from '../../util/url.js';
6
+ import { clean } from '../../util/util.js';
7
+ import { createDictionaryReferenceCollection } from '../DictionaryReferenceCollection.js';
8
+ import { isDictionaryDefinitionInlineInternal } from './InternalDictionaryDef.js';
9
9
  /**
10
10
  * Combines the list of desired dictionaries with the list of dictionary
11
11
  * definitions. Order does not matter, but the number of leading `!` does.
@@ -99,9 +99,11 @@ class _DictionaryDefinitionInternalWithSource {
99
99
  ignoreForbiddenWords;
100
100
  scope;
101
101
  __source;
102
- ddi;
102
+ #ddi;
103
+ #def;
103
104
  constructor(def, sourceURL) {
104
105
  this.sourceURL = sourceURL;
106
+ this.#def = def;
105
107
  this.__source = sourceURL.href;
106
108
  // this bit of assignment is to have the compiler help use if any new fields are added.
107
109
  const defAll = def;
@@ -129,7 +131,7 @@ class _DictionaryDefinitionInternalWithSource {
129
131
  useCompounds,
130
132
  };
131
133
  Object.assign(this, clean(ddi));
132
- this.ddi = ddi;
134
+ this.#ddi = ddi;
133
135
  this.name = ddi.name;
134
136
  this.file = ddi.file;
135
137
  this.path = ddi.path;
@@ -141,7 +143,10 @@ class _DictionaryDefinitionInternalWithSource {
141
143
  return this._weightMap;
142
144
  }
143
145
  toJSON() {
144
- return this.ddi;
146
+ return this.#ddi;
147
+ }
148
+ __getOriginalDefinition() {
149
+ return this.#def;
145
150
  }
146
151
  }
147
152
  //# sourceMappingURL=DictionarySettings.js.map
@@ -1,17 +1,5 @@
1
- import type { AdvancedCSpellSettingsWithSourceTrace, CSpellSettingsWithSourceTrace, DictionaryDefinition, DictionaryDefinitionAugmented, DictionaryDefinitionCustom, DictionaryDefinitionInline, DictionaryDefinitionPreferred, DictionaryDefinitionSimple, Parser } from '@cspell/cspell-types';
1
+ import type { DictionaryDefinition, DictionaryDefinitionAugmented, DictionaryDefinitionCustom, DictionaryDefinitionInline, DictionaryDefinitionPreferred, DictionaryDefinitionSimple } from '@cspell/cspell-types';
2
2
  import type { WeightMap } from 'cspell-trie-lib';
3
- import type { OptionalOrUndefined } from '../util/types.js';
4
- export declare const SymbolCSpellSettingsInternal: unique symbol;
5
- export interface CSpellSettingsInternal extends Omit<AdvancedCSpellSettingsWithSourceTrace, 'dictionaryDefinitions'> {
6
- [SymbolCSpellSettingsInternal]: true;
7
- dictionaryDefinitions?: DictionaryDefinitionInternal[];
8
- }
9
- export interface CSpellSettingsInternalFinalized extends CSpellSettingsInternal {
10
- parserFn: Parser | undefined;
11
- finalized: true;
12
- ignoreRegExpList: RegExp[];
13
- includeRegExpList: RegExp[];
14
- }
15
3
  type DictionaryDefinitionCustomUniqueFields = Omit<DictionaryDefinitionCustom, keyof DictionaryDefinitionPreferred>;
16
4
  export type DictionaryDefinitionInternal = DictionaryFileDefinitionInternal | DictionaryDefinitionInlineInternal | DictionaryDefinitionSimpleInternal;
17
5
  export type DictionaryDefinitionInlineInternal = DictionaryDefinitionInline & {
@@ -36,10 +24,7 @@ export interface DictionaryFileDefinitionInternalWithSource extends DictionaryFi
36
24
  export type DictionaryDefinitionInternalWithSource = DictionaryDefinitionInternal & {
37
25
  readonly __source: string;
38
26
  };
39
- export declare function cleanCSpellSettingsInternal(parts?: OptionalOrUndefined<Partial<CSpellSettingsInternal>>): CSpellSettingsInternal;
40
- export declare function createCSpellSettingsInternal(parts?: OptionalOrUndefined<Partial<CSpellSettingsInternal>>): CSpellSettingsInternal;
41
- export declare function isCSpellSettingsInternal(cs: CSpellSettingsInternal | CSpellSettingsWithSourceTrace | OptionalOrUndefined<CSpellSettingsInternal | CSpellSettingsWithSourceTrace>): cs is CSpellSettingsInternal;
42
27
  export declare function isDictionaryDefinitionInlineInternal(def: DictionaryDefinitionInternal | DictionaryDefinitionInline | DictionaryDefinition): def is DictionaryDefinitionInlineInternal;
43
28
  export declare function isDictionaryFileDefinitionInternal(def: DictionaryDefinitionInternal | DictionaryDefinitionInline | DictionaryDefinition): def is DictionaryFileDefinitionInternal;
44
29
  export {};
45
- //# sourceMappingURL=CSpellSettingsInternalDef.d.ts.map
30
+ //# sourceMappingURL=InternalDictionaryDef.d.ts.map
@@ -0,0 +1,10 @@
1
+ export function isDictionaryDefinitionInlineInternal(def) {
2
+ if (def.path)
3
+ return false;
4
+ const defInline = def;
5
+ return !!(defInline.words || defInline.flagWords || defInline.ignoreWords || defInline.suggestWords);
6
+ }
7
+ export function isDictionaryFileDefinitionInternal(def) {
8
+ return !!(def.path || def.file);
9
+ }
10
+ //# sourceMappingURL=InternalDictionaryDef.js.map
@@ -0,0 +1,6 @@
1
+ export type { CSpellSettingsInternal, CSpellSettingsInternalFinalized } from './CSpellSettingsInternalDef.js';
2
+ export { cleanCSpellSettingsInternal, createCSpellSettingsInternal, isCSpellSettingsInternal, } from './CSpellSettingsInternalDef.js';
3
+ export { calcDictionaryDefsToLoad, filterDictDefsToLoad, mapDictDefsToInternal, mapDictDefToInternal, } from './DictionarySettings.js';
4
+ export type { DictionaryDefinitionInlineInternal, DictionaryDefinitionInternal, DictionaryDefinitionSimpleInternal, DictionaryFileDefinitionInternal, } from './InternalDictionaryDef.js';
5
+ export { isDictionaryDefinitionInlineInternal, isDictionaryFileDefinitionInternal } from './InternalDictionaryDef.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export { cleanCSpellSettingsInternal, createCSpellSettingsInternal, isCSpellSettingsInternal, } from './CSpellSettingsInternalDef.js';
2
+ export { calcDictionaryDefsToLoad, filterDictDefsToLoad, mapDictDefsToInternal, mapDictDefToInternal, } from './DictionarySettings.js';
3
+ export { isDictionaryDefinitionInlineInternal, isDictionaryFileDefinitionInternal } from './InternalDictionaryDef.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,11 @@
1
+ import type { CSpellSettingsWithSourceTrace } from '@cspell/cspell-types';
2
+ import type { CSpellSettingsInternal, CSpellSettingsInternalFinalized } from './internal/index.js';
3
+ type CloneableSettings = CSpellSettingsWithSourceTrace | CSpellSettingsInternal | CSpellSettingsInternalFinalized;
4
+ /**
5
+ * Sanitize settings for export by removing any internal only properties.
6
+ *
7
+ * @param settings - the input settings
8
+ */
9
+ export declare function cloneSettingsForExport(settings: Readonly<CloneableSettings>): CSpellSettingsWithSourceTrace;
10
+ export {};
11
+ //# sourceMappingURL=sanitizeSettings.d.ts.map