From 88b3c47286456c8c0d77bf80c3aada171626653c Mon Sep 17 00:00:00 2001 From: Jason3S Date: Mon, 13 Mar 2023 12:07:43 +0000 Subject: [PATCH] feat: Update CSpell to (6.29.1) --- action-src/package.json | 4 +- action/node_modules/.bin/cspell-esm | 1 + action/node_modules/.bin/cspell-gitignore | 2 +- action/node_modules/.bin/cspell-grammar | 2 +- .../@cspell/cspell-bundled-dicts/package.json | 14 +- .../@cspell/cspell-pipe/package.json | 4 +- .../@cspell/cspell-service-bus/package.json | 4 +- .../@cspell/cspell-types/package.json | 4 +- .../@cspell/dict-python/README.md | 2 +- .../@cspell/dict-python/package.json | 4 +- .../@cspell/dict-python/python.txt.gz | Bin 47152 -> 47155 bytes .../@cspell/dict-sql/cspell-ext.json | 3 +- .../@cspell/dict-sql/package.json | 4 +- .../@cspell/dynamic-import/package.json | 6 +- .../@cspell/strong-weak-map/package.json | 4 +- .../createInlineSpellingDictionary.js | 25 - .../SpellingDictionary/CachingDictionary.js | 18 +- .../SpellingDictionary/FlagWordsDictionary.js | 22 +- .../IgnoreWordsDictionary.js | 10 +- .../SpellingDictionary/SpellingDictionary.js | 0 .../SpellingDictionaryCollection.js | 24 +- .../SpellingDictionaryFromTrie.js | 32 +- .../SpellingDictionaryMethods.js | 10 +- .../SpellingDictionary/SuggestDictionary.js | 18 +- .../SpellingDictionary/Terms/index.js | 0 .../SpellingDictionary/Terms/terms.js | 0 .../SpellingDictionary/Typos/index.js | 14 +- .../SpellingDictionary/Typos/typos.js | 0 .../SpellingDictionary/Typos/typosParser.js | 12 +- .../SpellingDictionary/Typos/util.js | 0 .../SpellingDictionary/TyposDictionary.js | 20 +- .../createInlineSpellingDictionary.js | 25 + .../createSpellingDictionary.js | 18 +- .../{ => cjs}/SpellingDictionary/defaults.js | 0 .../{ => cjs}/SpellingDictionary/index.js | 40 +- .../cspell-dictionary/dist/{ => cjs}/index.js | 22 +- .../dist/{ => cjs}/util/AutoCache.js | 0 .../dist/{ => cjs}/util/AutoResolve.js | 0 .../dist/{ => cjs}/util/IterableLike.js | 0 .../dist/{ => cjs}/util/clean.js | 0 .../dist/{ => cjs}/util/regexHelper.js | 0 .../dist/{ => cjs}/util/repMap.js | 8 +- .../dist/{ => cjs}/util/simpleCache.js | 0 .../dist/{ => cjs}/util/text.js | 0 .../dist/{ => cjs}/util/textMappers.js | 4 +- .../dist/{ => cjs}/util/types.js | 0 .../dist/{ => cjs}/util/util.js | 0 .../CachingDictionary.d.mts | 30 + .../SpellingDictionary/CachingDictionary.mjs | 45 ++ .../FlagWordsDictionary.d.mts | 11 + .../FlagWordsDictionary.mjs | 134 +++++ .../IgnoreWordsDictionary.d.mts | 11 + .../IgnoreWordsDictionary.mjs | 96 ++++ .../SpellingDictionary.d.mts | 150 +++++ .../SpellingDictionary/SpellingDictionary.mjs | 4 + .../SpellingDictionaryCollection.d.mts | 16 + .../SpellingDictionaryCollection.mjs | 111 ++++ .../SpellingDictionaryFromTrie.d.mts | 50 ++ .../SpellingDictionaryFromTrie.mjs | 172 ++++++ .../SpellingDictionaryMethods.d.mts | 26 + .../SpellingDictionaryMethods.mjs | 96 ++++ .../SuggestDictionary.d.mts | 20 + .../SpellingDictionary/SuggestDictionary.mjs | 97 ++++ .../esm/SpellingDictionary/Terms/index.d.mts | 2 + .../esm/SpellingDictionary/Terms/index.mjs} | 0 .../esm/SpellingDictionary/Terms/terms.d.mts | 12 + .../esm/SpellingDictionary/Terms/terms.mjs} | 0 .../esm/SpellingDictionary/Typos/index.d.mts | 4 + .../esm/SpellingDictionary/Typos/index.mjs | 2 + .../esm/SpellingDictionary/Typos/typos.d.mts | 18 + .../esm/SpellingDictionary/Typos/typos.mjs} | 0 .../Typos/typosParser.d.mts | 34 ++ .../SpellingDictionary/Typos/typosParser.mjs | 131 +++++ .../esm/SpellingDictionary/Typos/util.d.mts | 31 + .../esm/SpellingDictionary/Typos/util.mjs | 105 ++++ .../SpellingDictionary/TyposDictionary.d.mts | 21 + .../SpellingDictionary/TyposDictionary.mjs | 129 +++++ .../createInlineSpellingDictionary.d.mts | 3 + .../createInlineSpellingDictionary.mjs | 20 + .../createSpellingDictionary.d.mts | 23 + .../createSpellingDictionary.mjs | 68 +++ .../esm/SpellingDictionary/defaults.d.mts | 3 + .../dist/esm/SpellingDictionary/defaults.mjs | 2 + .../dist/esm/SpellingDictionary/index.d.mts | 11 + .../dist/esm/SpellingDictionary/index.mjs | 9 + .../cspell-dictionary/dist/esm/index.d.mts | 3 + .../cspell-dictionary/dist/esm/index.mjs | 1 + .../dist/esm/util/AutoCache.d.mts | 25 + .../dist/esm/util/AutoCache.mjs | 67 +++ .../dist/esm/util/AutoResolve.d.mts | 21 + .../dist/esm/util/AutoResolve.mjs | 52 ++ .../dist/esm/util/IterableLike.d.mts | 4 + .../dist/esm/util/IterableLike.mjs | 1 + .../dist/esm/util/clean.d.mts | 7 + .../cspell-dictionary/dist/esm/util/clean.mjs | 13 + .../dist/esm/util/regexHelper.d.mts | 7 + .../dist/esm/util/regexHelper.mjs | 8 + .../dist/esm/util/repMap.d.mts | 27 + .../dist/esm/util/repMap.mjs | 152 +++++ .../dist/esm/util/simpleCache.d.mts | 46 ++ .../dist/esm/util/simpleCache.mjs | 135 +++++ .../dist/esm/util/text.d.mts | 10 + .../cspell-dictionary/dist/esm/util/text.mjs | 46 ++ .../dist/esm/util/textMappers.d.mts | 3 + .../dist/esm/util/textMappers.mjs | 15 + .../dist/esm/util/types.d.mts | 7 + .../cspell-dictionary/dist/esm/util/types.mjs | 1 + .../dist/esm/util/util.d.mts | 2 + .../cspell-dictionary/dist/esm/util/util.mjs | 3 + .../cspell-dictionary/package.json | 45 +- action/node_modules/cspell-gitignore/bin.js | 6 - action/node_modules/cspell-gitignore/bin.mjs | 5 + .../dist/{ => cjs}/GitIgnore.js | 14 +- .../dist/{ => cjs}/GitIgnoreFile.js | 8 +- .../cspell-gitignore/dist/{ => cjs}/app.js | 8 +- .../dist/{ => cjs}/helpers.js | 0 .../cspell-gitignore/dist/{ => cjs}/index.js | 22 +- .../cspell-gitignore/dist/esm/GitIgnore.d.mts | 36 ++ .../cspell-gitignore/dist/esm/GitIgnore.mjs | 124 ++++ .../dist/esm/GitIgnoreFile.d.mts | 47 ++ .../dist/esm/GitIgnoreFile.mjs | 121 ++++ .../cspell-gitignore/dist/esm/app.d.mts | 2 + .../cspell-gitignore/dist/esm/app.mjs | 83 +++ .../cspell-gitignore/dist/esm/helpers.d.mts | 117 ++++ .../cspell-gitignore/dist/esm/helpers.mjs | 90 +++ .../cspell-gitignore/dist/esm/index.d.mts | 4 + .../cspell-gitignore/dist/esm/index.mjs | 3 + .../cspell-gitignore/package.json | 35 +- .../cspell-glob/dist/{ => cjs}/GlobMatcher.js | 8 +- .../dist/{ => cjs}/GlobMatcherTypes.js | 0 .../cspell-glob/dist/{ => cjs}/globHelper.js | 0 .../cspell-glob/dist/{ => cjs}/index.js | 18 +- .../cspell-glob/dist/esm/GlobMatcher.d.mts | 94 +++ .../cspell-glob/dist/esm/GlobMatcher.mjs | 101 ++++ .../dist/esm/GlobMatcherTypes.d.mts | 55 ++ .../cspell-glob/dist/esm/GlobMatcherTypes.mjs | 2 + .../cspell-glob/dist/esm/globHelper.d.mts | 73 +++ .../cspell-glob/dist/esm/globHelper.mjs | 257 +++++++++ .../cspell-glob/dist/esm/index.d.mts | 4 + .../cspell-glob/dist/esm/index.mjs | 3 + action/node_modules/cspell-glob/package.json | 36 +- action/node_modules/cspell-grammar/bin.js | 6 - action/node_modules/cspell-grammar/bin.mjs | 5 + .../cspell-grammar/dist/{ => cjs}/app.js | 4 +- .../dist/{ => cjs}/grammars/index.js | 4 +- .../dist/{ => cjs}/grammars/markdown.js | 0 .../dist/{ => cjs}/grammars/simple.js | 0 .../dist/{ => cjs}/grammars/typescript.js | 0 .../cspell-grammar/dist/{ => cjs}/index.js | 12 +- .../{ => cjs}/mappers/appendMappedText.js | 0 .../dist/{ => cjs}/mappers/types.js | 0 .../dist/{ => cjs}/mappers/typescript.js | 0 .../dist/{ => cjs}/parser/grammar.js | 4 +- .../{ => cjs}/parser/grammarDefinition.js | 0 .../{ => cjs}/parser/grammarNormalized.js | 0 .../{ => cjs}/parser/grammarNormalizer.js | 22 +- .../{ => cjs}/parser/grammarTypesHelpers.js | 0 .../dist/{ => cjs}/parser/index.js | 10 +- .../dist/{ => cjs}/parser/matchResult.js | 0 .../dist/{ => cjs}/parser/parser.js | 6 +- .../parser/processors/procMatchingRule.js | 12 +- .../dist/{ => cjs}/parser/scope.js | 0 .../dist/{ => cjs}/parser/tokenizeLine.js | 10 +- .../dist/{ => cjs}/parser/types.js | 0 .../dist/{ => cjs}/parser/util.js | 0 .../dist/{ => cjs}/parser/validateGrammar.js | 12 +- .../dist/{ => cjs}/parsers/index.js | 4 +- .../parsers/typescript/TypeScriptParser.js | 22 +- .../{ => cjs}/parsers/typescript/index.js | 4 +- .../dist/{ => cjs}/viewer/escapeMarkdown.js | 0 .../dist/{ => cjs}/viewer/markdownHelper.js | 4 +- .../dist/{ => cjs}/viewer/visualizeAsMD.js | 10 +- .../cspell-grammar/dist/esm/app.d.mts | 7 + .../cspell-grammar/dist/esm/app.mjs | 39 ++ .../dist/esm/grammars/index.d.mts | 3 + .../dist/esm/grammars/index.mjs | 2 + .../dist/esm/grammars/markdown.d.mts | 3 + .../dist/esm/grammars/markdown.mjs | 32 ++ .../dist/esm/grammars/simple.d.mts | 3 + .../dist/esm/grammars/simple.mjs | 108 ++++ .../dist/esm/grammars/typescript.d.mts | 3 + .../dist/esm/grammars/typescript.mjs | 161 ++++++ .../cspell-grammar/dist/esm/index.d.mts | 4 + .../cspell-grammar/dist/esm/index.mjs | 2 + .../dist/esm/mappers/appendMappedText.d.mts | 3 + .../dist/esm/mappers/appendMappedText.mjs | 37 ++ .../dist/esm/mappers/types.d.mts | 17 + .../cspell-grammar/dist/esm/mappers/types.mjs | 1 + .../dist/esm/mappers/typescript.d.mts | 6 + .../dist/esm/mappers/typescript.mjs | 142 +++++ .../dist/esm/parser/grammar.d.mts | 5 + .../dist/esm/parser/grammar.mjs | 4 + .../dist/esm/parser/grammarDefinition.d.mts | 113 ++++ .../dist/esm/parser/grammarDefinition.mjs | 1 + .../dist/esm/parser/grammarNormalized.d.mts | 114 ++++ .../dist/esm/parser/grammarNormalized.mjs | 1 + .../dist/esm/parser/grammarNormalizer.d.mts | 13 + .../dist/esm/parser/grammarNormalizer.mjs | 260 +++++++++ .../dist/esm/parser/grammarTypesHelpers.d.mts | 7 + .../dist/esm/parser/grammarTypesHelpers.mjs | 23 + .../dist/esm/parser/index.d.mts | 5 + .../cspell-grammar/dist/esm/parser/index.mjs | 2 + .../dist/esm/parser/matchResult.d.mts | 13 + .../dist/esm/parser/matchResult.mjs | 49 ++ .../dist/esm/parser/parser.d.mts | 12 + .../cspell-grammar/dist/esm/parser/parser.mjs | 26 + .../parser/processors/procMatchingRule.d.mts | 21 + .../parser/processors/procMatchingRule.mjs | 148 +++++ .../dist/esm/parser/scope.d.mts | 41 ++ .../cspell-grammar/dist/esm/parser/scope.mjs | 69 +++ .../dist/esm/parser/tokenizeLine.d.mts | 6 + .../dist/esm/parser/tokenizeLine.mjs | 121 ++++ .../dist/esm/parser/types.d.mts | 95 ++++ .../cspell-grammar/dist/esm/parser/types.mjs | 1 + .../cspell-grammar/dist/esm/parser/util.d.mts | 2 + .../cspell-grammar/dist/esm/parser/util.mjs | 3 + .../dist/esm/parser/validateGrammar.d.mts | 12 + .../dist/esm/parser/validateGrammar.mjs | 55 ++ .../dist/esm/parsers/index.d.mts | 2 + .../cspell-grammar/dist/esm/parsers/index.mjs | 2 + .../parsers/typescript/TypeScriptParser.d.mts | 2 + .../parsers/typescript/TypeScriptParser.mjs | 89 +++ .../dist/esm/parsers/typescript/index.d.mts | 2 + .../dist/esm/parsers/typescript/index.mjs | 1 + .../dist/esm/viewer/escapeMarkdown.d.mts | 3 + .../dist/esm/viewer/escapeMarkdown.mjs | 39 ++ .../dist/esm/viewer/markdownHelper.d.mts | 2 + .../dist/esm/viewer/markdownHelper.mjs | 4 + .../dist/esm/viewer/visualizeAsMD.d.mts | 5 + .../dist/esm/viewer/visualizeAsMD.mjs | 31 + .../node_modules/cspell-grammar/package.json | 74 ++- action/node_modules/cspell-io/package.json | 7 +- .../cspell-lib/dist/Document/isBinaryDoc.js | 22 - .../configLoader/defaultSettings.js | 11 - .../configLoader/readSettingsFiles.js | 17 - .../dist/{ => cjs}/Cache/cspell.cache.js | 0 .../cspell-lib/dist/{ => cjs}/Cache/index.js | 0 .../dist/{ => cjs}/Document/Document.js | 0 .../dist/{ => cjs}/Document/index.js | 10 +- .../dist/cjs/Document/isBinaryDoc.js | 22 + .../Document/normalizeLanguageIds.js | 0 .../{ => cjs}/Document/resolveDocument.js | 10 +- .../{ => cjs}/FeatureFlags/FeatureFlags.js | 0 .../dist/{ => cjs}/FeatureFlags/index.js | 8 +- .../cspell-lib/dist/{ => cjs}/LanguageIds.js | 4 +- .../Models/CSpellSettingsInternalDef.js | 6 +- .../dist/{ => cjs}/Models/PatternRegExp.js | 0 .../dist/{ => cjs}/Models/Suggestion.js | 0 .../dist/{ => cjs}/Models/TextDocument.js | 6 +- .../dist/{ => cjs}/Models/ValidationIssue.js | 0 .../dist/{ => cjs}/Models/ValidationResult.js | 0 .../Settings/CSpellSettingsServer.js | 44 +- .../Settings/Controller/ImportError.js | 4 +- .../Settings/Controller/SettingsController.js | 0 .../Controller/configLoader/PnPSettings.js | 4 +- .../Controller/configLoader/configLoader.js | 153 ++--- .../configLoader/defaultSettings.js | 11 + .../configLoader/extractImportErrors.js | 0 .../Settings/Controller/configLoader/index.js | 46 +- .../configLoader/normalizeRawSettings.js | 18 +- .../Controller/configLoader/readSettings.js | 4 +- .../configLoader/readSettingsFiles.js | 17 + .../Controller/configLoader/toGlobDef.js | 0 .../Settings/Controller/configLoader/types.js | 0 .../{ => cjs}/Settings/Controller/index.js | 4 +- .../Settings/Controller/pnpLoader.js | 14 +- .../{ => cjs}/Settings/DefaultSettings.js | 33 +- .../Settings/DictionaryReferenceCollection.js | 0 .../{ => cjs}/Settings/DictionarySettings.js | 24 +- .../dist/{ => cjs}/Settings/GlobalSettings.js | 21 +- .../dist/{ => cjs}/Settings/InDocSettings.js | 18 +- .../{ => cjs}/Settings/LanguageSettings.js | 23 +- .../dist/{ => cjs}/Settings/RegExpPatterns.js | 0 .../Settings/TextDocumentSettings.js | 12 +- .../cspell-lib/dist/cjs/Settings/cfgStore.js | 9 + .../dist/{ => cjs}/Settings/constants.js | 0 .../dist/{ => cjs}/Settings/index.js | 62 +- .../dist/{ => cjs}/Settings/index.link.js | 8 +- .../dist/{ => cjs}/Settings/link.js | 18 +- .../dist/{ => cjs}/Settings/patterns.js | 12 +- .../SpellingDictionary/Dictionaries.js | 18 +- .../DictionaryController/DictionaryLoader.js | 24 +- .../DictionaryController/index.js | 4 +- .../SpellingDictionary/DictionaryLoader.js | 6 +- .../SpellingDictionary/SpellingDictionary.js | 0 .../SpellingDictionaryError.js | 0 .../SuggestionCollector.js | 4 +- .../SuggestExperimental/entities.js | 0 .../SuggestExperimental/helpers.js | 0 .../SuggestExperimental/suggest.js | 8 +- .../{ => cjs}/SpellingDictionary/index.js | 6 +- .../dist/{ => cjs}/clearCachedFiles.js | 6 +- .../dist/{ => cjs}/exclusionHelper.js | 6 +- .../dist/{ => cjs}/getDictionary.js | 6 +- .../cspell-lib/dist/{ => cjs}/index.js | 168 +++--- .../dist/{ => cjs}/spellCheckFile.js | 30 +- .../cspell-lib/dist/{ => cjs}/static.js | 0 .../cspell-lib/dist/{ => cjs}/suggestions.js | 34 +- .../textValidation/ValidateTextOptions.js | 0 .../textValidation/ValidationTypes.js | 0 .../{ => cjs}/textValidation/checkText.js | 24 +- .../textValidation/defaultConstants.js | 0 .../determineTextDocumentSettings.js | 18 +- .../{ => cjs}/textValidation/docValidator.js | 124 ++-- .../dist/{ => cjs}/textValidation/index.js | 22 +- .../{ => cjs}/textValidation/isWordValid.js | 0 .../textValidation/lineValidatorFactory.js | 26 +- .../{ => cjs}/textValidation/parsedText.js | 4 +- .../settingsToValidateOptions.js | 0 .../{ => cjs}/textValidation/textValidator.js | 12 +- .../{ => cjs}/textValidation/validator.js | 22 +- .../cspell-lib/dist/{ => cjs}/trace.js | 24 +- .../dist/{ => cjs}/util/AutoResolve.js | 0 .../{ => cjs}/util/AutoResolveLRUCache.js | 4 +- .../dist/{ => cjs}/util/Comparable.js | 0 .../dist/{ => cjs}/util/FreqCounter.js | 0 .../dist/{ => cjs}/util/IterableLike.js | 0 .../dist/{ => cjs}/util/MinHeapQueue.js | 0 .../dist/{ => cjs}/util/PairingHeap.js | 0 .../cspell-lib/dist/{ => cjs}/util/TextMap.js | 0 .../dist/{ => cjs}/util/TextRange.js | 0 .../cspell-lib/dist/{ => cjs}/util/Uri.js | 0 .../dist/{ => cjs}/util/debugPerf.js | 4 +- .../cspell-lib/dist/{ => cjs}/util/errors.js | 0 .../dist/{ => cjs}/util/fileReader.js | 4 +- .../{ => cjs}/util/iterableIteratorLib.js | 0 .../cspell-lib/dist/{ => cjs}/util/logger.js | 0 .../dist/{ => cjs}/util/memorizeLastCall.js | 4 +- .../dist/{ => cjs}/util/memorizerWeak.js | 0 .../dist/{ => cjs}/util/regexHelper.js | 0 .../cspell-lib/dist/{ => cjs}/util/repMap.js | 4 +- .../dist/{ => cjs}/util/resolveFile.js | 0 .../cspell-lib/dist/{ => cjs}/util/search.js | 0 .../dist/{ => cjs}/util/simpleCache.js | 0 .../cspell-lib/dist/{ => cjs}/util/text.js | 56 +- .../dist/{ => cjs}/util/textRegex.js | 3 +- .../cspell-lib/dist/{ => cjs}/util/timer.js | 0 .../cspell-lib/dist/{ => cjs}/util/types.js | 0 .../cspell-lib/dist/{ => cjs}/util/util.js | 0 .../dist/{ => cjs}/util/wordSplitter.js | 24 +- .../cspell-lib/dist/{ => cjs}/validator.js | 10 +- .../dist/{ => cjs}/wordListHelper.js | 16 +- .../dist/esm/Cache/cspell.cache.d.mts | 42 ++ .../dist/esm/Cache/cspell.cache.mjs | 11 + .../cspell-lib/dist/esm/Cache/index.d.mts | 2 + .../cspell-lib/dist/esm/Cache/index.mjs | 1 + .../dist/esm/Document/Document.d.mts | 13 + .../cspell-lib/dist/esm/Document/Document.mjs | 1 + .../cspell-lib/dist/esm/Document/index.d.mts | 4 + .../cspell-lib/dist/esm/Document/index.mjs | 2 + .../dist/esm/Document/isBinaryDoc.d.mts | 5 + .../dist/esm/Document/isBinaryDoc.mjs | 16 + .../esm/Document/normalizeLanguageIds.d.mts | 2 + .../esm/Document/normalizeLanguageIds.mjs | 3 + .../dist/esm/Document/resolveDocument.d.mts | 11 + .../dist/esm/Document/resolveDocument.mjs | 43 ++ .../dist/esm/FeatureFlags/FeatureFlags.d.mts | 30 + .../dist/esm/FeatureFlags/FeatureFlags.mjs | 70 +++ .../dist/esm/FeatureFlags/index.d.mts | 2 + .../dist/esm/FeatureFlags/index.mjs | 1 + .../cspell-lib/dist/esm/LanguageIds.d.mts | 37 ++ .../cspell-lib/dist/esm/LanguageIds.mjs | 303 ++++++++++ .../Models/CSpellSettingsInternalDef.d.mts | 40 ++ .../esm/Models/CSpellSettingsInternalDef.mjs | 22 + .../dist/esm/Models/PatternRegExp.d.mts | 5 + .../dist/esm/Models/PatternRegExp.mjs | 8 + .../dist/esm/Models/Suggestion.d.mts | 15 + .../cspell-lib/dist/esm/Models/Suggestion.mjs | 1 + .../dist/esm/Models/TextDocument.d.mts | 85 +++ .../dist/esm/Models/TextDocument.mjs | 105 ++++ .../dist/esm/Models/ValidationIssue.d.mts | 7 + .../dist/esm/Models/ValidationIssue.mjs | 1 + .../dist/esm/Models/ValidationResult.d.mts | 7 + .../dist/esm/Models/ValidationResult.mjs | 1 + .../esm/Settings/CSpellSettingsServer.d.mts | 48 ++ .../esm/Settings/CSpellSettingsServer.mjs | 338 +++++++++++ .../esm/Settings/Controller/ImportError.d.mts | 11 + .../esm/Settings/Controller/ImportError.mjs | 17 + .../Controller/SettingsController.d.mts | 9 + .../Controller/SettingsController.mjs | 8 + .../Controller/configLoader/PnPSettings.d.mts | 12 + .../Controller/configLoader/PnPSettings.mjs | 21 + .../configLoader/configLoader.d.mts | 141 +++++ .../Controller/configLoader/configLoader.mjs | 476 ++++++++++++++++ .../configLoader/defaultSettings.d.mts | 3 + .../configLoader/defaultSettings.mjs | 7 + .../configLoader/extractImportErrors.d.mts | 7 + .../configLoader/extractImportErrors.mjs | 21 + .../Controller/configLoader/index.d.mts | 5 + .../Controller/configLoader/index.mjs | 4 + .../configLoader/normalizeRawSettings.d.mts | 51 ++ .../configLoader/normalizeRawSettings.mjs | 103 ++++ .../configLoader/readSettings.d.mts | 23 + .../Controller/configLoader/readSettings.mjs | 7 + .../configLoader/readSettingsFiles.d.mts | 9 + .../configLoader/readSettingsFiles.mjs | 12 + .../Controller/configLoader/toGlobDef.d.mts | 6 + .../Controller/configLoader/toGlobDef.mjs | 18 + .../Controller/configLoader/types.d.mts | 5 + .../Controller/configLoader/types.mjs | 1 + .../dist/esm/Settings/Controller/index.d.mts | 2 + .../dist/esm/Settings/Controller/index.mjs | 1 + .../esm/Settings/Controller/pnpLoader.d.mts | 29 + .../esm/Settings/Controller/pnpLoader.mjs | 133 +++++ .../dist/esm/Settings/DefaultSettings.d.mts | 6 + .../dist/esm/Settings/DefaultSettings.mjs | 161 ++++++ .../DictionaryReferenceCollection.d.mts | 10 + .../DictionaryReferenceCollection.mjs | 42 ++ .../esm/Settings/DictionarySettings.d.mts | 27 + .../dist/esm/Settings/DictionarySettings.mjs | 120 ++++ .../dist/esm/Settings/GlobalSettings.d.mts | 11 + .../dist/esm/Settings/GlobalSettings.mjs | 55 ++ .../dist/esm/Settings/InDocSettings.d.mts | 45 ++ .../dist/esm/Settings/InDocSettings.mjs | 272 +++++++++ .../dist/esm/Settings/LanguageSettings.d.mts | 18 + .../dist/esm/Settings/LanguageSettings.mjs | 125 ++++ .../dist/esm/Settings/RegExpPatterns.d.mts | 46 ++ .../dist/esm/Settings/RegExpPatterns.mjs | 53 ++ .../esm/Settings/TextDocumentSettings.d.mts | 5 + .../esm/Settings/TextDocumentSettings.mjs | 16 + .../dist/esm/Settings/cfgStore.d.mts | 4 + .../cspell-lib/dist/esm/Settings/cfgStore.mjs | 2 + .../dist/esm/Settings/constants.d.mts | 5 + .../dist/esm/Settings/constants.mjs | 4 + .../cspell-lib/dist/esm/Settings/index.d.mts | 7 + .../dist/esm/Settings/index.link.d.mts | 3 + .../dist/esm/Settings/index.link.mjs | 1 + .../cspell-lib/dist/esm/Settings/index.mjs | 5 + .../cspell-lib/dist/esm/Settings/link.d.mts | 50 ++ .../cspell-lib/dist/esm/Settings/link.mjs | 136 +++++ .../dist/esm/Settings/patterns.d.mts | 3 + .../cspell-lib/dist/esm/Settings/patterns.mjs | 27 + .../esm/SpellingDictionary/Dictionaries.d.mts | 8 + .../esm/SpellingDictionary/Dictionaries.mjs | 47 ++ .../DictionaryLoader.d.mts | 32 ++ .../DictionaryController/DictionaryLoader.mjs | 280 +++++++++ .../DictionaryController/index.d.mts | 2 + .../DictionaryController/index.mjs | 1 + .../SpellingDictionary/DictionaryLoader.d.mts | 15 + .../SpellingDictionary/DictionaryLoader.mjs | 22 + .../SpellingDictionary.d.mts | 4 + .../SpellingDictionary/SpellingDictionary.mjs | 2 + .../SpellingDictionaryError.d.mts | 10 + .../SpellingDictionaryError.mjs | 12 + .../SuggestionCollector.d.mts | 10 + .../SuggestionCollector.mjs | 14 + .../SuggestExperimental/entities.d.mts | 6 + .../SuggestExperimental/entities.mjs | 1 + .../SuggestExperimental/helpers.d.mts | 21 + .../SuggestExperimental/helpers.mjs | 58 ++ .../SuggestExperimental/suggest.d.mts | 6 + .../SuggestExperimental/suggest.mjs | 27 + .../dist/esm/SpellingDictionary/index.d.mts | 4 + .../dist/esm/SpellingDictionary/index.mjs | 3 + .../dist/esm/clearCachedFiles.d.mts | 2 + .../cspell-lib/dist/esm/clearCachedFiles.mjs | 5 + .../cspell-lib/dist/esm/exclusionHelper.d.mts | 23 + .../cspell-lib/dist/esm/exclusionHelper.mjs | 50 ++ .../cspell-lib/dist/esm/getDictionary.d.mts | 9 + .../cspell-lib/dist/esm/getDictionary.mjs | 10 + .../cspell-lib/dist/esm/index.d.mts | 30 + .../cspell-lib/dist/esm/index.mjs | 24 + .../cspell-lib/dist/esm/spellCheckFile.d.mts | 67 +++ .../cspell-lib/dist/esm/spellCheckFile.mjs | 106 ++++ .../cspell-lib/dist/esm/static.d.mts | 3 + .../cspell-lib/dist/esm/static.mjs | 5 + .../cspell-lib/dist/esm/suggestions.d.mts | 74 +++ .../cspell-lib/dist/esm/suggestions.mjs | 183 ++++++ .../textValidation/ValidateTextOptions.d.mts | 15 + .../textValidation/ValidateTextOptions.mjs | 1 + .../esm/textValidation/ValidationTypes.d.mts | 37 ++ .../esm/textValidation/ValidationTypes.mjs | 1 + .../dist/esm/textValidation/checkText.d.mts | 48 ++ .../dist/esm/textValidation/checkText.mjs | 118 ++++ .../esm/textValidation/defaultConstants.d.mts | 5 + .../esm/textValidation/defaultConstants.mjs | 4 + .../determineTextDocumentSettings.d.mts | 17 + .../determineTextDocumentSettings.mjs | 35 ++ .../esm/textValidation/docValidator.d.mts | 125 ++++ .../dist/esm/textValidation/docValidator.mjs | 397 +++++++++++++ .../dist/esm/textValidation/index.d.mts | 12 + .../dist/esm/textValidation/index.mjs | 4 + .../dist/esm/textValidation/isWordValid.d.mts | 8 + .../dist/esm/textValidation/isWordValid.mjs | 13 + .../textValidation/lineValidatorFactory.d.mts | 14 + .../textValidation/lineValidatorFactory.mjs | 118 ++++ .../dist/esm/textValidation/parsedText.d.mts | 15 + .../dist/esm/textValidation/parsedText.mjs | 102 ++++ .../settingsToValidateOptions.d.mts | 4 + .../settingsToValidateOptions.mjs | 7 + .../esm/textValidation/textValidator.d.mts | 21 + .../dist/esm/textValidation/textValidator.mjs | 88 +++ .../dist/esm/textValidation/validator.d.mts | 10 + .../dist/esm/textValidation/validator.mjs | 58 ++ .../cspell-lib/dist/esm/trace.d.mts | 23 + .../cspell-lib/dist/esm/trace.mjs | 64 +++ .../dist/esm/util/AutoResolve.d.mts | 21 + .../cspell-lib/dist/esm/util/AutoResolve.mjs | 52 ++ .../dist/esm/util/AutoResolveLRUCache.d.mts | 54 ++ .../dist/esm/util/AutoResolveLRUCache.mjs | 128 +++++ .../cspell-lib/dist/esm/util/Comparable.d.mts | 20 + .../cspell-lib/dist/esm/util/Comparable.mjs | 46 ++ .../dist/esm/util/FreqCounter.d.mts | 16 + .../cspell-lib/dist/esm/util/FreqCounter.mjs | 47 ++ .../dist/esm/util/IterableLike.d.mts | 4 + .../cspell-lib/dist/esm/util/IterableLike.mjs | 1 + .../dist/esm/util/MinHeapQueue.d.mts | 23 + .../cspell-lib/dist/esm/util/MinHeapQueue.mjs | 92 +++ .../dist/esm/util/PairingHeap.d.mts | 32 ++ .../dist/esm/util/PairingHeap.mjs} | 0 .../cspell-lib/dist/esm/util/TextMap.d.mts | 15 + .../cspell-lib/dist/esm/util/TextMap.mjs | 53 ++ .../cspell-lib/dist/esm/util/TextRange.d.mts | 28 + .../cspell-lib/dist/esm/util/TextRange.mjs | 112 ++++ .../cspell-lib/dist/esm/util/Uri.d.mts | 50 ++ .../cspell-lib/dist/esm/util/Uri.mjs | 158 ++++++ .../cspell-lib/dist/esm/util/debugPerf.d.mts | 9 + .../cspell-lib/dist/esm/util/debugPerf.mjs | 17 + .../cspell-lib/dist/esm/util/errors.d.mts | 26 + .../cspell-lib/dist/esm/util/errors.mjs | 67 +++ .../cspell-lib/dist/esm/util/fileReader.d.mts | 4 + .../cspell-lib/dist/esm/util/fileReader.mjs | 15 + .../dist/esm/util/iterableIteratorLib.d.mts | 4 + .../dist/esm/util/iterableIteratorLib.mjs | 8 + .../cspell-lib/dist/esm/util/logger.d.mts | 31 + .../cspell-lib/dist/esm/util/logger.mjs | 37 ++ .../dist/esm/util/memorizeLastCall.d.mts | 13 + .../dist/esm/util/memorizeLastCall.mjs | 13 + .../dist/esm/util/memorizerWeak.d.mts | 6 + .../dist/esm/util/memorizerWeak.mjs} | 6 +- .../dist/esm/util/regexHelper.d.mts | 7 + .../cspell-lib/dist/esm/util/regexHelper.mjs | 8 + .../cspell-lib/dist/esm/util/repMap.d.mts | 4 + .../cspell-lib/dist/esm/util/repMap.mjs | 33 ++ .../dist/esm/util/resolveFile.d.mts | 13 + .../cspell-lib/dist/esm/util/resolveFile.mjs | 96 ++++ .../cspell-lib/dist/esm/util/search.d.mts | 6 + .../cspell-lib/dist/esm/util/search.mjs | 18 + .../dist/esm/util/simpleCache.d.mts | 46 ++ .../cspell-lib/dist/esm/util/simpleCache.mjs | 135 +++++ .../cspell-lib/dist/esm/util/text.d.mts | 49 ++ .../cspell-lib/dist/esm/util/text.mjs | 180 ++++++ .../cspell-lib/dist/esm/util/textRegex.d.mts | 19 + .../cspell-lib/dist/esm/util/textRegex.mjs | 124 ++++ .../cspell-lib/dist/esm/util/timer.d.mts | 26 + .../cspell-lib/dist/esm/util/timer.mjs | 50 ++ .../cspell-lib/dist/esm/util/types.d.mts | 62 ++ .../cspell-lib/dist/esm/util/types.mjs | 7 + .../cspell-lib/dist/esm/util/util.d.mts | 33 ++ .../cspell-lib/dist/esm/util/util.mjs | 97 ++++ .../dist/esm/util/wordSplitter.d.mts | 46 ++ .../cspell-lib/dist/esm/util/wordSplitter.mjs | 321 +++++++++++ .../cspell-lib/dist/esm/validator.d.mts | 3 + .../cspell-lib/dist/esm/validator.mjs | 1 + .../cspell-lib/dist/esm/wordListHelper.d.mts | 14 + .../cspell-lib/dist/esm/wordListHelper.mjs | 30 + .../cspell-lib/dist/lib-cjs/index.cjs | 10 + .../cspell-lib/dist/lib-cjs/index.d.cts | 6 + .../cspell-lib/dist/lib-cjs/pkg-info.cjs | 5 + .../cspell-lib/dist/lib-cjs/pkg-info.d.cts | 2 + .../cspell-lib/dist/test/test.matchers.js | 27 - .../cspell-lib/dist/util/Memorizer.js | 124 ---- .../node_modules/.bin/cspell-grammar | 2 +- action/node_modules/cspell-lib/package.json | 65 ++- .../cspell-trie-lib/dist/esm/index.js | 1 - .../dist/esm/lib/SimpleDictionaryParser.js | 191 ------- .../dist/esm/lib/TrieBuilder.js | 214 ------- .../cspell-trie-lib/dist/esm/lib/TrieNode.js | 3 - .../dist/esm/lib/compoundWalker.js | 56 -- .../dist/esm/lib/consolidate.js | 90 --- .../cspell-trie-lib/dist/esm/lib/constants.js | 11 - .../dist/esm/lib/convertToTrieRefNodes.js | 83 --- .../dist/esm/lib/distance/distance.js | 42 -- .../dist/esm/lib/distance/distanceAStar.js | 53 -- .../esm/lib/distance/distanceAStarWeighted.js | 136 ----- .../dist/esm/lib/distance/formatResultEx.js | 53 -- .../dist/esm/lib/distance/index.js | 1 - .../dist/esm/lib/distance/levenshtein.js | 43 -- .../dist/esm/lib/distance/weightedMaps.js | 289 ---------- .../cspell-trie-lib/dist/esm/lib/find.js | 282 --------- .../cspell-trie-lib/dist/esm/lib/flatten.js | 108 ---- .../cspell-trie-lib/dist/esm/lib/index.js | 16 - .../dist/esm/lib/io/importExport.js | 59 -- .../dist/esm/lib/io/importExportV1.js | 121 ---- .../dist/esm/lib/io/importExportV2.js | 168 ------ .../dist/esm/lib/io/importExportV3.js | 281 --------- .../dist/esm/lib/io/importExportV4.js | 439 --------------- .../dist/esm/lib/mappers/joinLetters.js | 10 - .../dist/esm/lib/mappers/mapCosts.js | 22 - .../dist/esm/lib/mappers/mapDictionaryInfo.js | 63 --- .../mappers/mapDictionaryInfoToWeightMap.js | 34 -- .../esm/lib/mappers/mapHunspellInformation.js | 195 ------- .../esm/lib/mappers/mapToSuggestionCostDef.js | 112 ---- .../dist/esm/lib/models/locale/index.js | 1 - .../esm/lib/models/locale/knownLocales.js | 533 ------------------ .../dist/esm/lib/models/locale/locale.js | 60 -- .../cspell-trie-lib/dist/esm/lib/suggest.js | 4 - .../dist/esm/lib/suggestCollector.js | 1 - .../dist/esm/lib/suggestions/constants.js | 1 - .../lib/suggestions/genSuggestionsOptions.js | 44 -- .../dist/esm/lib/suggestions/orthography.js | 65 --- .../dist/esm/lib/suggestions/suggest.js | 195 ------- .../dist/esm/lib/suggestions/suggestAStar.js | 415 -------------- .../esm/lib/suggestions/suggestCollector.js | 205 ------- .../cspell-trie-lib/dist/esm/lib/trie-util.js | 152 ----- .../cspell-trie-lib/dist/esm/lib/trie.js | 211 ------- .../cspell-trie-lib/dist/esm/lib/types.js | 13 - .../dist/esm/lib/utils/autoCacheMap.js | 28 - .../dist/esm/lib/utils/bufferLines.js | 26 - .../dist/esm/lib/utils/clean.js | 9 - .../dist/esm/lib/utils/isDefined.js | 3 - .../dist/esm/lib/utils/memorizeLastCall.js | 13 - .../dist/esm/lib/utils/mergeDefaults.js | 19 - .../lib/utils/mergeOptionalWithDefaults.js | 5 - .../dist/esm/lib/utils/normalizeWord.js | 22 - .../dist/esm/lib/utils/secondChanceCache.js | 55 -- .../dist/esm/lib/utils/text.js | 101 ---- .../dist/esm/lib/utils/timer.js | 22 - .../dist/esm/lib/utils/util.js | 71 --- .../dist/esm/lib/walker/hintedWalker.js | 103 ---- .../dist/esm/lib/walker/index.js | 3 - .../dist/esm/lib/walker/walker.js | 38 -- .../dist/esm/lib/walker/walkerTypes.js | 17 - .../node_modules/cspell-trie-lib/package.json | 10 +- action/node_modules/cspell/bin.js | 2 +- action/node_modules/cspell/bin.mjs | 15 + .../node_modules/cspell/dist/{ => cjs}/app.js | 35 +- .../cspell/dist/{ => cjs}/application.js | 60 +- .../cspell/dist/{ => cjs}/cli-reporter.js | 8 +- .../cspell/dist/{ => cjs}/commandCheck.js | 12 +- .../cspell/dist/{ => cjs}/commandLink.js | 24 +- .../cspell/dist/{ => cjs}/commandLint.js | 12 +- .../dist/{ => cjs}/commandSuggestion.js | 10 +- .../cspell/dist/{ => cjs}/commandTrace.js | 16 +- .../emitters/DictionaryPathFormat.js | 0 .../{ => cjs}/emitters/suggestionsEmitter.js | 8 +- .../dist/{ => cjs}/emitters/traceEmitter.js | 16 +- .../{ => cjs}/featureFlags/featureFlags.js | 0 .../dist/{ => cjs}/featureFlags/index.js | 6 +- .../cspell/dist/{ => cjs}/index.js | 6 +- .../cspell/dist/{ => cjs}/link.js | 0 .../cspell/dist/{ => cjs}/lint/LintRequest.js | 6 +- .../cspell/dist/{ => cjs}/lint/index.js | 8 +- .../cspell/dist/{ => cjs}/lint/lint.js | 93 ++- .../cspell/dist/{ => cjs}/options.js | 0 .../cspell/dist/{ => cjs}/repl/index.js | 0 .../dist/{ => cjs}/util/InMemoryReporter.js | 0 .../cspell/dist/{ => cjs}/util/async.js | 0 .../util/cache/CSpellLintResultCache.js | 0 .../dist/{ => cjs}/util/cache/CacheOptions.js | 0 .../dist/{ => cjs}/util/cache/DiskCache.js | 24 +- .../dist/{ => cjs}/util/cache/DummyCache.js | 0 .../{ => cjs}/util/cache/ObjectCollection.js | 0 .../dist/{ => cjs}/util/cache/createCache.js | 10 +- .../{ => cjs}/util/cache/fileEntryCache.js | 4 +- .../cspell/dist/{ => cjs}/util/cache/index.js | 8 +- .../cspell/dist/{ => cjs}/util/constants.js | 0 .../cspell/dist/{ => cjs}/util/errors.js | 0 .../cspell/dist/{ => cjs}/util/fileHelper.js | 61 +- .../cspell/dist/{ => cjs}/util/glob.js | 10 +- .../cspell/dist/{ => cjs}/util/prefetch.js | 0 .../cspell/dist/{ => cjs}/util/reporters.js | 7 +- .../cspell/dist/{ => cjs}/util/stdin.js | 0 .../cspell/dist/{ => cjs}/util/table.js | 0 .../cspell/dist/{ => cjs}/util/timer.js | 0 .../cspell/dist/cjs/util/types.js | 6 + .../cspell/dist/{ => cjs}/util/util.js | 0 action/node_modules/cspell/dist/esm/app.d.mts | 5 + action/node_modules/cspell/dist/esm/app.mjs | 44 ++ .../cspell/dist/esm/application.d.mts | 16 + .../cspell/dist/esm/application.mjs | 87 +++ .../cspell/dist/esm/cli-reporter.d.mts | 16 + .../cspell/dist/esm/cli-reporter.mjs | 201 +++++++ .../cspell/dist/esm/commandCheck.d.mts | 3 + .../cspell/dist/esm/commandCheck.mjs | 47 ++ .../cspell/dist/esm/commandLink.d.mts | 3 + .../cspell/dist/esm/commandLink.mjs | 46 ++ .../cspell/dist/esm/commandLint.d.mts | 3 + .../cspell/dist/esm/commandLint.mjs | 121 ++++ .../cspell/dist/esm/commandSuggestion.d.mts | 3 + .../cspell/dist/esm/commandSuggestion.mjs | 60 ++ .../cspell/dist/esm/commandTrace.d.mts | 3 + .../cspell/dist/esm/commandTrace.mjs | 59 ++ .../esm/emitters/DictionaryPathFormat.d.mts | 3 + .../esm/emitters/DictionaryPathFormat.mjs | 11 + .../esm/emitters/suggestionsEmitter.d.mts | 13 + .../dist/esm/emitters/suggestionsEmitter.mjs | 76 +++ .../dist/esm/emitters/traceEmitter.d.mts | 21 + .../cspell/dist/esm/emitters/traceEmitter.mjs | 140 +++++ .../dist/esm/featureFlags/featureFlags.d.mts | 4 + .../dist/esm/featureFlags/featureFlags.mjs | 19 + .../cspell/dist/esm/featureFlags/index.d.mts | 2 + .../cspell/dist/esm/featureFlags/index.mjs | 1 + .../node_modules/cspell/dist/esm/index.d.mts | 5 + action/node_modules/cspell/dist/esm/index.mjs | 3 + .../node_modules/cspell/dist/esm/link.d.mts | 8 + action/node_modules/cspell/dist/esm/link.mjs | 38 ++ .../cspell/dist/esm/lint/LintRequest.d.mts | 23 + .../cspell/dist/esm/lint/LintRequest.mjs | 20 + .../cspell/dist/esm/lint/index.d.mts | 3 + .../cspell/dist/esm/lint/index.mjs | 2 + .../cspell/dist/esm/lint/lint.d.mts | 4 + .../cspell/dist/esm/lint/lint.mjs | 468 +++++++++++++++ .../cspell/dist/esm/options.d.mts | 178 ++++++ .../node_modules/cspell/dist/esm/options.mjs | 7 + .../cspell/dist/esm/repl/index.d.mts | 18 + .../cspell/dist/esm/repl/index.mjs | 46 ++ .../dist/esm/util/InMemoryReporter.d.mts | 28 + .../cspell/dist/esm/util/InMemoryReporter.mjs | 42 ++ .../cspell/dist/esm/util/async.d.mts | 3 + .../cspell/dist/esm/util/async.mjs | 3 + .../util/cache/CSpellLintResultCache.d.mts | 20 + .../esm/util/cache/CSpellLintResultCache.mjs | 1 + .../dist/esm/util/cache/CacheOptions.d.mts | 34 ++ .../dist/esm/util/cache/CacheOptions.mjs | 1 + .../dist/esm/util/cache/DiskCache.d.mts | 63 +++ .../cspell/dist/esm/util/cache/DiskCache.mjs | 206 +++++++ .../dist/esm/util/cache/DummyCache.d.mts | 11 + .../cspell/dist/esm/util/cache/DummyCache.mjs | 17 + .../esm/util/cache/ObjectCollection.d.mts | 17 + .../dist/esm/util/cache/ObjectCollection.mjs | 130 +++++ .../dist/esm/util/cache/createCache.d.mts | 31 + .../dist/esm/util/cache/createCache.mjs | 68 +++ .../dist/esm/util/cache/fileEntryCache.d.mts | 9 + .../dist/esm/util/cache/fileEntryCache.mjs | 78 +++ .../cspell/dist/esm/util/cache/index.d.mts | 4 + .../cspell/dist/esm/util/cache/index.mjs | 1 + .../cspell/dist/esm/util/constants.d.mts | 6 + .../cspell/dist/esm/util/constants.mjs | 4 + .../cspell/dist/esm/util/errors.d.mts | 23 + .../cspell/dist/esm/util/errors.mjs | 50 ++ .../cspell/dist/esm/util/fileHelper.d.mts | 63 +++ .../cspell/dist/esm/util/fileHelper.mjs | 177 ++++++ .../cspell/dist/esm/util/glob.d.mts | 45 ++ .../cspell/dist/esm/util/glob.mjs | 136 +++++ .../cspell/dist/esm/util/prefetch.d.mts | 2 + .../cspell/dist/esm/util/prefetch.mjs | 15 + .../cspell/dist/esm/util/reporters.d.mts | 14 + .../cspell/dist/esm/util/reporters.mjs | 61 ++ .../cspell/dist/esm/util/stdin.d.mts | 2 + .../cspell/dist/esm/util/stdin.mjs | 4 + .../cspell/dist/esm/util/table.d.mts | 10 + .../cspell/dist/esm/util/table.mjs | 31 + .../cspell/dist/esm/util/timer.d.mts | 8 + .../cspell/dist/esm/util/timer.mjs | 10 + .../cspell/dist/esm/util/types.d.mts | 7 + .../cspell/dist/esm/util/types.mjs | 4 + .../cspell/dist/esm/util/util.d.mts | 13 + .../cspell/dist/esm/util/util.mjs | 44 ++ .../cspell/dist/lib/file-entry-cache.cjs | 32 ++ .../cspell/dist/lib/file-entry-cache.d.cts | 4 + .../node_modules/cspell/dist/lib/pkgInfo.cjs | 30 + .../cspell/dist/lib/pkgInfo.d.cts | 3 + action/node_modules/cspell/dist/lib/uri.cjs | 7 + action/node_modules/cspell/dist/lib/uri.d.cts | 2 + .../cspell/node_modules/.bin/cspell-gitignore | 2 +- action/node_modules/cspell/package.json | 80 +-- .../import-meta-resolve/lib/get-format.js | 2 +- .../lib/resolve-get-package-type.js | 23 + .../import-meta-resolve/lib/resolve.js | 12 +- .../import-meta-resolve/package.json | 2 +- action/package.json | 4 +- yarn.lock | 194 +++---- 763 files changed, 19447 insertions(+), 7227 deletions(-) create mode 120000 action/node_modules/.bin/cspell-esm delete mode 100644 action/node_modules/cspell-dictionary/dist/SpellingDictionary/createInlineSpellingDictionary.js rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/CachingDictionary.js (61%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/FlagWordsDictionary.js (87%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/IgnoreWordsDictionary.js (92%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/SpellingDictionary.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/SpellingDictionaryCollection.js (84%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/SpellingDictionaryFromTrie.js (84%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/SpellingDictionaryMethods.js (93%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/SuggestDictionary.js (88%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/Terms/index.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/Terms/terms.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/Typos/index.js (55%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/Typos/typos.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/Typos/typosParser.js (93%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/Typos/util.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/TyposDictionary.js (89%) create mode 100644 action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/createInlineSpellingDictionary.js rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/createSpellingDictionary.js (75%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/defaults.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/SpellingDictionary/index.js (53%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/index.js (51%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/util/AutoCache.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/util/AutoResolve.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/util/IterableLike.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/util/clean.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/util/regexHelper.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/util/repMap.js (96%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/util/simpleCache.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/util/text.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/util/textMappers.js (86%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/util/types.js (100%) rename action/node_modules/cspell-dictionary/dist/{ => cjs}/util/util.js (100%) create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/CachingDictionary.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/CachingDictionary.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/FlagWordsDictionary.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/FlagWordsDictionary.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/IgnoreWordsDictionary.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/IgnoreWordsDictionary.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionary.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionary.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryCollection.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryCollection.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryMethods.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryMethods.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SuggestDictionary.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SuggestDictionary.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/index.d.mts rename action/node_modules/{cspell-trie-lib/dist/esm/lib/models/DictionaryInformation.js => cspell-dictionary/dist/esm/SpellingDictionary/Terms/index.mjs} (100%) create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/terms.d.mts rename action/node_modules/{cspell-trie-lib/dist/esm/lib/models/suggestionCostsDef.js => cspell-dictionary/dist/esm/SpellingDictionary/Terms/terms.mjs} (100%) create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/index.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/index.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typos.d.mts rename action/node_modules/{cspell-trie-lib/dist/esm/lib/trieRef.js => cspell-dictionary/dist/esm/SpellingDictionary/Typos/typos.mjs} (100%) create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typosParser.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typosParser.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/util.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/util.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/TyposDictionary.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/TyposDictionary.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createInlineSpellingDictionary.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createInlineSpellingDictionary.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createSpellingDictionary.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createSpellingDictionary.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/defaults.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/defaults.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/index.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/index.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/index.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/index.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/AutoCache.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/AutoCache.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/AutoResolve.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/AutoResolve.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/IterableLike.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/IterableLike.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/clean.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/clean.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/regexHelper.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/regexHelper.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/repMap.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/repMap.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/simpleCache.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/simpleCache.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/text.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/text.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/textMappers.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/textMappers.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/types.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/types.mjs create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/util.d.mts create mode 100644 action/node_modules/cspell-dictionary/dist/esm/util/util.mjs delete mode 100755 action/node_modules/cspell-gitignore/bin.js create mode 100755 action/node_modules/cspell-gitignore/bin.mjs rename action/node_modules/cspell-gitignore/dist/{ => cjs}/GitIgnore.js (91%) rename action/node_modules/cspell-gitignore/dist/{ => cjs}/GitIgnoreFile.js (95%) rename action/node_modules/cspell-gitignore/dist/{ => cjs}/app.js (94%) rename action/node_modules/cspell-gitignore/dist/{ => cjs}/helpers.js (100%) rename action/node_modules/cspell-gitignore/dist/{ => cjs}/index.js (55%) create mode 100644 action/node_modules/cspell-gitignore/dist/esm/GitIgnore.d.mts create mode 100644 action/node_modules/cspell-gitignore/dist/esm/GitIgnore.mjs create mode 100644 action/node_modules/cspell-gitignore/dist/esm/GitIgnoreFile.d.mts create mode 100644 action/node_modules/cspell-gitignore/dist/esm/GitIgnoreFile.mjs create mode 100644 action/node_modules/cspell-gitignore/dist/esm/app.d.mts create mode 100644 action/node_modules/cspell-gitignore/dist/esm/app.mjs create mode 100644 action/node_modules/cspell-gitignore/dist/esm/helpers.d.mts create mode 100644 action/node_modules/cspell-gitignore/dist/esm/helpers.mjs create mode 100644 action/node_modules/cspell-gitignore/dist/esm/index.d.mts create mode 100644 action/node_modules/cspell-gitignore/dist/esm/index.mjs rename action/node_modules/cspell-glob/dist/{ => cjs}/GlobMatcher.js (94%) rename action/node_modules/cspell-glob/dist/{ => cjs}/GlobMatcherTypes.js (100%) rename action/node_modules/cspell-glob/dist/{ => cjs}/globHelper.js (100%) rename action/node_modules/cspell-glob/dist/{ => cjs}/index.js (67%) create mode 100644 action/node_modules/cspell-glob/dist/esm/GlobMatcher.d.mts create mode 100644 action/node_modules/cspell-glob/dist/esm/GlobMatcher.mjs create mode 100644 action/node_modules/cspell-glob/dist/esm/GlobMatcherTypes.d.mts create mode 100644 action/node_modules/cspell-glob/dist/esm/GlobMatcherTypes.mjs create mode 100644 action/node_modules/cspell-glob/dist/esm/globHelper.d.mts create mode 100644 action/node_modules/cspell-glob/dist/esm/globHelper.mjs create mode 100644 action/node_modules/cspell-glob/dist/esm/index.d.mts create mode 100644 action/node_modules/cspell-glob/dist/esm/index.mjs delete mode 100755 action/node_modules/cspell-grammar/bin.js create mode 100755 action/node_modules/cspell-grammar/bin.mjs rename action/node_modules/cspell-grammar/dist/{ => cjs}/app.js (96%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/grammars/index.js (90%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/grammars/markdown.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/grammars/simple.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/grammars/typescript.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/index.js (58%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/mappers/appendMappedText.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/mappers/types.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/mappers/typescript.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/grammar.js (62%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/grammarDefinition.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/grammarNormalized.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/grammarNormalizer.js (91%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/grammarTypesHelpers.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/index.js (56%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/matchResult.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/parser.js (84%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/processors/procMatchingRule.js (92%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/scope.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/tokenizeLine.js (91%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/types.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/util.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parser/validateGrammar.js (78%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parsers/index.js (59%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parsers/typescript/TypeScriptParser.js (76%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/parsers/typescript/index.js (62%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/viewer/escapeMarkdown.js (100%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/viewer/markdownHelper.js (54%) rename action/node_modules/cspell-grammar/dist/{ => cjs}/viewer/visualizeAsMD.js (86%) create mode 100644 action/node_modules/cspell-grammar/dist/esm/app.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/app.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/grammars/index.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/grammars/index.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/grammars/markdown.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/grammars/markdown.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/grammars/simple.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/grammars/simple.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/grammars/typescript.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/grammars/typescript.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/index.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/index.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/mappers/appendMappedText.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/mappers/appendMappedText.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/mappers/types.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/mappers/types.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/mappers/typescript.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/mappers/typescript.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/grammar.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/grammar.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/grammarDefinition.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/grammarDefinition.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalized.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalized.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalizer.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalizer.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/grammarTypesHelpers.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/grammarTypesHelpers.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/index.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/index.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/matchResult.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/matchResult.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/parser.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/parser.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/processors/procMatchingRule.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/processors/procMatchingRule.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/scope.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/scope.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/tokenizeLine.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/tokenizeLine.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/types.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/types.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/util.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/util.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/validateGrammar.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parser/validateGrammar.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parsers/index.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parsers/index.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parsers/typescript/TypeScriptParser.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parsers/typescript/TypeScriptParser.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/parsers/typescript/index.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/parsers/typescript/index.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/viewer/escapeMarkdown.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/viewer/escapeMarkdown.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/viewer/markdownHelper.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/viewer/markdownHelper.mjs create mode 100644 action/node_modules/cspell-grammar/dist/esm/viewer/visualizeAsMD.d.mts create mode 100644 action/node_modules/cspell-grammar/dist/esm/viewer/visualizeAsMD.mjs delete mode 100644 action/node_modules/cspell-lib/dist/Document/isBinaryDoc.js delete mode 100644 action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/defaultSettings.js delete mode 100644 action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/readSettingsFiles.js rename action/node_modules/cspell-lib/dist/{ => cjs}/Cache/cspell.cache.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Cache/index.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Document/Document.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Document/index.js (53%) create mode 100644 action/node_modules/cspell-lib/dist/cjs/Document/isBinaryDoc.js rename action/node_modules/cspell-lib/dist/{ => cjs}/Document/normalizeLanguageIds.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Document/resolveDocument.js (90%) rename action/node_modules/cspell-lib/dist/{ => cjs}/FeatureFlags/FeatureFlags.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/FeatureFlags/index.js (57%) rename action/node_modules/cspell-lib/dist/{ => cjs}/LanguageIds.js (98%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Models/CSpellSettingsInternalDef.js (91%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Models/PatternRegExp.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Models/Suggestion.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Models/TextDocument.js (96%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Models/ValidationIssue.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Models/ValidationResult.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/CSpellSettingsServer.js (87%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/ImportError.js (82%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/SettingsController.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/configLoader/PnPSettings.js (88%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/configLoader/configLoader.js (73%) create mode 100644 action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/defaultSettings.js rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/configLoader/extractImportErrors.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/configLoader/index.js (52%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/configLoader/normalizeRawSettings.js (86%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/configLoader/readSettings.js (79%) create mode 100644 action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/readSettingsFiles.js rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/configLoader/toGlobDef.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/configLoader/types.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/index.js (58%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/Controller/pnpLoader.js (92%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/DefaultSettings.js (85%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/DictionaryReferenceCollection.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/DictionarySettings.js (85%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/GlobalSettings.js (72%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/InDocSettings.js (95%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/LanguageSettings.js (89%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/RegExpPatterns.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/TextDocumentSettings.js (83%) create mode 100644 action/node_modules/cspell-lib/dist/cjs/Settings/cfgStore.js rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/constants.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/index.js (53%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/index.link.js (59%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/link.js (90%) rename action/node_modules/cspell-lib/dist/{ => cjs}/Settings/patterns.js (78%) rename action/node_modules/cspell-lib/dist/{ => cjs}/SpellingDictionary/Dictionaries.js (82%) rename action/node_modules/cspell-lib/dist/{ => cjs}/SpellingDictionary/DictionaryController/DictionaryLoader.js (91%) rename action/node_modules/cspell-lib/dist/{ => cjs}/SpellingDictionary/DictionaryController/index.js (59%) rename action/node_modules/cspell-lib/dist/{ => cjs}/SpellingDictionary/DictionaryLoader.js (83%) rename action/node_modules/cspell-lib/dist/{ => cjs}/SpellingDictionary/SpellingDictionary.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/SpellingDictionary/SpellingDictionaryError.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/SpellingDictionary/SuggestExperimental/SuggestionCollector.js (80%) rename action/node_modules/cspell-lib/dist/{ => cjs}/SpellingDictionary/SuggestExperimental/entities.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/SpellingDictionary/SuggestExperimental/helpers.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/SpellingDictionary/SuggestExperimental/suggest.js (80%) rename action/node_modules/cspell-lib/dist/{ => cjs}/SpellingDictionary/index.js (81%) rename action/node_modules/cspell-lib/dist/{ => cjs}/clearCachedFiles.js (51%) rename action/node_modules/cspell-lib/dist/{ => cjs}/exclusionHelper.js (93%) rename action/node_modules/cspell-lib/dist/{ => cjs}/getDictionary.js (63%) rename action/node_modules/cspell-lib/dist/{ => cjs}/index.js (61%) rename action/node_modules/cspell-lib/dist/{ => cjs}/spellCheckFile.js (78%) rename action/node_modules/cspell-lib/dist/{ => cjs}/static.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/suggestions.js (84%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/ValidateTextOptions.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/ValidationTypes.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/checkText.js (85%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/defaultConstants.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/determineTextDocumentSettings.js (78%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/docValidator.js (71%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/index.js (51%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/isWordValid.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/lineValidatorFactory.js (85%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/parsedText.js (96%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/settingsToValidateOptions.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/textValidator.js (90%) rename action/node_modules/cspell-lib/dist/{ => cjs}/textValidation/validator.js (77%) rename action/node_modules/cspell-lib/dist/{ => cjs}/trace.js (78%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/AutoResolve.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/AutoResolveLRUCache.js (97%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/Comparable.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/FreqCounter.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/IterableLike.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/MinHeapQueue.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/PairingHeap.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/TextMap.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/TextRange.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/Uri.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/debugPerf.js (87%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/errors.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/fileReader.js (80%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/iterableIteratorLib.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/logger.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/memorizeLastCall.js (80%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/memorizerWeak.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/regexHelper.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/repMap.js (91%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/resolveFile.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/search.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/simpleCache.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/text.js (77%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/textRegex.js (97%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/timer.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/types.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/util.js (100%) rename action/node_modules/cspell-lib/dist/{ => cjs}/util/wordSplitter.js (91%) rename action/node_modules/cspell-lib/dist/{ => cjs}/validator.js (59%) rename action/node_modules/cspell-lib/dist/{ => cjs}/wordListHelper.js (77%) create mode 100644 action/node_modules/cspell-lib/dist/esm/Cache/cspell.cache.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Cache/cspell.cache.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Cache/index.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Cache/index.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Document/Document.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Document/Document.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Document/index.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Document/index.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Document/isBinaryDoc.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Document/isBinaryDoc.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Document/normalizeLanguageIds.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Document/normalizeLanguageIds.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Document/resolveDocument.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Document/resolveDocument.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/FeatureFlags/FeatureFlags.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/FeatureFlags/FeatureFlags.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/FeatureFlags/index.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/FeatureFlags/index.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/LanguageIds.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/LanguageIds.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/CSpellSettingsInternalDef.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/CSpellSettingsInternalDef.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/PatternRegExp.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/PatternRegExp.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/Suggestion.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/Suggestion.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/TextDocument.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/TextDocument.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/ValidationIssue.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/ValidationIssue.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/ValidationResult.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Models/ValidationResult.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/CSpellSettingsServer.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/CSpellSettingsServer.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/ImportError.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/ImportError.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/SettingsController.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/SettingsController.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/PnPSettings.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/PnPSettings.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/configLoader.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/configLoader.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/defaultSettings.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/defaultSettings.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/extractImportErrors.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/extractImportErrors.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/index.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/index.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/normalizeRawSettings.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/normalizeRawSettings.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettings.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettings.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettingsFiles.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettingsFiles.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/toGlobDef.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/toGlobDef.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/types.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/types.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/index.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/index.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/pnpLoader.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/Controller/pnpLoader.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/DefaultSettings.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/DefaultSettings.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/DictionaryReferenceCollection.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/DictionaryReferenceCollection.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/DictionarySettings.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/DictionarySettings.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/GlobalSettings.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/GlobalSettings.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/InDocSettings.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/InDocSettings.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/LanguageSettings.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/LanguageSettings.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/RegExpPatterns.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/RegExpPatterns.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/TextDocumentSettings.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/TextDocumentSettings.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/cfgStore.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/cfgStore.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/constants.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/constants.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/index.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/index.link.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/index.link.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/index.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/link.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/link.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/patterns.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/Settings/patterns.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/Dictionaries.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/Dictionaries.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/index.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/index.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryLoader.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryLoader.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionary.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionary.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionaryError.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionaryError.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/SuggestionCollector.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/SuggestionCollector.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/entities.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/entities.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/helpers.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/helpers.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/suggest.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/suggest.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/index.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/SpellingDictionary/index.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/clearCachedFiles.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/clearCachedFiles.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/exclusionHelper.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/exclusionHelper.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/getDictionary.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/getDictionary.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/index.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/index.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/spellCheckFile.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/spellCheckFile.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/static.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/static.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/suggestions.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/suggestions.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/ValidateTextOptions.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/ValidateTextOptions.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/ValidationTypes.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/ValidationTypes.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/checkText.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/checkText.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/defaultConstants.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/defaultConstants.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/determineTextDocumentSettings.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/determineTextDocumentSettings.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/docValidator.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/docValidator.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/index.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/index.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/isWordValid.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/isWordValid.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/lineValidatorFactory.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/lineValidatorFactory.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/parsedText.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/parsedText.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/settingsToValidateOptions.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/settingsToValidateOptions.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/textValidator.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/textValidator.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/validator.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/textValidation/validator.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/trace.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/trace.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/AutoResolve.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/AutoResolve.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/AutoResolveLRUCache.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/AutoResolveLRUCache.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/Comparable.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/Comparable.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/FreqCounter.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/FreqCounter.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/IterableLike.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/IterableLike.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/MinHeapQueue.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/MinHeapQueue.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/PairingHeap.d.mts rename action/node_modules/{cspell-trie-lib/dist/esm/lib/utils/PairingHeap.js => cspell-lib/dist/esm/util/PairingHeap.mjs} (100%) create mode 100644 action/node_modules/cspell-lib/dist/esm/util/TextMap.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/TextMap.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/TextRange.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/TextRange.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/Uri.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/Uri.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/debugPerf.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/debugPerf.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/errors.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/errors.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/fileReader.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/fileReader.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/iterableIteratorLib.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/iterableIteratorLib.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/logger.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/logger.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/memorizeLastCall.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/memorizeLastCall.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/memorizerWeak.d.mts rename action/node_modules/{cspell-trie-lib/dist/esm/lib/utils/memorizer.js => cspell-lib/dist/esm/util/memorizerWeak.mjs} (83%) create mode 100644 action/node_modules/cspell-lib/dist/esm/util/regexHelper.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/regexHelper.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/repMap.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/repMap.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/resolveFile.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/resolveFile.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/search.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/search.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/simpleCache.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/simpleCache.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/text.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/text.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/textRegex.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/textRegex.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/timer.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/timer.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/types.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/types.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/util.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/util.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/util/wordSplitter.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/util/wordSplitter.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/validator.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/validator.mjs create mode 100644 action/node_modules/cspell-lib/dist/esm/wordListHelper.d.mts create mode 100644 action/node_modules/cspell-lib/dist/esm/wordListHelper.mjs create mode 100644 action/node_modules/cspell-lib/dist/lib-cjs/index.cjs create mode 100644 action/node_modules/cspell-lib/dist/lib-cjs/index.d.cts create mode 100644 action/node_modules/cspell-lib/dist/lib-cjs/pkg-info.cjs create mode 100644 action/node_modules/cspell-lib/dist/lib-cjs/pkg-info.d.cts delete mode 100644 action/node_modules/cspell-lib/dist/test/test.matchers.js delete mode 100644 action/node_modules/cspell-lib/dist/util/Memorizer.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/index.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/SimpleDictionaryParser.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/TrieBuilder.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/TrieNode.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/compoundWalker.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/consolidate.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/constants.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/convertToTrieRefNodes.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distance.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distanceAStar.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distanceAStarWeighted.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/distance/formatResultEx.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/distance/index.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/distance/levenshtein.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/distance/weightedMaps.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/find.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/flatten.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/index.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExport.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV1.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV2.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV3.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV4.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/joinLetters.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapCosts.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapDictionaryInfo.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapDictionaryInfoToWeightMap.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapHunspellInformation.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapToSuggestionCostDef.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/index.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/knownLocales.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/locale.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/suggest.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/suggestCollector.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/constants.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/genSuggestionsOptions.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/orthography.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggest.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggestAStar.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggestCollector.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/trie-util.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/trie.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/types.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/autoCacheMap.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/bufferLines.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/clean.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/isDefined.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/memorizeLastCall.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/mergeDefaults.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/mergeOptionalWithDefaults.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/normalizeWord.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/secondChanceCache.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/text.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/timer.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/utils/util.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/walker/hintedWalker.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/walker/index.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/walker/walker.js delete mode 100644 action/node_modules/cspell-trie-lib/dist/esm/lib/walker/walkerTypes.js create mode 100755 action/node_modules/cspell/bin.mjs rename action/node_modules/cspell/dist/{ => cjs}/app.js (52%) rename action/node_modules/cspell/dist/{ => cjs}/application.js (64%) rename action/node_modules/cspell/dist/{ => cjs}/cli-reporter.js (97%) rename action/node_modules/cspell/dist/{ => cjs}/commandCheck.js (89%) rename action/node_modules/cspell/dist/{ => cjs}/commandLink.js (60%) rename action/node_modules/cspell/dist/{ => cjs}/commandLint.js (95%) rename action/node_modules/cspell/dist/{ => cjs}/commandSuggestion.js (92%) rename action/node_modules/cspell/dist/{ => cjs}/commandTrace.js (87%) rename action/node_modules/cspell/dist/{ => cjs}/emitters/DictionaryPathFormat.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/emitters/suggestionsEmitter.js (92%) rename action/node_modules/cspell/dist/{ => cjs}/emitters/traceEmitter.js (91%) rename action/node_modules/cspell/dist/{ => cjs}/featureFlags/featureFlags.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/featureFlags/index.js (59%) rename action/node_modules/cspell/dist/{ => cjs}/index.js (84%) rename action/node_modules/cspell/dist/{ => cjs}/link.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/lint/LintRequest.js (91%) rename action/node_modules/cspell/dist/{ => cjs}/lint/index.js (58%) rename action/node_modules/cspell/dist/{ => cjs}/lint/lint.js (85%) rename action/node_modules/cspell/dist/{ => cjs}/options.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/repl/index.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/InMemoryReporter.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/async.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/cache/CSpellLintResultCache.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/cache/CacheOptions.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/cache/DiskCache.js (87%) rename action/node_modules/cspell/dist/{ => cjs}/util/cache/DummyCache.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/cache/ObjectCollection.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/cache/createCache.js (88%) rename action/node_modules/cspell/dist/{ => cjs}/util/cache/fileEntryCache.js (95%) rename action/node_modules/cspell/dist/{ => cjs}/util/cache/index.js (58%) rename action/node_modules/cspell/dist/{ => cjs}/util/constants.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/errors.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/fileHelper.js (77%) rename action/node_modules/cspell/dist/{ => cjs}/util/glob.js (96%) rename action/node_modules/cspell/dist/{ => cjs}/util/prefetch.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/reporters.js (88%) rename action/node_modules/cspell/dist/{ => cjs}/util/stdin.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/table.js (100%) rename action/node_modules/cspell/dist/{ => cjs}/util/timer.js (100%) create mode 100644 action/node_modules/cspell/dist/cjs/util/types.js rename action/node_modules/cspell/dist/{ => cjs}/util/util.js (100%) create mode 100644 action/node_modules/cspell/dist/esm/app.d.mts create mode 100644 action/node_modules/cspell/dist/esm/app.mjs create mode 100644 action/node_modules/cspell/dist/esm/application.d.mts create mode 100644 action/node_modules/cspell/dist/esm/application.mjs create mode 100644 action/node_modules/cspell/dist/esm/cli-reporter.d.mts create mode 100644 action/node_modules/cspell/dist/esm/cli-reporter.mjs create mode 100644 action/node_modules/cspell/dist/esm/commandCheck.d.mts create mode 100644 action/node_modules/cspell/dist/esm/commandCheck.mjs create mode 100644 action/node_modules/cspell/dist/esm/commandLink.d.mts create mode 100644 action/node_modules/cspell/dist/esm/commandLink.mjs create mode 100644 action/node_modules/cspell/dist/esm/commandLint.d.mts create mode 100644 action/node_modules/cspell/dist/esm/commandLint.mjs create mode 100644 action/node_modules/cspell/dist/esm/commandSuggestion.d.mts create mode 100644 action/node_modules/cspell/dist/esm/commandSuggestion.mjs create mode 100644 action/node_modules/cspell/dist/esm/commandTrace.d.mts create mode 100644 action/node_modules/cspell/dist/esm/commandTrace.mjs create mode 100644 action/node_modules/cspell/dist/esm/emitters/DictionaryPathFormat.d.mts create mode 100644 action/node_modules/cspell/dist/esm/emitters/DictionaryPathFormat.mjs create mode 100644 action/node_modules/cspell/dist/esm/emitters/suggestionsEmitter.d.mts create mode 100644 action/node_modules/cspell/dist/esm/emitters/suggestionsEmitter.mjs create mode 100644 action/node_modules/cspell/dist/esm/emitters/traceEmitter.d.mts create mode 100644 action/node_modules/cspell/dist/esm/emitters/traceEmitter.mjs create mode 100644 action/node_modules/cspell/dist/esm/featureFlags/featureFlags.d.mts create mode 100644 action/node_modules/cspell/dist/esm/featureFlags/featureFlags.mjs create mode 100644 action/node_modules/cspell/dist/esm/featureFlags/index.d.mts create mode 100644 action/node_modules/cspell/dist/esm/featureFlags/index.mjs create mode 100644 action/node_modules/cspell/dist/esm/index.d.mts create mode 100644 action/node_modules/cspell/dist/esm/index.mjs create mode 100644 action/node_modules/cspell/dist/esm/link.d.mts create mode 100644 action/node_modules/cspell/dist/esm/link.mjs create mode 100644 action/node_modules/cspell/dist/esm/lint/LintRequest.d.mts create mode 100644 action/node_modules/cspell/dist/esm/lint/LintRequest.mjs create mode 100644 action/node_modules/cspell/dist/esm/lint/index.d.mts create mode 100644 action/node_modules/cspell/dist/esm/lint/index.mjs create mode 100644 action/node_modules/cspell/dist/esm/lint/lint.d.mts create mode 100644 action/node_modules/cspell/dist/esm/lint/lint.mjs create mode 100644 action/node_modules/cspell/dist/esm/options.d.mts create mode 100644 action/node_modules/cspell/dist/esm/options.mjs create mode 100644 action/node_modules/cspell/dist/esm/repl/index.d.mts create mode 100644 action/node_modules/cspell/dist/esm/repl/index.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/InMemoryReporter.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/InMemoryReporter.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/async.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/async.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/cache/CSpellLintResultCache.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/cache/CSpellLintResultCache.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/cache/CacheOptions.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/cache/CacheOptions.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/cache/DiskCache.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/cache/DiskCache.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/cache/DummyCache.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/cache/DummyCache.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/cache/ObjectCollection.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/cache/ObjectCollection.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/cache/createCache.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/cache/createCache.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/cache/fileEntryCache.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/cache/fileEntryCache.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/cache/index.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/cache/index.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/constants.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/constants.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/errors.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/errors.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/fileHelper.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/fileHelper.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/glob.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/glob.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/prefetch.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/prefetch.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/reporters.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/reporters.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/stdin.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/stdin.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/table.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/table.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/timer.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/timer.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/types.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/types.mjs create mode 100644 action/node_modules/cspell/dist/esm/util/util.d.mts create mode 100644 action/node_modules/cspell/dist/esm/util/util.mjs create mode 100644 action/node_modules/cspell/dist/lib/file-entry-cache.cjs create mode 100644 action/node_modules/cspell/dist/lib/file-entry-cache.d.cts create mode 100644 action/node_modules/cspell/dist/lib/pkgInfo.cjs create mode 100644 action/node_modules/cspell/dist/lib/pkgInfo.d.cts create mode 100644 action/node_modules/cspell/dist/lib/uri.cjs create mode 100644 action/node_modules/cspell/dist/lib/uri.d.cts create mode 100644 action/node_modules/import-meta-resolve/lib/resolve-get-package-type.js diff --git a/action-src/package.json b/action-src/package.json index 58165ac38..fcc6d5423 100644 --- a/action-src/package.json +++ b/action-src/package.json @@ -36,8 +36,8 @@ "@octokit/core": "^4.2.0", "@octokit/plugin-rest-endpoint-methods": "^7.0.1", "@octokit/rest": "^19.0.7", - "cspell": "^6.28.0", - "cspell-glob": "^6.28.0", + "cspell": "^6.29.1", + "cspell-glob": "^6.29.1", "vscode-uri": "^3.0.7" } } diff --git a/action/node_modules/.bin/cspell-esm b/action/node_modules/.bin/cspell-esm new file mode 120000 index 000000000..7023aa7c9 --- /dev/null +++ b/action/node_modules/.bin/cspell-esm @@ -0,0 +1 @@ +../cspell/bin.mjs \ No newline at end of file diff --git a/action/node_modules/.bin/cspell-gitignore b/action/node_modules/.bin/cspell-gitignore index 61a0ca1db..a0cdb74cb 120000 --- a/action/node_modules/.bin/cspell-gitignore +++ b/action/node_modules/.bin/cspell-gitignore @@ -1 +1 @@ -../cspell-gitignore/bin.js \ No newline at end of file +../cspell-gitignore/bin.mjs \ No newline at end of file diff --git a/action/node_modules/.bin/cspell-grammar b/action/node_modules/.bin/cspell-grammar index c1260831a..b6d108401 120000 --- a/action/node_modules/.bin/cspell-grammar +++ b/action/node_modules/.bin/cspell-grammar @@ -1 +1 @@ -../cspell-grammar/bin.js \ No newline at end of file +../cspell-grammar/bin.mjs \ No newline at end of file diff --git a/action/node_modules/@cspell/cspell-bundled-dicts/package.json b/action/node_modules/@cspell/cspell-bundled-dicts/package.json index 8e203ee67..0c8dd0ddc 100644 --- a/action/node_modules/@cspell/cspell-bundled-dicts/package.json +++ b/action/node_modules/@cspell/cspell-bundled-dicts/package.json @@ -1,6 +1,6 @@ { "name": "@cspell/cspell-bundled-dicts", - "version": "6.28.0", + "version": "6.29.1", "description": "Dictionaries bundled with cspell", "publishConfig": { "access": "public" @@ -47,7 +47,7 @@ "@cspell/dict-ada": "^4.0.1", "@cspell/dict-aws": "^3.0.0", "@cspell/dict-bash": "^4.1.1", - "@cspell/dict-companies": "^3.0.8", + "@cspell/dict-companies": "^3.0.9", "@cspell/dict-cpp": "^4.0.3", "@cspell/dict-cryptocurrencies": "^3.0.1", "@cspell/dict-csharp": "^4.0.2", @@ -79,13 +79,13 @@ "@cspell/dict-php": "^3.0.4", "@cspell/dict-powershell": "^4.0.2", "@cspell/dict-public-licenses": "^2.0.1", - "@cspell/dict-python": "^4.0.1", + "@cspell/dict-python": "^4.0.2", "@cspell/dict-r": "^2.0.1", "@cspell/dict-ruby": "^4.0.2", "@cspell/dict-rust": "^4.0.1", "@cspell/dict-scala": "^4.0.1", "@cspell/dict-software-terms": "^3.1.5", - "@cspell/dict-sql": "^2.0.2", + "@cspell/dict-sql": "^2.1.0", "@cspell/dict-svelte": "^1.0.2", "@cspell/dict-swift": "^2.0.1", "@cspell/dict-typescript": "^3.1.1", @@ -95,9 +95,9 @@ "node": ">=14" }, "devDependencies": { - "@cspell/cspell-tools": "6.28.0", - "@cspell/cspell-types": "6.28.0", + "@cspell/cspell-tools": "6.29.1", + "@cspell/cspell-types": "6.29.1", "typescript": "^4.9.5" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/@cspell/cspell-pipe/package.json b/action/node_modules/@cspell/cspell-pipe/package.json index ab56f0090..cf6275a7c 100644 --- a/action/node_modules/@cspell/cspell-pipe/package.json +++ b/action/node_modules/@cspell/cspell-pipe/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "6.28.0", + "version": "6.29.1", "description": "Library to make working with Iterators/AsyncIterators easier.", "keywords": [ "cspell", @@ -127,5 +127,5 @@ "devDependencies": { "globby": "^13.1.3" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/@cspell/cspell-service-bus/package.json b/action/node_modules/@cspell/cspell-service-bus/package.json index 2b77fc190..26e468312 100644 --- a/action/node_modules/@cspell/cspell-service-bus/package.json +++ b/action/node_modules/@cspell/cspell-service-bus/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "6.28.0", + "version": "6.29.1", "description": "A Library for connecting requests to services that can fulfill them.", "keywords": [ "cspell" @@ -54,5 +54,5 @@ "engines": { "node": ">=14" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/@cspell/cspell-types/package.json b/action/node_modules/@cspell/cspell-types/package.json index 780a8abd6..2c693c42e 100644 --- a/action/node_modules/@cspell/cspell-types/package.json +++ b/action/node_modules/@cspell/cspell-types/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "6.28.0", + "version": "6.29.1", "description": "Types for cspell and cspell-lib", "type": "commonjs", "main": "./dist/cjs/index.js", @@ -90,5 +90,5 @@ "ts-json-schema-generator": "^1.2.0", "typescript": "^4.9.5" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/@cspell/dict-python/README.md b/action/node_modules/@cspell/dict-python/README.md index 080365e29..2c919b83c 100644 --- a/action/node_modules/@cspell/dict-python/README.md +++ b/action/node_modules/@cspell/dict-python/README.md @@ -1,4 +1,4 @@ -# Cspell Python Dictionary +# CSpell Python Dictionary Python dictionary for cspell. diff --git a/action/node_modules/@cspell/dict-python/package.json b/action/node_modules/@cspell/dict-python/package.json index e5869b935..bbb449d72 100644 --- a/action/node_modules/@cspell/dict-python/package.json +++ b/action/node_modules/@cspell/dict-python/package.json @@ -1,6 +1,6 @@ { "name": "@cspell/dict-python", - "version": "4.0.1", + "version": "4.0.2", "description": "Python dictionary for cspell.", "publishConfig": { "access": "public" @@ -44,5 +44,5 @@ "python-common.txt.gz", "cspell-ext.json" ], - "gitHead": "47a34789c05111e7b3cb693beb5d456bf25a0cb0" + "gitHead": "598ddd61d73d1f268f3cb6ab67761de2e52883a1" } diff --git a/action/node_modules/@cspell/dict-python/python.txt.gz b/action/node_modules/@cspell/dict-python/python.txt.gz index d166c07c4043fddbb3fc1993493732ca19f4d9dc..68fe4f037f4aa08111a4b761e881f08ec932033a 100644 GIT binary patch delta 427 zcmV;c0aX65@B*{&0hV+YV?ce!0nN@onMc(3*~{O(qDrJ=&QZTYc6X5wW}t+Kbe^wE1*2 zoDaoA6O*AjxO$^NS`#cN6^1G*lXZ1vX*s#LLvSwQq_tpUq!hwHe_v%zooYdZ1Tz7~ zfSfAPBvsN#I+qjDGjc-8IOQHjIp@FbOC4!N4_yS#d)P;OZaFRtz6KW{W}h`;c#pwF^!RWT#qu2(s_5yaRkH z#N?Ov-83(-ak;Nx$_CGI@1S8;+{qx(S`&)I3eFU^kJp$hA-do436m^sH!*2K%njJF VKp~0N4^x!p{{w)a)zf|q0s!Z+#4G>+ delta 424 zcmV;Z0ayOB@B*;#0684`o3V23N z+Xu#^&7waTm}}bsEyXT3RV_X(oD^D^7-x|cSejt29g zaA;x@R0maW6hLc&<)p$-MJ2K>t}H1h7jp>CMVqu1XpEF180f3af2dO}fRJDYz!->A zC6c5{3Q6bkL3&0$NO{~()nLzPOWOyQt3f}t)w%NM@0yT?;gjGVge>*TVgK&1BqmdD zI9vBLzwwF`jU?PIr^sWBRDvV2AAg%7&uJuJr;j}{GxkkLMUY)Ns6-+}WF>?-ShriH zqJD-MgJL={hah7Le^^C#58W-&)Y(nXOm2p-5%PLscr=4UDq$OP;si2Ax}taX<=}uu z=hlW15fvWc1pgPfgfJU!%>G^N!&!>qqsMA7=>8t^iLrLU34!cWi|;`8`IT3IPl1^9 z^1hqq1-32s6-?RCIqn@a%!xZ0B3f%gkyyc*y7uuJb42%79zJ1mrR^prONg}r`xPi6 S(fVP6()@o5bt%?%3<3bBf6S)< diff --git a/action/node_modules/@cspell/dict-sql/cspell-ext.json b/action/node_modules/@cspell/dict-sql/cspell-ext.json index 959022103..6181703de 100644 --- a/action/node_modules/@cspell/dict-sql/cspell-ext.json +++ b/action/node_modules/@cspell/dict-sql/cspell-ext.json @@ -31,5 +31,6 @@ "ignoreRegExpList": ["sql-hex-number", "sql-unicode-string-prefix"], "dictionaryDefinitions": [] } - ] + ], + "enableFiletypes": ["sql"] } diff --git a/action/node_modules/@cspell/dict-sql/package.json b/action/node_modules/@cspell/dict-sql/package.json index cc2cbdf8b..806621680 100644 --- a/action/node_modules/@cspell/dict-sql/package.json +++ b/action/node_modules/@cspell/dict-sql/package.json @@ -1,6 +1,6 @@ { "name": "@cspell/dict-sql", - "version": "2.0.2", + "version": "2.1.0", "description": "SQL dictionary for cspell.", "publishConfig": { "access": "public" @@ -41,5 +41,5 @@ "*.js", "*.d.ts" ], - "gitHead": "a8ff83095adc9f526f48772c52195e0456f78668" + "gitHead": "7488f0ff144ce7cb739dc2e8ed33ae046700c019" } diff --git a/action/node_modules/@cspell/dynamic-import/package.json b/action/node_modules/@cspell/dynamic-import/package.json index 49e11bb2a..29354d7cd 100644 --- a/action/node_modules/@cspell/dynamic-import/package.json +++ b/action/node_modules/@cspell/dynamic-import/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "6.28.0", + "version": "6.29.1", "description": "Dynamic Module Loader", "keywords": [ "module", @@ -57,7 +57,7 @@ "node": ">=14" }, "dependencies": { - "import-meta-resolve": "^2.2.1" + "import-meta-resolve": "^2.2.2" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/@cspell/strong-weak-map/package.json b/action/node_modules/@cspell/strong-weak-map/package.json index 9beaefb59..0bbafbf2b 100644 --- a/action/node_modules/@cspell/strong-weak-map/package.json +++ b/action/node_modules/@cspell/strong-weak-map/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "6.28.0", + "version": "6.29.1", "description": "A Map with weakly referenced values.", "keywords": [ "Map", @@ -60,5 +60,5 @@ "engines": { "node": ">=14.6" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/createInlineSpellingDictionary.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/createInlineSpellingDictionary.js deleted file mode 100644 index 078750554..000000000 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/createInlineSpellingDictionary.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createInlineSpellingDictionary = void 0; -const AutoResolve_1 = require("../util/AutoResolve"); -const util_1 = require("../util/util"); -const createSpellingDictionary_1 = require("./createSpellingDictionary"); -const FlagWordsDictionary_1 = require("./FlagWordsDictionary"); -const IgnoreWordsDictionary_1 = require("./IgnoreWordsDictionary"); -const SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection"); -const SuggestDictionary_1 = require("./SuggestDictionary"); -const cache = (0, AutoResolve_1.createAutoResolveWeakCache)(); -function createInlineSpellingDictionary(inlineDict, source) { - return cache.get(inlineDict, () => { - const { words, flagWords, ignoreWords, suggestWords, name } = inlineDict; - const dictSources = [ - words && (0, createSpellingDictionary_1.createSpellingDictionary)(words, name + '-words', source, inlineDict), - flagWords && (0, FlagWordsDictionary_1.createFlagWordsDictionary)(flagWords, name + '-flag-words', source), - ignoreWords && (0, IgnoreWordsDictionary_1.createIgnoreWordsDictionary)(ignoreWords, name + '-ignore-words', source), - suggestWords && (0, SuggestDictionary_1.createSuggestDictionary)(suggestWords, name + '-suggest', source), - ].filter(util_1.isDefined); - return (0, SpellingDictionaryCollection_1.createCollection)(dictSources, name, source); - }); -} -exports.createInlineSpellingDictionary = createInlineSpellingDictionary; -//# sourceMappingURL=createInlineSpellingDictionary.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/CachingDictionary.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/CachingDictionary.js similarity index 61% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/CachingDictionary.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/CachingDictionary.js index aca03eb5f..2c4289a7c 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/CachingDictionary.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/CachingDictionary.js @@ -1,17 +1,17 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createCachingDictionary = void 0; -const AutoCache_1 = require("../util/AutoCache"); -const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods"); +const AutoCache_js_1 = require("../util/AutoCache.js"); +const SpellingDictionaryMethods_js_1 = require("./SpellingDictionaryMethods.js"); let dictionaryCounter = 0; class CachedDict { constructor(dict, options) { this.dict = dict; this.options = options; this.id = ++dictionaryCounter; - this.has = (0, AutoCache_1.autoCache)((word) => this.dict.has(word, this.options)); - this.isNoSuggestWord = (0, AutoCache_1.autoCache)((word) => this.dict.isNoSuggestWord(word, this.options)); - this.isForbidden = (0, AutoCache_1.autoCache)((word) => this.dict.isForbidden(word)); + this.has = (0, AutoCache_js_1.autoCache)((word) => this.dict.has(word, this.options)); + this.isNoSuggestWord = (0, AutoCache_js_1.autoCache)((word) => this.dict.isNoSuggestWord(word, this.options)); + this.isForbidden = (0, AutoCache_js_1.autoCache)((word) => this.dict.isForbidden(word)); this.name = dict.name; // console.log(`CachedDict for ${this.name}`); } @@ -19,9 +19,9 @@ class CachedDict { return { name: this.name, id: this.id, - has: (0, AutoCache_1.extractStats)(this.has), - isNoSuggestWord: (0, AutoCache_1.extractStats)(this.isNoSuggestWord), - isForbidden: (0, AutoCache_1.extractStats)(this.isForbidden), + has: (0, AutoCache_js_1.extractStats)(this.has), + isNoSuggestWord: (0, AutoCache_js_1.extractStats)(this.isNoSuggestWord), + isForbidden: (0, AutoCache_js_1.extractStats)(this.isForbidden), }; } } @@ -33,7 +33,7 @@ const knownDicts = new Map(); * @returns CachingDictionary */ function createCachingDictionary(dict, options) { - options = (0, SpellingDictionaryMethods_1.canonicalSearchOptions)(options); + options = (0, SpellingDictionaryMethods_js_1.canonicalSearchOptions)(options); let knownOptions = knownDicts.get(options); if (!knownOptions) { knownOptions = new WeakMap(); diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/FlagWordsDictionary.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/FlagWordsDictionary.js similarity index 87% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/FlagWordsDictionary.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/FlagWordsDictionary.js index 75015b658..f6e25584a 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/FlagWordsDictionary.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/FlagWordsDictionary.js @@ -26,15 +26,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.createFlagWordsDictionary = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); const cspell_trie_lib_1 = require("cspell-trie-lib"); -const AutoResolve_1 = require("../util/AutoResolve"); -const Defaults = __importStar(require("./defaults")); -const SpellingDictionary_1 = require("./SpellingDictionary"); -const SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie"); -const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods"); -const TyposDictionary_1 = require("./TyposDictionary"); -class FlagWordsDictionaryTrie extends SpellingDictionaryFromTrie_1.SpellingDictionaryFromTrie { +const AutoResolve_js_1 = require("../util/AutoResolve.js"); +const Defaults = __importStar(require("./defaults.js")); +const SpellingDictionary_js_1 = require("./SpellingDictionary.js"); +const SpellingDictionaryFromTrie_js_1 = require("./SpellingDictionaryFromTrie.js"); +const SpellingDictionaryMethods_js_1 = require("./SpellingDictionaryMethods.js"); +const TyposDictionary_js_1 = require("./TyposDictionary.js"); +class FlagWordsDictionaryTrie extends SpellingDictionaryFromTrie_js_1.SpellingDictionaryFromTrie { constructor(trie, name, source) { - super(trie, name, SpellingDictionary_1.defaultOptions, source); + super(trie, name, SpellingDictionary_js_1.defaultOptions, source); this.name = name; this.source = source; this.containsNoSuggestWords = false; @@ -104,7 +104,7 @@ class FlagWordsDictionary { } suggest(...args) { const [word] = args; - const suggestOptions = (0, SpellingDictionaryMethods_1.suggestArgsToSuggestOptions)(args); + const suggestOptions = (0, SpellingDictionaryMethods_js_1.suggestArgsToSuggestOptions)(args); return this.dictTypos.suggest(word, suggestOptions); } genSuggestions() { @@ -120,7 +120,7 @@ class FlagWordsDictionary { return []; } } -const createCache = (0, AutoResolve_1.createAutoResolveWeakCache)(); +const createCache = (0, AutoResolve_js_1.createAutoResolveWeakCache)(); /** * Create a dictionary where all words are to be forbidden. * @param wordList - list of words @@ -134,7 +134,7 @@ function createFlagWordsDictionary(wordList, name, source) { const testSpecialCharacters = /[~*+]/; const { t: specialWords, f: typoWords } = bisect((0, cspell_trie_lib_1.parseDictionaryLines)(wordList, { stripCaseAndAccents: false }), (line) => testSpecialCharacters.test(line)); const trieDict = specialWords.size ? buildTrieDict(specialWords, name, source) : undefined; - const typosDict = (0, TyposDictionary_1.createTyposDictionary)(typoWords, name, source); + const typosDict = (0, TyposDictionary_js_1.createTyposDictionary)(typoWords, name, source); if (!trieDict) return typosDict; return new FlagWordsDictionary(name, source, typosDict, trieDict); diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/IgnoreWordsDictionary.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/IgnoreWordsDictionary.js similarity index 92% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/IgnoreWordsDictionary.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/IgnoreWordsDictionary.js index 8b345de3e..e4a732ad6 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/IgnoreWordsDictionary.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/IgnoreWordsDictionary.js @@ -26,9 +26,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.createIgnoreWordsDictionary = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); const cspell_trie_lib_1 = require("cspell-trie-lib"); -const AutoResolve_1 = require("../util/AutoResolve"); -const createSpellingDictionary_1 = require("./createSpellingDictionary"); -const Defaults = __importStar(require("./defaults")); +const AutoResolve_js_1 = require("../util/AutoResolve.js"); +const createSpellingDictionary_js_1 = require("./createSpellingDictionary.js"); +const Defaults = __importStar(require("./defaults.js")); const NormalizeForm = 'NFC'; class IgnoreWordsDictionary { constructor(name, source, words) { @@ -95,7 +95,7 @@ class IgnoreWordsDictionary { return []; } } -const createCache = (0, AutoResolve_1.createAutoResolveWeakCache)(); +const createCache = (0, AutoResolve_js_1.createAutoResolveWeakCache)(); /** * Create a dictionary where all words are to be ignored. * Ignored words override forbidden words. @@ -110,7 +110,7 @@ function createIgnoreWordsDictionary(wordList, name, source) { const words = [...(0, cspell_trie_lib_1.parseDictionaryLines)(wordList, { stripCaseAndAccents: true })].map((w) => w.normalize(NormalizeForm)); const hasSpecial = words.findIndex((word) => testSpecialCharacters.test(word)) >= 0; if (hasSpecial) { - return (0, createSpellingDictionary_1.createSpellingDictionary)(words, name, source, { + return (0, createSpellingDictionary_js_1.createSpellingDictionary)(words, name, source, { caseSensitive: true, noSuggest: true, weightMap: undefined, diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionary.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SpellingDictionary.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionary.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SpellingDictionary.js diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryCollection.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SpellingDictionaryCollection.js similarity index 84% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryCollection.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SpellingDictionaryCollection.js index 0c1bb15d6..598cecb4d 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryCollection.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SpellingDictionaryCollection.js @@ -26,10 +26,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.__testing__ = exports.isSpellingDictionaryCollection = exports.createCollection = void 0; const cspell_trie_lib_1 = require("cspell-trie-lib"); const gensequence_1 = require("gensequence"); -const util_1 = require("../util/util"); -const Defaults = __importStar(require("./defaults")); -const SpellingDictionary_1 = require("./SpellingDictionary"); -const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods"); +const util_js_1 = require("../util/util.js"); +const Defaults = __importStar(require("./defaults.js")); +const SpellingDictionary_js_1 = require("./SpellingDictionary.js"); +const SpellingDictionaryMethods_js_1 = require("./SpellingDictionaryMethods.js"); function identityString(w) { return w; } @@ -51,11 +51,11 @@ class SpellingDictionaryCollectionImpl { this.containsNoSuggestWords = this.dictionaries.reduce((a, b) => a || b.containsNoSuggestWords, false); } has(word, hasOptions) { - const options = (0, SpellingDictionaryMethods_1.hasOptionToSearchOption)(hasOptions); + const options = (0, SpellingDictionaryMethods_js_1.hasOptionToSearchOption)(hasOptions); return !!isWordInAnyDictionary(this.dictionaries, word, options) && !this.isForbidden(word); } find(word, hasOptions) { - const options = (0, SpellingDictionaryMethods_1.hasOptionToSearchOption)(hasOptions); + const options = (0, SpellingDictionaryMethods_js_1.hasOptionToSearchOption)(hasOptions); return findInAnyDictionary(this.dictionaries, word, options); } isNoSuggestWord(word, options) { @@ -67,11 +67,11 @@ class SpellingDictionaryCollectionImpl { } suggest(...args) { const [word] = args; - const suggestOptions = (0, SpellingDictionaryMethods_1.suggestArgsToSuggestOptions)(args); + const suggestOptions = (0, SpellingDictionaryMethods_js_1.suggestArgsToSuggestOptions)(args); return this._suggest(word, suggestOptions); } _suggest(word, suggestOptions) { - const { numSuggestions = SpellingDictionaryMethods_1.defaultNumSuggestions, numChanges, ignoreCase, includeTies, timeout } = suggestOptions; + const { numSuggestions = SpellingDictionaryMethods_js_1.defaultNumSuggestions, numChanges, ignoreCase, includeTies, timeout } = suggestOptions; const prefixNoCase = cspell_trie_lib_1.CASE_INSENSITIVE_PREFIX; const filter = (word, _cost) => { return ((ignoreCase || word[0] !== prefixNoCase) && @@ -86,7 +86,7 @@ class SpellingDictionaryCollectionImpl { ignoreCase, timeout, }; - const collector = (0, SpellingDictionaryMethods_1.suggestionCollector)(word, collectorOptions); + const collector = (0, SpellingDictionaryMethods_js_1.suggestionCollector)(word, collectorOptions); this.genSuggestions(collector, suggestOptions); return collector.suggestions.map((r) => ({ ...r, word: r.word })); } @@ -95,8 +95,8 @@ class SpellingDictionaryCollectionImpl { } genSuggestions(collector, suggestOptions) { const _suggestOptions = { ...suggestOptions }; - const { compoundMethod = SpellingDictionary_1.CompoundWordsMethod.SEPARATE_WORDS } = suggestOptions; - _suggestOptions.compoundMethod = this.options.useCompounds ? SpellingDictionary_1.CompoundWordsMethod.JOIN_WORDS : compoundMethod; + const { compoundMethod = SpellingDictionary_js_1.CompoundWordsMethod.SEPARATE_WORDS } = suggestOptions; + _suggestOptions.compoundMethod = this.options.useCompounds ? SpellingDictionary_js_1.CompoundWordsMethod.JOIN_WORDS : compoundMethod; this.dictionaries.forEach((dict) => dict.genSuggestions(collector, _suggestOptions)); } getErrors() { @@ -114,7 +114,7 @@ function isWordInAnyDictionary(dicts, word, options) { return (0, gensequence_1.genSequence)(dicts).first((dict) => dict.has(word, options)); } function findInAnyDictionary(dicts, word, options) { - const found = dicts.map((dict) => dict.find(word, options)).filter(util_1.isDefined); + const found = dicts.map((dict) => dict.find(word, options)).filter(util_js_1.isDefined); if (!found.length) return undefined; return found.reduce((a, b) => ({ diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryFromTrie.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SpellingDictionaryFromTrie.js similarity index 84% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryFromTrie.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SpellingDictionaryFromTrie.js index 2c2875f22..9e5a3ad89 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryFromTrie.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SpellingDictionaryFromTrie.js @@ -26,11 +26,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.__testing__ = exports.createSpellingDictionaryFromTrieFile = exports.SpellingDictionaryFromTrie = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); const cspell_trie_lib_1 = require("cspell-trie-lib"); -const AutoCache_1 = require("../util/AutoCache"); -const clean_1 = require("../util/clean"); -const repMap_1 = require("../util/repMap"); -const Defaults = __importStar(require("./defaults")); -const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods"); +const AutoCache_js_1 = require("../util/AutoCache.js"); +const clean_js_1 = require("../util/clean.js"); +const repMap_js_1 = require("../util/repMap.js"); +const Defaults = __importStar(require("./defaults.js")); +const SpellingDictionaryMethods_js_1 = require("./SpellingDictionaryMethods.js"); const findWordOptionsCaseSensitive = Object.freeze({ caseSensitive: true }); const findWordOptionsNotCaseSensitive = Object.freeze({ caseSensitive: false }); class SpellingDictionaryFromTrie { @@ -44,15 +44,15 @@ class SpellingDictionaryFromTrie { this.unknownWords = new Set(); this.type = 'SpellingDictionaryFromTrie'; this._find = findCache((word, useCompounds, ignoreCase) => this.findAnyForm(word, useCompounds, ignoreCase)); - this._isForbidden = (0, AutoCache_1.autoCache)((word) => { + this._isForbidden = (0, AutoCache_js_1.autoCache)((word) => { return this.trie.isForbiddenWord(word); }); - this.mapWord = (0, repMap_1.createMapper)(options.repMap, options.dictionaryInformation?.ignore); - this.remapWord = (0, repMap_1.createRepMapper)(options.repMap, options.dictionaryInformation?.ignore); + this.mapWord = (0, repMap_js_1.createMapper)(options.repMap, options.dictionaryInformation?.ignore); + this.remapWord = (0, repMap_js_1.createRepMapper)(options.repMap, options.dictionaryInformation?.ignore); this.isDictionaryCaseSensitive = options.caseSensitive ?? !trie.isLegacy; this.containsNoSuggestWords = options.noSuggest || false; this._size = size || 0; - this.weightMap = options.weightMap || (0, SpellingDictionaryMethods_1.createWeightMapFromDictionaryInformation)(options.dictionaryInformation); + this.weightMap = options.weightMap || (0, SpellingDictionaryMethods_js_1.createWeightMapFromDictionaryInformation)(options.dictionaryInformation); } get size() { if (!this._size) { @@ -86,7 +86,7 @@ class SpellingDictionaryFromTrie { return { found, forbidden, noSuggest }; } resolveOptions(hasOptions) { - const { useCompounds = this.options.useCompounds, ignoreCase = Defaults.ignoreCase } = (0, SpellingDictionaryMethods_1.hasOptionToSearchOption)(hasOptions); + const { useCompounds = this.options.useCompounds, ignoreCase = Defaults.ignoreCase } = (0, SpellingDictionaryMethods_js_1.hasOptionToSearchOption)(hasOptions); return { useCompounds, ignoreCase }; } findAnyForm(word, useCompounds, ignoreCase) { @@ -104,7 +104,7 @@ class SpellingDictionaryFromTrie { if (findResult.found !== false) { return findResult; } - const forms = (0, SpellingDictionaryMethods_1.wordSearchForms)(mWord, this.isDictionaryCaseSensitive, ignoreCase); + const forms = (0, SpellingDictionaryMethods_js_1.wordSearchForms)(mWord, this.isDictionaryCaseSensitive, ignoreCase); for (const w of forms) { const findResult = this.trie.findWord(w, opts); if (findResult.found !== false) { @@ -130,15 +130,15 @@ class SpellingDictionaryFromTrie { } suggest(...args) { const [word] = args; - const suggestOptions = (0, SpellingDictionaryMethods_1.suggestArgsToSuggestOptions)(args); + const suggestOptions = (0, SpellingDictionaryMethods_js_1.suggestArgsToSuggestOptions)(args); return this._suggest(word, suggestOptions); } _suggest(word, suggestOptions) { - const { numSuggestions = SpellingDictionaryMethods_1.defaultNumSuggestions, numChanges, includeTies, ignoreCase, timeout } = suggestOptions; + const { numSuggestions = SpellingDictionaryMethods_js_1.defaultNumSuggestions, numChanges, includeTies, ignoreCase, timeout } = suggestOptions; function filter(_word) { return true; } - const collector = (0, cspell_trie_lib_1.suggestionCollector)(word, (0, clean_1.clean)({ + const collector = (0, cspell_trie_lib_1.suggestionCollector)(word, (0, clean_js_1.clean)({ numSuggestions, filter, changeLimit: numChanges, @@ -155,7 +155,7 @@ class SpellingDictionaryFromTrie { return; const _compoundMethod = suggestOptions.compoundMethod ?? (this.options.useCompounds ? cspell_trie_lib_1.CompoundWordsMethod.JOIN_WORDS : cspell_trie_lib_1.CompoundWordsMethod.NONE); - (0, SpellingDictionaryMethods_1.wordSuggestFormsArray)(collector.word).forEach((w) => this.trie.genSuggestions((0, SpellingDictionaryMethods_1.impersonateCollector)(collector, w), _compoundMethod)); + (0, SpellingDictionaryMethods_js_1.wordSuggestFormsArray)(collector.word).forEach((w) => this.trie.genSuggestions((0, SpellingDictionaryMethods_js_1.impersonateCollector)(collector, w), _compoundMethod)); } getErrors() { return []; @@ -179,7 +179,7 @@ function createSpellingDictionaryFromTrieFile(data, name, source, options) { } exports.createSpellingDictionaryFromTrieFile = createSpellingDictionaryFromTrieFile; function findCache(fn, size = 2000) { - const cache = (0, AutoCache_1.createCache01)(size); + const cache = (0, AutoCache_js_1.createCache01)(size); function find(word, useCompounds, ignoreCase) { const r = cache.get(word); if (r !== undefined) { diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryMethods.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SpellingDictionaryMethods.js similarity index 93% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryMethods.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SpellingDictionaryMethods.js index bca57ec8e..37e16bce7 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryMethods.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SpellingDictionaryMethods.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.__testMethods__ = exports.createWeightMapFromDictionaryInformation = exports.suggestArgsToSuggestOptions = exports.canonicalSearchOptions = exports.hasOptionToSearchOption = exports.wordSuggestForms = exports.wordSuggestFormsArray = exports.wordSearchForms = exports.defaultNumSuggestions = exports.suggestionCollector = exports.impersonateCollector = void 0; const cspell_trie_lib_1 = require("cspell-trie-lib"); -const text_1 = require("../util/text"); +const text_js_1 = require("../util/text.js"); var cspell_trie_lib_2 = require("cspell-trie-lib"); Object.defineProperty(exports, "impersonateCollector", { enumerable: true, get: function () { return cspell_trie_lib_2.impersonateCollector; } }); Object.defineProperty(exports, "suggestionCollector", { enumerable: true, get: function () { return cspell_trie_lib_2.suggestionCollector; } }); @@ -21,7 +21,7 @@ function wordSearchForms(word, isDictionaryCaseSensitive, ignoreCase) { else { forms.add(wordLc); // Legacy remove any unbound accents - forms.add((0, text_1.removeUnboundAccents)(wordLc)); + forms.add((0, text_js_1.removeUnboundAccents)(wordLc)); } } else { @@ -29,14 +29,14 @@ function wordSearchForms(word, isDictionaryCaseSensitive, ignoreCase) { forms.add(word); forms.add(wordLc); // HOUSE -> House, house - if ((0, text_1.isUpperCase)(word)) { - forms.add((0, text_1.ucFirst)(wordLc)); + if ((0, text_js_1.isUpperCase)(word)) { + forms.add((0, text_js_1.ucFirst)(wordLc)); } } else { forms.add(wordLc); // Legacy remove any unbound accents - forms.add((0, text_1.removeUnboundAccents)(wordLc)); + forms.add((0, text_js_1.removeUnboundAccents)(wordLc)); } } return forms; diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SuggestDictionary.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SuggestDictionary.js similarity index 88% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/SuggestDictionary.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SuggestDictionary.js index 65c643e27..ad494514e 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SuggestDictionary.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/SuggestDictionary.js @@ -25,11 +25,11 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.createSuggestDictionary = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); -const AutoResolve_1 = require("../util/AutoResolve"); -const textMappers_1 = require("../util/textMappers"); -const defaults = __importStar(require("./defaults")); -const Typos_1 = require("./Typos"); -const util_1 = require("./Typos/util"); +const AutoResolve_js_1 = require("../util/AutoResolve.js"); +const textMappers_js_1 = require("../util/textMappers.js"); +const defaults = __importStar(require("./defaults.js")); +const index_js_1 = require("./Typos/index.js"); +const util_js_1 = require("./Typos/util.js"); class SuggestDictionaryImpl { constructor(name, source, typosDef) { this.name = name; @@ -40,8 +40,8 @@ class SuggestDictionaryImpl { this.type = 'suggest'; this.isDictionaryCaseSensitive = true; this.size = Object.keys(typosDef).length; - this.suggestions = (0, util_1.extractAllSuggestions)(typosDef); - this.suggestionsLower = new Set((0, sync_1.pipe)(this.suggestions, textMappers_1.mapperRemoveCaseAndAccents)); + this.suggestions = (0, util_js_1.extractAllSuggestions)(typosDef); + this.suggestionsLower = new Set((0, sync_1.pipe)(this.suggestions, textMappers_js_1.mapperRemoveCaseAndAccents)); } /** * A Forbidden word list does not "have" valid words. @@ -107,7 +107,7 @@ class SuggestDictionaryImpl { return []; } } -const createCache = (0, AutoResolve_1.createAutoResolveWeakCache)(); +const createCache = (0, AutoResolve_js_1.createAutoResolveWeakCache)(); /** * Create a dictionary where all words are to be forbidden. * @param entries - list of Typos Entries @@ -117,7 +117,7 @@ const createCache = (0, AutoResolve_1.createAutoResolveWeakCache)(); */ function createSuggestDictionary(entries, name, source) { return createCache.get(entries, () => { - const def = (0, Typos_1.processEntriesToTyposDef)(entries); + const def = (0, index_js_1.processEntriesToTyposDef)(entries); return new SuggestDictionaryImpl(name, source, def); }); } diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/index.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Terms/index.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/index.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Terms/index.js diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/terms.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Terms/terms.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/terms.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Terms/terms.js diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/index.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Typos/index.js similarity index 55% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/index.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Typos/index.js index 1d27d6be4..b2e5f8861 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/index.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Typos/index.js @@ -1,11 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractAllSuggestions = exports.createTyposDef = exports.processEntriesToTyposDef = exports.parseTyposLine = exports.parseTyposFile = void 0; -var typosParser_1 = require("./typosParser"); -Object.defineProperty(exports, "parseTyposFile", { enumerable: true, get: function () { return typosParser_1.parseTyposFile; } }); -Object.defineProperty(exports, "parseTyposLine", { enumerable: true, get: function () { return typosParser_1.parseTyposLine; } }); -Object.defineProperty(exports, "processEntriesToTyposDef", { enumerable: true, get: function () { return typosParser_1.processEntriesToTyposDef; } }); -var util_1 = require("./util"); -Object.defineProperty(exports, "createTyposDef", { enumerable: true, get: function () { return util_1.createTyposDef; } }); -Object.defineProperty(exports, "extractAllSuggestions", { enumerable: true, get: function () { return util_1.extractAllSuggestions; } }); +var typosParser_js_1 = require("./typosParser.js"); +Object.defineProperty(exports, "parseTyposFile", { enumerable: true, get: function () { return typosParser_js_1.parseTyposFile; } }); +Object.defineProperty(exports, "parseTyposLine", { enumerable: true, get: function () { return typosParser_js_1.parseTyposLine; } }); +Object.defineProperty(exports, "processEntriesToTyposDef", { enumerable: true, get: function () { return typosParser_js_1.processEntriesToTyposDef; } }); +var util_js_1 = require("./util.js"); +Object.defineProperty(exports, "createTyposDef", { enumerable: true, get: function () { return util_js_1.createTyposDef; } }); +Object.defineProperty(exports, "extractAllSuggestions", { enumerable: true, get: function () { return util_js_1.extractAllSuggestions; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/typos.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Typos/typos.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/typos.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Typos/typos.js diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/typosParser.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Typos/typosParser.js similarity index 93% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/typosParser.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Typos/typosParser.js index 8ea42dc80..61ff90fe7 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/typosParser.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Typos/typosParser.js @@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.parseTyposFile = exports.parseTyposLine = exports.processEntriesToTyposDef = exports.sanitizeIntoTypoDef = exports.createTyposDefFromEntries = void 0; const assert_1 = __importDefault(require("assert")); -const util_1 = require("./util"); +const util_js_1 = require("./util.js"); function assertString(v) { (0, assert_1.default)(typeof v === 'string', 'A string was expected.'); return true; @@ -17,7 +17,7 @@ const inlineComment = /#.*/gm; function createTyposDefFromEntries(entries) { const def = Object.create(null); for (const entry of entries) { - (0, util_1.appendToDef)(def, entry); + (0, util_js_1.appendToDef)(def, entry); } return def; } @@ -41,7 +41,7 @@ function splitSuggestionsValue(value) { function sanitizeIntoTypoDef(dirtyDef) { if (!dirtyDef || typeof dirtyDef !== 'object') return undefined; - const def = (0, util_1.createTyposDef)(); + const def = (0, util_js_1.createTyposDef)(); for (const [rawKey, value] of Object.entries(dirtyDef)) { const key = normalize(rawKey.trim()); if (!key) @@ -91,9 +91,9 @@ function processEntriesToTyposDef(entries) { } exports.processEntriesToTyposDef = processEntriesToTyposDef; function reduceToTyposDef(entries) { - const def = (0, util_1.createTyposDef)(); + const def = (0, util_js_1.createTyposDef)(); for (const entry of entries) { - (0, util_1.appendToDef)(def, parseTyposLine(entry)); + (0, util_js_1.appendToDef)(def, parseTyposLine(entry)); } return def; } @@ -106,7 +106,7 @@ function parseTyposLine(line) { if (!line) return undefined; if (typeof line === 'string') { - const def = (0, util_1.createTyposDef)(); + const def = (0, util_js_1.createTyposDef)(); for (const subEntry of splitIntoLines(line)) { const [left, right] = splitEntry(subEntry); const typo = left.trim(); diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/util.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Typos/util.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/util.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/Typos/util.js diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/TyposDictionary.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/TyposDictionary.js similarity index 89% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/TyposDictionary.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/TyposDictionary.js index 9bdefef65..4db84608d 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/TyposDictionary.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/TyposDictionary.js @@ -25,11 +25,11 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.createTyposDictionary = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); -const AutoResolve_1 = require("../util/AutoResolve"); -const textMappers_1 = require("../util/textMappers"); -const defaults = __importStar(require("./defaults")); -const Typos_1 = require("./Typos"); -const util_1 = require("./Typos/util"); +const AutoResolve_js_1 = require("../util/AutoResolve.js"); +const textMappers_js_1 = require("../util/textMappers.js"); +const defaults = __importStar(require("./defaults.js")); +const index_js_1 = require("./Typos/index.js"); +const util_js_1 = require("./Typos/util.js"); class TyposDictionaryImpl { constructor(name, source, typosDef, ignoreList) { this.name = name; @@ -39,10 +39,10 @@ class TyposDictionaryImpl { this.type = 'typos'; this.isDictionaryCaseSensitive = true; this.size = Object.keys(typosDef).length; - this.explicitIgnoreWords = (0, util_1.extractIgnoreValues)(typosDef, '!'); - this.suggestions = (0, util_1.extractAllSuggestions)(typosDef); + this.explicitIgnoreWords = (0, util_js_1.extractIgnoreValues)(typosDef, '!'); + this.suggestions = (0, util_js_1.extractAllSuggestions)(typosDef); this.ignoreWords = new Set((0, sync_1.pipe)(this.explicitIgnoreWords, (0, sync_1.opAppend)(ignoreList || []))); - this.suggestionsLower = new Set((0, sync_1.pipe)(this.suggestions, textMappers_1.mapperRemoveCaseAndAccents)); + this.suggestionsLower = new Set((0, sync_1.pipe)(this.suggestions, textMappers_js_1.mapperRemoveCaseAndAccents)); this.containsNoSuggestWords = this.ignoreWords.size > 0; } /** @@ -139,7 +139,7 @@ class TyposDictionaryImpl { return []; } } -const createCache = (0, AutoResolve_1.createAutoResolveWeakCache)(); +const createCache = (0, AutoResolve_js_1.createAutoResolveWeakCache)(); /** * Create a dictionary where all words are to be forbidden. * @param entries - list of Typos Entries @@ -149,7 +149,7 @@ const createCache = (0, AutoResolve_1.createAutoResolveWeakCache)(); */ function createTyposDictionary(entries, name, source) { return createCache.get(entries, () => { - const def = (0, Typos_1.processEntriesToTyposDef)(entries); + const def = (0, index_js_1.processEntriesToTyposDef)(entries); return new TyposDictionaryImpl(name, source, def); }); } diff --git a/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/createInlineSpellingDictionary.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/createInlineSpellingDictionary.js new file mode 100644 index 000000000..f1772c84b --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/createInlineSpellingDictionary.js @@ -0,0 +1,25 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createInlineSpellingDictionary = void 0; +const AutoResolve_js_1 = require("../util/AutoResolve.js"); +const util_js_1 = require("../util/util.js"); +const createSpellingDictionary_js_1 = require("./createSpellingDictionary.js"); +const FlagWordsDictionary_js_1 = require("./FlagWordsDictionary.js"); +const IgnoreWordsDictionary_js_1 = require("./IgnoreWordsDictionary.js"); +const SpellingDictionaryCollection_js_1 = require("./SpellingDictionaryCollection.js"); +const SuggestDictionary_js_1 = require("./SuggestDictionary.js"); +const cache = (0, AutoResolve_js_1.createAutoResolveWeakCache)(); +function createInlineSpellingDictionary(inlineDict, source) { + return cache.get(inlineDict, () => { + const { words, flagWords, ignoreWords, suggestWords, name } = inlineDict; + const dictSources = [ + words && (0, createSpellingDictionary_js_1.createSpellingDictionary)(words, name + '-words', source, inlineDict), + flagWords && (0, FlagWordsDictionary_js_1.createFlagWordsDictionary)(flagWords, name + '-flag-words', source), + ignoreWords && (0, IgnoreWordsDictionary_js_1.createIgnoreWordsDictionary)(ignoreWords, name + '-ignore-words', source), + suggestWords && (0, SuggestDictionary_js_1.createSuggestDictionary)(suggestWords, name + '-suggest', source), + ].filter(util_js_1.isDefined); + return (0, SpellingDictionaryCollection_js_1.createCollection)(dictSources, name, source); + }); +} +exports.createInlineSpellingDictionary = createInlineSpellingDictionary; +//# sourceMappingURL=createInlineSpellingDictionary.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/createSpellingDictionary.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/createSpellingDictionary.js similarity index 75% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/createSpellingDictionary.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/createSpellingDictionary.js index cc470d576..e12d33625 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/createSpellingDictionary.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/createSpellingDictionary.js @@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.createFailedToLoadDictionary = exports.createSpellingDictionary = void 0; const cspell_trie_lib_1 = require("cspell-trie-lib"); const fast_equals_1 = require("fast-equals"); -const simpleCache_1 = require("../util/simpleCache"); -const SpellingDictionary_1 = require("./SpellingDictionary"); -const SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie"); -const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods"); -const cachedDictionaries = new simpleCache_1.AutoWeakCache(_createSpellingDictionary, 64); +const simpleCache_js_1 = require("../util/simpleCache.js"); +const SpellingDictionary_js_1 = require("./SpellingDictionary.js"); +const SpellingDictionaryFromTrie_js_1 = require("./SpellingDictionaryFromTrie.js"); +const SpellingDictionaryMethods_js_1 = require("./SpellingDictionaryMethods.js"); +const cachedDictionaries = new simpleCache_js_1.AutoWeakCache(_createSpellingDictionary, 64); const maxSetSize = 3; -const cachedParamsByWordList = new simpleCache_1.SimpleCache(64); +const cachedParamsByWordList = new simpleCache_js_1.SimpleCache(64); /** * Create a SpellingDictionary * @param wordList - list of words @@ -42,11 +42,11 @@ function _createSpellingDictionary(params) { const parseOptions = { stripCaseAndAccents: options?.supportNonStrictSearches ?? true }; const words = (0, cspell_trie_lib_1.parseDictionaryLines)(wordList, parseOptions); const trie = (0, cspell_trie_lib_1.buildTrieFast)(words); - const opts = { ...(options || SpellingDictionary_1.defaultOptions) }; + const opts = { ...(options || SpellingDictionary_js_1.defaultOptions) }; if (opts.weightMap === undefined && opts.dictionaryInformation) { - opts.weightMap = (0, SpellingDictionaryMethods_1.createWeightMapFromDictionaryInformation)(opts.dictionaryInformation); + opts.weightMap = (0, SpellingDictionaryMethods_js_1.createWeightMapFromDictionaryInformation)(opts.dictionaryInformation); } - return new SpellingDictionaryFromTrie_1.SpellingDictionaryFromTrie(trie, name, opts, source); + return new SpellingDictionaryFromTrie_js_1.SpellingDictionaryFromTrie(trie, name, opts, source); } function createFailedToLoadDictionary(name, source, error, options) { options = options || {}; diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/defaults.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/defaults.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/defaults.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/defaults.js diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/index.js b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/index.js similarity index 53% rename from action/node_modules/cspell-dictionary/dist/SpellingDictionary/index.js rename to action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/index.js index ca6a7f4a9..363283f34 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/index.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/SpellingDictionary/index.js @@ -1,24 +1,24 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createTyposDictionary = exports.createSuggestDictionary = exports.createSpellingDictionaryFromTrieFile = exports.createCollection = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createSpellingDictionary = exports.createFailedToLoadDictionary = exports.createInlineSpellingDictionary = exports.createCachingDictionary = void 0; -var CachingDictionary_1 = require("./CachingDictionary"); -Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return CachingDictionary_1.createCachingDictionary; } }); -var createInlineSpellingDictionary_1 = require("./createInlineSpellingDictionary"); -Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return createInlineSpellingDictionary_1.createInlineSpellingDictionary; } }); -var createSpellingDictionary_1 = require("./createSpellingDictionary"); -Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return createSpellingDictionary_1.createFailedToLoadDictionary; } }); -Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return createSpellingDictionary_1.createSpellingDictionary; } }); -var FlagWordsDictionary_1 = require("./FlagWordsDictionary"); -Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_1.createFlagWordsDictionary; } }); -Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_1.createFlagWordsDictionary; } }); -var IgnoreWordsDictionary_1 = require("./IgnoreWordsDictionary"); -Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return IgnoreWordsDictionary_1.createIgnoreWordsDictionary; } }); -var SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection"); -Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionaryCollection_1.createCollection; } }); -var SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie"); -Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionaryFromTrie_1.createSpellingDictionaryFromTrieFile; } }); -var SuggestDictionary_1 = require("./SuggestDictionary"); -Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return SuggestDictionary_1.createSuggestDictionary; } }); -var TyposDictionary_1 = require("./TyposDictionary"); -Object.defineProperty(exports, "createTyposDictionary", { enumerable: true, get: function () { return TyposDictionary_1.createTyposDictionary; } }); +var CachingDictionary_js_1 = require("./CachingDictionary.js"); +Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return CachingDictionary_js_1.createCachingDictionary; } }); +var createInlineSpellingDictionary_js_1 = require("./createInlineSpellingDictionary.js"); +Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return createInlineSpellingDictionary_js_1.createInlineSpellingDictionary; } }); +var createSpellingDictionary_js_1 = require("./createSpellingDictionary.js"); +Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return createSpellingDictionary_js_1.createFailedToLoadDictionary; } }); +Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return createSpellingDictionary_js_1.createSpellingDictionary; } }); +var FlagWordsDictionary_js_1 = require("./FlagWordsDictionary.js"); +Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_js_1.createFlagWordsDictionary; } }); +Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_js_1.createFlagWordsDictionary; } }); +var IgnoreWordsDictionary_js_1 = require("./IgnoreWordsDictionary.js"); +Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return IgnoreWordsDictionary_js_1.createIgnoreWordsDictionary; } }); +var SpellingDictionaryCollection_js_1 = require("./SpellingDictionaryCollection.js"); +Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionaryCollection_js_1.createCollection; } }); +var SpellingDictionaryFromTrie_js_1 = require("./SpellingDictionaryFromTrie.js"); +Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionaryFromTrie_js_1.createSpellingDictionaryFromTrieFile; } }); +var SuggestDictionary_js_1 = require("./SuggestDictionary.js"); +Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return SuggestDictionary_js_1.createSuggestDictionary; } }); +var TyposDictionary_js_1 = require("./TyposDictionary.js"); +Object.defineProperty(exports, "createTyposDictionary", { enumerable: true, get: function () { return TyposDictionary_js_1.createTyposDictionary; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/index.js b/action/node_modules/cspell-dictionary/dist/cjs/index.js similarity index 51% rename from action/node_modules/cspell-dictionary/dist/index.js rename to action/node_modules/cspell-dictionary/dist/cjs/index.js index b1c83caa6..53be5e216 100644 --- a/action/node_modules/cspell-dictionary/dist/index.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/index.js @@ -1,15 +1,15 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createSuggestDictionary = exports.createSpellingDictionaryFromTrieFile = exports.createSpellingDictionary = exports.createInlineSpellingDictionary = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createFailedToLoadDictionary = exports.createCollection = exports.createCachingDictionary = void 0; -var SpellingDictionary_1 = require("./SpellingDictionary"); -Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createCachingDictionary; } }); -Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionary_1.createCollection; } }); -Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createFailedToLoadDictionary; } }); -Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createFlagWordsDictionary; } }); -Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createForbiddenWordsDictionary; } }); -Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createIgnoreWordsDictionary; } }); -Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createInlineSpellingDictionary; } }); -Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createSpellingDictionary; } }); -Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionary_1.createSpellingDictionaryFromTrieFile; } }); -Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createSuggestDictionary; } }); +var index_js_1 = require("./SpellingDictionary/index.js"); +Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return index_js_1.createCachingDictionary; } }); +Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return index_js_1.createCollection; } }); +Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return index_js_1.createFailedToLoadDictionary; } }); +Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return index_js_1.createFlagWordsDictionary; } }); +Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return index_js_1.createForbiddenWordsDictionary; } }); +Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return index_js_1.createIgnoreWordsDictionary; } }); +Object.defineProperty(exports, "createInlineSpellingDictionary", { enumerable: true, get: function () { return index_js_1.createInlineSpellingDictionary; } }); +Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return index_js_1.createSpellingDictionary; } }); +Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return index_js_1.createSpellingDictionaryFromTrieFile; } }); +Object.defineProperty(exports, "createSuggestDictionary", { enumerable: true, get: function () { return index_js_1.createSuggestDictionary; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/util/AutoCache.js b/action/node_modules/cspell-dictionary/dist/cjs/util/AutoCache.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/util/AutoCache.js rename to action/node_modules/cspell-dictionary/dist/cjs/util/AutoCache.js diff --git a/action/node_modules/cspell-dictionary/dist/util/AutoResolve.js b/action/node_modules/cspell-dictionary/dist/cjs/util/AutoResolve.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/util/AutoResolve.js rename to action/node_modules/cspell-dictionary/dist/cjs/util/AutoResolve.js diff --git a/action/node_modules/cspell-dictionary/dist/util/IterableLike.js b/action/node_modules/cspell-dictionary/dist/cjs/util/IterableLike.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/util/IterableLike.js rename to action/node_modules/cspell-dictionary/dist/cjs/util/IterableLike.js diff --git a/action/node_modules/cspell-dictionary/dist/util/clean.js b/action/node_modules/cspell-dictionary/dist/cjs/util/clean.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/util/clean.js rename to action/node_modules/cspell-dictionary/dist/cjs/util/clean.js diff --git a/action/node_modules/cspell-dictionary/dist/util/regexHelper.js b/action/node_modules/cspell-dictionary/dist/cjs/util/regexHelper.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/util/regexHelper.js rename to action/node_modules/cspell-dictionary/dist/cjs/util/regexHelper.js diff --git a/action/node_modules/cspell-dictionary/dist/util/repMap.js b/action/node_modules/cspell-dictionary/dist/cjs/util/repMap.js similarity index 96% rename from action/node_modules/cspell-dictionary/dist/util/repMap.js rename to action/node_modules/cspell-dictionary/dist/cjs/util/repMap.js index ea5441b90..25ca758e0 100644 --- a/action/node_modules/cspell-dictionary/dist/util/repMap.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/util/repMap.js @@ -2,8 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.__testing__ = exports.createRepMapper = exports.createMapper = void 0; const cspell_trie_lib_1 = require("cspell-trie-lib"); -const regexHelper_1 = require("./regexHelper"); -const util_1 = require("./util"); +const regexHelper_js_1 = require("./regexHelper.js"); +const util_js_1 = require("./util.js"); function createMapper(repMap, ignoreCharset) { if (!repMap && !ignoreCharset) return (a) => a; @@ -62,7 +62,7 @@ function createMapperRegExp(repMap) { s = r; } catch (err) { - return (0, regexHelper_1.escapeRegEx)(s); + return (0, regexHelper_js_1.escapeRegEx)(s); } return s; }) @@ -130,7 +130,7 @@ function calcAllEdits(root, word) { return edits; } function createTrie(repMap, ignoreCharset) { - const combined = [repMap, charsetToRepMap(ignoreCharset)].filter(util_1.isDefined).flatMap((a) => a); + const combined = [repMap, charsetToRepMap(ignoreCharset)].filter(util_js_1.isDefined).flatMap((a) => a); const expanded = expandReplaceMap(combined); const trieRoot = Object.create(null); expanded.forEach(([match, replaceWith]) => addToTrie(trieRoot, match, replaceWith)); diff --git a/action/node_modules/cspell-dictionary/dist/util/simpleCache.js b/action/node_modules/cspell-dictionary/dist/cjs/util/simpleCache.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/util/simpleCache.js rename to action/node_modules/cspell-dictionary/dist/cjs/util/simpleCache.js diff --git a/action/node_modules/cspell-dictionary/dist/util/text.js b/action/node_modules/cspell-dictionary/dist/cjs/util/text.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/util/text.js rename to action/node_modules/cspell-dictionary/dist/cjs/util/text.js diff --git a/action/node_modules/cspell-dictionary/dist/util/textMappers.js b/action/node_modules/cspell-dictionary/dist/cjs/util/textMappers.js similarity index 86% rename from action/node_modules/cspell-dictionary/dist/util/textMappers.js rename to action/node_modules/cspell-dictionary/dist/cjs/util/textMappers.js index d033dc535..82e2cbff2 100644 --- a/action/node_modules/cspell-dictionary/dist/util/textMappers.js +++ b/action/node_modules/cspell-dictionary/dist/cjs/util/textMappers.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.mapperRemoveCaseAndAccents = exports.mapperNormalizeNFC = void 0; -const text_1 = require("./text"); +const text_js_1 = require("./text.js"); function* mapperNormalizeNFC(words) { for (const word of words) { yield word.normalize('NFC'); @@ -12,7 +12,7 @@ function* mapperRemoveCaseAndAccents(words) { for (const word of words) { const lc = word.toLowerCase(); yield lc; - const woAccents = (0, text_1.removeAccents)(lc); + const woAccents = (0, text_js_1.removeAccents)(lc); if (lc !== woAccents) yield woAccents; } diff --git a/action/node_modules/cspell-dictionary/dist/util/types.js b/action/node_modules/cspell-dictionary/dist/cjs/util/types.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/util/types.js rename to action/node_modules/cspell-dictionary/dist/cjs/util/types.js diff --git a/action/node_modules/cspell-dictionary/dist/util/util.js b/action/node_modules/cspell-dictionary/dist/cjs/util/util.js similarity index 100% rename from action/node_modules/cspell-dictionary/dist/util/util.js rename to action/node_modules/cspell-dictionary/dist/cjs/util/util.js diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/CachingDictionary.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/CachingDictionary.d.mts new file mode 100644 index 000000000..abf5afee8 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/CachingDictionary.d.mts @@ -0,0 +1,30 @@ +import type { CacheStats } from '../util/AutoCache.mjs'; +import type { SearchOptions, SpellingDictionary } from './SpellingDictionary.mjs'; +import type { SpellingDictionaryCollection } from './SpellingDictionaryCollection.mjs'; +interface CallStats { + name: string; + id: number; + has: CacheStats; + isNoSuggestWord: CacheStats; + isForbidden: CacheStats; +} +/** + * Caching Dictionary remembers method calls to increase performance. + */ +export interface CachingDictionary { + name: string; + id: number; + has(word: string): boolean; + isNoSuggestWord(word: string): boolean; + isForbidden(word: string): boolean; + stats(): CallStats; +} +/** + * create a caching dictionary + * @param dict - Dictionary to cache the search results. + * @param options - Search options to use. + * @returns CachingDictionary + */ +export declare function createCachingDictionary(dict: SpellingDictionary | SpellingDictionaryCollection, options: SearchOptions): CachingDictionary; +export {}; +//# sourceMappingURL=CachingDictionary.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/CachingDictionary.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/CachingDictionary.mjs new file mode 100644 index 000000000..db5179a1d --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/CachingDictionary.mjs @@ -0,0 +1,45 @@ +import { autoCache, extractStats } from '../util/AutoCache.mjs'; +import { canonicalSearchOptions } from './SpellingDictionaryMethods.mjs'; +let dictionaryCounter = 0; +class CachedDict { + constructor(dict, options) { + this.dict = dict; + this.options = options; + this.id = ++dictionaryCounter; + this.has = autoCache((word) => this.dict.has(word, this.options)); + this.isNoSuggestWord = autoCache((word) => this.dict.isNoSuggestWord(word, this.options)); + this.isForbidden = autoCache((word) => this.dict.isForbidden(word)); + this.name = dict.name; + // console.log(`CachedDict for ${this.name}`); + } + stats() { + return { + name: this.name, + id: this.id, + has: extractStats(this.has), + isNoSuggestWord: extractStats(this.isNoSuggestWord), + isForbidden: extractStats(this.isForbidden), + }; + } +} +const knownDicts = new Map(); +/** + * create a caching dictionary + * @param dict - Dictionary to cache the search results. + * @param options - Search options to use. + * @returns CachingDictionary + */ +export function createCachingDictionary(dict, options) { + options = canonicalSearchOptions(options); + let knownOptions = knownDicts.get(options); + if (!knownOptions) { + knownOptions = new WeakMap(); + knownDicts.set(options, knownOptions); + } + const known = knownOptions.get(dict); + if (known) + return known; + const cached = new CachedDict(dict, options); + knownOptions.set(dict, cached); + return cached; +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/FlagWordsDictionary.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/FlagWordsDictionary.d.mts new file mode 100644 index 000000000..07f7843e1 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/FlagWordsDictionary.d.mts @@ -0,0 +1,11 @@ +import type { SpellingDictionary } from './SpellingDictionary.mjs'; +/** + * Create a dictionary where all words are to be forbidden. + * @param wordList - list of words + * @param name + * @param source + * @param options + * @returns SpellingDictionary + */ +export declare function createFlagWordsDictionary(wordList: readonly string[], name: string, source: string): SpellingDictionary; +//# sourceMappingURL=FlagWordsDictionary.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/FlagWordsDictionary.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/FlagWordsDictionary.mjs new file mode 100644 index 000000000..8ac6d7d10 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/FlagWordsDictionary.mjs @@ -0,0 +1,134 @@ +import { opMap, pipe } from '@cspell/cspell-pipe/sync'; +import { buildTrieFast, parseDictionaryLines } from 'cspell-trie-lib'; +import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs'; +import * as Defaults from './defaults.mjs'; +import { defaultOptions } from './SpellingDictionary.mjs'; +import { SpellingDictionaryFromTrie } from './SpellingDictionaryFromTrie.mjs'; +import { suggestArgsToSuggestOptions } from './SpellingDictionaryMethods.mjs'; +import { createTyposDictionary } from './TyposDictionary.mjs'; +class FlagWordsDictionaryTrie extends SpellingDictionaryFromTrie { + constructor(trie, name, source) { + super(trie, name, defaultOptions, source); + this.name = name; + this.source = source; + this.containsNoSuggestWords = false; + this.options = {}; + this.isDictionaryCaseSensitive = true; + } + /** + * A Forbidden word list does not "have" valid words. + * Therefore it always returns false. + * @param _word - the word + * @param _options - options + * @returns always false + */ + has(_word, _options) { + return false; + } + find(word, hasOptions) { + const f = super.find(word, hasOptions); + if (!f || !f.forbidden) + return undefined; + return f; + } + suggest() { + return []; + } + genSuggestions() { + return; + } +} +class FlagWordsDictionary { + constructor(name, source, dictTypos, dictTrie) { + this.name = name; + this.source = source; + this.dictTypos = dictTypos; + this.dictTrie = dictTrie; + this.containsNoSuggestWords = false; + this.options = {}; + this.type = 'flag-words'; + this.isDictionaryCaseSensitive = true; + } + /** + * A Forbidden word list does not "have" valid words. + * Therefore it always returns false. + * @param word - the word + * @param options - options + * @returns always false + */ + has(word, options) { + return this.dictTypos.has(word, options) || this.dictTrie?.has(word, options) || false; + } + /** A more detailed search for a word, might take longer than `has` */ + find(word, options) { + const findTypos = this.dictTypos.find(word, options); + if (findTypos) + return findTypos; + const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase; + if (this.dictTypos.isSuggestedWord(word, ignoreCase)) + return undefined; + return this.dictTrie?.find(word, options); + } + isForbidden(word, ignoreCaseAndAccents = Defaults.isForbiddenIgnoreCaseAndAccents) { + const findResult = this.find(word, { ignoreCase: ignoreCaseAndAccents }); + return findResult?.forbidden || false; + } + isNoSuggestWord(word, options) { + return this.dictTrie?.isNoSuggestWord(word, options) || this.dictTypos.isNoSuggestWord(word, options); + } + suggest(...args) { + const [word] = args; + const suggestOptions = suggestArgsToSuggestOptions(args); + return this.dictTypos.suggest(word, suggestOptions); + } + genSuggestions() { + return; + } + mapWord(word) { + return word; + } + get size() { + return this.dictTypos.size + (this.dictTrie?.size || 0); + } + getErrors() { + return []; + } +} +const createCache = createAutoResolveWeakCache(); +/** + * Create a dictionary where all words are to be forbidden. + * @param wordList - list of words + * @param name + * @param source + * @param options + * @returns SpellingDictionary + */ +export function createFlagWordsDictionary(wordList, name, source) { + return createCache.get(wordList, () => { + const testSpecialCharacters = /[~*+]/; + const { t: specialWords, f: typoWords } = bisect(parseDictionaryLines(wordList, { stripCaseAndAccents: false }), (line) => testSpecialCharacters.test(line)); + const trieDict = specialWords.size ? buildTrieDict(specialWords, name, source) : undefined; + const typosDict = createTyposDictionary(typoWords, name, source); + if (!trieDict) + return typosDict; + return new FlagWordsDictionary(name, source, typosDict, trieDict); + }); +} +const regExpCleanIgnore = /^(!!)+/; +function buildTrieDict(words, name, source) { + const trie = buildTrieFast(pipe(words, opMap((w) => '!' + w), opMap((w) => w.replace(regExpCleanIgnore, '')))); + return new FlagWordsDictionaryTrie(trie, name, source); +} +function bisect(values, predicate) { + const t = new Set(); + const f = new Set(); + for (const v of values) { + if (predicate(v)) { + t.add(v); + } + else { + f.add(v); + } + } + return { t, f }; +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/IgnoreWordsDictionary.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/IgnoreWordsDictionary.d.mts new file mode 100644 index 000000000..ff41aff36 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/IgnoreWordsDictionary.d.mts @@ -0,0 +1,11 @@ +import type { SpellingDictionary } from './SpellingDictionary.mjs'; +/** + * Create a dictionary where all words are to be ignored. + * Ignored words override forbidden words. + * @param wordList - list of words + * @param name - name of dictionary + * @param source - dictionary source + * @returns + */ +export declare function createIgnoreWordsDictionary(wordList: readonly string[], name: string, source: string): SpellingDictionary; +//# sourceMappingURL=IgnoreWordsDictionary.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/IgnoreWordsDictionary.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/IgnoreWordsDictionary.mjs new file mode 100644 index 000000000..b0f24a1f1 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/IgnoreWordsDictionary.mjs @@ -0,0 +1,96 @@ +import { opFilter, opMap, pipe } from '@cspell/cspell-pipe/sync'; +import { parseDictionaryLines } from 'cspell-trie-lib'; +import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs'; +import { createSpellingDictionary } from './createSpellingDictionary.mjs'; +import * as Defaults from './defaults.mjs'; +const NormalizeForm = 'NFC'; +class IgnoreWordsDictionary { + constructor(name, source, words) { + this.name = name; + this.source = source; + this.containsNoSuggestWords = true; + this.options = {}; + this.type = 'ignore'; + this.isDictionaryCaseSensitive = true; + this.dict = new Set(words); + this.dictNonStrict = new Set(pipe(this.dict, opFilter((w) => w.startsWith('~')), opMap((w) => w.slice(1)))); + } + /** + * A Forbidden word list does not "have" valid words. + * Therefore it always returns false. + * @param _word - the word + * @param _options - options + * @returns always false + */ + has(word, options) { + const nWord = word.normalize(NormalizeForm); + if (this.dict.has(nWord)) + return true; + const lcWord = nWord.toLowerCase(); + if (this.dict.has(lcWord)) + return true; + const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase; + return ignoreCase && (this.dictNonStrict.has(nWord) || this.dictNonStrict.has(lcWord)); + } + /** A more detailed search for a word, might take longer than `has` */ + find(word, options) { + const nWord = word.normalize(NormalizeForm); + if (this.dict.has(nWord)) + return { found: nWord, forbidden: false, noSuggest: true }; + const lcWord = nWord.toLowerCase(); + if (this.dict.has(lcWord)) + return { found: lcWord, forbidden: false, noSuggest: true }; + const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase; + if (!ignoreCase) + return undefined; + if (this.dictNonStrict.has(nWord)) + return { found: nWord, forbidden: false, noSuggest: true }; + return (this.dictNonStrict.has(lcWord) && { found: lcWord, forbidden: false, noSuggest: true }) || undefined; + } + isForbidden(_word, _ignoreCase) { + return false; + } + isNoSuggestWord(word, options) { + return this.has(word, options); + } + suggest() { + return []; + } + genSuggestions() { + return; + } + mapWord(word) { + return word; + } + get size() { + return this.dict.size; + } + getErrors() { + return []; + } +} +const createCache = createAutoResolveWeakCache(); +/** + * Create a dictionary where all words are to be ignored. + * Ignored words override forbidden words. + * @param wordList - list of words + * @param name - name of dictionary + * @param source - dictionary source + * @returns + */ +export function createIgnoreWordsDictionary(wordList, name, source) { + return createCache.get(wordList, () => { + const testSpecialCharacters = /[*+]/; + const words = [...parseDictionaryLines(wordList, { stripCaseAndAccents: true })].map((w) => w.normalize(NormalizeForm)); + const hasSpecial = words.findIndex((word) => testSpecialCharacters.test(word)) >= 0; + if (hasSpecial) { + return createSpellingDictionary(words, name, source, { + caseSensitive: true, + noSuggest: true, + weightMap: undefined, + supportNonStrictSearches: true, + }); + } + return new IgnoreWordsDictionary(name, source, words); + }); +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionary.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionary.d.mts new file mode 100644 index 000000000..ae3ad2203 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionary.d.mts @@ -0,0 +1,150 @@ +import type { DictionaryInformation, ReplaceMap } from '@cspell/cspell-types'; +import type { CompoundWordsMethod, SuggestionCollector, SuggestionResult, WeightMap } from 'cspell-trie-lib'; +export type { DictionaryDefinitionInline } from '@cspell/cspell-types'; +export { CompoundWordsMethod, type SuggestionCollector, type SuggestionResult } from 'cspell-trie-lib'; +export interface SearchOptions { + /** + * Legacy compounds have been deprecated. + * + * @deprecated + */ + useCompounds?: boolean | number | undefined; + /** + * Ignore Case and Accents + */ + ignoreCase?: boolean | undefined; +} +export interface SuggestOptions { + /** + * Compounding Mode. + * `NONE` is the best option. + */ + compoundMethod?: CompoundWordsMethod | undefined; + /** + * The limit on the number of suggestions to generate. If `allowTies` is true, it is possible + * for more suggestions to be generated. + */ + numSuggestions?: number | undefined; + /** + * Max number of changes / edits to the word to get to a suggestion matching suggestion. + */ + numChanges?: number | undefined; + /** + * Allow for case-ingestive checking. + */ + ignoreCase?: boolean | undefined; + /** + * If multiple suggestions have the same edit / change "cost", then included them even if + * it causes more than `numSuggestions` to be returned. + * @default false + */ + includeTies?: boolean | undefined; + /** + * Maximum amount of time to allow for generating suggestions. + */ + timeout?: number | undefined; +} +export type FindOptions = SearchOptions; +export interface FindResult { + /** the text found, otherwise `false` */ + found: string | false; + /** `true` if it is considered a forbidden word. */ + forbidden: boolean; + /** `true` if it is a no-suggest word. */ + noSuggest: boolean; +} +export type HasOptions = SearchOptions; +export type IgnoreCaseOption = boolean; +export interface SpellingDictionaryOptions { + repMap?: ReplaceMap; + /** + * The dictionary is case aware. + */ + caseSensitive?: boolean; + /** + * This is a NO Suggest dictionary used for words to be ignored. + */ + noSuggest?: boolean; + /** + * Extra dictionary information used in improving suggestions + * based upon locale. + */ + dictionaryInformation?: DictionaryInformation; + /** + * Strip Case and Accents to allow for case insensitive searches and + * words without accents. + * + * Note: this setting only applies to word lists. It has no-impact on trie + * dictionaries. + * + * @default true + */ + supportNonStrictSearches?: boolean; + /** + * Turns on legacy word compounds. + * @deprecated + */ + useCompounds?: boolean; + /** + * Optional WeightMap used to improve suggestions. + */ + weightMap?: WeightMap | undefined; +} +export interface DictionaryInfo { + /** The name of the dictionary */ + readonly name: string; + /** The source, filename or URI */ + readonly source: string; + /** Options */ + readonly options: SpellingDictionaryOptions; +} +export interface SpellingDictionary extends DictionaryInfo { + readonly type: string; + readonly containsNoSuggestWords: boolean; + has(word: string, options?: HasOptions): boolean; + /** A more detailed search for a word, might take longer than `has` */ + find(word: string, options?: SearchOptions): FindResult | undefined; + /** + * Checks if a word is forbidden. + * @param word - word to check. + */ + isForbidden(word: string, ignoreCaseAndAccents?: IgnoreCaseOption): boolean; + /** + * No Suggest words are considered correct but will not be listed when + * suggestions are generated. + * No Suggest words and "Ignored" words are equivalent. Ignored / no suggest words override forbidden words. + * @param word - word to check + * @param options - options + */ + isNoSuggestWord(word: string, options: HasOptions): boolean; + /** + * Generate suggestions for a word. + * @param word - word + * @param numSuggestions - max number of suggestions to generate. + * @param compoundMethod - Default NONE. + * @param numChanges - Default 5 + * @param ignoreCase - true + */ + suggest(word: string, numSuggestions?: number, compoundMethod?: CompoundWordsMethod, numChanges?: number, ignoreCase?: boolean): SuggestionResult[]; + /** + * Generate suggestions for a word + * @param word - word + * @param suggestOptions - options + */ + suggest(word: string, suggestOptions: SuggestOptions): SuggestionResult[]; + genSuggestions(collector: SuggestionCollector, suggestOptions: SuggestOptions): void; + mapWord(word: string): string; + /** + * Generates all possible word combinations by applying `repMap`. + * This acts a bit like brace expansions in globs. + * @param word - the word to map + * @returns array of adjusted words. + */ + remapWord?: (word: string) => string[]; + readonly size: number; + readonly isDictionaryCaseSensitive: boolean; + getErrors?(): Error[]; +} +export type SuggestArgs = Parameters | Parameters<(word: string, numSuggestions?: number, compoundMethod?: CompoundWordsMethod, numChanges?: number, ignoreCase?: boolean) => SuggestionResult[]>; +export declare const defaultOptions: SpellingDictionaryOptions; +//# sourceMappingURL=SpellingDictionary.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionary.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionary.mjs new file mode 100644 index 000000000..7696cc734 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionary.mjs @@ -0,0 +1,4 @@ +export { CompoundWordsMethod } from 'cspell-trie-lib'; +export const defaultOptions = Object.freeze({ + weightMap: undefined, +}); diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryCollection.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryCollection.d.mts new file mode 100644 index 000000000..95bb34a12 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryCollection.d.mts @@ -0,0 +1,16 @@ +import type { SearchOptions, SpellingDictionary } from './SpellingDictionary.mjs'; +export interface SpellingDictionaryCollection extends SpellingDictionary { + readonly type: 'SpellingDictionaryCollection'; + readonly dictionaries: SpellingDictionary[]; + getErrors(): Error[]; +} +export declare function createCollection(dictionaries: SpellingDictionary[], name: string, source?: string): SpellingDictionaryCollection; +declare function isWordInAnyDictionary(dicts: SpellingDictionary[], word: string, options: SearchOptions): SpellingDictionary | undefined; +declare function isWordForbiddenInAnyDictionary(dicts: SpellingDictionary[], word: string, ignoreCase: boolean | undefined): SpellingDictionary | undefined; +export declare function isSpellingDictionaryCollection(dict: SpellingDictionary): dict is SpellingDictionaryCollection; +export declare const __testing__: { + isWordInAnyDictionary: typeof isWordInAnyDictionary; + isWordForbiddenInAnyDictionary: typeof isWordForbiddenInAnyDictionary; +}; +export {}; +//# sourceMappingURL=SpellingDictionaryCollection.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryCollection.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryCollection.mjs new file mode 100644 index 000000000..479e300bf --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryCollection.mjs @@ -0,0 +1,111 @@ +import { CASE_INSENSITIVE_PREFIX } from 'cspell-trie-lib'; +import { genSequence } from 'gensequence'; +import { isDefined } from '../util/util.mjs'; +import * as Defaults from './defaults.mjs'; +import { CompoundWordsMethod } from './SpellingDictionary.mjs'; +import { defaultNumSuggestions, hasOptionToSearchOption, suggestArgsToSuggestOptions, suggestionCollector, } from './SpellingDictionaryMethods.mjs'; +function identityString(w) { + return w; +} +class SpellingDictionaryCollectionImpl { + constructor(dictionaries, name, source) { + this.dictionaries = dictionaries; + this.name = name; + this.options = { weightMap: undefined }; + this.mapWord = identityString; + this.type = 'SpellingDictionaryCollection'; + this._isNoSuggestWord = (word, options) => { + if (!this.containsNoSuggestWords) + return false; + return !!isNoSuggestWordInAnyDictionary(this.dictionaries, word, options || {}); + }; + this.dictionaries = this.dictionaries.sort((a, b) => b.size - a.size); + this.source = source || dictionaries.map((d) => d.name).join(', '); + this.isDictionaryCaseSensitive = this.dictionaries.reduce((a, b) => a || b.isDictionaryCaseSensitive, false); + this.containsNoSuggestWords = this.dictionaries.reduce((a, b) => a || b.containsNoSuggestWords, false); + } + has(word, hasOptions) { + const options = hasOptionToSearchOption(hasOptions); + return !!isWordInAnyDictionary(this.dictionaries, word, options) && !this.isForbidden(word); + } + find(word, hasOptions) { + const options = hasOptionToSearchOption(hasOptions); + return findInAnyDictionary(this.dictionaries, word, options); + } + isNoSuggestWord(word, options) { + return this._isNoSuggestWord(word, options); + } + isForbidden(word, ignoreCaseAndAccents) { + const ignoreCase = ignoreCaseAndAccents ?? Defaults.isForbiddenIgnoreCaseAndAccents; + return !!this._isForbiddenInDict(word, ignoreCase) && !this.isNoSuggestWord(word, { ignoreCase }); + } + suggest(...args) { + const [word] = args; + const suggestOptions = suggestArgsToSuggestOptions(args); + return this._suggest(word, suggestOptions); + } + _suggest(word, suggestOptions) { + const { numSuggestions = defaultNumSuggestions, numChanges, ignoreCase, includeTies, timeout } = suggestOptions; + const prefixNoCase = CASE_INSENSITIVE_PREFIX; + const filter = (word, _cost) => { + return ((ignoreCase || word[0] !== prefixNoCase) && + !this.isForbidden(word) && + !this.isNoSuggestWord(word, suggestOptions)); + }; + const collectorOptions = { + numSuggestions, + filter, + changeLimit: numChanges, + includeTies, + ignoreCase, + timeout, + }; + const collector = suggestionCollector(word, collectorOptions); + this.genSuggestions(collector, suggestOptions); + return collector.suggestions.map((r) => ({ ...r, word: r.word })); + } + get size() { + return this.dictionaries.reduce((a, b) => a + b.size, 0); + } + genSuggestions(collector, suggestOptions) { + const _suggestOptions = { ...suggestOptions }; + const { compoundMethod = CompoundWordsMethod.SEPARATE_WORDS } = suggestOptions; + _suggestOptions.compoundMethod = this.options.useCompounds ? CompoundWordsMethod.JOIN_WORDS : compoundMethod; + this.dictionaries.forEach((dict) => dict.genSuggestions(collector, _suggestOptions)); + } + getErrors() { + return this.dictionaries.reduce((errors, dict) => errors.concat(dict.getErrors?.() || []), []); + } + _isForbiddenInDict(word, ignoreCase) { + return isWordForbiddenInAnyDictionary(this.dictionaries, word, ignoreCase); + } +} +export function createCollection(dictionaries, name, source) { + return new SpellingDictionaryCollectionImpl(dictionaries, name, source); +} +function isWordInAnyDictionary(dicts, word, options) { + return genSequence(dicts).first((dict) => dict.has(word, options)); +} +function findInAnyDictionary(dicts, word, options) { + const found = dicts.map((dict) => dict.find(word, options)).filter(isDefined); + if (!found.length) + return undefined; + return found.reduce((a, b) => ({ + found: a.forbidden ? a.found : b.forbidden ? b.found : a.found || b.found, + forbidden: a.forbidden || b.forbidden, + noSuggest: a.noSuggest || b.noSuggest, + })); +} +function isNoSuggestWordInAnyDictionary(dicts, word, options) { + return genSequence(dicts).first((dict) => dict.isNoSuggestWord(word, options)); +} +function isWordForbiddenInAnyDictionary(dicts, word, ignoreCase) { + return genSequence(dicts).first((dict) => dict.isForbidden(word, ignoreCase)); +} +export function isSpellingDictionaryCollection(dict) { + return dict instanceof SpellingDictionaryCollectionImpl; +} +export const __testing__ = { + isWordInAnyDictionary, + isWordForbiddenInAnyDictionary, +}; diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.d.mts new file mode 100644 index 000000000..260e2651c --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.d.mts @@ -0,0 +1,50 @@ +import type { SuggestionCollector, SuggestionResult } from 'cspell-trie-lib'; +import { CompoundWordsMethod, Trie } from 'cspell-trie-lib'; +import type { FindResult, HasOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestOptions } from './SpellingDictionary.mjs'; +export declare class SpellingDictionaryFromTrie implements SpellingDictionary { + readonly trie: Trie; + readonly name: string; + readonly options: SpellingDictionaryOptions; + readonly source: string; + static readonly cachedWordsLimit = 50000; + private _size; + readonly knownWords: Set; + readonly unknownWords: Set; + readonly mapWord: (word: string) => string; + readonly remapWord: (word: string) => string[]; + readonly type = "SpellingDictionaryFromTrie"; + readonly isDictionaryCaseSensitive: boolean; + readonly containsNoSuggestWords: boolean; + private weightMap; + constructor(trie: Trie, name: string, options: SpellingDictionaryOptions, source?: string, size?: number); + get size(): number; + has(word: string, hasOptions?: HasOptions): boolean; + find(word: string, hasOptions?: HasOptions): FindResult | undefined; + private resolveOptions; + private _find; + private findAnyForm; + private _findAnyForm; + isNoSuggestWord(word: string, options?: HasOptions): boolean; + isForbidden(word: string, _ignoreCaseAndAccents?: boolean): boolean; + private _isForbidden; + suggest(word: string, numSuggestions?: number, compoundMethod?: CompoundWordsMethod, numChanges?: number, ignoreCase?: boolean): SuggestionResult[]; + suggest(word: string, suggestOptions: SuggestOptions): SuggestionResult[]; + private _suggest; + genSuggestions(collector: SuggestionCollector, suggestOptions: SuggestOptions): void; + getErrors(): Error[]; +} +/** + * Create a dictionary from a trie file. + * @param data - contents of a trie file. + * @param name - name of dictionary + * @param source - filename or uri + * @param options - options. + * @returns SpellingDictionary + */ +export declare function createSpellingDictionaryFromTrieFile(data: Iterable | string, name: string, source: string, options: SpellingDictionaryOptions): SpellingDictionary; +declare function outerWordForms(word: string, mapWord: (word: string) => string[]): Set; +export declare const __testing__: { + outerWordForms: typeof outerWordForms; +}; +export {}; +//# sourceMappingURL=SpellingDictionaryFromTrie.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.mjs new file mode 100644 index 000000000..10946e0fa --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryFromTrie.mjs @@ -0,0 +1,172 @@ +import { opConcatMap, pipe } from '@cspell/cspell-pipe/sync'; +import { CompoundWordsMethod, importTrie, suggestionCollector, Trie } from 'cspell-trie-lib'; +import { autoCache, createCache01 } from '../util/AutoCache.mjs'; +import { clean } from '../util/clean.mjs'; +import { createMapper, createRepMapper } from '../util/repMap.mjs'; +import * as Defaults from './defaults.mjs'; +import { createWeightMapFromDictionaryInformation, defaultNumSuggestions, hasOptionToSearchOption, impersonateCollector, suggestArgsToSuggestOptions, wordSearchForms, wordSuggestFormsArray, } from './SpellingDictionaryMethods.mjs'; +const findWordOptionsCaseSensitive = Object.freeze({ caseSensitive: true }); +const findWordOptionsNotCaseSensitive = Object.freeze({ caseSensitive: false }); +export class SpellingDictionaryFromTrie { + constructor(trie, name, options, source = 'from trie', size) { + this.trie = trie; + this.name = name; + this.options = options; + this.source = source; + this._size = 0; + this.knownWords = new Set(); + this.unknownWords = new Set(); + this.type = 'SpellingDictionaryFromTrie'; + this._find = findCache((word, useCompounds, ignoreCase) => this.findAnyForm(word, useCompounds, ignoreCase)); + this._isForbidden = autoCache((word) => { + return this.trie.isForbiddenWord(word); + }); + this.mapWord = createMapper(options.repMap, options.dictionaryInformation?.ignore); + this.remapWord = createRepMapper(options.repMap, options.dictionaryInformation?.ignore); + this.isDictionaryCaseSensitive = options.caseSensitive ?? !trie.isLegacy; + this.containsNoSuggestWords = options.noSuggest || false; + this._size = size || 0; + this.weightMap = options.weightMap || createWeightMapFromDictionaryInformation(options.dictionaryInformation); + } + get size() { + if (!this._size) { + // walk the trie and get the approximate size. + const i = this.trie.iterate(); + let deeper = true; + let size = 0; + for (let r = i.next(); !r.done; r = i.next(deeper)) { + // count all nodes even though they are not words. + // because we are not going to all the leaves, this should give a good enough approximation. + size += 1; + deeper = r.value.text.length < 5; + } + this._size = size; + } + return this._size; + } + has(word, hasOptions) { + const { useCompounds, ignoreCase } = this.resolveOptions(hasOptions); + const r = this._find(word, useCompounds, ignoreCase); + return !!r && !r.forbidden && !!r.found; + } + find(word, hasOptions) { + const { useCompounds, ignoreCase } = this.resolveOptions(hasOptions); + const r = this._find(word, useCompounds, ignoreCase); + const { forbidden = this.isForbidden(word) } = r || {}; + if (!r && !forbidden) + return undefined; + const { found = forbidden ? word : false } = r || {}; + const noSuggest = found !== false && this.containsNoSuggestWords; + return { found, forbidden, noSuggest }; + } + resolveOptions(hasOptions) { + const { useCompounds = this.options.useCompounds, ignoreCase = Defaults.ignoreCase } = hasOptionToSearchOption(hasOptions); + return { useCompounds, ignoreCase }; + } + findAnyForm(word, useCompounds, ignoreCase) { + const outerForms = outerWordForms(word, this.remapWord ? this.remapWord : (word) => [this.mapWord(word)]); + for (const form of outerForms) { + const r = this._findAnyForm(form, useCompounds, ignoreCase); + if (r) + return r; + } + return undefined; + } + _findAnyForm(mWord, useCompounds, ignoreCase) { + const opts = ignoreCase ? findWordOptionsNotCaseSensitive : findWordOptionsCaseSensitive; + const findResult = this.trie.findWord(mWord, opts); + if (findResult.found !== false) { + return findResult; + } + const forms = wordSearchForms(mWord, this.isDictionaryCaseSensitive, ignoreCase); + for (const w of forms) { + const findResult = this.trie.findWord(w, opts); + if (findResult.found !== false) { + return findResult; + } + } + if (useCompounds) { + const optsUseCompounds = { ...opts, useLegacyWordCompounds: useCompounds }; + for (const w of forms) { + const findResult = this.trie.findWord(w, optsUseCompounds); + if (findResult.found !== false) { + return findResult; + } + } + } + return undefined; + } + isNoSuggestWord(word, options) { + return this.containsNoSuggestWords ? this.has(word, options) : false; + } + isForbidden(word, _ignoreCaseAndAccents) { + return this._isForbidden(word); + } + suggest(...args) { + const [word] = args; + const suggestOptions = suggestArgsToSuggestOptions(args); + return this._suggest(word, suggestOptions); + } + _suggest(word, suggestOptions) { + const { numSuggestions = defaultNumSuggestions, numChanges, includeTies, ignoreCase, timeout } = suggestOptions; + function filter(_word) { + return true; + } + const collector = suggestionCollector(word, clean({ + numSuggestions, + filter, + changeLimit: numChanges, + includeTies, + ignoreCase, + timeout, + weightMap: this.weightMap, + })); + this.genSuggestions(collector, suggestOptions); + return collector.suggestions.map((r) => ({ ...r, word: r.word })); + } + genSuggestions(collector, suggestOptions) { + if (this.options.noSuggest) + return; + const _compoundMethod = suggestOptions.compoundMethod ?? + (this.options.useCompounds ? CompoundWordsMethod.JOIN_WORDS : CompoundWordsMethod.NONE); + wordSuggestFormsArray(collector.word).forEach((w) => this.trie.genSuggestions(impersonateCollector(collector, w), _compoundMethod)); + } + getErrors() { + return []; + } +} +SpellingDictionaryFromTrie.cachedWordsLimit = 50000; +/** + * Create a dictionary from a trie file. + * @param data - contents of a trie file. + * @param name - name of dictionary + * @param source - filename or uri + * @param options - options. + * @returns SpellingDictionary + */ +export function createSpellingDictionaryFromTrieFile(data, name, source, options) { + data = typeof data === 'string' ? data.split('\n') : data; + const trieNode = importTrie(data); + const trie = new Trie(trieNode); + return new SpellingDictionaryFromTrie(trie, name, options, source); +} +function findCache(fn, size = 2000) { + const cache = createCache01(size); + function find(word, useCompounds, ignoreCase) { + const r = cache.get(word); + if (r !== undefined) { + if (r.useCompounds === useCompounds && r.ignoreCase === ignoreCase) { + return r.findResult; + } + } + const findResult = fn(word, useCompounds, ignoreCase); + cache.set(word, { useCompounds, ignoreCase, findResult }); + return findResult; + } + return find; +} +function outerWordForms(word, mapWord) { + const forms = pipe([word], opConcatMap((word) => [word, word.normalize('NFC'), word.normalize('NFD')]), opConcatMap((word) => [word, ...mapWord(word)])); + return new Set(forms); +} +export const __testing__ = { outerWordForms }; diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryMethods.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryMethods.d.mts new file mode 100644 index 000000000..4b13786f5 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryMethods.d.mts @@ -0,0 +1,26 @@ +import type { DictionaryInformation } from '@cspell/cspell-types'; +import type { SuggestionResult, WeightMap } from 'cspell-trie-lib'; +import type { HasOptions, SearchOptions, SuggestArgs, SuggestOptions } from './SpellingDictionary.mjs'; +export { impersonateCollector, suggestionCollector } from 'cspell-trie-lib'; +export type FilterSuggestionsPredicate = (word: SuggestionResult) => boolean; +export declare const defaultNumSuggestions = 10; +declare function wordSearchFormsArray(word: string, isDictionaryCaseSensitive: boolean, ignoreCase: boolean): string[]; +export declare function wordSearchForms(word: string, isDictionaryCaseSensitive: boolean, ignoreCase: boolean): Set; +export declare function wordSuggestFormsArray(word: string): string[]; +export declare function wordSuggestForms(word: string): Set; +export declare function hasOptionToSearchOption(opt: HasOptions | undefined): SearchOptions; +/** + * Find the canonical form for SearchOptions. Useful Maps and WeakMaps. + * @param opt - options to normalize + * @returns SearchOptions - the canonical form + */ +export declare function canonicalSearchOptions(opt: SearchOptions): SearchOptions; +export declare function suggestArgsToSuggestOptions(args: SuggestArgs): SuggestOptions; +export declare function createWeightMapFromDictionaryInformation(di: undefined): undefined; +export declare function createWeightMapFromDictionaryInformation(di: DictionaryInformation): WeightMap; +export declare function createWeightMapFromDictionaryInformation(di: DictionaryInformation | undefined): WeightMap | undefined; +export declare const __testMethods__: { + wordSearchForms: typeof wordSearchForms; + wordSearchFormsArray: typeof wordSearchFormsArray; +}; +//# sourceMappingURL=SpellingDictionaryMethods.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryMethods.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryMethods.mjs new file mode 100644 index 000000000..8260d91d8 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SpellingDictionaryMethods.mjs @@ -0,0 +1,96 @@ +import { mapDictionaryInformationToWeightMap } from 'cspell-trie-lib'; +import { isUpperCase, removeUnboundAccents, ucFirst } from '../util/text.mjs'; +export { impersonateCollector, suggestionCollector } from 'cspell-trie-lib'; +export const defaultNumSuggestions = 10; +function wordSearchFormsArray(word, isDictionaryCaseSensitive, ignoreCase) { + return [...wordSearchForms(word, isDictionaryCaseSensitive, ignoreCase)]; +} +export function wordSearchForms(word, isDictionaryCaseSensitive, ignoreCase) { + const forms = new Set(); + word = word.normalize('NFC'); + const wordLc = word.toLowerCase(); + if (ignoreCase) { + if (isDictionaryCaseSensitive) { + forms.add(wordLc); + } + else { + forms.add(wordLc); + // Legacy remove any unbound accents + forms.add(removeUnboundAccents(wordLc)); + } + } + else { + if (isDictionaryCaseSensitive) { + forms.add(word); + forms.add(wordLc); + // HOUSE -> House, house + if (isUpperCase(word)) { + forms.add(ucFirst(wordLc)); + } + } + else { + forms.add(wordLc); + // Legacy remove any unbound accents + forms.add(removeUnboundAccents(wordLc)); + } + } + return forms; +} +export function wordSuggestFormsArray(word) { + return [...wordSuggestForms(word)]; +} +export function wordSuggestForms(word) { + word = word.normalize('NFC'); + const forms = new Set([word]); + const wordLc = word.toLowerCase(); + forms.add(wordLc); + return forms; +} +const DEFAULT_HAS_OPTIONS = Object.freeze({}); +export function hasOptionToSearchOption(opt) { + return canonicalSearchOptions(!opt ? DEFAULT_HAS_OPTIONS : opt); +} +const canonicalSearchOptionsMap = new Map(); +const knownCanonicalOptions = new WeakMap(); +/** + * Find the canonical form for SearchOptions. Useful Maps and WeakMaps. + * @param opt - options to normalize + * @returns SearchOptions - the canonical form + */ +export function canonicalSearchOptions(opt) { + const known = knownCanonicalOptions.get(opt); + if (known) + return known; + const { ignoreCase, useCompounds } = opt; + const foundLevel1Map = canonicalSearchOptionsMap.get(ignoreCase); + const useLevel1Map = foundLevel1Map || new Map(); + if (!foundLevel1Map) { + canonicalSearchOptionsMap.set(ignoreCase, useLevel1Map); + } + const foundCanOpts = useLevel1Map.get(useCompounds); + const canOpts = foundCanOpts || Object.freeze({ ignoreCase, useCompounds }); + if (!foundCanOpts) { + useLevel1Map.set(useCompounds, canOpts); + } + knownCanonicalOptions.set(opt, canOpts); + return canOpts; +} +export function suggestArgsToSuggestOptions(args) { + const [_word, options, compoundMethod, numChanges, ignoreCase] = args; + const suggestOptions = typeof options === 'object' + ? options + : { + numSuggestions: options, + compoundMethod, + numChanges, + ignoreCase, + }; + return suggestOptions; +} +export function createWeightMapFromDictionaryInformation(di) { + return di ? mapDictionaryInformationToWeightMap(di) : undefined; +} +export const __testMethods__ = { + wordSearchForms, + wordSearchFormsArray, +}; diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SuggestDictionary.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SuggestDictionary.d.mts new file mode 100644 index 000000000..20372de68 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SuggestDictionary.d.mts @@ -0,0 +1,20 @@ +import type { IgnoreCaseOption, SpellingDictionary } from './SpellingDictionary.mjs'; +import { type TypoEntry, type TyposDef } from './Typos/index.mjs'; +export interface SuggestDictionary extends SpellingDictionary { + /** + * Determine if the word can appear in a list of suggestions. + * @param word - word + * @param ignoreCaseAndAccents - ignore case. + * @returns true if a word is suggested, otherwise false. + */ + isSuggestedWord(word: string, ignoreCaseAndAccents?: IgnoreCaseOption): boolean; +} +/** + * Create a dictionary where all words are to be forbidden. + * @param entries - list of Typos Entries + * @param name - name of dictionary + * @param source - source + * @returns + */ +export declare function createSuggestDictionary(entries: readonly string[] | TyposDef | Iterable, name: string, source: string): SuggestDictionary; +//# sourceMappingURL=SuggestDictionary.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SuggestDictionary.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SuggestDictionary.mjs new file mode 100644 index 000000000..2bba2e2a7 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/SuggestDictionary.mjs @@ -0,0 +1,97 @@ +import { pipe } from '@cspell/cspell-pipe/sync'; +import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs'; +import { mapperRemoveCaseAndAccents } from '../util/textMappers.mjs'; +import * as defaults from './defaults.mjs'; +import { processEntriesToTyposDef } from './Typos/index.mjs'; +import { extractAllSuggestions } from './Typos/util.mjs'; +class SuggestDictionaryImpl { + constructor(name, source, typosDef) { + this.name = name; + this.source = source; + this.typosDef = typosDef; + this.containsNoSuggestWords = false; + this.options = {}; + this.type = 'suggest'; + this.isDictionaryCaseSensitive = true; + this.size = Object.keys(typosDef).length; + this.suggestions = extractAllSuggestions(typosDef); + this.suggestionsLower = new Set(pipe(this.suggestions, mapperRemoveCaseAndAccents)); + } + /** + * A Forbidden word list does not "have" valid words. + * Therefore it always returns false. + * @param _word - the word + * @param _options - options + * @returns always false + */ + has(_word, _options) { + return false; + } + /** A more detailed search for a word, might take longer than `has` */ + find(_word, _options) { + return undefined; + } + isForbidden(_word, _ignoreCaseAndAccents) { + return false; + } + isNoSuggestWord(_word, _options) { + return false; + } + /** + * Determine if the word can appear in a list of suggestions. + * @param word - word + * @param ignoreCaseAndAccents - ignore case. + * @returns true if a word is suggested, otherwise false. + */ + isSuggestedWord(word, ignoreCaseAndAccents = defaults.isForbiddenIgnoreCaseAndAccents) { + if (this.suggestions.has(word)) + return true; + const lcWord = word.toLowerCase(); + return ignoreCaseAndAccents && (this.suggestions.has(lcWord) || this.suggestionsLower.has(lcWord)); + } + suggest(word) { + return this._suggest(word) || this._suggest(word.toLowerCase()) || []; + } + _suggest(word) { + if (!(word in this.typosDef)) + return undefined; + const sug = this.typosDef[word]; + const isPreferred = true; + if (!sug) + return []; + if (typeof sug === 'string') { + return [ + { + word: sug, + cost: 1, + isPreferred, + }, + ]; + } + return sug.map((word, index) => ({ word, cost: index + 1, isPreferred })); + } + genSuggestions(collector) { + const sugs = this.suggest(collector.word); + sugs.forEach((result) => collector.add(result)); + } + mapWord(word) { + return word; + } + getErrors() { + return []; + } +} +const createCache = createAutoResolveWeakCache(); +/** + * Create a dictionary where all words are to be forbidden. + * @param entries - list of Typos Entries + * @param name - name of dictionary + * @param source - source + * @returns + */ +export function createSuggestDictionary(entries, name, source) { + return createCache.get(entries, () => { + const def = processEntriesToTyposDef(entries); + return new SuggestDictionaryImpl(name, source, def); + }); +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/index.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/index.d.mts new file mode 100644 index 000000000..a070732e7 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/index.d.mts @@ -0,0 +1,2 @@ +export { TermsDef, TermsDefKey, TermsDefValue, TermValueIgnoreWord, TermValueOk, TermValueTypo, TermValueTypoNoSuggestions, TermValueTypoWithSuggestions, } from './terms.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/models/DictionaryInformation.js b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/index.mjs similarity index 100% rename from action/node_modules/cspell-trie-lib/dist/esm/lib/models/DictionaryInformation.js rename to action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/index.mjs diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/terms.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/terms.d.mts new file mode 100644 index 000000000..4799035ef --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/terms.d.mts @@ -0,0 +1,12 @@ +export type TermValueTypoNoSuggestions = false; +type TermValueTypoSingleSuggestion = string; +type TermValueTypoMultipleSuggestions = string[]; +export type TermValueTypoWithSuggestions = TermValueTypoSingleSuggestion | TermValueTypoMultipleSuggestions; +export type TermValueTypo = TermValueTypoWithSuggestions | TermValueTypoNoSuggestions; +export type TermValueIgnoreWord = null; +export type TermValueOk = true; +export type TermsDefValue = TermValueTypo | TermValueIgnoreWord | TermValueOk; +export type TermsDefKey = string; +export type TermsDef = Record; +export {}; +//# sourceMappingURL=terms.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/models/suggestionCostsDef.js b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/terms.mjs similarity index 100% rename from action/node_modules/cspell-trie-lib/dist/esm/lib/models/suggestionCostsDef.js rename to action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Terms/terms.mjs diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/index.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/index.d.mts new file mode 100644 index 000000000..cd1d0872b --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/index.d.mts @@ -0,0 +1,4 @@ +export type { TypoEntry, TyposDef } from './typos.mjs'; +export { parseTyposFile, parseTyposLine, processEntriesToTyposDef } from './typosParser.mjs'; +export { createTyposDef, extractAllSuggestions } from './util.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/index.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/index.mjs new file mode 100644 index 000000000..e2fbf75b3 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/index.mjs @@ -0,0 +1,2 @@ +export { parseTyposFile, parseTyposLine, processEntriesToTyposDef } from './typosParser.mjs'; +export { createTyposDef, extractAllSuggestions } from './util.mjs'; diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typos.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typos.d.mts new file mode 100644 index 000000000..a1d958fd5 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typos.d.mts @@ -0,0 +1,18 @@ +import type { TermsDefKey, TermValueTypo, TermValueTypoNoSuggestions, TermValueTypoWithSuggestions } from '../Terms/index.mjs'; +export type TypoValueNoSuggestions = TermValueTypoNoSuggestions; +export type TypoValueWithSuggestions = TermValueTypoWithSuggestions; +export type TyposDefValue = TermValueTypo; +export type TyposDefKey = TermsDefKey; +/** + * Typos Definition + * key - the incorrect word + * value - the suggestions. + */ +export type TyposDef = Record; +type TypoWithNoSuggestions = string; +type TypoWithSuggestionsArray = [forbidWord: string, ...suggestions: string[]]; +type TypoWithSuggestionsObj = TyposDef; +type TypoWithSuggestions = TypoWithSuggestionsArray | TypoWithSuggestionsObj; +export type TypoEntry = TypoWithNoSuggestions | TypoWithSuggestions; +export {}; +//# sourceMappingURL=typos.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/trieRef.js b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typos.mjs similarity index 100% rename from action/node_modules/cspell-trie-lib/dist/esm/lib/trieRef.js rename to action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typos.mjs diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typosParser.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typosParser.d.mts new file mode 100644 index 000000000..5e6803ad8 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typosParser.d.mts @@ -0,0 +1,34 @@ +import type { TypoEntry, TyposDef } from './typos.mjs'; +export declare function createTyposDefFromEntries(entries: Iterable): TyposDef; +export declare function sanitizeIntoTypoDef(dirtyDef: TyposDef | Record | unknown): TyposDef | undefined; +/** + * Parse Typos Entries + * + * Format: + * - `word:suggestion` + * - `word->suggestion` + * - `word: first, second, third suggestions` + * + * Note: + * ```plaintext + * yellow:blue, green + * ``` + * Is the same as multiple entries with the same key and different suggestions. + * ```plaintext + * yellow:blue + * yellow:green + * ``` + * + * Used to process entries found in a `cspell.json` file. + * @param entries - entries to process + * @returns a TyposDef + */ +export declare function processEntriesToTyposDef(entries: Iterable | TyposDef | Record): TyposDef; +/** + * Tries to parse an entry. + * @param line - any valid TypoEntry. + * @returns a valid TypoEntry + */ +export declare function parseTyposLine(line: TypoEntry): TypoEntry | undefined; +export declare function parseTyposFile(content: string): TyposDef; +//# sourceMappingURL=typosParser.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typosParser.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typosParser.mjs new file mode 100644 index 000000000..24b6f7195 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/typosParser.mjs @@ -0,0 +1,131 @@ +import assert from 'assert'; +import { appendToDef, createTyposDef } from './util.mjs'; +function assertString(v) { + assert(typeof v === 'string', 'A string was expected.'); + return true; +} +const suggestionsSeparator = /[,]/; +const typoSuggestionsSeparator = /:|->/; +const typoEntrySeparator = /[\n;]/; +const inlineComment = /#.*/gm; +export function createTyposDefFromEntries(entries) { + const def = Object.create(null); + for (const entry of entries) { + appendToDef(def, entry); + } + return def; +} +function normalize(s) { + return s.normalize(); +} +function trimAndFilter(lines) { + return lines + .map((s) => s.trim()) + .filter((s) => !!s) + .map(normalize); +} +function cleanSugs(rawSugs) { + const sugs = trimAndFilter(rawSugs); + return sugs.length === 1 ? sugs[0] : sugs.length ? sugs : false; +} +function splitSuggestionsValue(value) { + return cleanSugs(value.split(suggestionsSeparator)); +} +export function sanitizeIntoTypoDef(dirtyDef) { + if (!dirtyDef || typeof dirtyDef !== 'object') + return undefined; + const def = createTyposDef(); + for (const [rawKey, value] of Object.entries(dirtyDef)) { + const key = normalize(rawKey.trim()); + if (!key) + continue; + if (typeof value === 'string') { + def[key] = splitSuggestionsValue(value); + continue; + } + if (Array.isArray(value)) { + const sugs = cleanSugs(value.filter(assertString)); + def[key] = sugs; + continue; + } + assert(value === false, 'Unexpected suggestion type.'); + def[key] = false; + } + return def; +} +/** + * Parse Typos Entries + * + * Format: + * - `word:suggestion` + * - `word->suggestion` + * - `word: first, second, third suggestions` + * + * Note: + * ```plaintext + * yellow:blue, green + * ``` + * Is the same as multiple entries with the same key and different suggestions. + * ```plaintext + * yellow:blue + * yellow:green + * ``` + * + * Used to process entries found in a `cspell.json` file. + * @param entries - entries to process + * @returns a TyposDef + */ +export function processEntriesToTyposDef(entries) { + const def = isIterable(entries) ? reduceToTyposDef(entries) : entries; + const result = sanitizeIntoTypoDef(def); + assert(result); + return result; +} +function reduceToTyposDef(entries) { + const def = createTyposDef(); + for (const entry of entries) { + appendToDef(def, parseTyposLine(entry)); + } + return def; +} +/** + * Tries to parse an entry. + * @param line - any valid TypoEntry. + * @returns a valid TypoEntry + */ +export function parseTyposLine(line) { + if (!line) + return undefined; + if (typeof line === 'string') { + const def = createTyposDef(); + for (const subEntry of splitIntoLines(line)) { + const [left, right] = splitEntry(subEntry); + const typo = left.trim(); + if (!right) + return typo; + const sugs = splitSuggestionsValue(right); + def[typo] = sugs; + } + return def; + } + if (Array.isArray(line)) { + const [key, ...sugs] = line.filter(assertString).map((s) => s.trim()); + if (!key) + return undefined; + return [key, ...sugs]; + } + return sanitizeIntoTypoDef(line); +} +function splitIntoLines(content) { + return trimAndFilter(normalize(content).split(typoEntrySeparator)); +} +function splitEntry(line) { + return line.split(typoSuggestionsSeparator, 2); +} +export function parseTyposFile(content) { + const lines = splitIntoLines(content.replace(inlineComment, '')); + return reduceToTyposDef(lines); +} +function isIterable(v) { + return Symbol.iterator in v; +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/util.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/util.d.mts new file mode 100644 index 000000000..af1649da5 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/util.d.mts @@ -0,0 +1,31 @@ +import type { TypoEntry, TyposDef, TyposDefKey, TyposDefValue } from './typos.mjs'; +export declare function mergeDefEntry(targetDef: TyposDef, key: string, value: TyposDefValue): TyposDef; +/** + * Merge in place the entries `fromDef` into `targetDef` + * @param targetDef - the target + * @param fromDef - the source + * @returns the target + */ +export declare function mergeDef(targetDef: TyposDef, fromDef: TyposDef): TyposDef; +/** + * Append an entry to a TyposDef. + * @param def - modified in place + * @param entry- entry to add. + * @returns def + */ +export declare function appendToDef(def: TyposDef, entry: TypoEntry | undefined): TyposDef; +export declare function createTyposDef(entries?: Iterable<[TyposDefKey, TyposDefValue]>): TyposDef; +/** + * Extract all suggestions. + * @param typosDef - the def + * @returns the set of suggestions. + */ +export declare function extractAllSuggestions(typosDef: TyposDef): Set; +/** + * Extract all words that have been explicitly ignore because they contains the `ignorePrefix`. + * @param typosDef - the def + * @param ignorePrefix - prefix + * @returns set of ignored words with the prefix removed. + */ +export declare function extractIgnoreValues(typosDef: TyposDef, ignorePrefix: string): Set; +//# sourceMappingURL=util.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/util.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/util.mjs new file mode 100644 index 000000000..b5552ef62 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/Typos/util.mjs @@ -0,0 +1,105 @@ +import { opConcatMap, opFilter, pipe } from '@cspell/cspell-pipe/sync'; +function normalizeTyposDefValue(value) { + if (!value) + return false; + if (typeof value === 'string') + return value; + const unique = [...new Set(value)]; + return unique.length > 1 ? unique : unique.length === 1 ? unique[0] : false; +} +export function mergeDefEntry(targetDef, key, value) { + const curValue = targetDef[key]; + if (!curValue) { + targetDef[key] = normalizeTyposDefValue(value); + return targetDef; + } + if (!value) + return targetDef; + const newValue = Array.isArray(curValue) ? curValue : [curValue]; + if (Array.isArray(value)) { + newValue.push(...value); + } + else { + newValue.push(value); + } + targetDef[key] = normalizeTyposDefValue(newValue); + return targetDef; +} +/** + * Merge in place the entries `fromDef` into `targetDef` + * @param targetDef - the target + * @param fromDef - the source + * @returns the target + */ +export function mergeDef(targetDef, fromDef) { + for (const key of Object.keys(fromDef)) { + mergeDefEntry(targetDef, key, fromDef[key]); + } + return targetDef; +} +/** + * Append an entry to a TyposDef. + * @param def - modified in place + * @param entry- entry to add. + * @returns def + */ +export function appendToDef(def, entry) { + if (!entry) + return def; + if (typeof entry === 'string') { + if (!def[entry]) { + def[entry] = false; + } + return def; + } + if (Array.isArray(entry)) { + const [key, ...sugs] = entry.map((s) => s.trim()); + if (!key) + return def; + const s = sugs.map((s) => s.trim()).filter((s) => !!s); + return mergeDefEntry(def, key, s); + } + return mergeDef(def, entry); +} +export function createTyposDef(entries) { + const def = Object.create(null); + if (!entries) + return def; + for (const [key, value] of entries) { + def[key] = isDefined(value) ? value : false; + } + return def; +} +/** + * Extract all suggestions. + * @param typosDef - the def + * @returns the set of suggestions. + */ +export function extractAllSuggestions(typosDef) { + const allSugs = pipe(Object.values(typosDef), opFilter(hasSuggestions), opConcatMap((v) => (Array.isArray(v) ? v : [v]))); + return new Set(allSugs); +} +/** + * Extract all words that have been explicitly ignore because they contains the `ignorePrefix`. + * @param typosDef - the def + * @param ignorePrefix - prefix + * @returns set of ignored words with the prefix removed. + */ +export function extractIgnoreValues(typosDef, ignorePrefix) { + const pfxLen = ignorePrefix.length; + return new Set(Object.keys(typosDef) + .filter((k) => k.startsWith(ignorePrefix)) + .map((k) => k.slice(pfxLen))); +} +function isDefined(v) { + return v !== undefined && v !== null; +} +function isString(v) { + return typeof v === 'string'; +} +function isArray(v) { + return Array.isArray(v); +} +function hasSuggestions(v) { + return isString(v) || isArray(v); +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/TyposDictionary.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/TyposDictionary.d.mts new file mode 100644 index 000000000..a2872a8a5 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/TyposDictionary.d.mts @@ -0,0 +1,21 @@ +import type { IgnoreCaseOption, SpellingDictionary } from './SpellingDictionary.mjs'; +import { type TypoEntry, type TyposDef } from './Typos/index.mjs'; +export interface TyposDictionary extends SpellingDictionary { + isForbidden(word: string, ignoreCaseAndAccents?: IgnoreCaseOption): boolean; + /** + * Determine if the word can appear in a list of suggestions. + * @param word - word + * @param ignoreCaseAndAccents - ignore case. + * @returns true if a word is suggested, otherwise false. + */ + isSuggestedWord(word: string, ignoreCaseAndAccents?: IgnoreCaseOption): boolean; +} +/** + * Create a dictionary where all words are to be forbidden. + * @param entries - list of Typos Entries + * @param name - name of dictionary + * @param source - source + * @returns + */ +export declare function createTyposDictionary(entries: readonly string[] | TyposDef | Iterable, name: string, source: string): TyposDictionary; +//# sourceMappingURL=TyposDictionary.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/TyposDictionary.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/TyposDictionary.mjs new file mode 100644 index 000000000..9f90b1611 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/TyposDictionary.mjs @@ -0,0 +1,129 @@ +import { opAppend, pipe } from '@cspell/cspell-pipe/sync'; +import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs'; +import { mapperRemoveCaseAndAccents } from '../util/textMappers.mjs'; +import * as defaults from './defaults.mjs'; +import { processEntriesToTyposDef } from './Typos/index.mjs'; +import { extractAllSuggestions, extractIgnoreValues } from './Typos/util.mjs'; +class TyposDictionaryImpl { + constructor(name, source, typosDef, ignoreList) { + this.name = name; + this.source = source; + this.typosDef = typosDef; + this.options = {}; + this.type = 'typos'; + this.isDictionaryCaseSensitive = true; + this.size = Object.keys(typosDef).length; + this.explicitIgnoreWords = extractIgnoreValues(typosDef, '!'); + this.suggestions = extractAllSuggestions(typosDef); + this.ignoreWords = new Set(pipe(this.explicitIgnoreWords, opAppend(ignoreList || []))); + this.suggestionsLower = new Set(pipe(this.suggestions, mapperRemoveCaseAndAccents)); + this.containsNoSuggestWords = this.ignoreWords.size > 0; + } + /** + * A Forbidden word list does not "have" valid words. + * Therefore it always returns false. + * @param _word - the word + * @param _options - options + * @returns always false + */ + has(_word, _options) { + return false; + } + /** A more detailed search for a word, might take longer than `has` */ + find(word, options) { + const result = this._findForms(word, options?.ignoreCase ?? defaults.ignoreCase); + if (result === false) + return undefined; + const { found, ignore } = result; + return { found, forbidden: !ignore, noSuggest: ignore }; + } + _findForms(word, ignoreCaseAndAccents) { + const lcWord = word.toLowerCase(); + if (this.ignoreWords.has(word)) { + return { found: word, ignore: true }; + } + if (this.suggestions.has(word)) { + return false; + } + if (ignoreCaseAndAccents) { + if (this.suggestionsLower.has(lcWord)) { + return false; + } + if (this.ignoreWords.has(lcWord)) { + return { found: lcWord, ignore: true }; + } + } + if (word in this.typosDef) + return { found: word, ignore: false }; + if (lcWord in this.typosDef) + return { found: lcWord, ignore: false }; + return false; + } + isForbidden(word, ignoreCaseAndAccents = defaults.isForbiddenIgnoreCaseAndAccents) { + const found = this._findForms(word, ignoreCaseAndAccents); + return found !== false && !found.ignore; + } + isNoSuggestWord(word, options) { + const result = this.find(word, options); + return result?.noSuggest ?? false; + } + /** + * Determine if the word can appear in a list of suggestions. + * @param word - word + * @param ignoreCaseAndAccents - ignore case. + * @returns true if a word is suggested, otherwise false. + */ + isSuggestedWord(word, ignoreCaseAndAccents = defaults.isForbiddenIgnoreCaseAndAccents) { + if (this.suggestions.has(word)) + return true; + const lcWord = word.toLowerCase(); + return ignoreCaseAndAccents && (this.suggestions.has(lcWord) || this.suggestionsLower.has(lcWord)); + } + suggest(word) { + return this._suggest(word) || this._suggest(word.toLowerCase()) || []; + } + _suggest(word) { + if (this.ignoreWords.has(word)) + return []; + if (!(word in this.typosDef)) + return undefined; + const sug = this.typosDef[word]; + const isPreferred = true; + if (!sug) + return []; + if (typeof sug === 'string') { + return [ + { + word: sug, + cost: 1, + isPreferred, + }, + ]; + } + return sug.map((word, index) => ({ word, cost: index + 1, isPreferred })); + } + genSuggestions(collector) { + const sugs = this.suggest(collector.word); + sugs.forEach((result) => collector.add(result)); + } + mapWord(word) { + return word; + } + getErrors() { + return []; + } +} +const createCache = createAutoResolveWeakCache(); +/** + * Create a dictionary where all words are to be forbidden. + * @param entries - list of Typos Entries + * @param name - name of dictionary + * @param source - source + * @returns + */ +export function createTyposDictionary(entries, name, source) { + return createCache.get(entries, () => { + const def = processEntriesToTyposDef(entries); + return new TyposDictionaryImpl(name, source, def); + }); +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createInlineSpellingDictionary.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createInlineSpellingDictionary.d.mts new file mode 100644 index 000000000..d285459ef --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createInlineSpellingDictionary.d.mts @@ -0,0 +1,3 @@ +import type { DictionaryDefinitionInline, SpellingDictionary } from './SpellingDictionary.mjs'; +export declare function createInlineSpellingDictionary(inlineDict: DictionaryDefinitionInline, source: string): SpellingDictionary; +//# sourceMappingURL=createInlineSpellingDictionary.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createInlineSpellingDictionary.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createInlineSpellingDictionary.mjs new file mode 100644 index 000000000..fd09ba68d --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createInlineSpellingDictionary.mjs @@ -0,0 +1,20 @@ +import { createAutoResolveWeakCache } from '../util/AutoResolve.mjs'; +import { isDefined } from '../util/util.mjs'; +import { createSpellingDictionary } from './createSpellingDictionary.mjs'; +import { createFlagWordsDictionary } from './FlagWordsDictionary.mjs'; +import { createIgnoreWordsDictionary } from './IgnoreWordsDictionary.mjs'; +import { createCollection } from './SpellingDictionaryCollection.mjs'; +import { createSuggestDictionary } from './SuggestDictionary.mjs'; +const cache = createAutoResolveWeakCache(); +export function createInlineSpellingDictionary(inlineDict, source) { + return cache.get(inlineDict, () => { + const { words, flagWords, ignoreWords, suggestWords, name } = inlineDict; + const dictSources = [ + words && createSpellingDictionary(words, name + '-words', source, inlineDict), + flagWords && createFlagWordsDictionary(flagWords, name + '-flag-words', source), + ignoreWords && createIgnoreWordsDictionary(ignoreWords, name + '-ignore-words', source), + suggestWords && createSuggestDictionary(suggestWords, name + '-suggest', source), + ].filter(isDefined); + return createCollection(dictSources, name, source); + }); +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createSpellingDictionary.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createSpellingDictionary.d.mts new file mode 100644 index 000000000..e9198ddf0 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createSpellingDictionary.d.mts @@ -0,0 +1,23 @@ +import type { IterableLike } from '../util/IterableLike.mjs'; +import type { DictionaryInfo, SpellingDictionary, SpellingDictionaryOptions } from './SpellingDictionary.mjs'; +/** + * Create a SpellingDictionary + * @param wordList - list of words + * @param name - name of dictionary + * @param source - filename or uri + * @param options - dictionary options + * @returns a Spelling Dictionary + */ +export declare function createSpellingDictionary(wordList: readonly string[] | IterableLike, name: string, source: string, options?: SpellingDictionaryOptions | undefined): SpellingDictionary; +export interface SpellingDictionaryLoadError extends Error { + /** The Error Name */ + readonly name: string; + /** Possible Cause */ + readonly cause?: Error | undefined; + /** Message to Display */ + readonly message: string; + /** Dictionary Information */ + readonly info: DictionaryInfo; +} +export declare function createFailedToLoadDictionary(name: string, source: string, error: Error, options?: SpellingDictionaryOptions | undefined): SpellingDictionary; +//# sourceMappingURL=createSpellingDictionary.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createSpellingDictionary.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createSpellingDictionary.mjs new file mode 100644 index 000000000..808b58de7 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/createSpellingDictionary.mjs @@ -0,0 +1,68 @@ +import { buildTrieFast, parseDictionaryLines } from 'cspell-trie-lib'; +import { deepEqual } from 'fast-equals'; +import { AutoWeakCache, SimpleCache } from '../util/simpleCache.mjs'; +import { defaultOptions } from './SpellingDictionary.mjs'; +import { SpellingDictionaryFromTrie } from './SpellingDictionaryFromTrie.mjs'; +import { createWeightMapFromDictionaryInformation } from './SpellingDictionaryMethods.mjs'; +const cachedDictionaries = new AutoWeakCache(_createSpellingDictionary, 64); +const maxSetSize = 3; +const cachedParamsByWordList = new SimpleCache(64); +/** + * Create a SpellingDictionary + * @param wordList - list of words + * @param name - name of dictionary + * @param source - filename or uri + * @param options - dictionary options + * @returns a Spelling Dictionary + */ +export function createSpellingDictionary(wordList, name, source, options) { + const params = [wordList, name, source, options]; + if (!Array.isArray(wordList)) { + return _createSpellingDictionary(params); + } + const cached = cachedParamsByWordList.get(name) || new Set(); + for (const cachedParams of cached) { + if (deepEqual(params, cachedParams)) { + return cachedDictionaries.get(cachedParams); + } + } + if (cached.size > maxSetSize) + cached.clear(); + cached.add(params); + cachedParamsByWordList.set(name, cached); + return cachedDictionaries.get(params); +} +function _createSpellingDictionary(params) { + const [wordList, name, source, options] = params; + // console.log(`createSpellingDictionary ${name} ${source}`); + const parseOptions = { stripCaseAndAccents: options?.supportNonStrictSearches ?? true }; + const words = parseDictionaryLines(wordList, parseOptions); + const trie = buildTrieFast(words); + const opts = { ...(options || defaultOptions) }; + if (opts.weightMap === undefined && opts.dictionaryInformation) { + opts.weightMap = createWeightMapFromDictionaryInformation(opts.dictionaryInformation); + } + return new SpellingDictionaryFromTrie(trie, name, opts, source); +} +export function createFailedToLoadDictionary(name, source, error, options) { + options = options || {}; + return { + name, + source, + type: 'error', + containsNoSuggestWords: false, + has: () => false, + find: () => undefined, + isNoSuggestWord: () => false, + isForbidden: () => false, + suggest: () => [], + mapWord: (a) => a, + genSuggestions: () => { + return; + }, + size: 0, + options, + isDictionaryCaseSensitive: false, + getErrors: () => [error], + }; +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/defaults.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/defaults.d.mts new file mode 100644 index 000000000..53eda7527 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/defaults.d.mts @@ -0,0 +1,3 @@ +export declare const ignoreCase: true; +export declare const isForbiddenIgnoreCaseAndAccents: false; +//# sourceMappingURL=defaults.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/defaults.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/defaults.mjs new file mode 100644 index 000000000..7e0789366 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/defaults.mjs @@ -0,0 +1,2 @@ +export const ignoreCase = true; +export const isForbiddenIgnoreCaseAndAccents = false; diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/index.d.mts b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/index.d.mts new file mode 100644 index 000000000..e7c407ae7 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/index.d.mts @@ -0,0 +1,11 @@ +export { CachingDictionary, createCachingDictionary } from './CachingDictionary.mjs'; +export { createInlineSpellingDictionary } from './createInlineSpellingDictionary.mjs'; +export { createFailedToLoadDictionary, createSpellingDictionary } from './createSpellingDictionary.mjs'; +export { createFlagWordsDictionary, createFlagWordsDictionary as createForbiddenWordsDictionary, } from './FlagWordsDictionary.mjs'; +export { createIgnoreWordsDictionary } from './IgnoreWordsDictionary.mjs'; +export type { DictionaryDefinitionInline, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary.mjs'; +export { createCollection, SpellingDictionaryCollection } from './SpellingDictionaryCollection.mjs'; +export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie.mjs'; +export { createSuggestDictionary } from './SuggestDictionary.mjs'; +export { createTyposDictionary } from './TyposDictionary.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/index.mjs b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/index.mjs new file mode 100644 index 000000000..c5047a7a7 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/SpellingDictionary/index.mjs @@ -0,0 +1,9 @@ +export { createCachingDictionary } from './CachingDictionary.mjs'; +export { createInlineSpellingDictionary } from './createInlineSpellingDictionary.mjs'; +export { createFailedToLoadDictionary, createSpellingDictionary } from './createSpellingDictionary.mjs'; +export { createFlagWordsDictionary, createFlagWordsDictionary as createForbiddenWordsDictionary, } from './FlagWordsDictionary.mjs'; +export { createIgnoreWordsDictionary } from './IgnoreWordsDictionary.mjs'; +export { createCollection } from './SpellingDictionaryCollection.mjs'; +export { createSpellingDictionaryFromTrieFile } from './SpellingDictionaryFromTrie.mjs'; +export { createSuggestDictionary } from './SuggestDictionary.mjs'; +export { createTyposDictionary } from './TyposDictionary.mjs'; diff --git a/action/node_modules/cspell-dictionary/dist/esm/index.d.mts b/action/node_modules/cspell-dictionary/dist/esm/index.d.mts new file mode 100644 index 000000000..a105766a7 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/index.d.mts @@ -0,0 +1,3 @@ +export type { CachingDictionary, FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary/index.mjs'; +export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, } from './SpellingDictionary/index.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/index.mjs b/action/node_modules/cspell-dictionary/dist/esm/index.mjs new file mode 100644 index 000000000..fbcf1bb3c --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/index.mjs @@ -0,0 +1 @@ +export { createCachingDictionary, createCollection, createFailedToLoadDictionary, createFlagWordsDictionary, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, createSuggestDictionary, } from './SpellingDictionary/index.mjs'; diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/AutoCache.d.mts b/action/node_modules/cspell-dictionary/dist/esm/util/AutoCache.d.mts new file mode 100644 index 000000000..3ed547cc8 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/AutoCache.d.mts @@ -0,0 +1,25 @@ +interface AutoCache extends CacheStats { + (word: string): R; +} +export interface CacheStats { + hits: number; + misses: number; + swaps: number; +} +declare class Cache01 implements CacheStats { + readonly maxSize: number; + private count; + private cache0; + private cache1; + hits: number; + misses: number; + swaps: number; + constructor(maxSize: number); + get(key: string): R | undefined; + set(key: string, value: R): this; +} +export declare function createCache01(size: number): Cache01; +export declare function autoCache(fn: (p: string) => R, size?: number): AutoCache; +export declare function extractStats(ac: AutoCache | CacheStats): CacheStats; +export {}; +//# sourceMappingURL=AutoCache.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/AutoCache.mjs b/action/node_modules/cspell-dictionary/dist/esm/util/AutoCache.mjs new file mode 100644 index 000000000..48c10ede6 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/AutoCache.mjs @@ -0,0 +1,67 @@ +const CACHE_SIZE = 100; +class Cache01 { + constructor(maxSize) { + this.maxSize = maxSize; + this.count = 0; + this.cache0 = Object.create(null); + this.cache1 = Object.create(null); + this.hits = 0; + this.misses = 0; + this.swaps = 0; + } + get(key) { + const cache0 = this.cache0; + const cache1 = this.cache1; + if (key in cache0) { + ++this.hits; + return cache0[key]; + } + if (key in cache1) { + ++this.hits; + ++this.count; + const r = cache1[key]; + cache0[key] = r; + return r; + } + ++this.misses; + return undefined; + } + set(key, value) { + if (this.count >= this.maxSize) { + this.cache1 = this.cache0; + this.cache0 = Object.create(null); + this.swaps++; + this.count = 0; + } + ++this.count; + this.cache0[key] = value; + return this; + } +} +export function createCache01(size) { + return new Cache01(size); +} +export function autoCache(fn, size = CACHE_SIZE) { + const cache = createCache01(size); + const ac = get; + ac.hits = 0; + ac.misses = 0; + ac.swaps = 0; + function get(k) { + const f = cache.get(k); + if (f !== undefined) { + ++ac.hits; + return f; + } + const r = fn(k); + cache.set(k, r); + ac.swaps = cache.swaps; + ++ac.misses; + return r; + } + return ac; +} +export function extractStats(ac) { + const { hits, misses, swaps } = ac; + return { hits, misses, swaps }; +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/AutoResolve.d.mts b/action/node_modules/cspell-dictionary/dist/esm/util/AutoResolve.d.mts new file mode 100644 index 000000000..0381846c7 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/AutoResolve.d.mts @@ -0,0 +1,21 @@ +export declare function autoResolve(map: Map, key: K, resolve: (k: K) => V): V; +export declare class AutoResolveCache { + readonly map: Map; + get(k: K): V | undefined; + get(k: K, resolve: (k: K) => V): V; + get(k: K, resolve?: (k: K) => V): V | undefined; + has(k: K): boolean; + set(k: K, v: V): this; +} +export declare function createAutoResolveCache(): AutoResolveCache; +export declare function autoResolveWeak(map: WeakMap, key: K, resolve: (k: K) => V): V; +export declare class AutoResolveWeakCache { + readonly map: WeakMap; + get(k: K): V | undefined; + get(k: K, resolve: (k: K) => V): V; + get(k: K, resolve?: (k: K) => V): V | undefined; + has(k: K): boolean; + set(k: K, v: V): this; +} +export declare function createAutoResolveWeakCache(): AutoResolveWeakCache; +//# sourceMappingURL=AutoResolve.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/AutoResolve.mjs b/action/node_modules/cspell-dictionary/dist/esm/util/AutoResolve.mjs new file mode 100644 index 000000000..971480732 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/AutoResolve.mjs @@ -0,0 +1,52 @@ +export function autoResolve(map, key, resolve) { + const found = map.get(key); + if (found !== undefined || map.has(key)) + return found; + const value = resolve(key); + map.set(key, value); + return value; +} +export class AutoResolveCache { + constructor() { + this.map = new Map(); + } + get(k, resolve) { + return resolve ? autoResolve(this.map, k, resolve) : this.map.get(k); + } + has(k) { + return this.map.has(k); + } + set(k, v) { + this.map.set(k, v); + return this; + } +} +export function createAutoResolveCache() { + return new AutoResolveCache(); +} +export function autoResolveWeak(map, key, resolve) { + const found = map.get(key); + if (found !== undefined || map.has(key)) + return found; + const value = resolve(key); + map.set(key, value); + return value; +} +export class AutoResolveWeakCache { + constructor() { + this.map = new WeakMap(); + } + get(k, resolve) { + return resolve ? autoResolveWeak(this.map, k, resolve) : this.map.get(k); + } + has(k) { + return this.map.has(k); + } + set(k, v) { + this.map.set(k, v); + return this; + } +} +export function createAutoResolveWeakCache() { + return new AutoResolveWeakCache(); +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/IterableLike.d.mts b/action/node_modules/cspell-dictionary/dist/esm/util/IterableLike.d.mts new file mode 100644 index 000000000..eaaa91b93 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/IterableLike.d.mts @@ -0,0 +1,4 @@ +export interface IterableLike { + [Symbol.iterator]: () => Iterator | IterableIterator; +} +//# sourceMappingURL=IterableLike.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/IterableLike.mjs b/action/node_modules/cspell-dictionary/dist/esm/util/IterableLike.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/IterableLike.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/clean.d.mts b/action/node_modules/cspell-dictionary/dist/esm/util/clean.d.mts new file mode 100644 index 000000000..da43df165 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/clean.d.mts @@ -0,0 +1,7 @@ +import type { RemoveUndefined } from './types.mjs'; +/** + * Delete all `undefined` fields from an object. + * @param src - object to be cleaned + */ +export declare function clean(src: T): RemoveUndefined; +//# sourceMappingURL=clean.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/clean.mjs b/action/node_modules/cspell-dictionary/dist/esm/util/clean.mjs new file mode 100644 index 000000000..d43562012 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/clean.mjs @@ -0,0 +1,13 @@ +/** + * Delete all `undefined` fields from an object. + * @param src - object to be cleaned + */ +export function clean(src) { + const r = src; + for (const key of Object.keys(r)) { + if (r[key] === undefined) { + delete r[key]; + } + } + return r; +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/regexHelper.d.mts b/action/node_modules/cspell-dictionary/dist/esm/util/regexHelper.d.mts new file mode 100644 index 000000000..9961db057 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/regexHelper.d.mts @@ -0,0 +1,7 @@ +/** + * Escape a string so it can be used as an exact match within a RegExp. + * @param s - string to escape + * @returns - the escaped string. + */ +export declare function escapeRegEx(s: string): string; +//# sourceMappingURL=regexHelper.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/regexHelper.mjs b/action/node_modules/cspell-dictionary/dist/esm/util/regexHelper.mjs new file mode 100644 index 000000000..a13c7c38e --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/regexHelper.mjs @@ -0,0 +1,8 @@ +/** + * Escape a string so it can be used as an exact match within a RegExp. + * @param s - string to escape + * @returns - the escaped string. + */ +export function escapeRegEx(s) { + return s.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d'); +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/repMap.d.mts b/action/node_modules/cspell-dictionary/dist/esm/util/repMap.d.mts new file mode 100644 index 000000000..a4a7a311a --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/repMap.d.mts @@ -0,0 +1,27 @@ +import type { CharacterSet, ReplaceMap } from '@cspell/cspell-types'; +export type ReplaceMapper = (src: string) => string; +export declare function createMapper(repMap: ReplaceMap | undefined, ignoreCharset?: string): ReplaceMapper; +declare function charsetToRepMapRegEx(charset: CharacterSet | undefined, replaceWith?: string): ReplaceMap | undefined; +declare function createMapperRegExp(repMap: ReplaceMap): RegExp; +interface RepTrieNode { + rep?: string[]; + children?: Record; +} +interface Edit { + b: number; + e: number; + r: string; +} +export declare function createRepMapper(repMap: ReplaceMap | undefined, ignoreCharset?: string): (word: string) => string[]; +declare function applyEdits(word: string, edits: Edit[]): string[]; +declare function calcAllEdits(root: RepTrieNode, word: string): Edit[]; +declare function createTrie(repMap: ReplaceMap | undefined, ignoreCharset?: string): RepTrieNode; +export declare const __testing__: { + charsetToRepMap: typeof charsetToRepMapRegEx; + createMapperRegExp: typeof createMapperRegExp; + createTrie: typeof createTrie; + calcAllEdits: typeof calcAllEdits; + applyEdits: typeof applyEdits; +}; +export {}; +//# sourceMappingURL=repMap.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/repMap.mjs b/action/node_modules/cspell-dictionary/dist/esm/util/repMap.mjs new file mode 100644 index 000000000..f321a6706 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/repMap.mjs @@ -0,0 +1,152 @@ +import { expandCharacterSet } from 'cspell-trie-lib'; +import { escapeRegEx } from './regexHelper.mjs'; +import { isDefined } from './util.mjs'; +export function createMapper(repMap, ignoreCharset) { + if (!repMap && !ignoreCharset) + return (a) => a; + repMap = repMap || []; + const charsetMap = charsetToRepMapRegEx(ignoreCharset); + if (charsetMap) { + repMap = repMap.concat(charsetMap); + } + const filteredMap = repMap.filter(([match, _]) => !!match); + if (!filteredMap.length) { + return (a) => a; + } + const regEx = createMapperRegExp(repMap); + const values = repMap.filter(([match, _]) => !!match).map(([_, into]) => into); + function resolve(m, ...matches) { + const index = matches.findIndex((a) => !!a); + return 0 <= index && index < values.length ? values[index] : m; + } + return function (s) { + return s.replace(regEx, resolve); + }; +} +function charsetToRepMapRegEx(charset, replaceWith = '') { + if (!charset) + return undefined; + return charset + .split('|') + .map((chars) => `[${chars.replace(/[\][\\]/g, '\\$&')}]`) + .map((map) => [map, replaceWith]); +} +function charsetToRepMap(charset, replaceWith = '') { + if (!charset) + return undefined; + return charset + .split('|') + .flatMap((chars) => [...expandCharacterSet(chars)]) + .map((char) => [char, replaceWith]); +} +function expandReplaceMap(repMap) { + return repMap.flatMap(([from, replaceWith]) => from.split('|').map((w) => [w, replaceWith])); +} +function createMapperRegExp(repMap) { + const filteredMap = repMap.filter(([match, _]) => !!match); + if (!filteredMap.length) { + return /$^/; + } + const regExStr = filteredMap + .map(([from, _]) => from) + // make sure it compiles into a regex + .map((s) => { + try { + // fix up any nested () + const r = s.match(/\(/) ? s.replace(/\((?=.*\))/g, '(?:').replace(/\(\?:\?/g, '(?') : s; + new RegExp(r); + s = r; + } + catch (err) { + return escapeRegEx(s); + } + return s; + }) + .map((s) => `(${s})`) + .join('|'); + const regEx = new RegExp(regExStr, 'g'); + return regEx; +} +export function createRepMapper(repMap, ignoreCharset) { + if (!repMap && !ignoreCharset) + return (word) => [word]; + const trie = createTrie(repMap, ignoreCharset); + // const root = createTrie(repMap, ignoreCharset); + return (word) => { + const edits = calcAllEdits(trie, word); + return applyEdits(word, edits); + }; +} +function applyEdits(word, edits) { + if (!edits.length) + return [word]; + // Prepare + const letterEdits = []; + for (let i = 0; i < word.length; ++i) { + letterEdits[i] = { edits: [{ b: i, e: i + 1, r: word[i] }], suffixes: [] }; + } + letterEdits[word.length] = { edits: [], suffixes: [''] }; + // Add edits + for (const edit of edits) { + const le = letterEdits[edit.b]; + le.edits.push(edit); + } + // Apply edits in reverse + for (let i = word.length - 1; i >= 0; --i) { + const le = letterEdits[i]; + const sfx = le.suffixes; + for (const edit of le.edits) { + const pfx = edit.r; + const nSfx = letterEdits[edit.e].suffixes; + for (const s of nSfx) { + sfx.push(pfx + s); + } + } + } + const results = new Set(letterEdits[0].suffixes); + return [...results]; +} +function calcAllEdits(root, word) { + const edits = []; + function walk(node, b, e) { + if (node.rep) { + node.rep.forEach((r) => edits.push({ b, e, r })); + } + if (e === word.length || !node.children) + return; + const n = node.children[word[e]]; + if (!n) + return; + walk(n, b, e + 1); + } + for (let i = 0; i < word.length; ++i) { + walk(root, i, i); + } + return edits; +} +function createTrie(repMap, ignoreCharset) { + const combined = [repMap, charsetToRepMap(ignoreCharset)].filter(isDefined).flatMap((a) => a); + const expanded = expandReplaceMap(combined); + const trieRoot = Object.create(null); + expanded.forEach(([match, replaceWith]) => addToTrie(trieRoot, match, replaceWith)); + return trieRoot; +} +function addToTrie(node, match, replaceWith) { + while (match) { + const children = node.children || (node.children = Object.create(null)); + const k = match[0]; + const childNode = children[k] || (children[k] = Object.create(null)); + node = childNode; + match = match.slice(1); + } + const s = new Set(node.rep || []); + s.add(replaceWith); + node.rep = [...s]; +} +export const __testing__ = { + charsetToRepMap: charsetToRepMapRegEx, + createMapperRegExp, + createTrie, + calcAllEdits, + applyEdits, +}; diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/simpleCache.d.mts b/action/node_modules/cspell-dictionary/dist/esm/util/simpleCache.d.mts new file mode 100644 index 000000000..d00f7179b --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/simpleCache.d.mts @@ -0,0 +1,46 @@ +export declare class SimpleWeakCache { + readonly size: number; + private L0; + private L1; + private L2; + private sizeL0; + constructor(size: number); + has(key: K): boolean; + get(key: K): T | undefined; + set(key: K, value: T): void; + private _set; + private caches; + private rotate; +} +export declare class AutoWeakCache extends SimpleWeakCache { + readonly factory: (key: K) => T; + constructor(factory: (key: K) => T, size: number); + get(key: K): T; +} +/** + * This will cache between `size` and 3 x `size` items. + * It has three stashes, L0, L1, and L2. Each can contain `size` items. + * When L0 is full, its items are given to L1 and L1's are given to L2, and L2 is empties. + * + * The stashes are searched in order, L0...L2. If an item is found in L1, or L2, it is + * promoted to L0. + */ +export declare class SimpleCache { + readonly size: number; + private L0; + private L1; + private L2; + constructor(size: number); + has(key: K): boolean; + get(key: K): T | undefined; + set(key: K, value: T): void; + private _set; + private caches; + private rotate; +} +export declare class AutoCache extends SimpleCache { + readonly factory: (key: K) => T; + constructor(factory: (key: K) => T, size: number); + get(key: K): T; +} +//# sourceMappingURL=simpleCache.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/simpleCache.mjs b/action/node_modules/cspell-dictionary/dist/esm/util/simpleCache.mjs new file mode 100644 index 000000000..3b61a5a22 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/simpleCache.mjs @@ -0,0 +1,135 @@ +export class SimpleWeakCache { + constructor(size) { + this.size = size; + this.L0 = new WeakMap(); + this.L1 = new WeakMap(); + this.L2 = new WeakMap(); + this.sizeL0 = 0; + } + has(key) { + for (const c of this.caches()) { + if (c.has(key)) + return true; + } + return false; + } + get(key) { + for (const c of this.caches()) { + const entry = c.get(key); + if (entry) { + if (c !== this.L0) { + this._set(key, entry); + } + return entry.v; + } + } + return undefined; + } + set(key, value) { + this._set(key, { v: value }); + } + _set(key, entry) { + if (this.L0.has(key)) { + this.L0.set(key, entry); + return this; + } + if (this.sizeL0 >= this.size) { + this.rotate(); + } + this.sizeL0 += 1; + this.L0.set(key, entry); + } + caches() { + return [this.L0, this.L1, this.L2]; + } + rotate() { + this.L2 = this.L1; + this.L1 = this.L0; + this.L0 = new WeakMap(); + this.sizeL0 = 0; + } +} +export class AutoWeakCache extends SimpleWeakCache { + constructor(factory, size) { + super(size); + this.factory = factory; + } + get(key) { + const v = super.get(key); + if (v !== undefined) + return v; + const val = this.factory(key); + this.set(key, val); + return val; + } +} +/** + * This will cache between `size` and 3 x `size` items. + * It has three stashes, L0, L1, and L2. Each can contain `size` items. + * When L0 is full, its items are given to L1 and L1's are given to L2, and L2 is empties. + * + * The stashes are searched in order, L0...L2. If an item is found in L1, or L2, it is + * promoted to L0. + */ +export class SimpleCache { + constructor(size) { + this.size = size; + this.L0 = new Map(); + this.L1 = new Map(); + this.L2 = new Map(); + } + has(key) { + for (const c of this.caches()) { + if (c.has(key)) + return true; + } + return false; + } + get(key) { + for (const c of this.caches()) { + const entry = c.get(key); + if (entry) { + if (c !== this.L0) { + this._set(key, entry); + } + return entry.v; + } + } + return undefined; + } + set(key, value) { + this._set(key, { v: value }); + } + _set(key, entry) { + if (this.L0.has(key)) { + this.L0.set(key, entry); + return this; + } + if (this.L0.size >= this.size) { + this.rotate(); + } + this.L0.set(key, entry); + } + caches() { + return [this.L0, this.L1, this.L2]; + } + rotate() { + this.L2 = this.L1; + this.L1 = this.L0; + this.L0 = new Map(); + } +} +export class AutoCache extends SimpleCache { + constructor(factory, size) { + super(size); + this.factory = factory; + } + get(key) { + const v = super.get(key); + if (v !== undefined) + return v; + const val = this.factory(key); + this.set(key, val); + return val; + } +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/text.d.mts b/action/node_modules/cspell-dictionary/dist/esm/util/text.d.mts new file mode 100644 index 000000000..75ddaa6d6 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/text.d.mts @@ -0,0 +1,10 @@ +export declare function isUpperCase(word: string): boolean; +export declare function isLowerCase(word: string): boolean; +export declare function isFirstCharacterUpper(word: string): boolean; +export declare function isFirstCharacterLower(word: string): boolean; +export declare function ucFirst(word: string): string; +export declare function lcFirst(word: string): string; +export declare function matchCase(example: string, word: string): string; +export declare function removeAccents(text: string): string; +export declare function removeUnboundAccents(text: string): string; +//# sourceMappingURL=text.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/text.mjs b/action/node_modules/cspell-dictionary/dist/esm/util/text.mjs new file mode 100644 index 000000000..723951652 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/text.mjs @@ -0,0 +1,46 @@ +const regExFirstUpper = /^\p{Lu}\p{M}?\p{Ll}+$/u; +const regExAllUpper = /^(?:\p{Lu}\p{M}?)+$/u; +const regExAllLower = /^(?:\p{Ll}\p{M}?)+$/u; +const regExAccents = /\p{M}/gu; +export function isUpperCase(word) { + return !!word.match(regExAllUpper); +} +export function isLowerCase(word) { + return !!word.match(regExAllLower); +} +export function isFirstCharacterUpper(word) { + return isUpperCase(word.slice(0, 1)); +} +export function isFirstCharacterLower(word) { + return isLowerCase(word.slice(0, 1)); +} +export function ucFirst(word) { + return word.slice(0, 1).toUpperCase() + word.slice(1); +} +export function lcFirst(word) { + return word.slice(0, 1).toLowerCase() + word.slice(1); +} +export function matchCase(example, word) { + if (example.match(regExFirstUpper)) { + return word.slice(0, 1).toUpperCase() + word.slice(1).toLowerCase(); + } + if (example.match(regExAllLower)) { + return word.toLowerCase(); + } + if (example.match(regExAllUpper)) { + return word.toUpperCase(); + } + if (isFirstCharacterUpper(example)) { + return ucFirst(word); + } + if (isFirstCharacterLower(example)) { + return lcFirst(word); + } + return word; +} +export function removeAccents(text) { + return text.normalize('NFD').replace(regExAccents, ''); +} +export function removeUnboundAccents(text) { + return text.replace(regExAccents, ''); +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/textMappers.d.mts b/action/node_modules/cspell-dictionary/dist/esm/util/textMappers.d.mts new file mode 100644 index 000000000..41404e9ff --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/textMappers.d.mts @@ -0,0 +1,3 @@ +export declare function mapperNormalizeNFC(words: Iterable): Iterable; +export declare function mapperRemoveCaseAndAccents(words: Iterable): Iterable; +//# sourceMappingURL=textMappers.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/textMappers.mjs b/action/node_modules/cspell-dictionary/dist/esm/util/textMappers.mjs new file mode 100644 index 000000000..91354bb29 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/textMappers.mjs @@ -0,0 +1,15 @@ +import { removeAccents } from './text.mjs'; +export function* mapperNormalizeNFC(words) { + for (const word of words) { + yield word.normalize('NFC'); + } +} +export function* mapperRemoveCaseAndAccents(words) { + for (const word of words) { + const lc = word.toLowerCase(); + yield lc; + const woAccents = removeAccents(lc); + if (lc !== woAccents) + yield woAccents; + } +} diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/types.d.mts b/action/node_modules/cspell-dictionary/dist/esm/util/types.d.mts new file mode 100644 index 000000000..4189bcf0d --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/types.d.mts @@ -0,0 +1,7 @@ +/** + * Like Required, but keeps the Optional. + */ +export type RemoveUndefined = { + [P in keyof T]: Exclude; +}; +//# sourceMappingURL=types.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/types.mjs b/action/node_modules/cspell-dictionary/dist/esm/util/types.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/types.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/util.d.mts b/action/node_modules/cspell-dictionary/dist/esm/util/util.d.mts new file mode 100644 index 000000000..923d4f089 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/util.d.mts @@ -0,0 +1,2 @@ +export declare function isDefined(v: T | undefined): v is T; +//# sourceMappingURL=util.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/esm/util/util.mjs b/action/node_modules/cspell-dictionary/dist/esm/util/util.mjs new file mode 100644 index 000000000..dbbc68391 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/esm/util/util.mjs @@ -0,0 +1,3 @@ +export function isDefined(v) { + return v !== undefined; +} diff --git a/action/node_modules/cspell-dictionary/package.json b/action/node_modules/cspell-dictionary/package.json index 7515f0099..78846d26f 100644 --- a/action/node_modules/cspell-dictionary/package.json +++ b/action/node_modules/cspell-dictionary/package.json @@ -1,25 +1,39 @@ { "name": "cspell-dictionary", - "version": "6.28.0", + "version": "6.29.1", "description": "A spelling dictionary library useful for checking words and getting suggestions.", - "main": "dist/index.js", - "typings": "dist/index.d.ts", + "type": "commonjs", + "main": "dist/cjs/index.js", + "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.mjs", + "exports": { + ".": { + "import": "./dist/esm/index.mjs", + "require": "./dist/cjs/index.js" + } + }, "files": [ "dist", + "!dist/esm/**/*.js", + "!dist/esm/**/*.ts", "!**/*.tsbuildInfo", "!**/__mocks__", + "!**/test/**", "!**/*.test.*", "!**/*.spec.*", "!**/*.map" ], "scripts": { - "build": "tsc -p .", - "watch": "tsc -p . -w", - "clean": "shx rm -rf dist temp coverage .tsbuildinfo", + "clean": "shx rm -rf dist coverage .tsbuildinfo", + "build": "tsc -b . && ts2mjs dist/esm", + "build:esm": "tsc -p tsconfig.esm.json", "clean-build": "pnpm run clean && pnpm run build", - "coverage": "jest --coverage", - "test-watch": "jest --watch", - "test": "jest" + "coverage": "pnpm coverage:vitest && pnpm coverage:fix", + "coverage:vitest": "vitest run --coverage", + "coverage:fix": "nyc report --temp-dir \"$(pwd)/coverage\" --reporter lcov --report-dir \"$(pwd)/coverage\" --cwd ../..", + "test:watch": "vitest", + "test": "vitest run", + "watch": "tsc -b . -w" }, "repository": { "type": "git", @@ -37,17 +51,12 @@ "engines": { "node": ">=14" }, - "devDependencies": { - "@types/jest": "^29.4.0", - "jest": "^29.4.3", - "ts-jest": "^29.0.5" - }, "dependencies": { - "@cspell/cspell-pipe": "6.28.0", - "@cspell/cspell-types": "6.28.0", - "cspell-trie-lib": "6.28.0", + "@cspell/cspell-pipe": "6.29.1", + "@cspell/cspell-types": "6.29.1", + "cspell-trie-lib": "6.29.1", "fast-equals": "^4.0.3", "gensequence": "^5.0.2" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/cspell-gitignore/bin.js b/action/node_modules/cspell-gitignore/bin.js deleted file mode 100755 index 302af0b0d..000000000 --- a/action/node_modules/cspell-gitignore/bin.js +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env node -'use strict'; - -const app = require('./dist/app.js'); - -app.run(process.argv); diff --git a/action/node_modules/cspell-gitignore/bin.mjs b/action/node_modules/cspell-gitignore/bin.mjs new file mode 100755 index 000000000..1ca5d19c3 --- /dev/null +++ b/action/node_modules/cspell-gitignore/bin.mjs @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +import * as app from './dist/esm/app.mjs'; + +app.run(process.argv); diff --git a/action/node_modules/cspell-gitignore/dist/GitIgnore.js b/action/node_modules/cspell-gitignore/dist/cjs/GitIgnore.js similarity index 91% rename from action/node_modules/cspell-gitignore/dist/GitIgnore.js rename to action/node_modules/cspell-gitignore/dist/cjs/GitIgnore.js index 707c52048..9cf61b9e0 100644 --- a/action/node_modules/cspell-gitignore/dist/GitIgnore.js +++ b/action/node_modules/cspell-gitignore/dist/cjs/GitIgnore.js @@ -25,8 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.GitIgnore = void 0; const path = __importStar(require("path")); -const GitIgnoreFile_1 = require("./GitIgnoreFile"); -const helpers_1 = require("./helpers"); +const GitIgnoreFile_js_1 = require("./GitIgnoreFile.js"); +const helpers_js_1 = require("./helpers.js"); /** * Class to cache and process `.gitignore` file queries. */ @@ -105,19 +105,19 @@ class GitIgnore { async _findGitIgnoreHierarchy(directory) { const root = this.determineRoot(directory); const parent = path.dirname(directory); - const parentHierarchy = parent !== directory && (0, helpers_1.contains)(root, parent) ? await this.findGitIgnoreHierarchy(parent) : undefined; - const git = await (0, GitIgnoreFile_1.loadGitIgnore)(directory); + const parentHierarchy = parent !== directory && (0, helpers_js_1.contains)(root, parent) ? await this.findGitIgnoreHierarchy(parent) : undefined; + const git = await (0, GitIgnoreFile_js_1.loadGitIgnore)(directory); if (!git) { - return parentHierarchy || new GitIgnoreFile_1.GitIgnoreHierarchy([]); + return parentHierarchy || new GitIgnoreFile_js_1.GitIgnoreHierarchy([]); } const chain = parentHierarchy?.gitIgnoreChain.concat([git]) ?? [git]; - return new GitIgnoreFile_1.GitIgnoreHierarchy(chain); + return new GitIgnoreFile_js_1.GitIgnoreHierarchy(chain); } determineRoot(directory) { const roots = this.roots; for (let i = roots.length - 1; i >= 0; --i) { const r = roots[i]; - if ((0, helpers_1.contains)(r, directory)) + if ((0, helpers_js_1.contains)(r, directory)) return r; } return path.parse(directory).root; diff --git a/action/node_modules/cspell-gitignore/dist/GitIgnoreFile.js b/action/node_modules/cspell-gitignore/dist/cjs/GitIgnoreFile.js similarity index 95% rename from action/node_modules/cspell-gitignore/dist/GitIgnoreFile.js rename to action/node_modules/cspell-gitignore/dist/cjs/GitIgnoreFile.js index 6682ae4af..c83ee7fe7 100644 --- a/action/node_modules/cspell-gitignore/dist/GitIgnoreFile.js +++ b/action/node_modules/cspell-gitignore/dist/cjs/GitIgnoreFile.js @@ -27,7 +27,7 @@ exports.__testing__ = exports.loadGitIgnore = exports.GitIgnoreHierarchy = expor const cspell_glob_1 = require("cspell-glob"); const fs_1 = require("fs"); const path = __importStar(require("path")); -const helpers_1 = require("./helpers"); +const helpers_js_1 = require("./helpers.js"); /** * Represents an instance of a .gitignore file. */ @@ -58,7 +58,7 @@ class GitIgnoreFile { getGlobs(relativeTo) { return this.getGlobPatters() .map((pat) => globToString(pat, relativeTo)) - .filter(helpers_1.isDefined); + .filter(helpers_js_1.isDefined); } static parseGitignore(content, gitignoreFilename) { const options = { root: path.dirname(gitignoreFilename) }; @@ -138,9 +138,9 @@ function mustBeHierarchical(chain) { function globToString(glob, relativeTo) { if (glob.isGlobalPattern) return glob.glob; - if ((0, helpers_1.isParentOf)(glob.root, relativeTo) && glob.glob.startsWith('**/')) + if ((0, helpers_js_1.isParentOf)(glob.root, relativeTo) && glob.glob.startsWith('**/')) return glob.glob; - const base = (0, helpers_1.makeRelativeTo)(glob.root, relativeTo); + const base = (0, helpers_js_1.makeRelativeTo)(glob.root, relativeTo); if (base === undefined) return undefined; return (base ? base + '/' : '') + glob.glob; diff --git a/action/node_modules/cspell-gitignore/dist/app.js b/action/node_modules/cspell-gitignore/dist/cjs/app.js similarity index 94% rename from action/node_modules/cspell-gitignore/dist/app.js rename to action/node_modules/cspell-gitignore/dist/cjs/app.js index c57deb9ff..6cc3d45f7 100644 --- a/action/node_modules/cspell-gitignore/dist/app.js +++ b/action/node_modules/cspell-gitignore/dist/cjs/app.js @@ -25,8 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.run = void 0; const path = __importStar(require("path")); -const GitIgnore_1 = require("./GitIgnore"); -const helpers_1 = require("./helpers"); +const GitIgnore_js_1 = require("./GitIgnore.js"); +const helpers_js_1 = require("./helpers.js"); const helpText = `Usage cspell-gitignore [options] Check files against .gitignore @@ -44,7 +44,7 @@ Example: async function run(args) { const { roots, files, help } = parseArgs(args.slice(2)); const cwd = process.cwd(); - const repo = (await (0, helpers_1.findRepoRoot)(cwd)) || cwd; + const repo = (await (0, helpers_js_1.findRepoRoot)(cwd)) || cwd; const gi = await createGitIgnore(roots, repo); if (help) { console.log(help); @@ -106,6 +106,6 @@ async function createGitIgnore(roots, repoRoot) { if (!roots.length) { roots.push(repoRoot); } - return new GitIgnore_1.GitIgnore(roots); + return new GitIgnore_js_1.GitIgnore(roots); } //# sourceMappingURL=app.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-gitignore/dist/helpers.js b/action/node_modules/cspell-gitignore/dist/cjs/helpers.js similarity index 100% rename from action/node_modules/cspell-gitignore/dist/helpers.js rename to action/node_modules/cspell-gitignore/dist/cjs/helpers.js diff --git a/action/node_modules/cspell-gitignore/dist/index.js b/action/node_modules/cspell-gitignore/dist/cjs/index.js similarity index 55% rename from action/node_modules/cspell-gitignore/dist/index.js rename to action/node_modules/cspell-gitignore/dist/cjs/index.js index c601a95e0..e93bde88d 100644 --- a/action/node_modules/cspell-gitignore/dist/index.js +++ b/action/node_modules/cspell-gitignore/dist/cjs/index.js @@ -1,15 +1,15 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isParentOf = exports.findRepoRoot = exports.directoryRoot = exports.contains = exports.loadGitIgnore = exports.GitIgnoreHierarchy = exports.GitIgnoreFile = exports.GitIgnore = void 0; -var GitIgnore_1 = require("./GitIgnore"); -Object.defineProperty(exports, "GitIgnore", { enumerable: true, get: function () { return GitIgnore_1.GitIgnore; } }); -var GitIgnoreFile_1 = require("./GitIgnoreFile"); -Object.defineProperty(exports, "GitIgnoreFile", { enumerable: true, get: function () { return GitIgnoreFile_1.GitIgnoreFile; } }); -Object.defineProperty(exports, "GitIgnoreHierarchy", { enumerable: true, get: function () { return GitIgnoreFile_1.GitIgnoreHierarchy; } }); -Object.defineProperty(exports, "loadGitIgnore", { enumerable: true, get: function () { return GitIgnoreFile_1.loadGitIgnore; } }); -var helpers_1 = require("./helpers"); -Object.defineProperty(exports, "contains", { enumerable: true, get: function () { return helpers_1.contains; } }); -Object.defineProperty(exports, "directoryRoot", { enumerable: true, get: function () { return helpers_1.directoryRoot; } }); -Object.defineProperty(exports, "findRepoRoot", { enumerable: true, get: function () { return helpers_1.findRepoRoot; } }); -Object.defineProperty(exports, "isParentOf", { enumerable: true, get: function () { return helpers_1.isParentOf; } }); +var GitIgnore_js_1 = require("./GitIgnore.js"); +Object.defineProperty(exports, "GitIgnore", { enumerable: true, get: function () { return GitIgnore_js_1.GitIgnore; } }); +var GitIgnoreFile_js_1 = require("./GitIgnoreFile.js"); +Object.defineProperty(exports, "GitIgnoreFile", { enumerable: true, get: function () { return GitIgnoreFile_js_1.GitIgnoreFile; } }); +Object.defineProperty(exports, "GitIgnoreHierarchy", { enumerable: true, get: function () { return GitIgnoreFile_js_1.GitIgnoreHierarchy; } }); +Object.defineProperty(exports, "loadGitIgnore", { enumerable: true, get: function () { return GitIgnoreFile_js_1.loadGitIgnore; } }); +var helpers_js_1 = require("./helpers.js"); +Object.defineProperty(exports, "contains", { enumerable: true, get: function () { return helpers_js_1.contains; } }); +Object.defineProperty(exports, "directoryRoot", { enumerable: true, get: function () { return helpers_js_1.directoryRoot; } }); +Object.defineProperty(exports, "findRepoRoot", { enumerable: true, get: function () { return helpers_js_1.findRepoRoot; } }); +Object.defineProperty(exports, "isParentOf", { enumerable: true, get: function () { return helpers_js_1.isParentOf; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-gitignore/dist/esm/GitIgnore.d.mts b/action/node_modules/cspell-gitignore/dist/esm/GitIgnore.d.mts new file mode 100644 index 000000000..e562324a9 --- /dev/null +++ b/action/node_modules/cspell-gitignore/dist/esm/GitIgnore.d.mts @@ -0,0 +1,36 @@ +import type { IsIgnoredExResult } from './GitIgnoreFile.mjs'; +import { GitIgnoreHierarchy } from './GitIgnoreFile.mjs'; +/** + * Class to cache and process `.gitignore` file queries. + */ +export declare class GitIgnore { + private resolvedGitIgnoreHierarchies; + private knownGitIgnoreHierarchies; + private _roots; + private _sortedRoots; + /** + * @param roots - (search roots) an optional array of root paths to prevent searching for `.gitignore` files above the root. + * If a file is under multiple roots, the closest root will apply. If a file is not under any root, then + * the search for `.gitignore` will go all the way to the system root of the file. + */ + constructor(roots?: string[]); + findResolvedGitIgnoreHierarchy(directory: string): GitIgnoreHierarchy | undefined; + isIgnoredQuick(file: string): boolean | undefined; + isIgnored(file: string): Promise; + isIgnoredEx(file: string): Promise; + findGitIgnoreHierarchy(directory: string): Promise; + filterOutIgnored(files: string[]): Promise; + filterOutIgnored(files: Iterable): Promise; + filterOutIgnored(files: AsyncIterable): AsyncIterable; + filterOutIgnored(files: Iterable | AsyncIterable): Promise | AsyncIterable; + filterOutIgnored(files: Iterable & AsyncIterable): AsyncIterable; + filterOutIgnoredAsync(files: Iterable | AsyncIterable): AsyncIterable; + get roots(): string[]; + addRoots(roots: string[]): void; + peekGitIgnoreHierarchy(directory: string): Promise | undefined; + getGlobs(directory: string): Promise; + private cleanCachedEntries; + private _findGitIgnoreHierarchy; + private determineRoot; +} +//# sourceMappingURL=GitIgnore.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-gitignore/dist/esm/GitIgnore.mjs b/action/node_modules/cspell-gitignore/dist/esm/GitIgnore.mjs new file mode 100644 index 000000000..1020c6d23 --- /dev/null +++ b/action/node_modules/cspell-gitignore/dist/esm/GitIgnore.mjs @@ -0,0 +1,124 @@ +import * as path from 'path'; +import { GitIgnoreHierarchy, loadGitIgnore } from './GitIgnoreFile.mjs'; +import { contains } from './helpers.mjs'; +/** + * Class to cache and process `.gitignore` file queries. + */ +export class GitIgnore { + /** + * @param roots - (search roots) an optional array of root paths to prevent searching for `.gitignore` files above the root. + * If a file is under multiple roots, the closest root will apply. If a file is not under any root, then + * the search for `.gitignore` will go all the way to the system root of the file. + */ + constructor(roots = []) { + this.resolvedGitIgnoreHierarchies = new Map(); + this.knownGitIgnoreHierarchies = new Map(); + this._sortedRoots = resolveAndSortRoots(roots); + this._roots = new Set(this._sortedRoots); + } + findResolvedGitIgnoreHierarchy(directory) { + return this.resolvedGitIgnoreHierarchies.get(directory); + } + isIgnoredQuick(file) { + const gh = this.findResolvedGitIgnoreHierarchy(path.dirname(file)); + return gh?.isIgnored(file); + } + async isIgnored(file) { + const gh = await this.findGitIgnoreHierarchy(path.dirname(file)); + return gh.isIgnored(file); + } + async isIgnoredEx(file) { + const gh = await this.findGitIgnoreHierarchy(path.dirname(file)); + return gh.isIgnoredEx(file); + } + async findGitIgnoreHierarchy(directory) { + const known = this.knownGitIgnoreHierarchies.get(directory); + if (known) { + return known; + } + const find = this._findGitIgnoreHierarchy(directory); + this.knownGitIgnoreHierarchies.set(directory, find); + const found = await find; + this.resolvedGitIgnoreHierarchies.set(directory, found); + return find; + } + filterOutIgnored(files) { + const iter = this.filterOutIgnoredAsync(files); + return isAsyncIterable(files) ? iter : asyncIterableToArray(iter); + } + async *filterOutIgnoredAsync(files) { + for await (const file of files) { + const isIgnored = this.isIgnoredQuick(file) ?? (await this.isIgnored(file)); + if (!isIgnored) { + yield file; + } + } + } + get roots() { + return this._sortedRoots; + } + addRoots(roots) { + const rootsToAdd = roots.map((p) => path.resolve(p)).filter((r) => !this._roots.has(r)); + if (!rootsToAdd.length) + return; + rootsToAdd.forEach((r) => this._roots.add(r)); + this._sortedRoots = resolveAndSortRoots([...this._roots]); + this.cleanCachedEntries(); + } + peekGitIgnoreHierarchy(directory) { + return this.knownGitIgnoreHierarchies.get(directory); + } + async getGlobs(directory) { + const hierarchy = await this.findGitIgnoreHierarchy(directory); + return hierarchy.getGlobs(directory); + } + cleanCachedEntries() { + this.knownGitIgnoreHierarchies.clear(); + this.resolvedGitIgnoreHierarchies.clear(); + } + async _findGitIgnoreHierarchy(directory) { + const root = this.determineRoot(directory); + const parent = path.dirname(directory); + const parentHierarchy = parent !== directory && contains(root, parent) ? await this.findGitIgnoreHierarchy(parent) : undefined; + const git = await loadGitIgnore(directory); + if (!git) { + return parentHierarchy || new GitIgnoreHierarchy([]); + } + const chain = parentHierarchy?.gitIgnoreChain.concat([git]) ?? [git]; + return new GitIgnoreHierarchy(chain); + } + determineRoot(directory) { + const roots = this.roots; + for (let i = roots.length - 1; i >= 0; --i) { + const r = roots[i]; + if (contains(r, directory)) + return r; + } + return path.parse(directory).root; + } +} +function resolveAndSortRoots(roots) { + const sortedRoots = roots.map((a) => path.resolve(a)); + sortRoots(sortedRoots); + Object.freeze(sortedRoots); + return sortedRoots; +} +/** + * Sorts root paths based upon their length. + * @param roots - array to be sorted + */ +function sortRoots(roots) { + roots.sort((a, b) => a.length - b.length); + return roots; +} +function isAsyncIterable(i) { + const as = i; + return typeof as[Symbol.asyncIterator] === 'function'; +} +async function asyncIterableToArray(iter) { + const r = []; + for await (const t of iter) { + r.push(t); + } + return r; +} diff --git a/action/node_modules/cspell-gitignore/dist/esm/GitIgnoreFile.d.mts b/action/node_modules/cspell-gitignore/dist/esm/GitIgnoreFile.d.mts new file mode 100644 index 000000000..0db0e0ced --- /dev/null +++ b/action/node_modules/cspell-gitignore/dist/esm/GitIgnoreFile.d.mts @@ -0,0 +1,47 @@ +import type { GlobPatternWithRoot } from 'cspell-glob'; +import { GlobMatcher } from 'cspell-glob'; +export interface IsIgnoredExResult { + glob: string | undefined; + root: string | undefined; + matched: boolean; + gitIgnoreFile: string; + line: number | undefined; +} +/** + * Represents an instance of a .gitignore file. + */ +export declare class GitIgnoreFile { + readonly matcher: GlobMatcher; + readonly gitignore: string; + constructor(matcher: GlobMatcher, gitignore: string); + get root(): string; + isIgnored(file: string): boolean; + isIgnoredEx(file: string): IsIgnoredExResult; + getGlobPatters(): GlobPatternWithRoot[]; + getGlobs(relativeTo: string): string[]; + static parseGitignore(content: string, gitignoreFilename: string): GitIgnoreFile; + static loadGitignore(gitignore: string): Promise; +} +/** + * A collection of nested GitIgnoreFiles to be evaluated from top to bottom. + */ +export declare class GitIgnoreHierarchy { + readonly gitIgnoreChain: GitIgnoreFile[]; + constructor(gitIgnoreChain: GitIgnoreFile[]); + isIgnored(file: string): boolean; + /** + * Check to see which `.gitignore` file ignored the given file. + * @param file - fsPath to check. + * @returns IsIgnoredExResult of the match or undefined if there was no match. + */ + isIgnoredEx(file: string): IsIgnoredExResult | undefined; + getGlobPatters(): GlobPatternWithRoot[]; + getGlobs(relativeTo: string): string[]; +} +export declare function loadGitIgnore(dir: string): Promise; +declare function mustBeHierarchical(chain: GitIgnoreFile[]): void; +export declare const __testing__: { + mustBeHierarchical: typeof mustBeHierarchical; +}; +export {}; +//# sourceMappingURL=GitIgnoreFile.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-gitignore/dist/esm/GitIgnoreFile.mjs b/action/node_modules/cspell-gitignore/dist/esm/GitIgnoreFile.mjs new file mode 100644 index 000000000..20b2dc95e --- /dev/null +++ b/action/node_modules/cspell-gitignore/dist/esm/GitIgnoreFile.mjs @@ -0,0 +1,121 @@ +import { GlobMatcher } from 'cspell-glob'; +import { promises as fs } from 'fs'; +import * as path from 'path'; +import { isDefined, isParentOf, makeRelativeTo } from './helpers.mjs'; +/** + * Represents an instance of a .gitignore file. + */ +export class GitIgnoreFile { + constructor(matcher, gitignore) { + this.matcher = matcher; + this.gitignore = gitignore; + } + get root() { + return this.matcher.root; + } + isIgnored(file) { + return this.matcher.match(file); + } + isIgnoredEx(file) { + const m = this.matcher.matchEx(file); + const { matched } = m; + const partial = m; + const pattern = partial.pattern; + const glob = pattern?.rawGlob ?? partial.glob; + const root = partial.root; + const line = pattern?.line; + return { glob, matched, gitIgnoreFile: this.gitignore, root, line }; + } + getGlobPatters() { + return this.matcher.patterns; + } + getGlobs(relativeTo) { + return this.getGlobPatters() + .map((pat) => globToString(pat, relativeTo)) + .filter(isDefined); + } + static parseGitignore(content, gitignoreFilename) { + const options = { root: path.dirname(gitignoreFilename) }; + const globs = content + .split(/\r?\n/g) + .map((glob, index) => ({ + glob: glob.replace(/^#.*/, ''), + source: gitignoreFilename, + line: index + 1, + })) + .filter((g) => !!g.glob); + const globMatcher = new GlobMatcher(globs, options); + return new GitIgnoreFile(globMatcher, gitignoreFilename); + } + static async loadGitignore(gitignore) { + gitignore = path.resolve(gitignore); + const content = await fs.readFile(gitignore, 'utf8'); + return this.parseGitignore(content, gitignore); + } +} +/** + * A collection of nested GitIgnoreFiles to be evaluated from top to bottom. + */ +export class GitIgnoreHierarchy { + constructor(gitIgnoreChain) { + this.gitIgnoreChain = gitIgnoreChain; + mustBeHierarchical(gitIgnoreChain); + } + isIgnored(file) { + for (const git of this.gitIgnoreChain) { + if (git.isIgnored(file)) + return true; + } + return false; + } + /** + * Check to see which `.gitignore` file ignored the given file. + * @param file - fsPath to check. + * @returns IsIgnoredExResult of the match or undefined if there was no match. + */ + isIgnoredEx(file) { + for (const git of this.gitIgnoreChain) { + const r = git.isIgnoredEx(file); + if (r.matched) + return r; + } + return undefined; + } + getGlobPatters() { + return this.gitIgnoreChain.flatMap((gf) => gf.getGlobPatters()); + } + getGlobs(relativeTo) { + return this.gitIgnoreChain.flatMap((gf) => gf.getGlobs(relativeTo)); + } +} +export async function loadGitIgnore(dir) { + const file = path.join(dir, '.gitignore'); + try { + return await GitIgnoreFile.loadGitignore(file); + } + catch (e) { + return undefined; + } +} +function mustBeHierarchical(chain) { + let root = ''; + for (const file of chain) { + if (!file.root.startsWith(root)) { + throw new Error('Hierarchy violation - files are not nested'); + } + root = file.root; + } +} +function globToString(glob, relativeTo) { + if (glob.isGlobalPattern) + return glob.glob; + if (isParentOf(glob.root, relativeTo) && glob.glob.startsWith('**/')) + return glob.glob; + const base = makeRelativeTo(glob.root, relativeTo); + if (base === undefined) + return undefined; + return (base ? base + '/' : '') + glob.glob; +} +export const __testing__ = { + mustBeHierarchical, +}; diff --git a/action/node_modules/cspell-gitignore/dist/esm/app.d.mts b/action/node_modules/cspell-gitignore/dist/esm/app.d.mts new file mode 100644 index 000000000..83aa0fd66 --- /dev/null +++ b/action/node_modules/cspell-gitignore/dist/esm/app.d.mts @@ -0,0 +1,2 @@ +export declare function run(args: string[]): Promise; +//# sourceMappingURL=app.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-gitignore/dist/esm/app.mjs b/action/node_modules/cspell-gitignore/dist/esm/app.mjs new file mode 100644 index 000000000..7fa6b248b --- /dev/null +++ b/action/node_modules/cspell-gitignore/dist/esm/app.mjs @@ -0,0 +1,83 @@ +import * as path from 'path'; +import { GitIgnore } from './GitIgnore.mjs'; +import { findRepoRoot } from './helpers.mjs'; +const helpText = `Usage cspell-gitignore [options] + +Check files against .gitignore +Compare against git check-ignore -v -n + +Options: +-r, --root Add a root to prevent searching for .gitignore files above the root if the file is under the root. + This option can be used multiple times to add multiple roots. The default root is the current + repository root determined by the \`.git\` directory. + +Example: + cspell-gitignore README.md + cspell-gitignore -r . node_modules +`; +export async function run(args) { + const { roots, files, help } = parseArgs(args.slice(2)); + const cwd = process.cwd(); + const repo = (await findRepoRoot(cwd)) || cwd; + const gi = await createGitIgnore(roots, repo); + if (help) { + console.log(help); + return; + } + if (!files.length) { + console.error('Missing files'); + process.exitCode = 1; + return; + } + for (const file of files) { + const filename = path.relative(cwd, file); + const pFile = gi.isIgnoredEx(file); + const pDir = gi.isIgnoredEx(file + '/ '); + const r = (await pFile) || (await pDir); + const gitignore = r?.gitIgnoreFile ? path.relative(repo, r.gitIgnoreFile) : ''; + const line = r?.line || ''; + const glob = r?.glob || ''; + console.log(`${gitignore}:${line}:${glob}\t${filename}`); + } +} +function parseArgs(params) { + const roots = []; + const files = []; + let help = ''; + const options = { + '-r': optionRoot, + '--root': optionRoot, + '-h': optionHelp, + '--help': optionHelp, + }; + function optionRoot(params) { + const root = params[1]; + if (!root) { + throw new Error('Missing root parameter.'); + } + roots.push(path.resolve(root)); + return params.slice(2); + } + function optionFile(params) { + const file = params[0].trim(); + if (file) { + files.push(path.resolve(file)); + } + return params.slice(1); + } + function optionHelp(_params) { + help = helpText; + return []; + } + while (params.length) { + const fn = options[params[0]]; + params = fn?.(params) ?? optionFile(params); + } + return { roots, files, help }; +} +async function createGitIgnore(roots, repoRoot) { + if (!roots.length) { + roots.push(repoRoot); + } + return new GitIgnore(roots); +} diff --git a/action/node_modules/cspell-gitignore/dist/esm/helpers.d.mts b/action/node_modules/cspell-gitignore/dist/esm/helpers.d.mts new file mode 100644 index 000000000..b20b26029 --- /dev/null +++ b/action/node_modules/cspell-gitignore/dist/esm/helpers.d.mts @@ -0,0 +1,117 @@ +interface ParsedPath { + /** + * The root of the path such as '/' or 'c:\' + */ + root: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base: string; + /** + * The file extension (if any) such as '.html' + */ + ext: string; + /** + * The file name without extension (if any) such as 'index' + */ + name: string; +} +export interface PathInterface { + dirname(path: string): string; + isAbsolute(p: string): boolean; + join(...paths: string[]): string; + normalize(p: string): string; + parse(path: string): ParsedPath; + relative(from: string, to: string): string; + resolve(...paths: string[]): string; + sep: string; +} +interface PathHelper { + /** + * Parse a directory and return its root + * @param directory - directory to parse. + * @returns root directory + */ + directoryRoot(directory: string): string; + /** + * Find the git repository root directory. + * @param directory - directory to search up from. + * @returns resolves to `.git` root or undefined + */ + findRepoRoot(directory: string): Promise; + /** + * Checks to see if the child directory is nested under the parent directory. + * @param parent - parent directory + * @param child - possible child directory + * @returns true iff child is a child of parent. + */ + isParentOf(parent: string, child: string): boolean; + /** + * Check to see if a parent directory contains a child directory. + * @param parent - parent directory + * @param child - child directory + * @returns true iff child is the same as the parent or nested in the parent. + */ + contains(parent: string, child: string): boolean; + /** + * Make a path relative to another if the other is a parent. + * @param path - the path to make relative + * @param rootPath - a root of path + * @returns the normalized relative path or undefined if rootPath is not a parent. + */ + makeRelativeTo(path: string, rootPath: string): string | undefined; + /** + * Normalize a path to have only forward slashes. + * @param path - path to normalize + * @returns a normalized string. + */ + normalizePath(path: string): string; +} +export declare function factoryPathHelper(path: PathInterface): PathHelper; +/** + * Parse a directory and return its root + * @param directory - directory to parse. + * @returns root directory + */ +export declare const directoryRoot: (directory: string) => string; +/** + * Find the git repository root directory. + * @param directory - directory to search up from. + * @returns resolves to `.git` root or undefined + */ +export declare const findRepoRoot: (directory: string) => Promise; +/** + * Checks to see if the child directory is nested under the parent directory. + * @param parent - parent directory + * @param child - possible child directory + * @returns true iff child is a child of parent. + */ +export declare const isParentOf: (parent: string, child: string) => boolean; +/** + * Check to see if a parent directory contains a child directory. + * @param parent - parent directory + * @param child - child directory + * @returns true iff child is the same as the parent or nested in the parent. + */ +export declare const contains: (parent: string, child: string) => boolean; +/** + * Make a path relative to another if the other is a parent. + * @param path - the path to make relative + * @param rootPath - a root of path + * @returns the normalized relative path or undefined if rootPath is not a parent. + */ +export declare const makeRelativeTo: (path: string, rootPath: string) => string | undefined; +/** + * Normalize a path to have only forward slashes. + * @param path - path to normalize + * @returns a normalized string. + */ +export declare const normalizePath: (path: string) => string; +export declare const DefaultPathHelper: PathHelper; +export declare function isDefined(v: T | undefined | null): v is T; +export {}; +//# sourceMappingURL=helpers.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-gitignore/dist/esm/helpers.mjs b/action/node_modules/cspell-gitignore/dist/esm/helpers.mjs new file mode 100644 index 000000000..97fe53795 --- /dev/null +++ b/action/node_modules/cspell-gitignore/dist/esm/helpers.mjs @@ -0,0 +1,90 @@ +import findUp from 'find-up'; +import * as path from 'path'; +export function factoryPathHelper(path) { + function directoryRoot(directory) { + const p = path.parse(directory); + return p.root; + } + async function findRepoRoot(directory) { + const found = await findUp('.git', { cwd: directory, type: 'directory' }); + if (!found) + return undefined; + return path.dirname(found); + } + function isParentOf(parent, child) { + const rel = path.relative(parent, child); + return !!rel && !path.isAbsolute(rel) && rel[0] !== '.'; + } + function contains(parent, child) { + const rel = path.relative(parent, child); + return !rel || (!path.isAbsolute(rel) && rel[0] !== '.'); + } + function makeRelativeTo(child, parent) { + const rel = path.relative(parent, child); + if (path.isAbsolute(rel) || rel[0] === '.') + return undefined; + return normalizePath(rel); + } + function normalizePath(path) { + return path.replace(/\\/g, '/'); + } + return { + directoryRoot, + findRepoRoot, + isParentOf, + contains, + normalizePath, + makeRelativeTo, + }; +} +const defaultHelper = factoryPathHelper(path); +/** + * Parse a directory and return its root + * @param directory - directory to parse. + * @returns root directory + */ +export const directoryRoot = defaultHelper.directoryRoot; +/** + * Find the git repository root directory. + * @param directory - directory to search up from. + * @returns resolves to `.git` root or undefined + */ +export const findRepoRoot = defaultHelper.findRepoRoot; +/** + * Checks to see if the child directory is nested under the parent directory. + * @param parent - parent directory + * @param child - possible child directory + * @returns true iff child is a child of parent. + */ +export const isParentOf = defaultHelper.isParentOf; +/** + * Check to see if a parent directory contains a child directory. + * @param parent - parent directory + * @param child - child directory + * @returns true iff child is the same as the parent or nested in the parent. + */ +export const contains = defaultHelper.contains; +/** + * Make a path relative to another if the other is a parent. + * @param path - the path to make relative + * @param rootPath - a root of path + * @returns the normalized relative path or undefined if rootPath is not a parent. + */ +export const makeRelativeTo = defaultHelper.makeRelativeTo; +/** + * Normalize a path to have only forward slashes. + * @param path - path to normalize + * @returns a normalized string. + */ +export const normalizePath = defaultHelper.normalizePath; +export const DefaultPathHelper = { + directoryRoot, + findRepoRoot, + isParentOf, + contains, + makeRelativeTo, + normalizePath, +}; +export function isDefined(v) { + return v !== undefined && v !== null; +} diff --git a/action/node_modules/cspell-gitignore/dist/esm/index.d.mts b/action/node_modules/cspell-gitignore/dist/esm/index.d.mts new file mode 100644 index 000000000..2dee3bfd4 --- /dev/null +++ b/action/node_modules/cspell-gitignore/dist/esm/index.d.mts @@ -0,0 +1,4 @@ +export { GitIgnore } from './GitIgnore.mjs'; +export { GitIgnoreFile, GitIgnoreHierarchy, loadGitIgnore } from './GitIgnoreFile.mjs'; +export { contains, directoryRoot, findRepoRoot, isParentOf } from './helpers.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-gitignore/dist/esm/index.mjs b/action/node_modules/cspell-gitignore/dist/esm/index.mjs new file mode 100644 index 000000000..1cc2024e0 --- /dev/null +++ b/action/node_modules/cspell-gitignore/dist/esm/index.mjs @@ -0,0 +1,3 @@ +export { GitIgnore } from './GitIgnore.mjs'; +export { GitIgnoreFile, GitIgnoreHierarchy, loadGitIgnore } from './GitIgnoreFile.mjs'; +export { contains, directoryRoot, findRepoRoot, isParentOf } from './helpers.mjs'; diff --git a/action/node_modules/cspell-gitignore/package.json b/action/node_modules/cspell-gitignore/package.json index 305a573ae..28c6bf96d 100644 --- a/action/node_modules/cspell-gitignore/package.json +++ b/action/node_modules/cspell-gitignore/package.json @@ -1,6 +1,6 @@ { "name": "cspell-gitignore", - "version": "6.28.0", + "version": "6.29.1", "description": "Gitignore Glob matcher for cspell", "keywords": [ "cspell", @@ -10,33 +10,42 @@ "author": "Jason Dent ", "homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-gitignore#readme", "license": "MIT", - "main": "dist/index.js", "bin": { - "cspell-gitignore": "bin.js" + "cspell-gitignore": "bin.mjs" }, - "directories": { - "dist": "dist" + "type": "commonjs", + "main": "dist/cjs/index.js", + "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.mjs", + "exports": { + ".": { + "import": "./dist/esm/index.mjs", + "require": "./dist/cjs/index.js" + } }, - "typings": "dist/index.d.ts", "files": [ - "bin.js", + "bin.mjs", "dist", + "!dist/esm/**/*.js", + "!dist/esm/**/*.ts", "!**/*.tsbuildInfo", "!**/__mocks__", + "!**/test/**", "!**/*.test.*", "!**/*.spec.*", "!**/*.map" ], "scripts": { - "build": "tsc -p .", - "watch": "tsc -p . -w", "clean": "shx rm -rf dist coverage .tsbuildinfo", + "build": "tsc -b . && ts2mjs dist/esm", + "build:esm": "tsc -p tsconfig.esm.json", "clean-build": "pnpm run clean && pnpm run build", "coverage": "pnpm coverage:vitest && pnpm coverage:fix", "coverage:vitest": "vitest run --coverage", "coverage:fix": "nyc report --temp-dir \"$(pwd)/coverage\" --reporter lcov --report-dir \"$(pwd)/coverage\" --cwd ../..", - "test-watch": "vitest", - "test": "vitest run" + "test:watch": "vitest", + "test": "vitest run", + "watch": "tsc -b . -w" }, "repository": { "type": "git", @@ -49,8 +58,8 @@ "node": ">=14" }, "dependencies": { - "cspell-glob": "6.28.0", + "cspell-glob": "6.29.1", "find-up": "^5.0.0" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/cspell-glob/dist/GlobMatcher.js b/action/node_modules/cspell-glob/dist/cjs/GlobMatcher.js similarity index 94% rename from action/node_modules/cspell-glob/dist/GlobMatcher.js rename to action/node_modules/cspell-glob/dist/cjs/GlobMatcher.js index aa5c99135..81bed0b3f 100644 --- a/action/node_modules/cspell-glob/dist/GlobMatcher.js +++ b/action/node_modules/cspell-glob/dist/cjs/GlobMatcher.js @@ -29,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.GlobMatcher = void 0; const micromatch_1 = __importDefault(require("micromatch")); const Path = __importStar(require("path")); -const globHelper_1 = require("./globHelper"); +const globHelper_js_1 = require("./globHelper.js"); class GlobMatcher { constructor(patterns, rootOrOptions, _nodePath) { _nodePath = _nodePath ?? Path; @@ -45,9 +45,9 @@ class GlobMatcher { : typeof patterns === 'string' ? patterns.split(/\r?\n/g) : [patterns]; - const globPatterns = (0, globHelper_1.normalizeGlobPatterns)(patterns, this.options); + const globPatterns = (0, globHelper_js_1.normalizeGlobPatterns)(patterns, this.options); this.patternsNormalizedToRoot = globPatterns - .map((g) => (0, globHelper_1.normalizeGlobToRoot)(g, normalizedRoot, nodePath)) + .map((g) => (0, globHelper_js_1.normalizeGlobToRoot)(g, normalizedRoot, nodePath)) // Only keep globs that do not match the root when using exclude mode. .filter((g) => nodePath.relative(g.root, normalizedRoot) === ''); this.patterns = globPatterns; @@ -108,7 +108,7 @@ function buildMatcherFn(patterns, options) { const pattern = rule.pattern; const root = pattern.root; const isRelPat = !pattern.isGlobalPattern; - if (isRelPat && !(0, globHelper_1.doesRootContainPath)(root, filename, path)) { + if (isRelPat && !(0, globHelper_js_1.doesRootContainPath)(root, filename, path)) { continue; } const relName = isRelPat ? path.relative(root, filename) : filename; diff --git a/action/node_modules/cspell-glob/dist/GlobMatcherTypes.js b/action/node_modules/cspell-glob/dist/cjs/GlobMatcherTypes.js similarity index 100% rename from action/node_modules/cspell-glob/dist/GlobMatcherTypes.js rename to action/node_modules/cspell-glob/dist/cjs/GlobMatcherTypes.js diff --git a/action/node_modules/cspell-glob/dist/globHelper.js b/action/node_modules/cspell-glob/dist/cjs/globHelper.js similarity index 100% rename from action/node_modules/cspell-glob/dist/globHelper.js rename to action/node_modules/cspell-glob/dist/cjs/globHelper.js diff --git a/action/node_modules/cspell-glob/dist/index.js b/action/node_modules/cspell-glob/dist/cjs/index.js similarity index 67% rename from action/node_modules/cspell-glob/dist/index.js rename to action/node_modules/cspell-glob/dist/cjs/index.js index cd716a2c0..26b29ef17 100644 --- a/action/node_modules/cspell-glob/dist/index.js +++ b/action/node_modules/cspell-glob/dist/cjs/index.js @@ -15,13 +15,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.GlobMatcher = exports.normalizeGlobPatterns = exports.isGlobPatternWithRoot = exports.isGlobPatternWithOptionalRoot = exports.isGlobPatternNormalized = exports.fileOrGlobToGlob = void 0; -var globHelper_1 = require("./globHelper"); -Object.defineProperty(exports, "fileOrGlobToGlob", { enumerable: true, get: function () { return globHelper_1.fileOrGlobToGlob; } }); -Object.defineProperty(exports, "isGlobPatternNormalized", { enumerable: true, get: function () { return globHelper_1.isGlobPatternNormalized; } }); -Object.defineProperty(exports, "isGlobPatternWithOptionalRoot", { enumerable: true, get: function () { return globHelper_1.isGlobPatternWithOptionalRoot; } }); -Object.defineProperty(exports, "isGlobPatternWithRoot", { enumerable: true, get: function () { return globHelper_1.isGlobPatternWithRoot; } }); -Object.defineProperty(exports, "normalizeGlobPatterns", { enumerable: true, get: function () { return globHelper_1.normalizeGlobPatterns; } }); -var GlobMatcher_1 = require("./GlobMatcher"); -Object.defineProperty(exports, "GlobMatcher", { enumerable: true, get: function () { return GlobMatcher_1.GlobMatcher; } }); -__exportStar(require("./GlobMatcherTypes"), exports); +var globHelper_js_1 = require("./globHelper.js"); +Object.defineProperty(exports, "fileOrGlobToGlob", { enumerable: true, get: function () { return globHelper_js_1.fileOrGlobToGlob; } }); +Object.defineProperty(exports, "isGlobPatternNormalized", { enumerable: true, get: function () { return globHelper_js_1.isGlobPatternNormalized; } }); +Object.defineProperty(exports, "isGlobPatternWithOptionalRoot", { enumerable: true, get: function () { return globHelper_js_1.isGlobPatternWithOptionalRoot; } }); +Object.defineProperty(exports, "isGlobPatternWithRoot", { enumerable: true, get: function () { return globHelper_js_1.isGlobPatternWithRoot; } }); +Object.defineProperty(exports, "normalizeGlobPatterns", { enumerable: true, get: function () { return globHelper_js_1.normalizeGlobPatterns; } }); +var GlobMatcher_js_1 = require("./GlobMatcher.js"); +Object.defineProperty(exports, "GlobMatcher", { enumerable: true, get: function () { return GlobMatcher_js_1.GlobMatcher; } }); +__exportStar(require("./GlobMatcherTypes.js"), exports); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-glob/dist/esm/GlobMatcher.d.mts b/action/node_modules/cspell-glob/dist/esm/GlobMatcher.d.mts new file mode 100644 index 000000000..b96b2128b --- /dev/null +++ b/action/node_modules/cspell-glob/dist/esm/GlobMatcher.d.mts @@ -0,0 +1,94 @@ +import type { GlobMatch, GlobPattern, GlobPatternNormalized, GlobPatternWithRoot, PathInterface } from './GlobMatcherTypes.mjs'; +type Optional = { + [P in keyof T]?: T[P] | undefined; +}; +export type GlobMatchOptions = Optional; +export type MatcherMode = 'exclude' | 'include'; +interface NormalizedGlobMatchOptions { + /** + * The matcher has two modes (`include` or `exclude`) that impact how globs behave. + * + * `include` - designed for searching for file. By default it matches a sub-set of file. + * In include mode, the globs need to be more explicit to match. + * - `dot` is by default false. + * - `nested` is by default false. + * + * `exclude` - designed to emulate `.gitignore`. By default it matches a larger range of files. + * - `dot` is by default true. + * - `nested` is by default true. + * + * @default: 'exclude' + */ + mode: MatcherMode; + /** + * The default directory from which a glob is relative. + * Any globs that are not relative to the root will ignored. + * @default: process.cwd() + */ + root: string; + /** + * The directory to use as the current working directory. + * @default: process.cwd(); + */ + cwd: string; + /** + * Allows matching against directories with a leading `.`. + * + * @default: mode == 'exclude' + */ + dot: boolean; + /** + * Allows matching against nested directories or files without needing to add `**` + * + * @default: mode == 'exclude' + */ + nested: boolean; + /** + * Mostly used for testing purposes. It allows explicitly specifying `path.win32` or `path.posix`. + * + * @default: require('path') + */ + nodePath: PathInterface; + /** + * Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters. + * + * @default false + */ + nobrace?: boolean | undefined; +} +export declare class GlobMatcher { + /** + * @param filename full path of file to match against. + * @returns a GlobMatch - information about the match. + */ + readonly matchEx: (filename: string) => GlobMatch; + readonly path: PathInterface; + readonly patterns: GlobPatternWithRoot[]; + readonly patternsNormalizedToRoot: GlobPatternNormalized[]; + readonly root: string; + readonly dot: boolean; + readonly options: NormalizedGlobMatchOptions; + /** + * Construct a `.gitignore` emulator + * @param patterns - the contents of a `.gitignore` style file or an array of individual glob rules. + * @param root - the working directory + */ + constructor(patterns: GlobPattern | GlobPattern[], root?: string, nodePath?: PathInterface); + /** + * Construct a `.gitignore` emulator + * @param patterns - the contents of a `.gitignore` style file or an array of individual glob rules. + * @param options - to set the root and other options + */ + constructor(patterns: GlobPattern | GlobPattern[], options?: GlobMatchOptions); + constructor(patterns: GlobPattern | GlobPattern[], rootOrOptions?: string | GlobMatchOptions); + /** + * Check to see if a filename matches any of the globs. + * If filename is relative, it is considered relative to the root. + * If filename is absolute and contained within the root, it will be made relative before being tested for a glob match. + * If filename is absolute and not contained within the root, it will be tested as is. + * @param filename full path of the file to check. + */ + match(filename: string): boolean; +} +export {}; +//# sourceMappingURL=GlobMatcher.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-glob/dist/esm/GlobMatcher.mjs b/action/node_modules/cspell-glob/dist/esm/GlobMatcher.mjs new file mode 100644 index 000000000..730f1c4f3 --- /dev/null +++ b/action/node_modules/cspell-glob/dist/esm/GlobMatcher.mjs @@ -0,0 +1,101 @@ +import mm from 'micromatch'; +import * as Path from 'path'; +import { doesRootContainPath, normalizeGlobPatterns, normalizeGlobToRoot } from './globHelper.mjs'; +export class GlobMatcher { + constructor(patterns, rootOrOptions, _nodePath) { + _nodePath = _nodePath ?? Path; + const options = typeof rootOrOptions === 'string' ? { root: rootOrOptions } : rootOrOptions ?? {}; + const { mode = 'exclude' } = options; + const isExcludeMode = mode !== 'include'; + _nodePath = options.nodePath ?? _nodePath; + const { root = _nodePath.resolve(), dot = isExcludeMode, nodePath = _nodePath, nested = isExcludeMode, cwd = process.cwd(), nobrace, } = options; + const normalizedRoot = nodePath.resolve(nodePath.normalize(root)); + this.options = { root: normalizedRoot, dot, nodePath, nested, mode, nobrace, cwd }; + patterns = Array.isArray(patterns) + ? patterns + : typeof patterns === 'string' + ? patterns.split(/\r?\n/g) + : [patterns]; + const globPatterns = normalizeGlobPatterns(patterns, this.options); + this.patternsNormalizedToRoot = globPatterns + .map((g) => normalizeGlobToRoot(g, normalizedRoot, nodePath)) + // Only keep globs that do not match the root when using exclude mode. + .filter((g) => nodePath.relative(g.root, normalizedRoot) === ''); + this.patterns = globPatterns; + this.root = normalizedRoot; + this.path = nodePath; + this.dot = dot; + this.matchEx = buildMatcherFn(this.patterns, this.options); + } + /** + * Check to see if a filename matches any of the globs. + * If filename is relative, it is considered relative to the root. + * If filename is absolute and contained within the root, it will be made relative before being tested for a glob match. + * If filename is absolute and not contained within the root, it will be tested as is. + * @param filename full path of the file to check. + */ + match(filename) { + return this.matchEx(filename).matched; + } +} +/** + * This function attempts to emulate .gitignore functionality as much as possible. + * + * The resulting matcher function: (filename: string) => GlobMatch + * + * If filename is relative, it is considered relative to the root. + * If filename is absolute and contained within the root, it will be made relative before being tested for a glob match. + * If filename is absolute and not contained within the root, it will return a GlobMatchNoRule. + * + * @param patterns - the contents of a .gitignore style file or an array of individual glob rules. + * @param options - defines root and other options + * @returns a function given a filename returns true if it matches. + */ +function buildMatcherFn(patterns, options) { + const { nodePath: path, dot, nobrace } = options; + const makeReOptions = { dot, nobrace }; + const rules = patterns + .map((pattern, index) => ({ pattern, index })) + .filter((r) => !!r.pattern.glob) + .filter((r) => !r.pattern.glob.startsWith('#')) + .map(({ pattern, index }) => { + const matchNeg = pattern.glob.match(/^!/); + const glob = pattern.glob.replace(/^!/, ''); + const isNeg = (matchNeg && matchNeg[0].length & 1 && true) || false; + const reg = mm.makeRe(glob, makeReOptions); + const fn = (filename) => { + const match = filename.match(reg); + return !!match; + }; + return { pattern, index, isNeg, fn, reg }; + }); + const negRules = rules.filter((r) => r.isNeg); + const posRules = rules.filter((r) => !r.isNeg); + const fn = (filename) => { + filename = path.resolve(path.normalize(filename)); + function testRules(rules, matched) { + for (const rule of rules) { + const pattern = rule.pattern; + const root = pattern.root; + const isRelPat = !pattern.isGlobalPattern; + if (isRelPat && !doesRootContainPath(root, filename, path)) { + continue; + } + const relName = isRelPat ? path.relative(root, filename) : filename; + const fname = path.sep === '\\' ? relName.replace(/\\/g, '/') : relName; + if (rule.fn(fname)) { + return { + matched, + glob: pattern.glob, + root, + pattern, + index: rule.index, + isNeg: rule.isNeg, + }; + } + } + } + return testRules(negRules, false) || testRules(posRules, true) || { matched: false }; + }; + return fn; +} diff --git a/action/node_modules/cspell-glob/dist/esm/GlobMatcherTypes.d.mts b/action/node_modules/cspell-glob/dist/esm/GlobMatcherTypes.d.mts new file mode 100644 index 000000000..11bbcb69c --- /dev/null +++ b/action/node_modules/cspell-glob/dist/esm/GlobMatcherTypes.d.mts @@ -0,0 +1,55 @@ +export interface PathInterface { + normalize(p: string): string; + join(...paths: string[]): string; + resolve(...paths: string[]): string; + relative(from: string, to: string): string; + isAbsolute(p: string): boolean; + sep: string; +} +export type GlobMatch = GlobMatchRule | GlobMatchNoRule; +export interface GlobMatchRule { + matched: boolean; + glob: string; + root: string; + pattern: GlobPatternWithRoot; + index: number; + isNeg: boolean; +} +export interface GlobMatchNoRule { + matched: false; +} +export type GlobPattern = SimpleGlobPattern | GlobPatternWithRoot | GlobPatternWithOptionalRoot; +export type SimpleGlobPattern = string; +export interface GlobPatternWithOptionalRoot { + /** + * a glob pattern + */ + glob: string; + /** + * The root from which the glob pattern is relative. + * @default: options.root + */ + root?: string | undefined; + /** + * Optional value useful for tracing which file a glob pattern was defined in. + */ + source?: string | undefined; + /** + * Optional line number in the source + */ + line?: number | undefined; +} +export interface GlobPatternWithRoot extends GlobPatternWithOptionalRoot { + root: string; + /** + * Global patterns do not need to be relative to the root. + */ + isGlobalPattern: boolean; +} +export interface GlobPatternNormalized extends GlobPatternWithRoot { + /** the original glob pattern before it was normalized */ + rawGlob: string; + /** the original root */ + rawRoot: string | undefined; +} +//# sourceMappingURL=GlobMatcherTypes.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-glob/dist/esm/GlobMatcherTypes.mjs b/action/node_modules/cspell-glob/dist/esm/GlobMatcherTypes.mjs new file mode 100644 index 000000000..d521f223d --- /dev/null +++ b/action/node_modules/cspell-glob/dist/esm/GlobMatcherTypes.mjs @@ -0,0 +1,2 @@ +// cspell:ignore fname +export {}; diff --git a/action/node_modules/cspell-glob/dist/esm/globHelper.d.mts b/action/node_modules/cspell-glob/dist/esm/globHelper.d.mts new file mode 100644 index 000000000..259f876d8 --- /dev/null +++ b/action/node_modules/cspell-glob/dist/esm/globHelper.d.mts @@ -0,0 +1,73 @@ +import type { GlobPattern, GlobPatternNormalized, GlobPatternWithOptionalRoot, GlobPatternWithRoot, PathInterface } from './GlobMatcherTypes.mjs'; +/** + * This function tries its best to determine if `fileOrGlob` is a path to a file or a glob pattern. + * @param fileOrGlob - file (with absolute path) or glob. + * @param root - absolute path to the directory that will be considered the root when testing the glob pattern. + * @param path - optional node path methods - used for testing + */ +export declare function fileOrGlobToGlob(fileOrGlob: string | GlobPattern, root: string, path?: PathInterface): GlobPatternWithRoot; +/** + * Decide if a childPath is contained within a root or at the same level. + * @param root - absolute path + * @param childPath - absolute path + */ +export declare function doesRootContainPath(root: string, child: string, path: PathInterface): boolean; +export declare function isGlobPatternWithOptionalRoot(g: GlobPattern): g is GlobPatternWithOptionalRoot; +export declare function isGlobPatternWithRoot(g: GlobPatternWithRoot | GlobPatternWithOptionalRoot): g is GlobPatternWithRoot; +export declare function isGlobPatternNormalized(g: GlobPattern | GlobPatternNormalized): g is GlobPatternNormalized; +export interface NormalizeOptions { + /** + * Indicates that the glob should be modified to match nested patterns. + * + * Example: `node_modules` becomes `**​/node_modules/​**`, `**​/node_modules`, and `node_modules/​**` + */ + nested: boolean; + /** + * This is the root to use for the glob if the glob does not already contain one. + */ + root: string; + /** + * This is the replacement for `${cwd}` in either the root or in the glob. + */ + cwd?: string; + /** + * Optional path interface for working with paths. + */ + nodePath?: PathInterface; +} +/** + * + * @param patterns - glob patterns to normalize. + * @param options - Normalization options. + */ +export declare function normalizeGlobPatterns(patterns: GlobPattern[], options: NormalizeOptions): GlobPatternNormalized[]; +export declare function normalizeGlobPattern(g: GlobPattern, options: NormalizeOptions): GlobPatternNormalized[]; +/** + * Try to adjust the root of a glob to match a new root. If it is not possible, the original glob is returned. + * Note: this does NOT generate absolutely correct glob patterns. The results are intended to be used as a + * first pass only filter. Followed by testing against the original glob/root pair. + * @param glob - glob to map + * @param root - new root to use if possible + * @param path - Node Path modules to use (testing only) + */ +export declare function normalizeGlobToRoot(glob: Glob, root: string, path: PathInterface): Glob; +/** + * Rebase a glob string to a new prefix + * @param glob - glob string + * @param rebaseTo - glob prefix + */ +declare function rebaseGlob(glob: string, rebaseTo: string): string | undefined; +/** + * Trims any trailing spaces, tabs, line-feeds, new-lines, and comments + * @param glob - glob string + * @returns trimmed glob + */ +declare function trimGlob(glob: string): string; +declare function isGlobalGlob(glob: string): boolean; +export declare const __testing__: { + rebaseGlob: typeof rebaseGlob; + trimGlob: typeof trimGlob; + isGlobalGlob: typeof isGlobalGlob; +}; +export {}; +//# sourceMappingURL=globHelper.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-glob/dist/esm/globHelper.mjs b/action/node_modules/cspell-glob/dist/esm/globHelper.mjs new file mode 100644 index 000000000..dc13f1770 --- /dev/null +++ b/action/node_modules/cspell-glob/dist/esm/globHelper.mjs @@ -0,0 +1,257 @@ +/* eslint-disable no-irregular-whitespace */ +import * as Path from 'path'; +const { posix } = Path; +const relRegExp = /^\.[\\/]/; +/** test for glob patterns starting with `**` */ +const isGlobalPatternRegExp = /^!*[*]{2}/; +/** + * This function tries its best to determine if `fileOrGlob` is a path to a file or a glob pattern. + * @param fileOrGlob - file (with absolute path) or glob. + * @param root - absolute path to the directory that will be considered the root when testing the glob pattern. + * @param path - optional node path methods - used for testing + */ +export function fileOrGlobToGlob(fileOrGlob, root, path = Path) { + const pathToGlob = path.sep === '\\' ? (p) => p.replace(/\\/g, '/') : (p) => p; + const isGlobalPattern = false; + if (isGlobPatternWithOptionalRoot(fileOrGlob)) { + const useRoot = fileOrGlob.root ?? root; + const isGlobalPattern = isGlobPatternWithRoot(fileOrGlob) + ? fileOrGlob.isGlobalPattern + : isGlobalGlob(fileOrGlob.glob); + return { ...fileOrGlob, root: useRoot, isGlobalPattern }; + } + if (doesRootContainPath(root, fileOrGlob, path) || relRegExp.test(fileOrGlob)) { + const rel = path.relative(root, path.resolve(root, fileOrGlob)); + return { glob: pathToGlob(rel), root, isGlobalPattern }; + } + return { glob: pathToGlob(fileOrGlob), root, isGlobalPattern }; +} +/** + * Decide if a childPath is contained within a root or at the same level. + * @param root - absolute path + * @param childPath - absolute path + */ +export function doesRootContainPath(root, child, path) { + if (child.startsWith(root)) + return true; + const rel = path.relative(root, child); + return !rel || (rel !== child && !rel.startsWith('..') && !path.isAbsolute(rel)); +} +export function isGlobPatternWithOptionalRoot(g) { + return typeof g !== 'string' && typeof g.glob === 'string'; +} +export function isGlobPatternWithRoot(g) { + return typeof g.root === 'string' && 'isGlobalPattern' in g; +} +export function isGlobPatternNormalized(g) { + if (!isGlobPatternWithOptionalRoot(g)) + return false; + if (!isGlobPatternWithRoot(g)) + return false; + const gr = g; + return 'rawGlob' in gr && 'rawRoot' in gr && typeof gr.rawGlob === 'string'; +} +/** + * @param pattern glob pattern + * @param nested when true add `**​//​**` + * @returns the set of matching globs. + */ +function normalizePattern(pattern, nested) { + pattern = pattern.replace(/^(!!)+/, ''); + const isNeg = pattern.startsWith('!'); + const prefix = isNeg ? '!' : ''; + pattern = isNeg ? pattern.slice(1) : pattern; + const patterns = nested ? normalizePatternNested(pattern) : normalizePatternGeneral(pattern); + return patterns.map((p) => prefix + p); +} +function normalizePatternNested(pattern) { + // no slashes will match files names or folders + if (!pattern.includes('/')) { + if (pattern === '**') + return ['**']; + return ['**/' + pattern, '**/' + pattern + '/**']; + } + const hasLeadingSlash = pattern.startsWith('/'); + pattern = hasLeadingSlash ? pattern.slice(1) : pattern; + if (pattern.endsWith('/')) { + // legacy behavior, if it only has a trailing slash, allow matching against a nested directory. + return hasLeadingSlash || pattern.slice(0, -1).includes('/') ? [pattern + '**/*'] : ['**/' + pattern + '**/*']; + } + if (pattern.endsWith('**')) { + return [pattern]; + } + return [pattern, pattern + '/**']; +} +function normalizePatternGeneral(pattern) { + pattern = pattern.startsWith('/') ? pattern.slice(1) : pattern; + pattern = pattern.endsWith('/') ? pattern + '**/*' : pattern; + return [pattern]; +} +/** + * + * @param patterns - glob patterns to normalize. + * @param options - Normalization options. + */ +export function normalizeGlobPatterns(patterns, options) { + function* normalize() { + for (const glob of patterns) { + if (isGlobPatternNormalized(glob)) { + yield glob; + continue; + } + yield* normalizeGlobPattern(glob, options); + } + } + return [...normalize()]; +} +export function normalizeGlobPattern(g, options) { + const { root, nodePath: path = Path, nested, cwd = Path.resolve() } = options; + g = !isGlobPatternWithOptionalRoot(g) ? { glob: g } : g; + const gr = { ...g, root: g.root ?? root }; + const rawRoot = gr.root; + const rawGlob = g.glob; + gr.glob = gr.glob.trim(); // trimGlob(g.glob); + if (gr.glob.startsWith('${cwd}')) { + gr.glob = gr.glob.replace('${cwd}', ''); + gr.root = '${cwd}'; + } + if (gr.root.startsWith('${cwd}')) { + gr.root = path.resolve(gr.root.replace('${cwd}', cwd)); + } + const isGlobalPattern = isGlobalGlob(gr.glob); + gr.root = path.resolve(root, path.normalize(gr.root)); + const globs = normalizePattern(gr.glob, nested); + return globs.map((glob) => ({ ...gr, glob, rawGlob, rawRoot, isGlobalPattern })); +} +/** + * Try to adjust the root of a glob to match a new root. If it is not possible, the original glob is returned. + * Note: this does NOT generate absolutely correct glob patterns. The results are intended to be used as a + * first pass only filter. Followed by testing against the original glob/root pair. + * @param glob - glob to map + * @param root - new root to use if possible + * @param path - Node Path modules to use (testing only) + */ +export function normalizeGlobToRoot(glob, root, path) { + function relToGlob(relativePath) { + return path.sep === '\\' ? relativePath.replace(/\\/g, '/') : relativePath; + } + if (glob.root === root) { + return glob; + } + const relFromRootToGlob = path.relative(root, glob.root); + if (!relFromRootToGlob) { + return glob; + } + if (glob.isGlobalPattern) { + return { ...glob, root }; + } + const relFromGlobToRoot = path.relative(glob.root, root); + const globIsUnderRoot = relFromRootToGlob[0] !== '.' && !path.isAbsolute(relFromRootToGlob); + const rootIsUnderGlob = relFromGlobToRoot[0] !== '.' && !path.isAbsolute(relFromGlobToRoot); + // Root and Glob are not in the same part of the directory tree. + if (!globIsUnderRoot && !rootIsUnderGlob) { + return glob; + } + const isNeg = glob.glob.startsWith('!'); + const g = isNeg ? glob.glob.slice(1) : glob.glob; + const prefix = isNeg ? '!' : ''; + // prefix with root + if (globIsUnderRoot) { + const relGlob = relToGlob(relFromRootToGlob); + return { + ...glob, + glob: prefix + posix.join(relGlob, g), + root, + }; + } + // The root is under the glob root + // The more difficult case, the glob is higher than the root + // A best effort is made, but does not do advanced matching. + const relGlob = relToGlob(relFromGlobToRoot) + '/'; + const rebasedGlob = rebaseGlob(g, relGlob); + return rebasedGlob ? { ...glob, glob: prefix + rebasedGlob, root } : glob; +} +/** + * Rebase a glob string to a new prefix + * @param glob - glob string + * @param rebaseTo - glob prefix + */ +function rebaseGlob(glob, rebaseTo) { + if (!rebaseTo || rebaseTo === '/') + return glob; + if (glob.startsWith('**')) + return glob; + rebaseTo = rebaseTo.endsWith('/') ? rebaseTo : rebaseTo + '/'; + if (glob.startsWith(rebaseTo)) { + return glob.slice(rebaseTo.length); + } + const relParts = rebaseTo.split('/'); + const globParts = glob.split('/'); + for (let i = 0; i < relParts.length && i < globParts.length; ++i) { + const relSeg = relParts[i]; + const globSeg = globParts[i]; + // the empty segment due to the end relGlob / allows for us to test against an empty segment. + if (!relSeg || globSeg === '**') { + return globParts.slice(i).join('/'); + } + if (relSeg !== globSeg && globSeg !== '*') { + break; + } + } + return undefined; +} +/** + * Trims any trailing spaces, tabs, line-feeds, new-lines, and comments + * @param glob - glob string + * @returns trimmed glob + */ +function trimGlob(glob) { + glob = glob.replace(/(? + * @param glob - glob string + * @returns glob string with space to the right removed. + */ +function trimGlobRight(glob) { + const lenMin1 = glob.length - 1; + let i = lenMin1; + while (i >= 0 && glob[i] in spaces) { + --i; + } + if (glob[i] === '\\' && i < lenMin1) { + ++i; + } + ++i; + return i ? glob.slice(0, i) : ''; +} +/** + * Trim any leading spaces, tabs, line-feeds, or new-lines + * @param glob - any string + * @returns string with leading spaces removed. + */ +function trimGlobLeft(glob) { + let i = 0; + while (i < glob.length && glob[i] in spaces) { + ++i; + } + return glob.slice(i); +} +function isGlobalGlob(glob) { + return isGlobalPatternRegExp.test(glob); +} +export const __testing__ = { + rebaseGlob, + trimGlob, + isGlobalGlob, +}; diff --git a/action/node_modules/cspell-glob/dist/esm/index.d.mts b/action/node_modules/cspell-glob/dist/esm/index.d.mts new file mode 100644 index 000000000..c5380fb8a --- /dev/null +++ b/action/node_modules/cspell-glob/dist/esm/index.d.mts @@ -0,0 +1,4 @@ +export { fileOrGlobToGlob, isGlobPatternNormalized, isGlobPatternWithOptionalRoot, isGlobPatternWithRoot, normalizeGlobPatterns, NormalizeOptions, } from './globHelper.mjs'; +export { GlobMatcher, GlobMatchOptions } from './GlobMatcher.mjs'; +export * from './GlobMatcherTypes.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-glob/dist/esm/index.mjs b/action/node_modules/cspell-glob/dist/esm/index.mjs new file mode 100644 index 000000000..15de915e7 --- /dev/null +++ b/action/node_modules/cspell-glob/dist/esm/index.mjs @@ -0,0 +1,3 @@ +export { fileOrGlobToGlob, isGlobPatternNormalized, isGlobPatternWithOptionalRoot, isGlobPatternWithRoot, normalizeGlobPatterns, } from './globHelper.mjs'; +export { GlobMatcher } from './GlobMatcher.mjs'; +export * from './GlobMatcherTypes.mjs'; diff --git a/action/node_modules/cspell-glob/package.json b/action/node_modules/cspell-glob/package.json index 69813c851..cbdf344bf 100644 --- a/action/node_modules/cspell-glob/package.json +++ b/action/node_modules/cspell-glob/package.json @@ -1,6 +1,6 @@ { "name": "cspell-glob", - "version": "6.28.0", + "version": "6.29.1", "description": "Glob matcher for cspell", "keywords": [ "cspell", @@ -9,27 +9,39 @@ "author": "Jason Dent ", "homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-glob#readme", "license": "MIT", - "main": "dist/index.js", - "directories": { - "dist": "dist" + "type": "commonjs", + "main": "dist/cjs/index.js", + "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.mjs", + "exports": { + ".": { + "import": "./dist/esm/index.mjs", + "require": "./dist/cjs/index.js" + } }, - "typings": "dist/index.d.ts", "files": [ + "bin.mjs", "dist", + "!dist/esm/**/*.js", + "!dist/esm/**/*.ts", "!**/*.tsbuildInfo", "!**/__mocks__", + "!**/test/**", "!**/*.test.*", "!**/*.spec.*", "!**/*.map" ], "scripts": { - "build": "tsc -p .", - "watch": "tsc -p . -w", "clean": "shx rm -rf dist coverage .tsbuildinfo", + "build": "tsc -b . && ts2mjs dist/esm", + "build:esm": "tsc -p tsconfig.esm.json", "clean-build": "pnpm run clean && pnpm run build", - "coverage": "jest --coverage", - "test-watch": "jest --watch", - "test": "jest" + "coverage": "pnpm coverage:vitest && pnpm coverage:fix", + "coverage:vitest": "vitest run --coverage", + "coverage:fix": "nyc report --temp-dir \"$(pwd)/coverage\" --reporter lcov --report-dir \"$(pwd)/coverage\" --cwd ../..", + "test:watch": "vitest", + "test": "vitest run", + "watch": "tsc -b . -w" }, "repository": { "type": "git", @@ -46,7 +58,7 @@ }, "devDependencies": { "@types/micromatch": "^4.0.2", - "jest": "^29.4.3" + "jest": "^29.5.0" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/cspell-grammar/bin.js b/action/node_modules/cspell-grammar/bin.js deleted file mode 100755 index 302af0b0d..000000000 --- a/action/node_modules/cspell-grammar/bin.js +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env node -'use strict'; - -const app = require('./dist/app.js'); - -app.run(process.argv); diff --git a/action/node_modules/cspell-grammar/bin.mjs b/action/node_modules/cspell-grammar/bin.mjs new file mode 100755 index 000000000..1ca5d19c3 --- /dev/null +++ b/action/node_modules/cspell-grammar/bin.mjs @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +import * as app from './dist/esm/app.mjs'; + +app.run(process.argv); diff --git a/action/node_modules/cspell-grammar/dist/app.js b/action/node_modules/cspell-grammar/dist/cjs/app.js similarity index 96% rename from action/node_modules/cspell-grammar/dist/app.js rename to action/node_modules/cspell-grammar/dist/cjs/app.js index 92ee991e8..6a68e1fff 100644 --- a/action/node_modules/cspell-grammar/dist/app.js +++ b/action/node_modules/cspell-grammar/dist/cjs/app.js @@ -26,9 +26,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.run = void 0; const fs_1 = require("fs"); const path = __importStar(require("path")); -const typescript_1 = require("./parsers/typescript"); +const index_js_1 = require("./parsers/typescript/index.js"); const parsers = { - '.ts': typescript_1.parser, + '.ts': index_js_1.parser, }; /** * Run simple parser diff --git a/action/node_modules/cspell-grammar/dist/grammars/index.js b/action/node_modules/cspell-grammar/dist/cjs/grammars/index.js similarity index 90% rename from action/node_modules/cspell-grammar/dist/grammars/index.js rename to action/node_modules/cspell-grammar/dist/cjs/grammars/index.js index 67b0f8724..d38c199a9 100644 --- a/action/node_modules/cspell-grammar/dist/grammars/index.js +++ b/action/node_modules/cspell-grammar/dist/cjs/grammars/index.js @@ -24,6 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TypeScript = exports.Markdown = void 0; -exports.Markdown = __importStar(require("./markdown")); -exports.TypeScript = __importStar(require("./typescript")); +exports.Markdown = __importStar(require("./markdown.js")); +exports.TypeScript = __importStar(require("./typescript.js")); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/grammars/markdown.js b/action/node_modules/cspell-grammar/dist/cjs/grammars/markdown.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/grammars/markdown.js rename to action/node_modules/cspell-grammar/dist/cjs/grammars/markdown.js diff --git a/action/node_modules/cspell-grammar/dist/grammars/simple.js b/action/node_modules/cspell-grammar/dist/cjs/grammars/simple.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/grammars/simple.js rename to action/node_modules/cspell-grammar/dist/cjs/grammars/simple.js diff --git a/action/node_modules/cspell-grammar/dist/grammars/typescript.js b/action/node_modules/cspell-grammar/dist/cjs/grammars/typescript.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/grammars/typescript.js rename to action/node_modules/cspell-grammar/dist/cjs/grammars/typescript.js diff --git a/action/node_modules/cspell-grammar/dist/index.js b/action/node_modules/cspell-grammar/dist/cjs/index.js similarity index 58% rename from action/node_modules/cspell-grammar/dist/index.js rename to action/node_modules/cspell-grammar/dist/cjs/index.js index 04038f01b..41476b75a 100644 --- a/action/node_modules/cspell-grammar/dist/index.js +++ b/action/node_modules/cspell-grammar/dist/cjs/index.js @@ -1,10 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parsers = exports.tokenizeText = exports.tokenizeLine = exports.compileGrammar = void 0; -var parser_1 = require("./parser"); -Object.defineProperty(exports, "compileGrammar", { enumerable: true, get: function () { return parser_1.compileGrammar; } }); -Object.defineProperty(exports, "tokenizeLine", { enumerable: true, get: function () { return parser_1.tokenizeLine; } }); -Object.defineProperty(exports, "tokenizeText", { enumerable: true, get: function () { return parser_1.tokenizeText; } }); -var parsers_1 = require("./parsers"); -Object.defineProperty(exports, "parsers", { enumerable: true, get: function () { return parsers_1.parsers; } }); +var index_js_1 = require("./parser/index.js"); +Object.defineProperty(exports, "compileGrammar", { enumerable: true, get: function () { return index_js_1.compileGrammar; } }); +Object.defineProperty(exports, "tokenizeLine", { enumerable: true, get: function () { return index_js_1.tokenizeLine; } }); +Object.defineProperty(exports, "tokenizeText", { enumerable: true, get: function () { return index_js_1.tokenizeText; } }); +var index_js_2 = require("./parsers/index.js"); +Object.defineProperty(exports, "parsers", { enumerable: true, get: function () { return index_js_2.parsers; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/mappers/appendMappedText.js b/action/node_modules/cspell-grammar/dist/cjs/mappers/appendMappedText.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/mappers/appendMappedText.js rename to action/node_modules/cspell-grammar/dist/cjs/mappers/appendMappedText.js diff --git a/action/node_modules/cspell-grammar/dist/mappers/types.js b/action/node_modules/cspell-grammar/dist/cjs/mappers/types.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/mappers/types.js rename to action/node_modules/cspell-grammar/dist/cjs/mappers/types.js diff --git a/action/node_modules/cspell-grammar/dist/mappers/typescript.js b/action/node_modules/cspell-grammar/dist/cjs/mappers/typescript.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/mappers/typescript.js rename to action/node_modules/cspell-grammar/dist/cjs/mappers/typescript.js diff --git a/action/node_modules/cspell-grammar/dist/parser/grammar.js b/action/node_modules/cspell-grammar/dist/cjs/parser/grammar.js similarity index 62% rename from action/node_modules/cspell-grammar/dist/parser/grammar.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/grammar.js index 952c21215..45cf58dd1 100644 --- a/action/node_modules/cspell-grammar/dist/parser/grammar.js +++ b/action/node_modules/cspell-grammar/dist/cjs/parser/grammar.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.compileGrammar = void 0; -const grammarNormalizer_1 = require("./grammarNormalizer"); +const grammarNormalizer_js_1 = require("./grammarNormalizer.js"); function compileGrammar(grammar) { - return (0, grammarNormalizer_1.normalizeGrammar)(grammar); + return (0, grammarNormalizer_js_1.normalizeGrammar)(grammar); } exports.compileGrammar = compileGrammar; //# sourceMappingURL=grammar.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/parser/grammarDefinition.js b/action/node_modules/cspell-grammar/dist/cjs/parser/grammarDefinition.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/parser/grammarDefinition.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/grammarDefinition.js diff --git a/action/node_modules/cspell-grammar/dist/parser/grammarNormalized.js b/action/node_modules/cspell-grammar/dist/cjs/parser/grammarNormalized.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/parser/grammarNormalized.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/grammarNormalized.js diff --git a/action/node_modules/cspell-grammar/dist/parser/grammarNormalizer.js b/action/node_modules/cspell-grammar/dist/cjs/parser/grammarNormalizer.js similarity index 91% rename from action/node_modules/cspell-grammar/dist/parser/grammarNormalizer.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/grammarNormalizer.js index e54dc7661..a0d84a078 100644 --- a/action/node_modules/cspell-grammar/dist/parser/grammarNormalizer.js +++ b/action/node_modules/cspell-grammar/dist/cjs/parser/grammarNormalizer.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractScope = exports.nPattern = exports.normalizeGrammar = void 0; -const grammarTypesHelpers_1 = require("./grammarTypesHelpers"); -const matchResult_1 = require("./matchResult"); -const scope_1 = require("./scope"); +const grammarTypesHelpers_js_1 = require("./grammarTypesHelpers.js"); +const matchResult_js_1 = require("./matchResult.js"); +const scope_js_1 = require("./scope.js"); function normalizeGrammar(grammar) { return new ImplNGrammar(grammar); } @@ -13,13 +13,13 @@ const SpecialRepositoryReferences = { $base: true, }; function nPattern(p) { - if ((0, grammarTypesHelpers_1.isPatternMatch)(p)) + if ((0, grammarTypesHelpers_js_1.isPatternMatch)(p)) return normalizePatternMatch(p); - if ((0, grammarTypesHelpers_1.isPatternBeginEnd)(p)) + if ((0, grammarTypesHelpers_js_1.isPatternBeginEnd)(p)) return normalizePatternBeginEnd(p); - if ((0, grammarTypesHelpers_1.isPatternInclude)(p)) + if ((0, grammarTypesHelpers_js_1.isPatternInclude)(p)) return normalizePatternInclude(p); - if ((0, grammarTypesHelpers_1.isPatternPatterns)(p)) + if ((0, grammarTypesHelpers_js_1.isPatternPatterns)(p)) return normalizePatternsPatterns(p); return normalizePatternName(p); } @@ -77,7 +77,7 @@ function normalizePatternName(p) { function findMatch(line, parentRule) { const rule = factoryRule(parentRule, self); const input = line.text.slice(line.offset); - const match = (0, matchResult_1.createSimpleMatchResult)(input, input, line.offset, line.lineNumber); + const match = (0, matchResult_js_1.createSimpleMatchResult)(input, input, line.offset, line.lineNumber); return { rule, match, line }; } return self; @@ -186,7 +186,7 @@ function matchString(s) { const index = input.indexOf(s, line.offset); if (index < 0) return undefined; - return (0, matchResult_1.createSimpleMatchResult)(s, input, index, line.lineNumber); + return (0, matchResult_js_1.createSimpleMatchResult)(s, input, index, line.lineNumber); }; } function matchRegExp(r) { @@ -194,7 +194,7 @@ function matchRegExp(r) { const rg = RegExp(r, 'gm'); rg.lastIndex = line.offset; const m = rg.exec(line.text); - return (m && (0, matchResult_1.createMatchResult)(m, line.lineNumber)) ?? undefined; + return (m && (0, matchResult_js_1.createMatchResult)(m, line.lineNumber)) ?? undefined; }; } function extractScope(er, isContent = true) { @@ -227,7 +227,7 @@ class ImplNGrammar { this.patterns = self.patterns; this.repository = repository; this.self = self; - this.scopePool = new scope_1.ScopePool(); + this.scopePool = new scope_js_1.ScopePool(); } begin(parentRule) { const patterns = this.patterns; diff --git a/action/node_modules/cspell-grammar/dist/parser/grammarTypesHelpers.js b/action/node_modules/cspell-grammar/dist/cjs/parser/grammarTypesHelpers.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/parser/grammarTypesHelpers.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/grammarTypesHelpers.js diff --git a/action/node_modules/cspell-grammar/dist/parser/index.js b/action/node_modules/cspell-grammar/dist/cjs/parser/index.js similarity index 56% rename from action/node_modules/cspell-grammar/dist/parser/index.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/index.js index 5e0be9434..d023c8c6d 100644 --- a/action/node_modules/cspell-grammar/dist/parser/index.js +++ b/action/node_modules/cspell-grammar/dist/cjs/parser/index.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tokenizeText = exports.tokenizeLine = exports.compileGrammar = void 0; -var grammar_1 = require("./grammar"); -Object.defineProperty(exports, "compileGrammar", { enumerable: true, get: function () { return grammar_1.compileGrammar; } }); -var tokenizeLine_1 = require("./tokenizeLine"); -Object.defineProperty(exports, "tokenizeLine", { enumerable: true, get: function () { return tokenizeLine_1.tokenizeLine; } }); -Object.defineProperty(exports, "tokenizeText", { enumerable: true, get: function () { return tokenizeLine_1.tokenizeText; } }); +var grammar_js_1 = require("./grammar.js"); +Object.defineProperty(exports, "compileGrammar", { enumerable: true, get: function () { return grammar_js_1.compileGrammar; } }); +var tokenizeLine_js_1 = require("./tokenizeLine.js"); +Object.defineProperty(exports, "tokenizeLine", { enumerable: true, get: function () { return tokenizeLine_js_1.tokenizeLine; } }); +Object.defineProperty(exports, "tokenizeText", { enumerable: true, get: function () { return tokenizeLine_js_1.tokenizeText; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/parser/matchResult.js b/action/node_modules/cspell-grammar/dist/cjs/parser/matchResult.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/parser/matchResult.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/matchResult.js diff --git a/action/node_modules/cspell-grammar/dist/parser/parser.js b/action/node_modules/cspell-grammar/dist/cjs/parser/parser.js similarity index 84% rename from action/node_modules/cspell-grammar/dist/parser/parser.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/parser.js index d44663572..0355e0392 100644 --- a/action/node_modules/cspell-grammar/dist/parser/parser.js +++ b/action/node_modules/cspell-grammar/dist/cjs/parser/parser.js @@ -2,9 +2,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.createParser = exports.parseDocument = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); -const tokenizeLine_1 = require("./tokenizeLine"); +const tokenizeLine_js_1 = require("./tokenizeLine.js"); function parseDocument(grammar, _filename, content, emitter = (line) => console.log(line)) { - const r = (0, tokenizeLine_1.tokenizeText)(content, grammar); + const r = (0, tokenizeLine_js_1.tokenizeText)(content, grammar); const tokens = (0, sync_1.pipe)(r, (0, sync_1.opMap)((tl) => tl.tokens.map((t) => ({ t, l: tl.line }))), (0, sync_1.opFlatten)(), (0, sync_1.opFilter)((t) => !t.t.scope.value.startsWith('punctuation'))); for (const { t: token, l: line } of tokens) { emitter(`${(token.range[2] ?? line.lineNumber) + 1}:${token.range[0] + 1}\t ${JSON.stringify(token.text)}\t ${token.scope.toString()}`); @@ -23,7 +23,7 @@ function mapTokenizedLines(itl) { } function createParser(grammar, name, transform = mapTokenizedLines) { function parse(content, filename) { - const parsedTexts = (0, sync_1.pipe)((0, tokenizeLine_1.tokenizeTextIterable)(content, grammar), transform); + const parsedTexts = (0, sync_1.pipe)((0, tokenizeLine_js_1.tokenizeTextIterable)(content, grammar), transform); return { content, filename, parsedTexts }; } return { name, parse }; diff --git a/action/node_modules/cspell-grammar/dist/parser/processors/procMatchingRule.js b/action/node_modules/cspell-grammar/dist/cjs/parser/processors/procMatchingRule.js similarity index 92% rename from action/node_modules/cspell-grammar/dist/parser/processors/procMatchingRule.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/processors/procMatchingRule.js index 09ea1564a..a06289006 100644 --- a/action/node_modules/cspell-grammar/dist/parser/processors/procMatchingRule.js +++ b/action/node_modules/cspell-grammar/dist/cjs/parser/processors/procMatchingRule.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.applyCaptures = exports.applyCaptureToEnd = exports.applyCaptureToBeginOrMatch = void 0; -const grammarNormalizer_1 = require("../grammarNormalizer"); -const matchResult_1 = require("../matchResult"); -const util_1 = require("../util"); +const grammarNormalizer_js_1 = require("../grammarNormalizer.js"); +const matchResult_js_1 = require("../matchResult.js"); +const util_js_1 = require("../util.js"); /** * Apply the scopes to the line * @param line - line of text @@ -34,7 +34,7 @@ exports.applyCaptureToEnd = applyCaptureToEnd; * @param rule - the matching rule */ function applyCaptures(rule, match, captures) { - const scope = (0, grammarNormalizer_1.extractScope)(rule, false); + const scope = (0, grammarNormalizer_js_1.extractScope)(rule, false); const pool = rule.grammar.scopePool; const text = match.match; const input = match.input; @@ -79,7 +79,7 @@ function applyCaptures(rule, match, captures) { match: text, }; } - const segments = (0, matchResult_1.segmentMatch)(match).map(trimSegment).filter(util_1.isDefined); + const segments = (0, matchResult_js_1.segmentMatch)(match).map(trimSegment).filter(util_js_1.isDefined); function processSegments(segments) { const base = segments[0]; const root = { @@ -132,7 +132,7 @@ function applyCaptures(rule, match, captures) { } const scopeValues = [..._chain(chain)] .map((cap) => captureScopes.get(cap)) - .filter(util_1.isDefined) + .filter(util_js_1.isDefined) .reverse(); return scopeValues.reduce((s, v) => pool.getScope(v, s), scope); } diff --git a/action/node_modules/cspell-grammar/dist/parser/scope.js b/action/node_modules/cspell-grammar/dist/cjs/parser/scope.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/parser/scope.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/scope.js diff --git a/action/node_modules/cspell-grammar/dist/parser/tokenizeLine.js b/action/node_modules/cspell-grammar/dist/cjs/parser/tokenizeLine.js similarity index 91% rename from action/node_modules/cspell-grammar/dist/parser/tokenizeLine.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/tokenizeLine.js index 890c5b665..1d6b5d291 100644 --- a/action/node_modules/cspell-grammar/dist/parser/tokenizeLine.js +++ b/action/node_modules/cspell-grammar/dist/cjs/parser/tokenizeLine.js @@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.tokenizeTextIterable = exports.tokenizeText = exports.tokenizeLine = void 0; const assert_1 = __importDefault(require("assert")); -const grammarNormalizer_1 = require("./grammarNormalizer"); -const procMatchingRule_1 = require("./processors/procMatchingRule"); +const grammarNormalizer_js_1 = require("./grammarNormalizer.js"); +const procMatchingRule_js_1 = require("./processors/procMatchingRule.js"); function tokenizeLine(line, rule) { const text = line.text; const lineLen = line.text.length; @@ -18,7 +18,7 @@ function tokenizeLine(line, rule) { // We are at an end let endMatch = ctx.rule.end?.(ctx.line); while (endMatch?.index === ctx.line.offset) { - parsedText.push(...(0, procMatchingRule_1.applyCaptureToEnd)(ctx.rule, endMatch)); + parsedText.push(...(0, procMatchingRule_js_1.applyCaptureToEnd)(ctx.rule, endMatch)); ctx = findParentWithEnd(ctx); ctx.line.offset = endMatch.index + endMatch.match.length; endMatch = ctx.rule.end?.(ctx.line); @@ -31,7 +31,7 @@ function tokenizeLine(line, rule) { const limit = endMatch?.index ?? lineLen; const emitTil = match ? Math.min(match.match.index, limit) : limit; if (offset < emitTil) { - const scope = (0, grammarNormalizer_1.extractScope)(rule); + const scope = (0, grammarNormalizer_js_1.extractScope)(rule); const start = offset; const end = emitTil; parsedText.push({ @@ -45,7 +45,7 @@ function tokenizeLine(line, rule) { continue; // We are at an end, process it at the beginning of the loop. } // Process the beginning of the match - parsedText.push(...(0, procMatchingRule_1.applyCaptureToBeginOrMatch)(match)); + parsedText.push(...(0, procMatchingRule_js_1.applyCaptureToBeginOrMatch)(match)); line.anchor = match.match.index + match.match.match.length; line.offset = line.anchor; ctx = findNearestWithEnd(buildContext(line, match.rule)); diff --git a/action/node_modules/cspell-grammar/dist/parser/types.js b/action/node_modules/cspell-grammar/dist/cjs/parser/types.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/parser/types.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/types.js diff --git a/action/node_modules/cspell-grammar/dist/parser/util.js b/action/node_modules/cspell-grammar/dist/cjs/parser/util.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/parser/util.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/util.js diff --git a/action/node_modules/cspell-grammar/dist/parser/validateGrammar.js b/action/node_modules/cspell-grammar/dist/cjs/parser/validateGrammar.js similarity index 78% rename from action/node_modules/cspell-grammar/dist/parser/validateGrammar.js rename to action/node_modules/cspell-grammar/dist/cjs/parser/validateGrammar.js index f45420ac3..6b8b48d5b 100644 --- a/action/node_modules/cspell-grammar/dist/parser/validateGrammar.js +++ b/action/node_modules/cspell-grammar/dist/cjs/parser/validateGrammar.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.validateRepository = exports.validateGrammarRepository = exports.validatePattern = exports.validatePatterns = exports.validate = void 0; const assert_1 = require("assert"); const util_1 = require("util"); -const grammarTypesHelpers_1 = require("./grammarTypesHelpers"); +const grammarTypesHelpers_js_1 = require("./grammarTypesHelpers.js"); function validate(grammar) { (0, assert_1.strict)(grammar.scopeName); (0, assert_1.strict)(/^[\w.]*\.\w+$/.test(grammar.scopeName)); @@ -30,11 +30,11 @@ function validatePatternOrReference(pattern, context) { } } function validatePattern(pattern, context) { - (0, assert_1.strict)((0, grammarTypesHelpers_1.isPatternMatch)(pattern) || - (0, grammarTypesHelpers_1.isPatternBeginEnd)(pattern) || - (0, grammarTypesHelpers_1.isPatternInclude)(pattern) || - (0, grammarTypesHelpers_1.isPatternPatterns)(pattern), (0, util_1.format)('Unknown Pattern: %o', pattern)); - (0, assert_1.strict)(!((0, grammarTypesHelpers_1.isPatternBeginEnd)(pattern) && (0, grammarTypesHelpers_1.isPatternMatch)(pattern)), (0, util_1.format)('Pattern must be a Match pattern or a Begin/End pattern, but not both: %o', pattern)); + (0, assert_1.strict)((0, grammarTypesHelpers_js_1.isPatternMatch)(pattern) || + (0, grammarTypesHelpers_js_1.isPatternBeginEnd)(pattern) || + (0, grammarTypesHelpers_js_1.isPatternInclude)(pattern) || + (0, grammarTypesHelpers_js_1.isPatternPatterns)(pattern), (0, util_1.format)('Unknown Pattern: %o', pattern)); + (0, assert_1.strict)(!((0, grammarTypesHelpers_js_1.isPatternBeginEnd)(pattern) && (0, grammarTypesHelpers_js_1.isPatternMatch)(pattern)), (0, util_1.format)('Pattern must be a Match pattern or a Begin/End pattern, but not both: %o', pattern)); validatePatternName(pattern, context); } exports.validatePattern = validatePattern; diff --git a/action/node_modules/cspell-grammar/dist/parsers/index.js b/action/node_modules/cspell-grammar/dist/cjs/parsers/index.js similarity index 59% rename from action/node_modules/cspell-grammar/dist/parsers/index.js rename to action/node_modules/cspell-grammar/dist/cjs/parsers/index.js index 39f809b5a..c228bcd1a 100644 --- a/action/node_modules/cspell-grammar/dist/parsers/index.js +++ b/action/node_modules/cspell-grammar/dist/cjs/parsers/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parsers = void 0; -const typescript_1 = require("./typescript"); -exports.parsers = [typescript_1.parser]; +const index_js_1 = require("./typescript/index.js"); +exports.parsers = [index_js_1.parser]; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/parsers/typescript/TypeScriptParser.js b/action/node_modules/cspell-grammar/dist/cjs/parsers/typescript/TypeScriptParser.js similarity index 76% rename from action/node_modules/cspell-grammar/dist/parsers/typescript/TypeScriptParser.js rename to action/node_modules/cspell-grammar/dist/cjs/parsers/typescript/TypeScriptParser.js index 4e89f6f24..d53eddbbd 100644 --- a/action/node_modules/cspell-grammar/dist/parsers/typescript/TypeScriptParser.js +++ b/action/node_modules/cspell-grammar/dist/cjs/parsers/typescript/TypeScriptParser.js @@ -2,19 +2,19 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.parser = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); -const typescript_1 = require("../../grammars/typescript"); -const appendMappedText_1 = require("../../mappers/appendMappedText"); -const typescript_2 = require("../../mappers/typescript"); -const grammar_1 = require("../../parser/grammar"); -const parser_1 = require("../../parser/parser"); -const scope_1 = require("../../parser/scope"); -const tsGrammar = (0, grammar_1.compileGrammar)(typescript_1.grammar); -const pool = new scope_1.ScopePool(); +const typescript_js_1 = require("../../grammars/typescript.js"); +const appendMappedText_js_1 = require("../../mappers/appendMappedText.js"); +const typescript_js_2 = require("../../mappers/typescript.js"); +const grammar_js_1 = require("../../parser/grammar.js"); +const parser_js_1 = require("../../parser/parser.js"); +const scope_js_1 = require("../../parser/scope.js"); +const tsGrammar = (0, grammar_js_1.compileGrammar)(typescript_js_1.grammar); +const pool = new scope_js_1.ScopePool(); const useScope = new WeakMap(); function* transform(texts) { for (const parsed of texts) { if (doesScopeMatch(parsed.scope, 'constant.character.escape.ts')) { - const mapped = (0, typescript_2.mapRawString)(parsed.text); + const mapped = (0, typescript_js_2.mapRawString)(parsed.text); const scope = parsed.scope ? pool.parseScope(parsed.scope) : undefined; yield { text: mapped.text, @@ -53,7 +53,7 @@ function* mergeStringResults(results) { yield last; } function mergeParsedText(a, b) { - const abT = (0, appendMappedText_1.appendMappedText)(a, b); + const abT = (0, appendMappedText_js_1.appendMappedText)(a, b); const ab = { text: abT.text, scope: a.scope, @@ -84,7 +84,7 @@ function mapTokenizedLine(tl) { function mapTokenizedLines(itl) { return (0, sync_1.pipe)(itl, (0, sync_1.opMap)(mapTokenizedLine), (0, sync_1.opFlatten)(), transform, mergeStringResults); } -exports.parser = (0, parser_1.createParser)(tsGrammar, 'typescript', mapTokenizedLines); +exports.parser = (0, parser_js_1.createParser)(tsGrammar, 'typescript', mapTokenizedLines); function doesScopeMatch(s, match) { if (!s) return false; diff --git a/action/node_modules/cspell-grammar/dist/parsers/typescript/index.js b/action/node_modules/cspell-grammar/dist/cjs/parsers/typescript/index.js similarity index 62% rename from action/node_modules/cspell-grammar/dist/parsers/typescript/index.js rename to action/node_modules/cspell-grammar/dist/cjs/parsers/typescript/index.js index 6ef7ac71d..42fcb10dc 100644 --- a/action/node_modules/cspell-grammar/dist/parsers/typescript/index.js +++ b/action/node_modules/cspell-grammar/dist/cjs/parsers/typescript/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parser = void 0; -var TypeScriptParser_1 = require("./TypeScriptParser"); -Object.defineProperty(exports, "parser", { enumerable: true, get: function () { return TypeScriptParser_1.parser; } }); +var TypeScriptParser_js_1 = require("./TypeScriptParser.js"); +Object.defineProperty(exports, "parser", { enumerable: true, get: function () { return TypeScriptParser_js_1.parser; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/viewer/escapeMarkdown.js b/action/node_modules/cspell-grammar/dist/cjs/viewer/escapeMarkdown.js similarity index 100% rename from action/node_modules/cspell-grammar/dist/viewer/escapeMarkdown.js rename to action/node_modules/cspell-grammar/dist/cjs/viewer/escapeMarkdown.js diff --git a/action/node_modules/cspell-grammar/dist/viewer/markdownHelper.js b/action/node_modules/cspell-grammar/dist/cjs/viewer/markdownHelper.js similarity index 54% rename from action/node_modules/cspell-grammar/dist/viewer/markdownHelper.js rename to action/node_modules/cspell-grammar/dist/cjs/viewer/markdownHelper.js index eda9c7e44..c7709f239 100644 --- a/action/node_modules/cspell-grammar/dist/viewer/markdownHelper.js +++ b/action/node_modules/cspell-grammar/dist/cjs/viewer/markdownHelper.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toInlineCode = void 0; -const escapeMarkdown_1 = require("./escapeMarkdown"); +const escapeMarkdown_js_1 = require("./escapeMarkdown.js"); function toInlineCode(text) { - return `${(0, escapeMarkdown_1.escapeMarkdown)(text.replace(/\r/g, '↤').replace(/\n/g, '↩'))}`; + return `${(0, escapeMarkdown_js_1.escapeMarkdown)(text.replace(/\r/g, '↤').replace(/\n/g, '↩'))}`; } exports.toInlineCode = toInlineCode; //# sourceMappingURL=markdownHelper.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/viewer/visualizeAsMD.js b/action/node_modules/cspell-grammar/dist/cjs/viewer/visualizeAsMD.js similarity index 86% rename from action/node_modules/cspell-grammar/dist/viewer/visualizeAsMD.js rename to action/node_modules/cspell-grammar/dist/cjs/viewer/visualizeAsMD.js index ab45bebdb..c22dd50b6 100644 --- a/action/node_modules/cspell-grammar/dist/viewer/visualizeAsMD.js +++ b/action/node_modules/cspell-grammar/dist/cjs/viewer/visualizeAsMD.js @@ -1,22 +1,22 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tokenizedLinesToMarkdown = exports.tokenizedLineToMarkdown = exports._tokenizedLineToMarkdown = void 0; -const markdownHelper_1 = require("./markdownHelper"); +const markdownHelper_js_1 = require("./markdownHelper.js"); function _tokenizedLineToMarkdown(line, indentation = '') { const markdownLines = []; - const header = `- \`${line.line.lineNumber + 1}\`: ${(0, markdownHelper_1.toInlineCode)(line.line.text)} + const header = `- \`${line.line.lineNumber + 1}\`: ${(0, markdownHelper_js_1.toInlineCode)(line.line.text)} | text | scope | | --------- | -------------------------------------------------------- |`; markdownLines.push(...header.split('\n')); - markdownLines.push(...line.tokens.map((t) => ` | ${(0, markdownHelper_1.toInlineCode)(t.text)} | ${t.scope} |`)); + markdownLines.push(...line.tokens.map((t) => ` | ${(0, markdownHelper_js_1.toInlineCode)(t.text)} | ${t.scope} |`)); return markdownLines.map((line) => indentation + line).join('\n') + '\n\n'; } exports._tokenizedLineToMarkdown = _tokenizedLineToMarkdown; function tokenizedLineToMarkdown(line, indentation = '') { - const rows = line.tokens.map((t) => `| ${(0, markdownHelper_1.toInlineCode)(t.text)} | ${t.scope} |`); + const rows = line.tokens.map((t) => `| ${(0, markdownHelper_js_1.toInlineCode)(t.text)} | ${t.scope} |`); const detail = `
-${line.line.lineNumber + 1}: ${(0, markdownHelper_1.toInlineCode)(line.line.text)} +${line.line.lineNumber + 1}: ${(0, markdownHelper_js_1.toInlineCode)(line.line.text)} | text | scope | | --------- | -------------------------------------------------------- | diff --git a/action/node_modules/cspell-grammar/dist/esm/app.d.mts b/action/node_modules/cspell-grammar/dist/esm/app.d.mts new file mode 100644 index 000000000..1fa985f0d --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/app.d.mts @@ -0,0 +1,7 @@ +/** + * Run simple parser + * @param args -- command line arguments + * @returns Promise + */ +export declare function run(args: string[]): Promise; +//# sourceMappingURL=app.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/app.mjs b/action/node_modules/cspell-grammar/dist/esm/app.mjs new file mode 100644 index 000000000..02e1a7b2a --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/app.mjs @@ -0,0 +1,39 @@ +import { promises as fs } from 'fs'; +import * as path from 'path'; +import { parser as parserTypeScript } from './parsers/typescript/index.mjs'; +const parsers = { + '.ts': parserTypeScript, +}; +/** + * Run simple parser + * @param args -- command line arguments + * @returns Promise + */ +export async function run(args) { + // early out if there are not enough arguments + if (args.length < 3) { + console.log('usage...'); + return; + } + const filename = args.slice(2).filter((p) => !p.startsWith('-'))[0]; + if (!filename) { + console.log('filename missing'); + return; + } + const ext = path.extname(filename); + const parser = parsers[ext]; + if (!parser) { + console.log(`No parser for ${path.basename(filename)}`); + return; + } + console.log(`File: ${path.basename(filename)} Parser: ${parser.name}`); + const content = await fs.readFile(filename, 'utf-8'); + const result = parser.parse(content, filename); + for (const pt of result.parsedTexts) { + emit(pt); + } +} +function emit(pt) { + const t = pt.text.replace(/\t/g, '↦').replace(/\r?\n/g, '↩︎').replace(/\r/g, '⇠'); + console.log(`${pt.range[0]}-${pt.range[1]}\t${t}\t${pt.scope?.toString() || ''}`); +} diff --git a/action/node_modules/cspell-grammar/dist/esm/grammars/index.d.mts b/action/node_modules/cspell-grammar/dist/esm/grammars/index.d.mts new file mode 100644 index 000000000..c7924baf2 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/grammars/index.d.mts @@ -0,0 +1,3 @@ +export * as Markdown from './markdown.mjs'; +export * as TypeScript from './typescript.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/grammars/index.mjs b/action/node_modules/cspell-grammar/dist/esm/grammars/index.mjs new file mode 100644 index 000000000..ecf0d82c9 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/grammars/index.mjs @@ -0,0 +1,2 @@ +export * as Markdown from './markdown.mjs'; +export * as TypeScript from './typescript.mjs'; diff --git a/action/node_modules/cspell-grammar/dist/esm/grammars/markdown.d.mts b/action/node_modules/cspell-grammar/dist/esm/grammars/markdown.d.mts new file mode 100644 index 000000000..a98cd119e --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/grammars/markdown.d.mts @@ -0,0 +1,3 @@ +import type { GrammarDef } from '../parser/index.mjs'; +export declare const grammar: GrammarDef; +//# sourceMappingURL=markdown.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/grammars/markdown.mjs b/action/node_modules/cspell-grammar/dist/esm/grammars/markdown.mjs new file mode 100644 index 000000000..76584a8d7 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/grammars/markdown.mjs @@ -0,0 +1,32 @@ +const repository = { + frontMatter: { patterns: [] }, + block: { patterns: ['#raw'] }, + fenced_code_block: { + patterns: ['#fenced_code_block_unknown'], + }, + fenced_code_block_unknown: { + name: 'markup.fenced_code.block.markdown', + begin: /(^)(\s*)(`{3,}|~{3,})\s*(?=([^`~]*)?$)/, + beginCaptures: { + '3': 'punctuation.definition.markdown', + '4': 'fenced_code.block.language', + }, + // eslint-disable-next-line no-useless-backreference + end: /(^|\G)(\2|\s{0,3})(\3)\s*$/, + endCaptures: { + '3': 'punctuation.definition.markdown', + }, + }, + raw: { + name: 'markup.inline.raw.string.markdown', + captures: 'punctuation.definition.raw.markdown', + begin: /`+/, + end: '\\1', + }, +}; +export const grammar = { + name: 'Markdown', + scopeName: 'text.html.markdown', + patterns: ['#frontMatter', '#block'], + repository, +}; diff --git a/action/node_modules/cspell-grammar/dist/esm/grammars/simple.d.mts b/action/node_modules/cspell-grammar/dist/esm/grammars/simple.d.mts new file mode 100644 index 000000000..b8b1611d8 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/grammars/simple.d.mts @@ -0,0 +1,3 @@ +import type { GrammarDef } from '../parser/index.mjs'; +export declare const grammar: GrammarDef; +//# sourceMappingURL=simple.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/grammars/simple.mjs b/action/node_modules/cspell-grammar/dist/esm/grammars/simple.mjs new file mode 100644 index 000000000..7643453ed --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/grammars/simple.mjs @@ -0,0 +1,108 @@ +const repository = { + statements: { + patterns: ['#braces', '#comment', '#string'], + }, + braces: { + name: 'braces.s', + patterns: ['#braces_paren', '#braces_curly'], + }, + braces_paren: { + captures: 'paren.braces.s', + contentName: 'content.braces.s', + begin: '(', + end: ')', + patterns: ['$self'], + }, + braces_curly: { + captures: 'curly.braces.s', + contentName: 'content.braces.s', + begin: '{', + end: '}', + patterns: ['$self'], + }, + comment: { + patterns: ['#comment_line', '#comment_doc_block', '#comment_block'], + }, + comment_line: { + patterns: ['#comment_line_double_slash', '#comment_line_hash'], + }, + comment_line_hash: { + name: 'comment.line.s', + match: /(#).*\s?/, + captures: { + '1': 'punctuation.s', + }, + }, + comment_line_double_slash: { + name: 'comment.line.s', + match: /(\/\/).*\s?/, + captures: { + '1': 'punctuation.s', + }, + }, + comment_doc_block: { + name: 'comment.block.s', + begin: '/**', + end: '*/', + captures: { + '0': 'punctuation.s', + }, + }, + comment_block: { + name: 'comment.block.s', + begin: '/*', + end: '*/', + captures: { + '0': 'punctuation.s', + }, + }, + string: { + patterns: [{ include: '#string_q_single' }, { include: '#string_q_double' }, { include: '#string_template' }], + }, + string_q_single: { + name: 'string.quoted.single.s', + begin: "'", + end: /'|((?:[^\\\n])$)/, + patterns: [{ include: '#string_character_escape' }], + captures: { + '0': 'punctuation.s', + }, + }, + string_q_double: { + name: 'string.quoted.double.s', + begin: '"', + end: /"|((?:[^\\\n])$)/, + patterns: [{ include: '#string_character_escape' }], + captures: { + '0': 'punctuation.s', + }, + }, + string_template: { + name: 'string.template.s', + begin: '`', + end: '`', + patterns: [{ include: '#string_character_escape' }, '#template_embedded'], + captures: { + '0': 'punctuation.s', + }, + }, + string_character_escape: { + name: 'constant.character.escape.s', + match: /\\(x[0-9A-Fa-f]{2}|[0-3][0-7]{0,2}|[4-7][0-7]?|.|$)/, + }, + template_embedded: { + name: 'embedded.template.s', + begin: '${', + end: '}', + patterns: ['#statements'], + captures: { + '0': 'punctuation.s', + }, + }, +}; +export const grammar = { + name: 'Simple', + scopeName: 'source.s', + patterns: ['#statements'], + repository, +}; diff --git a/action/node_modules/cspell-grammar/dist/esm/grammars/typescript.d.mts b/action/node_modules/cspell-grammar/dist/esm/grammars/typescript.d.mts new file mode 100644 index 000000000..9d44fb051 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/grammars/typescript.d.mts @@ -0,0 +1,3 @@ +import type { GrammarDef } from '../parser/index.mjs'; +export declare const grammar: GrammarDef; +//# sourceMappingURL=typescript.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/grammars/typescript.mjs b/action/node_modules/cspell-grammar/dist/esm/grammars/typescript.mjs new file mode 100644 index 000000000..d3818a407 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/grammars/typescript.mjs @@ -0,0 +1,161 @@ +const repository = { + statements: { + name: 'code.ts', + patterns: [ + '#keyword', + '#regexp', + '#string', + '#comment', + '#braces', + '#punctuation', + '#space', + { name: 'identifier', match: /[^\s;,!|&:^%{}[\]()*/+=<>]+/ }, + ], + }, + keyword: { + patterns: ['#keywordBase', '#standardTypes', '#standardLib'], + }, + keywordBase: { + name: 'keyword.typescript.ts', + match: /\b(?:any|as|async|await|bigint|boolean|break|case|catch|const|continue|do|else|enum|export|extends|false|finally|for|from|function|get|if|implements|in|instanceof|interface|import|let|map|module|new|new|null|number|of|package|private|public|require|return|set|static|string|super|switch|this|throw|true|try|type|typeof|unknown|undefined|var|void|while|yield)\b/, + }, + standardTypes: { + name: 'keyword.type.ts', + match: /\b(?:Promise|Record|Omit|Extract|Exclude|BigInt|Array)\b/, + }, + standardLib: { + name: 'keyword.lib.ts', + match: /\b(?:console|process|window)\b/, + }, + string: { + patterns: ['#string_q_single', '#string_q_double', '#string_template'], + }, + string_q_single: { + name: 'string.quoted.single.ts', + begin: "'", + end: /'|((?:[^\\\n])$)/, + captures: 'punctuation.string.ts', + patterns: [{ include: '#string_character_escape' }], + }, + string_q_double: { + name: 'string.quoted.double.ts', + begin: '"', + end: /"|((?:[^\\\n])$)/, + captures: 'punctuation.string.ts', + patterns: [{ include: '#string_character_escape' }], + }, + string_template: { + name: 'string.template.ts', + begin: '`', + end: '`', + captures: 'punctuation.string.ts', + patterns: [ + { + name: 'meta.template.expression.ts', + contentName: 'meta.embedded.line.ts', + begin: '${', + end: '}', + patterns: ['#statements'], + captures: 'punctuation.definition.template.expression.ts', + }, + { include: '#string_character_escape' }, + ], + }, + string_character_escape: { + name: 'constant.character.escape.ts', + match: /\\(x[0-9A-Fa-f]{2}|[0-3][0-7]{0,2}|[4-7][0-7]?|u[0-9A-Fa-f]{4}|.|\r?\n?$)/, + }, + braces: { + patterns: [ + { + begin: '(', + end: ')', + captures: 'punctuation.meta.brace.ts', + patterns: ['#statements'], + name: 'meta.brace.ts', + contentName: 'code.ts', + }, + { + begin: '{', + end: '}', + captures: 'punctuation.meta.brace.ts', + patterns: ['#statements'], + name: 'meta.brace.ts', + contentName: 'code.ts', + }, + { + begin: '[', + end: ']', + captures: 'punctuation.meta.brace.ts', + patterns: ['#statements'], + name: 'meta.brace.ts', + contentName: 'code.ts', + }, + ], + }, + punctuation: { + name: 'punctuation.ts', + match: /[-;:,!|&^%*/+=<>\n\r]/, + }, + space: { + name: 'punctuation.space.ts', + match: /\s+/, + }, + comment: { + patterns: [ + { + name: 'comment.line.ts', + comment: 'line comment', + begin: '//', + end: /(?=$)/, + captures: 'punctuation.definition.comment.ts', + }, + { + name: 'comment.block.documentation.ts', + comment: 'DocBlock', + begin: /\/\*\*(?!\/)/, + captures: 'punctuation.definition.comment.ts', + end: '*/', + }, + { + name: 'comment.block.ts', + begin: '/*', + end: '*/', + captures: 'punctuation.definition.comment.ts', + }, + ], + }, + regexp: { + name: 'regexp.ts', + begin: /\/(?![/*])/, + end: /\/([a-z]*)/i, + beginCaptures: 'punctuation.begin.regexp.ts', + endCaptures: 'punctuation.end.regexp.ts', + patterns: ['#regexp_escape', '#regexp_brace'], + }, + regexp_escape: { + name: 'escape.regexp.ts', + match: /\\./, + }, + regexp_brace: { + name: 'brace.regexp.ts', + begin: '[', + end: ']', + contentName: 'character-class.regexp.ts', + patterns: ['#regexp_escape'], + }, +}; +export const grammar = { + name: 'TypeScript', + scopeName: 'source.ts', + patterns: [ + { + name: 'comment.line.shebang.ts', + match: /^#!.*(?=$)/, + }, + { + include: '#statements', + }, + ], + repository, +}; diff --git a/action/node_modules/cspell-grammar/dist/esm/index.d.mts b/action/node_modules/cspell-grammar/dist/esm/index.d.mts new file mode 100644 index 000000000..8f3df0514 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/index.d.mts @@ -0,0 +1,4 @@ +export type { Grammar, GrammarDef, Pattern, Repository } from './parser/index.mjs'; +export { compileGrammar, tokenizeLine, tokenizeText } from './parser/index.mjs'; +export { parsers } from './parsers/index.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/index.mjs b/action/node_modules/cspell-grammar/dist/esm/index.mjs new file mode 100644 index 000000000..4a5379a8f --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/index.mjs @@ -0,0 +1,2 @@ +export { compileGrammar, tokenizeLine, tokenizeText } from './parser/index.mjs'; +export { parsers } from './parsers/index.mjs'; diff --git a/action/node_modules/cspell-grammar/dist/esm/mappers/appendMappedText.d.mts b/action/node_modules/cspell-grammar/dist/esm/mappers/appendMappedText.d.mts new file mode 100644 index 000000000..4fd73e15b --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/mappers/appendMappedText.d.mts @@ -0,0 +1,3 @@ +import type { MappedText } from './types.mjs'; +export declare function appendMappedText(a: MappedText, b: MappedText): MappedText; +//# sourceMappingURL=appendMappedText.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/mappers/appendMappedText.mjs b/action/node_modules/cspell-grammar/dist/esm/mappers/appendMappedText.mjs new file mode 100644 index 000000000..550418e48 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/mappers/appendMappedText.mjs @@ -0,0 +1,37 @@ +import assert from 'assert'; +export function appendMappedText(a, b) { + if (!a.map && !b.map) { + return { text: a.text + b.text }; + } + const aLen = a.text.length; + const bLen = b.text.length; + const aMap = [0, 0].concat(a.map || [0, 0, aLen, aLen]); + const bMap = [0, 0].concat(b.map || [0, 0, bLen, bLen]); + assert(aMap[aMap.length - 1] === aLen); + assert(bMap[bMap.length - 1] === bLen); + assert((aMap.length & 1) === 0); + assert((bMap.length & 1) === 0); + return { + text: a.text + b.text, + map: joinMaps(aMap, bMap), + }; +} +function joinMaps(aMap, bMap) { + const n = aMap.length - 1; + const offsets = [aMap[n - 1], aMap[n]]; + const ab = aMap.concat(bMap.map((v, i) => v + offsets[i & 1])); + // Normalize the map by removing duplicate entries + const r = [0, 0]; + let last0 = 0, last1 = 0; + for (let i = 0; i < ab.length; i += 2) { + const v0 = ab[i]; + const v1 = ab[i + 1]; + if (v0 === last0 && v1 === last1) { + continue; + } + r.push(v0, v1); + last0 = v0; + last1 = v1; + } + return r; +} diff --git a/action/node_modules/cspell-grammar/dist/esm/mappers/types.d.mts b/action/node_modules/cspell-grammar/dist/esm/mappers/types.d.mts new file mode 100644 index 000000000..53b35a6c2 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/mappers/types.d.mts @@ -0,0 +1,17 @@ +export interface MappedText { + text: string; + /** + * `(i, j)` number pairs where + * - `i` is the offset in the source + * - `j` is the offset in the destination + * + * Example: + * - source text = `"caf\xe9"` + * - mapped text = `"café"` + * - map = `[3, 3, 7, 4]`, which is equivalent to `[0, 0, 3, 3, 7, 4]` + * where the `[0, 0]` is unnecessary. + * + */ + map?: number[] | undefined; +} +//# sourceMappingURL=types.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/mappers/types.mjs b/action/node_modules/cspell-grammar/dist/esm/mappers/types.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/mappers/types.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-grammar/dist/esm/mappers/typescript.d.mts b/action/node_modules/cspell-grammar/dist/esm/mappers/typescript.d.mts new file mode 100644 index 000000000..471291025 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/mappers/typescript.d.mts @@ -0,0 +1,6 @@ +/** + * Mappers for TypeScript and JavaScript + */ +import type { MappedText } from './types.mjs'; +export declare function mapRawString(text: string): MappedText; +//# sourceMappingURL=typescript.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/mappers/typescript.mjs b/action/node_modules/cspell-grammar/dist/esm/mappers/typescript.mjs new file mode 100644 index 000000000..0fe8eff9a --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/mappers/typescript.mjs @@ -0,0 +1,142 @@ +/** + * Mappers for TypeScript and JavaScript + */ +const hexChars = { + '0': 0, + '1': 1, + '2': 2, + '3': 3, + '4': 4, + '5': 5, + '6': 6, + '7': 7, + '8': 8, + '9': 9, + A: 10, + B: 11, + C: 12, + D: 13, + E: 14, + F: 15, + a: 10, + b: 11, + c: 12, + d: 13, + e: 14, + f: 15, +}; +const escapeChars = { + t: '\t', + n: '\n', + r: '\r', + b: '\b', + '\\': '\\', + '"': '"', + "'": "'", + '\n': '', +}; +export function mapRawString(text) { + const end = text.length; + let t = ''; + const map = []; + const isHex = /^[0-9a-fA-F]+$/; + let i, j; + for (i = 0, j = 0; i < end; ++i) { + let parsed; + const ti = text[i]; + if (ti === '\\') { + map.push(i, j); + const tc = text[++i]; + const ec = escapeChars[tc]; + if (ec) { + t += ec; + j += ec.length; + map.push(i, j); + continue; + } + switch (tc) { + case 'u': + { + let char; + let end; + if (text[i + 1] !== '{') { + const digits = text.slice(i + 1, i + 5); + parsed = isHex.test(digits) ? parseInt(digits, 16) : NaN; + char = isNaN(parsed) ? '' : String.fromCharCode(parsed); + end = i + 4; + } + else { + for (end = i + 2; text[end] in hexChars; ++end) { + // do nothing + } + if (text[end] !== '}') { + char = ''; + } + else { + const digits = text.slice(i + 2, end); + parsed = isHex.test(digits) ? parseInt(digits, 16) : NaN; + char = isNaN(parsed) ? '' : String.fromCodePoint(parsed); + } + } + if (!char) { + t += tc; + j += 1; + } + else { + t += char; + j += char.length; + i = end; + } + } + break; + case 'x': + { + const digits = text.slice(i + 1, i + 3); + parsed = isHex.test(digits) ? parseInt(digits, 16) : NaN; + if (isNaN(parsed)) { + // give up, it is not valid + t += tc; + j += 1; + } + else { + t += String.fromCharCode(parsed); + i += 2; + ++j; + } + } + break; + case '0': + // Deprecated in ES5 + t += '0'; + j += 1; + break; + case '\r': + i += text[i + 1] === '\n' ? 1 : 0; + break; + case '\n': + break; + case undefined: + break; + default: + t += tc; + ++j; + break; + } + map.push(i + 1, j); + continue; + } + t += ti; + ++j; + } + if (map.length) { + const ii = map[map.length - 2]; + const jj = map[map.length - 1]; + if (ii !== i || jj !== j) { + map.push(i, j); + } + } + return { + text: t, + map, + }; +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/grammar.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/grammar.d.mts new file mode 100644 index 000000000..c0efc707a --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/grammar.d.mts @@ -0,0 +1,5 @@ +import type { GrammarDef } from './grammarDefinition.mjs'; +import type { NGrammar } from './grammarNormalized.mjs'; +export type Grammar = NGrammar; +export declare function compileGrammar(grammar: GrammarDef): Grammar; +//# sourceMappingURL=grammar.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/grammar.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/grammar.mjs new file mode 100644 index 000000000..9173543bd --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/grammar.mjs @@ -0,0 +1,4 @@ +import { normalizeGrammar } from './grammarNormalizer.mjs'; +export function compileGrammar(grammar) { + return normalizeGrammar(grammar); +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/grammarDefinition.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/grammarDefinition.d.mts new file mode 100644 index 000000000..6ce21a559 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/grammarDefinition.d.mts @@ -0,0 +1,113 @@ +export interface GrammarDef extends PatternPatterns { + scopeName: ScopeSource; + repository?: Repository | undefined; +} +/** + * @pattern ^[-\w.]+$ + */ +export type ScopeName = string; +/** + * @pattern ^source\.[-\w.]+$ + */ +export type ScopeSource = string; +export type Pattern = _Pattern; +type _Pattern = PatternMatch | PatternBeginEnd | PatternInclude | PatternPatterns | PatternName; +export type PatternList = (Pattern | PatternRef)[]; +export type Match = string | RegExp; +/** + * A Pattern with a name but no match clauses. + * Used in Capture + */ +export interface PatternName extends PatternBase { + name: ScopeName; + patterns?: undefined; +} +/** + * A Pattern that contains only patterns + */ +export interface PatternPatterns extends PatternBase { + patterns: PatternList; +} +interface PatternMatchBase extends PatternBase { + begin?: Match | undefined; + beginCaptures?: Captures | undefined; + captures?: Captures | undefined; + contentName?: ScopeName | undefined; + end?: Match | undefined; + endCaptures?: Captures | undefined; + match?: Match | undefined; + while?: Match | undefined; + whileCaptures?: Captures | undefined; +} +/** + * A pattern with a single match clause + */ +export interface PatternMatch extends PatternMatchBase { + match: Match; + captures?: Captures | undefined; + patterns?: undefined; + begin?: undefined; + end?: undefined; + contentName?: undefined; + beginCaptures?: undefined; + endCaptures?: undefined; + while?: undefined; + whileCaptures?: undefined; +} +/** + * A Pattern with a Begin/End Match clause + */ +export interface PatternBeginEnd extends PatternMatchBase { + begin: Match; + end?: Match | undefined; + match?: undefined; + contentName?: ScopeName; + captures?: Captures | undefined; + beginCaptures?: Captures | undefined; + endCaptures?: Captures | undefined; + while?: undefined; + whileCaptures?: undefined; +} +export interface PatternBeginWhile extends PatternMatchBase { + begin: Match; + end?: Match | undefined; + match?: undefined; + contentName?: ScopeName | undefined; + captures?: Captures | undefined; + beginCaptures?: Captures | undefined; + endCaptures?: undefined; + while: Match; + whileCaptures?: Captures | undefined; +} +/** + * Include patterns for including patterns from another pattern + */ +export interface PatternInclude extends PatternBase { + include: PatternRef; + name?: undefined; + patterns?: undefined; +} +/** + * Reference to a Repository pattern + * @pattern ^(#.*|$self|$base)$ + */ +export type RepositoryReference = string; +/** + * Reference to an external grammar. + * @pattern ^source\..*$ + */ +export type ExternalGrammarReference = string; +export type PatternRef = RepositoryReference | ExternalGrammarReference; +export type Repository = Record; +export type Captures = ScopeName | Record; +export interface PatternBase { + /** Optional name scope */ + name?: ScopeName | undefined; + /** Optional comment */ + comment?: string | undefined; + /** Used to disable a rule. */ + disabled?: boolean | undefined; + patterns?: PatternList | undefined; +} +export {}; +//# sourceMappingURL=grammarDefinition.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/grammarDefinition.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/grammarDefinition.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/grammarDefinition.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalized.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalized.d.mts new file mode 100644 index 000000000..24abe86ba --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalized.d.mts @@ -0,0 +1,114 @@ +import type { ScopePool } from './scope.mjs'; +import type { LineOffsetAnchored, MatchResult } from './types.mjs'; +export interface NGrammar { + scopeName: NScopeSource; + patterns: NPattern[]; + repository: NRepository; + self: NPatternPatterns; + name: NScope; + contentName?: NScope | undefined; + comment?: string | undefined; + disabled?: boolean | undefined; + scopePool: ScopePool; + begin(rule?: Rule): GrammarRule; +} +/** + * @pattern ^[-\w.]+$ + */ +export type NScope = string; +/** + * @pattern ^source\.[-\w.]+$ + */ +export type NScopeSource = string; +export type NPattern = NPatternBeginEnd | NPatternInclude | NPatternMatch | NPatternName | NPatternPatterns | NPatternRepositoryReference; +export type Match = string | RegExp; +/** + * A Pattern with a name but no match clauses. + * Used with Capture + */ +export interface NPatternName extends NPatternBase { + name: NScope; +} +/** + * A Pattern that contains only patterns + */ +export interface NPatternPatterns extends NPatternBase { + patterns: NPattern[]; +} +/** + * A pattern with a single match clause + */ +export interface NPatternMatch extends NPatternBase { + match: Match; + captures?: NCaptures | undefined; + contentName?: undefined; +} +/** + * A Pattern with a Begin/End Match clause + */ +export interface NPatternBeginEnd extends NPatternBase { + begin: Match; + end?: Match | undefined; + contentName?: NScope | undefined; + captures?: NCaptures | undefined; + beginCaptures?: NCaptures | undefined; + endCaptures?: NCaptures | undefined; +} +/** + * Include a pattern from the repository + */ +export interface NPatternRepositoryReference extends NPatternBase { + reference: NRepositoryReference; + name?: undefined; + patterns?: undefined; +} +/** + * Include patterns for including patterns from another pattern + */ +export interface NPatternInclude extends NPatternBase { + include: IncludeExternalRef; + name?: undefined; + patterns?: undefined; +} +/** + * Reference to a Repository pattern + * @pattern ^([\w-]+|$self|$base)$ + */ +export type NRepositoryReference = string; +/** + * Reference to an external grammar. + * @pattern ^source\..*$ + */ +export type ExternalGrammarReference = string; +export type IncludeExternalRef = ExternalGrammarReference; +export type NRepository = Record; +export type NCaptures = Record; +export interface Rule { + id: number; + grammar: NGrammar; + pattern: NPattern | NGrammar; + parent: Rule | undefined; + repository: NRepository; + depth: number; + findNext?: ((line: LineOffsetAnchored) => MatchRuleResult | undefined) | undefined; + end?: ((line: LineOffsetAnchored) => MatchResult | undefined) | undefined; +} +export interface GrammarRule extends Rule { + pattern: NGrammar; + findNext: (line: LineOffsetAnchored) => MatchRuleResult | undefined; + end: (line: LineOffsetAnchored) => MatchResult | undefined; +} +export interface MatchRuleResult { + rule: Rule; + match: MatchResult; + line: LineOffsetAnchored; +} +export interface NPatternBase { + findMatch(line: LineOffsetAnchored, rule: Rule): MatchRuleResult | undefined; + name?: NScope | undefined; + contentName?: NScope | undefined; + comment?: string | undefined; + disabled?: boolean | undefined; + patterns?: NPattern[] | undefined; +} +//# sourceMappingURL=grammarNormalized.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalized.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalized.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalized.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalizer.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalizer.d.mts new file mode 100644 index 000000000..029141861 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalizer.d.mts @@ -0,0 +1,13 @@ +import type { GrammarDef, Pattern } from './index.mjs'; +import type { PatternBeginEnd, PatternInclude, PatternMatch, PatternName, PatternPatterns } from './grammarDefinition.mjs'; +import type { NGrammar, NPattern, NPatternBeginEnd, NPatternInclude, NPatternMatch, NPatternName, NPatternPatterns, Rule } from './grammarNormalized.mjs'; +import type { Scope } from './scope.mjs'; +export declare function normalizeGrammar(grammar: GrammarDef): NGrammar; +export declare function nPattern(p: PatternMatch): NPatternMatch; +export declare function nPattern(p: PatternInclude): NPatternInclude; +export declare function nPattern(p: PatternBeginEnd): NPatternBeginEnd; +export declare function nPattern(p: PatternPatterns): NPatternPatterns; +export declare function nPattern(p: PatternName): NPatternName; +export declare function nPattern(p: Pattern): NPattern; +export declare function extractScope(er: Rule, isContent?: boolean): Scope; +//# sourceMappingURL=grammarNormalizer.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalizer.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalizer.mjs new file mode 100644 index 000000000..daab55cd8 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/grammarNormalizer.mjs @@ -0,0 +1,260 @@ +import { isPatternBeginEnd, isPatternInclude, isPatternMatch, isPatternPatterns } from './grammarTypesHelpers.mjs'; +import { createMatchResult, createSimpleMatchResult } from './matchResult.mjs'; +import { ScopePool } from './scope.mjs'; +export function normalizeGrammar(grammar) { + return new ImplNGrammar(grammar); +} +const SpecialRepositoryReferences = { + $self: true, + $base: true, +}; +export function nPattern(p) { + if (isPatternMatch(p)) + return normalizePatternMatch(p); + if (isPatternBeginEnd(p)) + return normalizePatternBeginEnd(p); + if (isPatternInclude(p)) + return normalizePatternInclude(p); + if (isPatternPatterns(p)) + return normalizePatternsPatterns(p); + return normalizePatternName(p); +} +function normalizePatternMatch(p) { + const regExec = makeTestMatchFn(p.match); + const self = { + ...p, + captures: normalizeCapture(p.captures), + findMatch, + }; + function findMatch(line, parentRule) { + const match = regExec(line); + if (!match) + return undefined; + const rule = factoryRule(parentRule, self); + return { rule, match, line }; + } + return self; +} +function normalizePatternBeginEnd(p) { + const patterns = normalizePatterns(p.patterns); + const self = { + ...p, + captures: normalizeCapture(p.captures), + beginCaptures: normalizeCapture(p.beginCaptures), + endCaptures: normalizeCapture(p.endCaptures), + patterns, + findMatch, + }; + function findMatch(line, parentRule) { + const match = testBegin(line); + if (!match) + return undefined; + const rule = factoryRule(parentRule, self, findNext, end); + return { rule, match, line }; + } + const testBegin = makeTestMatchFn(p.begin); + const testEnd = p.end !== undefined ? makeTestMatchFn(p.end) : () => undefined; + function findNext(line) { + return patterns && findInPatterns(patterns, line, this); + } + function end(line) { + return testEnd(line); + } + return self; +} +function normalizePatternName(p) { + const patterns = undefined; + const self = { + ...p, + patterns, + findMatch, + }; + function findMatch(line, parentRule) { + const rule = factoryRule(parentRule, self); + const input = line.text.slice(line.offset); + const match = createSimpleMatchResult(input, input, line.offset, line.lineNumber); + return { rule, match, line }; + } + return self; +} +function normalizePatternInclude(p) { + const { include } = p; + return include.startsWith('#') || include in SpecialRepositoryReferences + ? normalizePatternIncludeRef(p) + : normalizePatternIncludeExt(p); +} +function normalizePatternIncludeRef(p) { + const { include, ...rest } = p; + const reference = include.startsWith('#') ? include.slice(1) : include; + const self = { + ...rest, + reference, + findMatch, + }; + function findMatch(line, parentRule) { + const pat = parentRule.repository[reference]; + if (pat === undefined) + throw new Error(`Unknown Include Reference ${include}`); + return pat.findMatch(line, parentRule); + } + return self; +} +function normalizePatternIncludeExt(p) { + function findMatch(_line) { + return undefined; + } + const self = { + ...p, + findMatch, + }; + return self; +} +function normalizePatternsPatterns(p) { + return new ImplNPatternPatterns(p); +} +function findInPatterns(patterns, line, rule) { + let r = undefined; + for (const pat of patterns) { + if (pat.disabled) + continue; + const er = pat.findMatch(line, rule); + if (er?.match !== undefined && !er.rule.pattern.disabled) { + r = (r && r.match && r.match.index <= er.match.index && r) || er; + } + } + return r; +} +function normalizePatterns(patterns) { + if (!patterns) + return undefined; + return patterns.map((p) => (typeof p === 'string' ? { include: p } : p)).map(nPattern); +} +const emptyRepository = Object.freeze(Object.create(null)); +function normalizePatternRepository(rep) { + if (!rep) + return emptyRepository; + return normalizeRepository(rep); +} +function normalizeRepository(rep) { + const repository = Object.create(null); + for (const [key, pat] of Object.entries(rep)) { + repository[key] = nPattern(pat); + } + return repository; +} +let ruleCounter = 0; +function factoryRuleBase(parent, pattern, repository, grammar, findNext, end) { + const depth = parent ? parent.depth + 1 : 0; + return { + id: ruleCounter++, + grammar, + pattern, + parent, + repository, + depth, + findNext, + end, + }; +} +function factoryRule(parent, pattern, findNext, end) { + return factoryRuleBase(parent, pattern, parent.repository, parent.grammar, findNext, end); +} +function normalizeCapture(cap) { + if (cap === undefined) + return undefined; + if (typeof cap === 'string') + return { [0]: cap }; + const capture = Object.create(null); + for (const [key, pat] of Object.entries(cap)) { + capture[key] = typeof pat === 'string' ? pat : normalizePatternName(pat).name; + } + return capture; +} +function makeTestMatchFn(reg) { + if (typeof reg === 'string') + return matchString(reg); + return matchRegExp(reg); +} +function matchString(s) { + return (line) => { + const input = line.text; + const index = input.indexOf(s, line.offset); + if (index < 0) + return undefined; + return createSimpleMatchResult(s, input, index, line.lineNumber); + }; +} +function matchRegExp(r) { + return (line) => { + const rg = RegExp(r, 'gm'); + rg.lastIndex = line.offset; + const m = rg.exec(line.text); + return (m && createMatchResult(m, line.lineNumber)) ?? undefined; + }; +} +export function extractScope(er, isContent = true) { + const scope = []; + for (let rule = er; rule; rule = rule.parent) { + const pattern = rule.pattern; + const { name, contentName } = pattern; + if (contentName && isContent) { + scope.push(contentName); + } + if (name !== undefined) { + scope.push(name); + } + isContent = true; + } + return er.grammar.scopePool.parseScope(scope); +} +class ImplNGrammar { + constructor(grammar) { + this.scopeName = grammar.scopeName; + this.name = grammar.scopeName; + this.comment = grammar.comment; + this.disabled = grammar.disabled; + this.grammarName = grammar.name; + const self = nPattern({ + patterns: [{ patterns: grammar.patterns }], + }); + const repository = normalizePatternRepository(grammar.repository); + this.patterns = self.patterns; + this.repository = repository; + this.self = self; + this.scopePool = new ScopePool(); + } + begin(parentRule) { + const patterns = this.patterns; + function grammarToRule(grammar, baseGrammar, parent) { + const repository = Object.create(null); + Object.assign(repository, grammar.repository); + repository['$self'] = grammar.self; + repository['$base'] = repository['$base'] || baseGrammar.self; + function findNext(line) { + return findInPatterns(patterns, line, this); + } + function end(_line) { + return undefined; + } + return factoryRuleBase(parent, grammar, repository, grammar, findNext, end); + } + return grammarToRule(this, parentRule?.grammar ?? this, parentRule); + } +} +class ImplNPatternPatterns { + constructor(p) { + const { name, comment, disabled, ...rest } = p; + this.patterns = normalizePatterns(rest.patterns); + this.name = name; + this.comment = comment; + this.disabled = disabled; + } + findMatch(line, parentRule) { + const patterns = this.patterns; + const rule = factoryRule(parentRule, this, findNext); + function findNext(line) { + return findInPatterns(patterns, line, this); + } + return rule.findNext?.(line); + } +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/grammarTypesHelpers.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/grammarTypesHelpers.d.mts new file mode 100644 index 000000000..4ad41f97a --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/grammarTypesHelpers.d.mts @@ -0,0 +1,7 @@ +import type { GrammarDef, Pattern, PatternBeginEnd, PatternInclude, PatternMatch, PatternPatterns } from './grammarDefinition.mjs'; +export declare function isPatternInclude(p: Pattern): p is PatternInclude; +export declare function isPatternMatch(pattern: Pattern): pattern is PatternMatch; +export declare function isPatternBeginEnd(pattern: Pattern): pattern is PatternBeginEnd; +export declare function isPatternPatterns(p: Pattern): p is PatternPatterns; +export declare function isGrammar(g: GrammarDef | Pattern): g is GrammarDef; +//# sourceMappingURL=grammarTypesHelpers.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/grammarTypesHelpers.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/grammarTypesHelpers.mjs new file mode 100644 index 000000000..4d70d07a9 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/grammarTypesHelpers.mjs @@ -0,0 +1,23 @@ +export function isPatternInclude(p) { + return !!p.include; +} +const TypeofMatch = { + object: true, + string: true, +}; +const TypeofBegin = TypeofMatch; +const TypeofEnd = { ...TypeofBegin, undefined: true }; +export function isPatternMatch(pattern) { + const p = pattern; + return !!p.match && typeof p.match in TypeofMatch; +} +export function isPatternBeginEnd(pattern) { + const p = pattern; + return p.begin !== undefined && typeof p.begin in TypeofBegin && typeof p.end in TypeofEnd; +} +export function isPatternPatterns(p) { + return Array.isArray(p.patterns); +} +export function isGrammar(g) { + return g.scopeName !== undefined; +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/index.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/index.d.mts new file mode 100644 index 000000000..3a827df17 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/index.d.mts @@ -0,0 +1,5 @@ +export { compileGrammar, Grammar } from './grammar.mjs'; +export type { GrammarDef, Pattern, Repository } from './grammarDefinition.mjs'; +export { tokenizeLine, tokenizeText } from './tokenizeLine.mjs'; +export type { Line, LineOffsetAnchored, TokenizedLine, TokenizedLineResult, TokenizedText } from './types.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/index.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/index.mjs new file mode 100644 index 000000000..03a25aaeb --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/index.mjs @@ -0,0 +1,2 @@ +export { compileGrammar } from './grammar.mjs'; +export { tokenizeLine, tokenizeText } from './tokenizeLine.mjs'; diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/matchResult.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/matchResult.d.mts new file mode 100644 index 000000000..0c2302c62 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/matchResult.d.mts @@ -0,0 +1,13 @@ +import type { MatchResult, MatchSegment } from './types.mjs'; +/** + * Try to assign group names and numbers to segments of the matching text. + * Note: this is NOT a perfect match. It tries its best given limited information. + * For example, it will give back the wrong indexes for the following RegExp and text: + * `/.+(a(?=p)).+/g.exec('bad apple')`. Group 1 will be the `a` in `bad`, not the `a` in apple. + * @param mr - match result + * @returns a list of matching segments in group number order. + */ +export declare function segmentMatch(mr: MatchResult): MatchSegment[]; +export declare function createMatchResult(r: RegExpExecArray, lineNumber: number): MatchResult; +export declare function createSimpleMatchResult(match: string, input: string, index: number, lineNumber: number): MatchResult; +//# sourceMappingURL=matchResult.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/matchResult.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/matchResult.mjs new file mode 100644 index 000000000..7b9ca2c49 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/matchResult.mjs @@ -0,0 +1,49 @@ +/** + * Try to assign group names and numbers to segments of the matching text. + * Note: this is NOT a perfect match. It tries its best given limited information. + * For example, it will give back the wrong indexes for the following RegExp and text: + * `/.+(a(?=p)).+/g.exec('bad apple')`. Group 1 will be the `a` in `bad`, not the `a` in apple. + * @param mr - match result + * @returns a list of matching segments in group number order. + */ +export function segmentMatch(mr) { + const { matches, index, groups, input } = mr; + const segments = []; + let p = index; + for (let groupNum = 0; groupNum < matches.length; ++groupNum) { + const m = matches[groupNum]; + if (!m) + continue; + // Look forwards for the next best match. + const idx0 = input.indexOf(m, p); + // try looking backwards if forwards does not work. + const idx = idx0 >= p ? idx0 : input.lastIndexOf(m, p); + if (idx < 0) + continue; + segments.push({ match: m, index: idx, groupNum, groupName: undefined }); + p = idx; + } + const textToSeg = new Map(segments.map((s) => [s.match, s])); + for (const [name, value] of Object.entries(groups)) { + const s = value && textToSeg.get(value); + if (!s) + continue; + s.groupName = s.groupName + ? Array.isArray(s.groupName) + ? s.groupName.concat([name]) + : [s.groupName, name] + : name; + } + return segments; +} +export function createMatchResult(r, lineNumber) { + const groups = Object.create(null); + r.groups && Object.assign(groups, r.groups); + const matches = r; + const match = r[0]; + return { index: r.index, input: r.input, match, matches, groups, lineNumber: lineNumber }; +} +export function createSimpleMatchResult(match, input, index, lineNumber) { + const groups = Object.create(null); + return { index, input, match, matches: [match], groups, lineNumber }; +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/parser.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/parser.d.mts new file mode 100644 index 000000000..a68777f60 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/parser.d.mts @@ -0,0 +1,12 @@ +import type { Parser, ParseResult } from '@cspell/cspell-types/Parser'; +import type { Grammar } from './grammar.mjs'; +import type { NGrammar } from './grammarNormalized.mjs'; +import type { TokenizedLine, TokenizedLineResult } from './types.mjs'; +export interface DocumentParser { + parse: (firstLine: string) => TokenizedLineResult; +} +export declare function parseDocument(grammar: NGrammar, _filename: string, content: string, emitter?: (line: string) => void): void; +declare function mapTokenizedLines(itl: Iterable): ParseResult['parsedTexts']; +export declare function createParser(grammar: Grammar, name: string, transform?: typeof mapTokenizedLines): Parser; +export {}; +//# sourceMappingURL=parser.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/parser.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/parser.mjs new file mode 100644 index 000000000..c32224c2b --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/parser.mjs @@ -0,0 +1,26 @@ +import { opFilter, opFlatten, opMap, pipe } from '@cspell/cspell-pipe/sync'; +import { tokenizeText, tokenizeTextIterable } from './tokenizeLine.mjs'; +export function parseDocument(grammar, _filename, content, emitter = (line) => console.log(line)) { + const r = tokenizeText(content, grammar); + const tokens = pipe(r, opMap((tl) => tl.tokens.map((t) => ({ t, l: tl.line }))), opFlatten(), opFilter((t) => !t.t.scope.value.startsWith('punctuation'))); + for (const { t: token, l: line } of tokens) { + emitter(`${(token.range[2] ?? line.lineNumber) + 1}:${token.range[0] + 1}\t ${JSON.stringify(token.text)}\t ${token.scope.toString()}`); + } +} +function mapTokenizedLine(tl) { + return tl.tokens.map((t) => ({ + text: t.text, + range: [tl.offset + t.range[0], tl.offset + t.range[1]], + scope: t.scope, + })); +} +function mapTokenizedLines(itl) { + return pipe(itl, opMap(mapTokenizedLine), opFlatten()); +} +export function createParser(grammar, name, transform = mapTokenizedLines) { + function parse(content, filename) { + const parsedTexts = pipe(tokenizeTextIterable(content, grammar), transform); + return { content, filename, parsedTexts }; + } + return { name, parse }; +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/processors/procMatchingRule.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/processors/procMatchingRule.d.mts new file mode 100644 index 000000000..a7d8a7825 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/processors/procMatchingRule.d.mts @@ -0,0 +1,21 @@ +import type { MatchRuleResult, NCaptures, Rule } from '../grammarNormalized.mjs'; +import type { MatchResult, TokenizedText } from '../types.mjs'; +/** + * Apply the scopes to the line + * @param line - line of text + * @param matchRuleResult - the matching rule + */ +export declare function applyCaptureToBeginOrMatch(matchRuleResult: MatchRuleResult): TokenizedText[]; +/** + * Apply the scopes to the line + * @param line - line of text + * @param rule - the matching rule + */ +export declare function applyCaptureToEnd(rule: Rule, match: MatchResult): TokenizedText[]; +/** + * Apply the scopes to the line + * @param line - line of text + * @param rule - the matching rule + */ +export declare function applyCaptures(rule: Rule, match: MatchResult, captures: NCaptures | undefined): TokenizedText[]; +//# sourceMappingURL=procMatchingRule.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/processors/procMatchingRule.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/processors/procMatchingRule.mjs new file mode 100644 index 000000000..ea0358ce4 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/processors/procMatchingRule.mjs @@ -0,0 +1,148 @@ +import { extractScope } from '../grammarNormalizer.mjs'; +import { segmentMatch } from '../matchResult.mjs'; +import { isDefined } from '../util.mjs'; +/** + * Apply the scopes to the line + * @param line - line of text + * @param matchRuleResult - the matching rule + */ +export function applyCaptureToBeginOrMatch(matchRuleResult) { + const { match, rule } = matchRuleResult; + const bePattern = rule.pattern; + const captures = bePattern.beginCaptures ?? bePattern.captures; + return applyCaptures(rule, match, captures); +} +/** + * Apply the scopes to the line + * @param line - line of text + * @param rule - the matching rule + */ +export function applyCaptureToEnd(rule, match) { + const { pattern } = rule; + const bePattern = pattern; + const captures = bePattern.endCaptures ?? bePattern.captures; + return applyCaptures(rule, match, captures); +} +/** + * Apply the scopes to the line + * @param line - line of text + * @param rule - the matching rule + */ +export function applyCaptures(rule, match, captures) { + const scope = extractScope(rule, false); + const pool = rule.grammar.scopePool; + const text = match.match; + const input = match.input; + const range = [match.index, match.index + text.length, match.lineNumber]; + // Do not emit empty captures. + if (!text && !captures) + return []; + if (!captures) { + const tokenized = { + scope, + text, + range, + }; + return [tokenized]; + } + const captureScopes = new Map(Object.entries(captures)); + const cap0 = captureScopes.get('0'); + // Handle the simple case. + if (captureScopes.size === 1 && cap0) { + const tokenized = { + scope: rule.grammar.scopePool.getScope(cap0, scope), + text, + range, + }; + return [tokenized]; + } + const min = match.index; + const max = match.index + text.length; + function trimSegment(seg) { + const { index, match } = seg; + const right = match.length; + if (index >= min && right <= max) + return seg; + if (index >= max || right < min) + return undefined; + const a = Math.max(index, min) - index; + const b = Math.min(right, max) - index; + const text = match.slice(a, b); + return { + ...seg, + index: index + a, + match: text, + }; + } + const segments = segmentMatch(match).map(trimSegment).filter(isDefined); + function processSegments(segments) { + const base = segments[0]; + const root = { + a: base.index, + b: base.index + base.match.length, + s: { seg: base }, + }; + let m; + for (let i = 1; i < segments.length; ++i) { + const seg = segments[i]; + const index = seg.index; + const end = index + seg.match.length; + m = m && m.a <= index ? m : root; + while (m && m.b <= index) { + m = m.n; + } + while (m && m.a < end) { + if (m.a < index) { + const n = { ...m, a: index }; + m.n = n; + m.b = index; + m = n; + } + if (m.b > end) { + const n = { ...m, a: end }; + m.b = end; + m.n = n; + } + m.s = { seg, next: m.s }; + m = m.n; + } + } + return root; + } + function segChainToScope(chain) { + function* _chain(chain) { + while (chain) { + const seg = chain.seg; + if (seg.groupName) { + if (Array.isArray(seg.groupName)) { + yield* seg.groupName; + } + else { + yield seg.groupName; + } + } + yield seg.groupNum.toString(); + chain = chain.next; + } + } + const scopeValues = [..._chain(chain)] + .map((cap) => captureScopes.get(cap)) + .filter(isDefined) + .reverse(); + return scopeValues.reduce((s, v) => pool.getScope(v, s), scope); + } + const merged = processSegments(segments); + function* emit(m) { + while (m) { + const t = { + text: input.slice(m.a, m.b), + range: [m.a, m.b, match.lineNumber], + scope: segChainToScope(m.s), + }; + yield t; + m = m.n; + } + } + const parsedText = [...emit(merged)]; + return parsedText; +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/scope.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/scope.d.mts new file mode 100644 index 000000000..3acccf0c3 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/scope.d.mts @@ -0,0 +1,41 @@ +export declare class Scope { + readonly value: string; + readonly parent?: Scope | undefined; + constructor(value: string, parent?: Scope | undefined); + /** + * Convert the scope hierarchy to a string + * @param ltr - return ancestry from left-to-right + * @returns the scope hierarchy as a string separated by a space. + */ + toString(ltr?: boolean): string; + static isScope(value: unknown): value is Scope; +} +/** + * A Scope Pool is used to keep the number of scope chains down to a minimum. It ensure that if two scopes match, + * then they will be the same object. + */ +export declare class ScopePool { + private pool; + /** + * Get a Scope that matches the scope. This method is idempotent. + * @param scopeValue - a single scope value: i.e. `source.ts` + * @param parent - optional parent Scope + */ + getScope(scopeValue: string, parent?: Scope): Scope; + /** + * + * @param scopes - the scope as a string or array of strings + * i.e. ` + * @param ltr - left-to-right ancestry + */ + parseScope(scopes: Scope | ScopeLike): Scope; + parseScope(scopes: string | ScopeLike): Scope; + parseScope(scopes: string | string[], ltr?: boolean): Scope; + private parseScopeString; +} +interface ScopeLike { + readonly value: string; + readonly parent?: ScopeLike | undefined; +} +export {}; +//# sourceMappingURL=scope.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/scope.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/scope.mjs new file mode 100644 index 000000000..a1d4776b6 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/scope.mjs @@ -0,0 +1,69 @@ +import assert from 'assert'; +export class Scope { + constructor(value, parent) { + this.value = value; + this.parent = parent; + } + /** + * Convert the scope hierarchy to a string + * @param ltr - return ancestry from left-to-right + * @returns the scope hierarchy as a string separated by a space. + */ + toString(ltr = false) { + if (!this.parent) + return this.value; + return ltr ? this.parent.toString(ltr) + ' ' + this.value : this.value + ' ' + this.parent.toString(ltr); + } + static isScope(value) { + return value instanceof Scope; + } +} +/** + * A Scope Pool is used to keep the number of scope chains down to a minimum. It ensure that if two scopes match, + * then they will be the same object. + */ +export class ScopePool { + constructor() { + this.pool = new Map(); + } + /** + * Get a Scope that matches the scope. This method is idempotent. + * @param scopeValue - a single scope value: i.e. `source.ts` + * @param parent - optional parent Scope + */ + getScope(scopeValue, parent) { + const foundPoolMap = this.pool.get(scopeValue); + const poolMap = foundPoolMap || new Map(); + if (poolMap !== foundPoolMap) { + this.pool.set(scopeValue, poolMap); + } + const foundScope = poolMap.get(parent); + if (foundScope) + return foundScope.v; + const scope = new Scope(scopeValue, parent); + poolMap.set(parent, { v: scope }); + return scope; + } + parseScope(scopes, ltr = false) { + if (Scope.isScope(scopes)) + return scopes; + if (isScopeLike(scopes)) { + const parent = scopes.parent ? this.parseScope(scopes.parent) : undefined; + return this.getScope(scopes.value, parent); + } + return this.parseScopeString(scopes, ltr); + } + parseScopeString(scopes, ltr) { + scopes = Array.isArray(scopes) ? scopes : scopes.split(' '); + const parentToChild = ltr ? scopes : scopes.reverse(); + let parent = undefined; + for (const value of parentToChild) { + parent = this.getScope(value, parent); + } + assert(parent, 'Empty scope is not allowed.'); + return parent; + } +} +function isScopeLike(value) { + return typeof value === 'object' && !Array.isArray(value) && value.value !== undefined; +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/tokenizeLine.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/tokenizeLine.d.mts new file mode 100644 index 000000000..7f5a0eb8e --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/tokenizeLine.d.mts @@ -0,0 +1,6 @@ +import type { NGrammar, Rule } from './grammarNormalized.mjs'; +import type { DocumentLine, TokenizedLine, TokenizedLineResult } from './types.mjs'; +export declare function tokenizeLine(line: DocumentLine, rule: Rule): TokenizedLineResult; +export declare function tokenizeText(text: string, grammar: NGrammar): TokenizedLine[]; +export declare function tokenizeTextIterable(text: string, grammar: NGrammar): Iterable; +//# sourceMappingURL=tokenizeLine.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/tokenizeLine.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/tokenizeLine.mjs new file mode 100644 index 000000000..bb2b7a562 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/tokenizeLine.mjs @@ -0,0 +1,121 @@ +import assert from 'assert'; +import { extractScope } from './grammarNormalizer.mjs'; +import { applyCaptureToBeginOrMatch, applyCaptureToEnd } from './processors/procMatchingRule.mjs'; +export function tokenizeLine(line, rule) { + const text = line.text; + const lineLen = line.text.length; + const parsedText = []; + let ctx = buildContext({ ...line, offset: 0, anchor: -1 }, rule); + // Note: the begin rule has already been matched and applied. + // Does it need to end or go deeper? + while (ctx.line.offset <= lineLen) { + // We are at an end + let endMatch = ctx.rule.end?.(ctx.line); + while (endMatch?.index === ctx.line.offset) { + parsedText.push(...applyCaptureToEnd(ctx.rule, endMatch)); + ctx = findParentWithEnd(ctx); + ctx.line.offset = endMatch.index + endMatch.match.length; + endMatch = ctx.rule.end?.(ctx.line); + } + if (ctx.line.offset >= lineLen) + break; + const { line, rule } = ctx; + const offset = line.offset; + const match = rule.findNext?.(line); + const limit = endMatch?.index ?? lineLen; + const emitTil = match ? Math.min(match.match.index, limit) : limit; + if (offset < emitTil) { + const scope = extractScope(rule); + const start = offset; + const end = emitTil; + parsedText.push({ + scope, + text: text.slice(start, end), + range: [start, end, line.lineNumber], + }); + ctx.line.offset = emitTil; + } + if (!match || (endMatch && endMatch.index <= match.match.index)) { + continue; // We are at an end, process it at the beginning of the loop. + } + // Process the beginning of the match + parsedText.push(...applyCaptureToBeginOrMatch(match)); + line.anchor = match.match.index + match.match.match.length; + line.offset = line.anchor; + ctx = findNearestWithEnd(buildContext(line, match.rule)); + } + return toParseLineResult(line, ctx.rule, parsedText); +} +export function tokenizeText(text, grammar) { + return [...tokenizeTextIterable(text, grammar)]; +} +export function* tokenizeTextIterable(text, grammar) { + const lines = text.split(/(?<=\r\n|\n|\r(?!\n))/); + const rule = grammar.begin(); + let documentOffset = 0; + let tr = tokenizeLine({ text: lines[0], lineNumber: 0, documentOffset }, rule); + documentOffset += lines[0].length; + yield toParsedLine(tr); + for (let i = 1; i < lines.length; ++i) { + const line = { text: lines[i], lineNumber: i, documentOffset }; + documentOffset += line.text.length; + tr = tr.parse(line); + yield toParsedLine(tr); + } +} +function toParsedLine(pr) { + const { tokens: parsedText, line, offset } = pr; + return { tokens: parsedText, line, offset }; +} +function toParseLineResult(line, rule, parsedText) { + return { + tokens: parsedText, + line, + offset: line.documentOffset, + parse: (line) => tokenizeLine(line, rule), + }; +} +function buildContext(line, rule) { + const rules = calcRuleStack(rule); + const numRules = rules.length; + const rootNum = numRules - 1; + const rootRule = rules[rootNum]; + const rootContext = { + line, + rule: rootRule, + }; + let ctx = rootContext; + for (let i = rootNum - 1; i >= 0; --i) { + const rule = rules[i]; + const line = ctx.line; + ctx = { + line, + rule, + parent: ctx, + }; + // Check while here. + } + return ctx; +} +function calcRuleStack(rule) { + const rules = []; + let r = rule; + while (r) { + rules.push(r); + r = r.parent; + } + return rules; +} +function must(t, msg = 'Must be defined') { + assert(t !== undefined && t !== null, msg); + return t; +} +function findParentWithEnd(ctx) { + return findNearestWithEnd(must(ctx.parent)); +} +function findNearestWithEnd(ctx) { + while (!ctx.rule.end) { + ctx = must(ctx.parent); + } + return ctx; +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/types.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/types.d.mts new file mode 100644 index 000000000..7529cb787 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/types.d.mts @@ -0,0 +1,95 @@ +import type { Scope } from './scope.mjs'; +export interface LineOffset extends Line { + /** + * offset in characters from the beginning of the line. + */ + offset: number; +} +export interface Line { + text: string; + /** Line number in document, starts with 0 */ + lineNumber: number; +} +/** + * A line of a document + */ +export interface DocumentLine { + /** + * The text at that line number + */ + text: string; + /** + * The 0 based line number + */ + lineNumber: number; + /** + * The absolute offset from the beginning of the document + */ + documentOffset: number; +} +export interface LineOffsetAnchored extends LineOffset { + /** The anchor is the position at the end of the last match */ + anchor: number; +} +export type Groups = Record; +export interface MatchResult { + /** offset of the match into the input strings */ + index: number; + /** the input string matched against */ + input: string; + /** + * line number of the input string. + */ + lineNumber: number; + /** + * This is the full match + */ + match: string; + /** + * Numbered group matches. + */ + matches: (string | undefined)[]; + /** + * Named matching groups. + */ + groups: Groups; +} +export interface MatchSegment { + match: string; + index: number; + groupNum: number; + groupName: string | string[] | undefined; +} +export type AppliedScopes = Scope[]; +export interface TokenizedLine { + tokens: TokenizedText[]; + line: Line; + offset: number; +} +export interface TokenizedLineResult extends TokenizedLine { + parse: (nextLine: DocumentLine) => TokenizedLineResult; +} +export interface TokenizedText { + /** + * Scopes that were applied + */ + scope: Scope; + /** + * The parsed text + */ + text: string; + /** + * start and end offset of the text. + */ + range: Range; +} +/** + * A Range that is relative to the beginning of a line. + */ +export type RangeRelativeToLine = [start: number, end: number, line: number]; +/** + * A Range where the start and end are relative to the beginning of the document. + */ +export type RangeAbsolute = [start: number, end: number]; +export type Range = RangeAbsolute | RangeRelativeToLine; +//# sourceMappingURL=types.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/types.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/types.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/types.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/util.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/util.d.mts new file mode 100644 index 000000000..704cb846c --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/util.d.mts @@ -0,0 +1,2 @@ +export declare function isDefined(t: T | undefined): t is T; +//# sourceMappingURL=util.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/util.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/util.mjs new file mode 100644 index 000000000..79df83af1 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/util.mjs @@ -0,0 +1,3 @@ +export function isDefined(t) { + return t !== undefined && t !== null; +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/validateGrammar.d.mts b/action/node_modules/cspell-grammar/dist/esm/parser/validateGrammar.d.mts new file mode 100644 index 000000000..05836874a --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/validateGrammar.d.mts @@ -0,0 +1,12 @@ +import type { GrammarDef, Pattern, PatternList, Repository } from './grammarDefinition.mjs'; +interface GrammarContext { + grammar: GrammarDef; + scopeExt: string; +} +export declare function validate(grammar: GrammarDef): asserts grammar; +export declare function validatePatterns(patterns: PatternList, context: GrammarContext): asserts patterns; +export declare function validatePattern(pattern: Pattern, context: GrammarContext): asserts pattern; +export declare function validateGrammarRepository(p: GrammarDef, context: GrammarContext): asserts p; +export declare function validateRepository(r: Repository, context: GrammarContext): asserts r; +export {}; +//# sourceMappingURL=validateGrammar.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parser/validateGrammar.mjs b/action/node_modules/cspell-grammar/dist/esm/parser/validateGrammar.mjs new file mode 100644 index 000000000..86831d5d3 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parser/validateGrammar.mjs @@ -0,0 +1,55 @@ +import { strict as assert } from 'assert'; +import { format } from 'util'; +import { isPatternBeginEnd, isPatternInclude, isPatternMatch, isPatternPatterns } from './grammarTypesHelpers.mjs'; +export function validate(grammar) { + assert(grammar.scopeName); + assert(/^[\w.]*\.\w+$/.test(grammar.scopeName)); + const scopeExt = '.' + grammar.scopeName.split('.').pop(); + const context = { + grammar, + scopeExt, + }; + validatePatterns(grammar.patterns, context); + validateGrammarRepository(grammar, context); +} +export function validatePatterns(patterns, context) { + assert(Array.isArray(patterns)); + patterns.forEach((p) => validatePatternOrReference(p, context)); +} +function validatePatternOrReference(pattern, context) { + if (typeof pattern === 'string') { + assert(/^\$self|\$base|#[\w-]+|[\w.]+$/.test(pattern)); + } + else { + validatePattern(pattern, context); + } +} +export function validatePattern(pattern, context) { + assert(isPatternMatch(pattern) || + isPatternBeginEnd(pattern) || + isPatternInclude(pattern) || + isPatternPatterns(pattern), format('Unknown Pattern: %o', pattern)); + assert(!(isPatternBeginEnd(pattern) && isPatternMatch(pattern)), format('Pattern must be a Match pattern or a Begin/End pattern, but not both: %o', pattern)); + validatePatternName(pattern, context); +} +export function validateGrammarRepository(p, context) { + p.repository && validateRepository(p.repository, context); +} +export function validateRepository(r, context) { + assert(typeof r === 'object'); + for (const [key, pat] of Object.entries(r)) { + assert(/^[\w.-]+$/.test(key), 'Invalid Repository key, must be `a-zA-Z0-9`, `.`, `-`'); + validatePattern(pat, context); + } +} +function validatePatternName(p, context) { + assert(isValidPatternName(p.name), format('Invalid pattern name: %o', p)); + assert(p.name === undefined || p.name.endsWith(context.scopeExt), format('Pattern name ending must match grammar scope ending. Grammar scope: "%s"; Pattern: %o', context.grammar.scopeName, p)); +} +function isValidPatternName(name) { + if (name === undefined) + return true; + if (typeof name !== 'string') + return false; + return /^[-\w.]+$/.test(name); +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parsers/index.d.mts b/action/node_modules/cspell-grammar/dist/esm/parsers/index.d.mts new file mode 100644 index 000000000..904a02007 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parsers/index.d.mts @@ -0,0 +1,2 @@ +export declare const parsers: import("@cspell/cspell-types/Parser").Parser[]; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parsers/index.mjs b/action/node_modules/cspell-grammar/dist/esm/parsers/index.mjs new file mode 100644 index 000000000..51b8b8991 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parsers/index.mjs @@ -0,0 +1,2 @@ +import { parser as parserTypeScript } from './typescript/index.mjs'; +export const parsers = [parserTypeScript]; diff --git a/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/TypeScriptParser.d.mts b/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/TypeScriptParser.d.mts new file mode 100644 index 000000000..917f24a24 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/TypeScriptParser.d.mts @@ -0,0 +1,2 @@ +export declare const parser: import("@cspell/cspell-types/Parser").Parser; +//# sourceMappingURL=TypeScriptParser.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/TypeScriptParser.mjs b/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/TypeScriptParser.mjs new file mode 100644 index 000000000..50dbb93b5 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/TypeScriptParser.mjs @@ -0,0 +1,89 @@ +import { opFlatten, opMap, pipe } from '@cspell/cspell-pipe/sync'; +import { grammar } from '../../grammars/typescript.mjs'; +import { appendMappedText } from '../../mappers/appendMappedText.mjs'; +import { mapRawString } from '../../mappers/typescript.mjs'; +import { compileGrammar } from '../../parser/grammar.mjs'; +import { createParser } from '../../parser/parser.mjs'; +import { ScopePool } from '../../parser/scope.mjs'; +const tsGrammar = compileGrammar(grammar); +const pool = new ScopePool(); +const useScope = new WeakMap(); +function* transform(texts) { + for (const parsed of texts) { + if (doesScopeMatch(parsed.scope, 'constant.character.escape.ts')) { + const mapped = mapRawString(parsed.text); + const scope = parsed.scope ? pool.parseScope(parsed.scope) : undefined; + yield { + text: mapped.text, + scope: scope?.parent, + map: mapped.map, + range: parsed.range, + }; + continue; + } + yield parsed; + } +} +function* mergeStringResults(results) { + let last; + for (const next of results) { + if (!doesScopeMatch(next.scope, 'string.')) { + if (last) { + yield last; + last = undefined; + } + yield next; + continue; + } + if (!last) { + last = next; + continue; + } + if (next.scope !== last.scope || last.range[1] !== next.range[0]) { + yield last; + last = next; + continue; + } + last = mergeParsedText(last, next); + } + if (last) + yield last; +} +function mergeParsedText(a, b) { + const abT = appendMappedText(a, b); + const ab = { + text: abT.text, + scope: a.scope, + range: [a.range[0], b.range[1]], + map: abT.map, + delegate: a.delegate, + }; + return ab; +} +function filterScope(scope) { + const cached = useScope.get(scope); + if (cached !== undefined) + return cached; + const value = scope.value; + const use = !value.startsWith('punctuation') && !value.startsWith('keyword.'); + useScope.set(scope, use); + return use; +} +function mapTokenizedLine(tl) { + return tl.tokens + .filter((t) => filterScope(t.scope)) + .map((t) => ({ + text: t.text, + range: [tl.offset + t.range[0], tl.offset + t.range[1]], + scope: t.scope, + })); +} +function mapTokenizedLines(itl) { + return pipe(itl, opMap(mapTokenizedLine), opFlatten(), transform, mergeStringResults); +} +export const parser = createParser(tsGrammar, 'typescript', mapTokenizedLines); +function doesScopeMatch(s, match) { + if (!s) + return false; + return typeof s === 'string' ? s.startsWith(match) : s.value.startsWith(match); +} diff --git a/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/index.d.mts b/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/index.d.mts new file mode 100644 index 000000000..1b9059d2a --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/index.d.mts @@ -0,0 +1,2 @@ +export { parser } from './TypeScriptParser.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/index.mjs b/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/index.mjs new file mode 100644 index 000000000..ff54ad78f --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/parsers/typescript/index.mjs @@ -0,0 +1 @@ +export { parser } from './TypeScriptParser.mjs'; diff --git a/action/node_modules/cspell-grammar/dist/esm/viewer/escapeMarkdown.d.mts b/action/node_modules/cspell-grammar/dist/esm/viewer/escapeMarkdown.d.mts new file mode 100644 index 000000000..3662f15d0 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/viewer/escapeMarkdown.d.mts @@ -0,0 +1,3 @@ +export declare function escapeMarkdown(text: string): string; +export declare function escapeHtml(str: string): string; +//# sourceMappingURL=escapeMarkdown.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/viewer/escapeMarkdown.mjs b/action/node_modules/cspell-grammar/dist/esm/viewer/escapeMarkdown.mjs new file mode 100644 index 000000000..0e5012cf2 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/viewer/escapeMarkdown.mjs @@ -0,0 +1,39 @@ +const matchHtml = /["'&<>]/g; +const matchMarkdown = /[-"'&<>`*_+[\]()\\|~]/g; +const entityMap = { + '<': '<', + '>': '>', + '&': '&', + '"': '"', + "'": ''', +}; +const charCodeToEntity = compileEntities(entityMap); +export function escapeMarkdown(text) { + return _escape(text, matchMarkdown); +} +export function escapeHtml(str) { + return _escape(str, matchHtml); +} +function _escape(str, r) { + const cvt = charCodeToEntity; + let lastIndex = 0; + let html = ''; + r.lastIndex = 0; + while (r.test(str)) { + const i = r.lastIndex - 1; + html += str.substring(lastIndex, i) + cvt[str.charCodeAt(i)]; + lastIndex = r.lastIndex; + } + return html + str.substring(lastIndex); +} +function compileEntities(entityMap) { + const result = []; + result.length = 127; + for (let i = 32; i < 128; ++i) { + result[i] = `&#${i};`; + } + for (const [char, entity] of Object.entries(entityMap)) { + result[char.charCodeAt(0)] = entity; + } + return result; +} diff --git a/action/node_modules/cspell-grammar/dist/esm/viewer/markdownHelper.d.mts b/action/node_modules/cspell-grammar/dist/esm/viewer/markdownHelper.d.mts new file mode 100644 index 000000000..a092258a2 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/viewer/markdownHelper.d.mts @@ -0,0 +1,2 @@ +export declare function toInlineCode(text: string): string; +//# sourceMappingURL=markdownHelper.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/viewer/markdownHelper.mjs b/action/node_modules/cspell-grammar/dist/esm/viewer/markdownHelper.mjs new file mode 100644 index 000000000..32ab26a3e --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/viewer/markdownHelper.mjs @@ -0,0 +1,4 @@ +import { escapeMarkdown } from './escapeMarkdown.mjs'; +export function toInlineCode(text) { + return `${escapeMarkdown(text.replace(/\r/g, '↤').replace(/\n/g, '↩'))}`; +} diff --git a/action/node_modules/cspell-grammar/dist/esm/viewer/visualizeAsMD.d.mts b/action/node_modules/cspell-grammar/dist/esm/viewer/visualizeAsMD.d.mts new file mode 100644 index 000000000..f7d855786 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/viewer/visualizeAsMD.d.mts @@ -0,0 +1,5 @@ +import type { TokenizedLine } from '../parser/index.mjs'; +export declare function _tokenizedLineToMarkdown(line: TokenizedLine, indentation?: string): string; +export declare function tokenizedLineToMarkdown(line: TokenizedLine, indentation?: string): string; +export declare function tokenizedLinesToMarkdown(lines: TokenizedLine[], indentation?: string): string; +//# sourceMappingURL=visualizeAsMD.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-grammar/dist/esm/viewer/visualizeAsMD.mjs b/action/node_modules/cspell-grammar/dist/esm/viewer/visualizeAsMD.mjs new file mode 100644 index 000000000..577382cc6 --- /dev/null +++ b/action/node_modules/cspell-grammar/dist/esm/viewer/visualizeAsMD.mjs @@ -0,0 +1,31 @@ +import { toInlineCode } from './markdownHelper.mjs'; +export function _tokenizedLineToMarkdown(line, indentation = '') { + const markdownLines = []; + const header = `- \`${line.line.lineNumber + 1}\`: ${toInlineCode(line.line.text)} + + | text | scope | + | --------- | -------------------------------------------------------- |`; + markdownLines.push(...header.split('\n')); + markdownLines.push(...line.tokens.map((t) => ` | ${toInlineCode(t.text)} | ${t.scope} |`)); + return markdownLines.map((line) => indentation + line).join('\n') + '\n\n'; +} +export function tokenizedLineToMarkdown(line, indentation = '') { + const rows = line.tokens.map((t) => `| ${toInlineCode(t.text)} | ${t.scope} |`); + const detail = `
+${line.line.lineNumber + 1}: ${toInlineCode(line.line.text)} + +| text | scope | +| --------- | -------------------------------------------------------- | +${rows.join('\n')} + +
+`; + const markdownLines = detail.split('\n'); + return (markdownLines + .map((line) => indentation + line) + .map((line) => (line.trim() === '' ? '' : line)) + .join('\n') + '\n\n'); +} +export function tokenizedLinesToMarkdown(lines, indentation = '') { + return lines.map((line) => tokenizedLineToMarkdown(line, indentation)).join(''); +} diff --git a/action/node_modules/cspell-grammar/package.json b/action/node_modules/cspell-grammar/package.json index 5e349c102..05dc92969 100644 --- a/action/node_modules/cspell-grammar/package.json +++ b/action/node_modules/cspell-grammar/package.json @@ -1,6 +1,6 @@ { "name": "cspell-grammar", - "version": "6.28.0", + "version": "6.29.1", "description": "Grammar parsing support for cspell", "keywords": [ "cspell", @@ -10,48 +10,68 @@ "homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-gitignore#readme", "license": "MIT", "bin": { - "cspell-grammar": "bin.js" + "cspell-grammar": "bin.mjs" }, - "main": "dist/index.js", - "directories": { - "dist": "dist" + "type": "commonjs", + "main": "dist/cjs/index.js", + "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.mjs", + "exports": { + ".": { + "import": "./dist/esm/index.mjs", + "require": "./dist/cjs/index.js" + }, + "./parsers/typescript": { + "import": "./dist/esm/parsers/typescript/index.mjs", + "require": "./dist/cjs/parsers/typescript/index.js" + } }, - "typings": "index.d.ts", "typesVersions": { "*": { - "*": [ - "dist/*" - ], - "parsers/*": [ - "dist/parsers/*" + "index.js": [ + "dist/cjs/index.d.ts" ], "index.d.ts": [ - "dist/index.d.ts" + "dist/cjs/index.d.ts" + ], + "dist/cjs/*.d.ts": [ + "dist/cjs/*.d.ts" + ], + "parsers/typescript": [ + "dist/cjs/parsers/typescript/index.d.ts" + ], + "parsers/typescript/*.d.ts": [ + "dist/cjs/parsers/typescript/*.d.ts" + ], + "*": [ + "dist/cjs/*.d.ts", + "dist/cjs/*/index.d.ts" ] } }, - "exports": { - ".": "./dist/index.js", - "./parsers/typescript": "./dist/parsers/typescript/index.js", - "./parsers/typescript/index.js": "./dist/parsers/typescript/index.js" - }, "files": [ + "bin.mjs", "dist", - "bin.js", + "!dist/esm/**/*.js", + "!dist/esm/**/*.ts", "!**/*.tsbuildInfo", "!**/__mocks__", + "!**/test/**", "!**/*.test.*", "!**/*.spec.*", "!**/*.map" ], "scripts": { - "build": "tsc -p .", - "watch": "tsc -p . -w", "clean": "shx rm -rf dist coverage .tsbuildinfo", + "build": "tsc -b . && ts2mjs dist/esm", + "build:esm": "tsc -p tsconfig.esm.json", "clean-build": "pnpm run clean && pnpm run build", - "coverage": "jest --coverage", - "test-watch": "jest --watch", - "test": "jest" + "coverage": "pnpm coverage:vitest && pnpm coverage:fix", + "coverage:vitest": "vitest run --coverage", + "coverage:fix": "nyc report --temp-dir \"$(pwd)/coverage\" --reporter lcov --report-dir \"$(pwd)/coverage\" --cwd ../..", + "test:watch": "vitest", + "test": "vitest run", + "watch": "tsc -b . -w" }, "repository": { "type": "git", @@ -64,11 +84,11 @@ "node": ">=14" }, "devDependencies": { - "jest": "^29.4.3" + "jest": "^29.5.0" }, "dependencies": { - "@cspell/cspell-pipe": "6.28.0", - "@cspell/cspell-types": "6.28.0" + "@cspell/cspell-pipe": "6.29.1", + "@cspell/cspell-types": "6.29.1" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/cspell-io/package.json b/action/node_modules/cspell-io/package.json index 0ae1f1e8a..9aad529d1 100644 --- a/action/node_modules/cspell-io/package.json +++ b/action/node_modules/cspell-io/package.json @@ -1,6 +1,6 @@ { "name": "cspell-io", - "version": "6.28.0", + "version": "6.29.1", "description": "A library of useful I/O functions used across various cspell tools.", "type": "commonjs", "module": "dist/esm/index.mjs", @@ -51,12 +51,11 @@ }, "devDependencies": { "@types/node-fetch": "^2.6.2", - "jest": "^29.4.3", "lorem-ipsum": "^2.0.8" }, "dependencies": { - "@cspell/cspell-service-bus": "6.28.0", + "@cspell/cspell-service-bus": "6.29.1", "node-fetch": "^2.6.9" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/cspell-lib/dist/Document/isBinaryDoc.js b/action/node_modules/cspell-lib/dist/Document/isBinaryDoc.js deleted file mode 100644 index 38deca6fa..000000000 --- a/action/node_modules/cspell-lib/dist/Document/isBinaryDoc.js +++ /dev/null @@ -1,22 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.isBinaryFile = exports.isBinaryDoc = void 0; -const LanguageIds_1 = require("../LanguageIds"); -const Uri_1 = require("../util/Uri"); -const normalizeLanguageIds_1 = require("./normalizeLanguageIds"); -function isBinaryDoc(document) { - return isBinaryFile((0, Uri_1.toUri)(document.uri), document.languageId); -} -exports.isBinaryDoc = isBinaryDoc; -function isBinaryFile(filename, languageId) { - const filenameUri = (0, Uri_1.toUri)(filename); - if (languageId) { - const ids = (0, normalizeLanguageIds_1.normalizeLanguageIds)(languageId); - if (ids.length) - return (0, LanguageIds_1.isGenerated)(ids); - } - const file = (0, Uri_1.basename)(filenameUri); - return (0, LanguageIds_1.isGeneratedFile)(file); -} -exports.isBinaryFile = isBinaryFile; -//# sourceMappingURL=isBinaryDoc.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/defaultSettings.js b/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/defaultSettings.js deleted file mode 100644 index d6d05e485..000000000 --- a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/defaultSettings.js +++ /dev/null @@ -1,11 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.defaultSettings = void 0; -const CSpellSettingsInternalDef_1 = require("../../../Models/CSpellSettingsInternalDef"); -const constants_1 = require("../../constants"); -exports.defaultSettings = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({ - id: 'default', - name: 'default', - version: constants_1.currentSettingsFileVersion, -}); -//# sourceMappingURL=defaultSettings.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/readSettingsFiles.js b/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/readSettingsFiles.js deleted file mode 100644 index a719a742d..000000000 --- a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/readSettingsFiles.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.readSettingsFiles = void 0; -const CSpellSettingsServer_1 = require("../../CSpellSettingsServer"); -const defaultSettings_1 = require("./defaultSettings"); -const readSettings_1 = require("./readSettings"); -/** - * - * @param filenames - settings files to read - * @returns combined configuration - * @deprecated true - */ -function readSettingsFiles(filenames) { - return filenames.map((filename) => (0, readSettings_1.readSettings)(filename)).reduce((a, b) => (0, CSpellSettingsServer_1.mergeSettings)(a, b), defaultSettings_1.defaultSettings); -} -exports.readSettingsFiles = readSettingsFiles; -//# sourceMappingURL=readSettingsFiles.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/Cache/cspell.cache.js b/action/node_modules/cspell-lib/dist/cjs/Cache/cspell.cache.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Cache/cspell.cache.js rename to action/node_modules/cspell-lib/dist/cjs/Cache/cspell.cache.js diff --git a/action/node_modules/cspell-lib/dist/Cache/index.js b/action/node_modules/cspell-lib/dist/cjs/Cache/index.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Cache/index.js rename to action/node_modules/cspell-lib/dist/cjs/Cache/index.js diff --git a/action/node_modules/cspell-lib/dist/Document/Document.js b/action/node_modules/cspell-lib/dist/cjs/Document/Document.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Document/Document.js rename to action/node_modules/cspell-lib/dist/cjs/Document/Document.js diff --git a/action/node_modules/cspell-lib/dist/Document/index.js b/action/node_modules/cspell-lib/dist/cjs/Document/index.js similarity index 53% rename from action/node_modules/cspell-lib/dist/Document/index.js rename to action/node_modules/cspell-lib/dist/cjs/Document/index.js index b2dd9b0ca..af2b0c530 100644 --- a/action/node_modules/cspell-lib/dist/Document/index.js +++ b/action/node_modules/cspell-lib/dist/cjs/Document/index.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fileToTextDocument = exports.fileToDocument = exports.isBinaryFile = void 0; -var isBinaryDoc_1 = require("./isBinaryDoc"); -Object.defineProperty(exports, "isBinaryFile", { enumerable: true, get: function () { return isBinaryDoc_1.isBinaryFile; } }); -var resolveDocument_1 = require("./resolveDocument"); -Object.defineProperty(exports, "fileToDocument", { enumerable: true, get: function () { return resolveDocument_1.fileToDocument; } }); -Object.defineProperty(exports, "fileToTextDocument", { enumerable: true, get: function () { return resolveDocument_1.fileToTextDocument; } }); +var isBinaryDoc_js_1 = require("./isBinaryDoc.js"); +Object.defineProperty(exports, "isBinaryFile", { enumerable: true, get: function () { return isBinaryDoc_js_1.isBinaryFile; } }); +var resolveDocument_js_1 = require("./resolveDocument.js"); +Object.defineProperty(exports, "fileToDocument", { enumerable: true, get: function () { return resolveDocument_js_1.fileToDocument; } }); +Object.defineProperty(exports, "fileToTextDocument", { enumerable: true, get: function () { return resolveDocument_js_1.fileToTextDocument; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/cjs/Document/isBinaryDoc.js b/action/node_modules/cspell-lib/dist/cjs/Document/isBinaryDoc.js new file mode 100644 index 000000000..3e53b1eec --- /dev/null +++ b/action/node_modules/cspell-lib/dist/cjs/Document/isBinaryDoc.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isBinaryFile = exports.isBinaryDoc = void 0; +const LanguageIds_js_1 = require("../LanguageIds.js"); +const Uri_js_1 = require("../util/Uri.js"); +const normalizeLanguageIds_js_1 = require("./normalizeLanguageIds.js"); +function isBinaryDoc(document) { + return isBinaryFile((0, Uri_js_1.toUri)(document.uri), document.languageId); +} +exports.isBinaryDoc = isBinaryDoc; +function isBinaryFile(filename, languageId) { + const filenameUri = (0, Uri_js_1.toUri)(filename); + if (languageId) { + const ids = (0, normalizeLanguageIds_js_1.normalizeLanguageIds)(languageId); + if (ids.length) + return (0, LanguageIds_js_1.isGenerated)(ids); + } + const file = (0, Uri_js_1.basename)(filenameUri); + return (0, LanguageIds_js_1.isGeneratedFile)(file); +} +exports.isBinaryFile = isBinaryFile; +//# sourceMappingURL=isBinaryDoc.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/Document/normalizeLanguageIds.js b/action/node_modules/cspell-lib/dist/cjs/Document/normalizeLanguageIds.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Document/normalizeLanguageIds.js rename to action/node_modules/cspell-lib/dist/cjs/Document/normalizeLanguageIds.js diff --git a/action/node_modules/cspell-lib/dist/Document/resolveDocument.js b/action/node_modules/cspell-lib/dist/cjs/Document/resolveDocument.js similarity index 90% rename from action/node_modules/cspell-lib/dist/Document/resolveDocument.js rename to action/node_modules/cspell-lib/dist/cjs/Document/resolveDocument.js index 0154f614b..6ea05ebb4 100644 --- a/action/node_modules/cspell-lib/dist/Document/resolveDocument.js +++ b/action/node_modules/cspell-lib/dist/cjs/Document/resolveDocument.js @@ -25,12 +25,12 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveDocument = exports.resolveDocumentToTextDocument = exports.documentToTextDocument = exports.fileToTextDocument = exports.fileToDocument = void 0; const promises_1 = require("fs/promises"); -const TextDocument_1 = require("../Models/TextDocument"); -const Uri = __importStar(require("../util/Uri")); -const util_1 = require("../util/util"); +const TextDocument_js_1 = require("../Models/TextDocument.js"); +const Uri = __importStar(require("../util/Uri.js")); +const util_js_1 = require("../util/util.js"); const defaultEncoding = 'utf8'; function fileToDocument(file, text, languageId, locale) { - return (0, util_1.clean)({ + return (0, util_js_1.clean)({ uri: Uri.toUri(file).toString(), text, languageId, @@ -44,7 +44,7 @@ async function fileToTextDocument(file) { exports.fileToTextDocument = fileToTextDocument; function documentToTextDocument(document) { const { uri, text: content, languageId, locale } = document; - return (0, TextDocument_1.createTextDocument)({ uri, content, languageId, locale }); + return (0, TextDocument_js_1.createTextDocument)({ uri, content, languageId, locale }); } exports.documentToTextDocument = documentToTextDocument; async function resolveDocumentToTextDocument(doc) { diff --git a/action/node_modules/cspell-lib/dist/FeatureFlags/FeatureFlags.js b/action/node_modules/cspell-lib/dist/cjs/FeatureFlags/FeatureFlags.js similarity index 100% rename from action/node_modules/cspell-lib/dist/FeatureFlags/FeatureFlags.js rename to action/node_modules/cspell-lib/dist/cjs/FeatureFlags/FeatureFlags.js diff --git a/action/node_modules/cspell-lib/dist/FeatureFlags/index.js b/action/node_modules/cspell-lib/dist/cjs/FeatureFlags/index.js similarity index 57% rename from action/node_modules/cspell-lib/dist/FeatureFlags/index.js rename to action/node_modules/cspell-lib/dist/cjs/FeatureFlags/index.js index 180c33dec..7037d3f91 100644 --- a/action/node_modules/cspell-lib/dist/FeatureFlags/index.js +++ b/action/node_modules/cspell-lib/dist/cjs/FeatureFlags/index.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UnknownFeatureFlagError = exports.getSystemFeatureFlags = exports.FeatureFlags = void 0; -var FeatureFlags_1 = require("./FeatureFlags"); -Object.defineProperty(exports, "FeatureFlags", { enumerable: true, get: function () { return FeatureFlags_1.FeatureFlags; } }); -Object.defineProperty(exports, "getSystemFeatureFlags", { enumerable: true, get: function () { return FeatureFlags_1.getSystemFeatureFlags; } }); -Object.defineProperty(exports, "UnknownFeatureFlagError", { enumerable: true, get: function () { return FeatureFlags_1.UnknownFeatureFlagError; } }); +var FeatureFlags_js_1 = require("./FeatureFlags.js"); +Object.defineProperty(exports, "FeatureFlags", { enumerable: true, get: function () { return FeatureFlags_js_1.FeatureFlags; } }); +Object.defineProperty(exports, "getSystemFeatureFlags", { enumerable: true, get: function () { return FeatureFlags_js_1.getSystemFeatureFlags; } }); +Object.defineProperty(exports, "UnknownFeatureFlagError", { enumerable: true, get: function () { return FeatureFlags_js_1.UnknownFeatureFlagError; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/LanguageIds.js b/action/node_modules/cspell-lib/dist/cjs/LanguageIds.js similarity index 98% rename from action/node_modules/cspell-lib/dist/LanguageIds.js rename to action/node_modules/cspell-lib/dist/cjs/LanguageIds.js index 14f37cc6f..5ebab1246 100644 --- a/action/node_modules/cspell-lib/dist/LanguageIds.js +++ b/action/node_modules/cspell-lib/dist/cjs/LanguageIds.js @@ -8,7 +8,7 @@ */ Object.defineProperty(exports, "__esModule", { value: true }); exports.getLanguagesForBasename = exports.getLanguagesForExt = exports.buildLanguageExtensionMapSet = exports.isGenerated = exports.isGeneratedFile = exports.isGeneratedExt = exports.isBinary = exports.isBinaryFile = exports.isBinaryExt = exports.languageIds = exports.generatedFiles = exports.binaryLanguages = exports.languageExtensionDefinitions = void 0; -const AutoResolve_1 = require("./util/AutoResolve"); +const AutoResolve_js_1 = require("./util/AutoResolve.js"); exports.languageExtensionDefinitions = [ { id: 'ada', extensions: ['.adb', '.ads'] }, { id: 'apiblueprint', extensions: ['.apib', '.apiblueprint'] }, @@ -280,7 +280,7 @@ function doesSetContainAnyOf(setOfIds, languageId) { function buildLanguageExtensionMapSet(defs) { return defs.reduce((map, def) => { function addId(value) { - (0, AutoResolve_1.autoResolve)(map, value, () => new Set()).add(def.id); + (0, AutoResolve_js_1.autoResolve)(map, value, () => new Set()).add(def.id); } def.extensions.forEach(addId); def.filenames?.forEach(addId); diff --git a/action/node_modules/cspell-lib/dist/Models/CSpellSettingsInternalDef.js b/action/node_modules/cspell-lib/dist/cjs/Models/CSpellSettingsInternalDef.js similarity index 91% rename from action/node_modules/cspell-lib/dist/Models/CSpellSettingsInternalDef.js rename to action/node_modules/cspell-lib/dist/cjs/Models/CSpellSettingsInternalDef.js index 64d54b6d5..749f585c5 100644 --- a/action/node_modules/cspell-lib/dist/Models/CSpellSettingsInternalDef.js +++ b/action/node_modules/cspell-lib/dist/cjs/Models/CSpellSettingsInternalDef.js @@ -1,16 +1,16 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isDictionaryDefinitionInlineInternal = exports.isCSpellSettingsInternal = exports.createCSpellSettingsInternal = exports.cleanCSpellSettingsInternal = exports.SymbolCSpellSettingsInternal = void 0; -const util_1 = require("../util/util"); +const util_js_1 = require("../util/util.js"); exports.SymbolCSpellSettingsInternal = Symbol('CSpellSettingsInternal'); function cleanCSpellSettingsInternal(parts = {}) { - const csi = (0, util_1.clean)(parts); + const csi = (0, util_js_1.clean)(parts); Object.assign(csi, { [exports.SymbolCSpellSettingsInternal]: true }); return csi; } exports.cleanCSpellSettingsInternal = cleanCSpellSettingsInternal; function createCSpellSettingsInternal(parts = {}) { - return (0, util_1.clean)({ + return (0, util_js_1.clean)({ ...parts, [exports.SymbolCSpellSettingsInternal]: true, }); diff --git a/action/node_modules/cspell-lib/dist/Models/PatternRegExp.js b/action/node_modules/cspell-lib/dist/cjs/Models/PatternRegExp.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Models/PatternRegExp.js rename to action/node_modules/cspell-lib/dist/cjs/Models/PatternRegExp.js diff --git a/action/node_modules/cspell-lib/dist/Models/Suggestion.js b/action/node_modules/cspell-lib/dist/cjs/Models/Suggestion.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Models/Suggestion.js rename to action/node_modules/cspell-lib/dist/cjs/Models/Suggestion.js diff --git a/action/node_modules/cspell-lib/dist/Models/TextDocument.js b/action/node_modules/cspell-lib/dist/cjs/Models/TextDocument.js similarity index 96% rename from action/node_modules/cspell-lib/dist/Models/TextDocument.js rename to action/node_modules/cspell-lib/dist/cjs/Models/TextDocument.js index 0b56bcd54..fd3fd858d 100644 --- a/action/node_modules/cspell-lib/dist/Models/TextDocument.js +++ b/action/node_modules/cspell-lib/dist/cjs/Models/TextDocument.js @@ -30,8 +30,8 @@ exports.isTextDocument = exports.loadTextDocument = exports.updateTextDocument = const assert_1 = __importDefault(require("assert")); const fs_1 = require("fs"); const vscode_languageserver_textdocument_1 = require("vscode-languageserver-textdocument"); -const LanguageIds_1 = require("../LanguageIds"); -const Uri = __importStar(require("../util/Uri")); +const LanguageIds_js_1 = require("../LanguageIds.js"); +const Uri = __importStar(require("../util/Uri.js")); class TextDocumentImpl { constructor(uri, text, languageId, locale, version) { this.uri = uri; @@ -115,7 +115,7 @@ class TextDocumentImpl { function createTextDocument({ uri, content, languageId, locale, version, }) { version = version ?? 1; uri = Uri.toUri(uri); - languageId = languageId ?? (0, LanguageIds_1.getLanguagesForBasename)(Uri.basename(uri)); + languageId = languageId ?? (0, LanguageIds_js_1.getLanguagesForBasename)(Uri.basename(uri)); languageId = languageId.length === 0 ? 'text' : languageId; return new TextDocumentImpl(uri, content, languageId, locale, version); } diff --git a/action/node_modules/cspell-lib/dist/Models/ValidationIssue.js b/action/node_modules/cspell-lib/dist/cjs/Models/ValidationIssue.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Models/ValidationIssue.js rename to action/node_modules/cspell-lib/dist/cjs/Models/ValidationIssue.js diff --git a/action/node_modules/cspell-lib/dist/Models/ValidationResult.js b/action/node_modules/cspell-lib/dist/cjs/Models/ValidationResult.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Models/ValidationResult.js rename to action/node_modules/cspell-lib/dist/cjs/Models/ValidationResult.js diff --git a/action/node_modules/cspell-lib/dist/Settings/CSpellSettingsServer.js b/action/node_modules/cspell-lib/dist/cjs/Settings/CSpellSettingsServer.js similarity index 87% rename from action/node_modules/cspell-lib/dist/Settings/CSpellSettingsServer.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/CSpellSettingsServer.js index 28972cfd1..043ceac69 100644 --- a/action/node_modules/cspell-lib/dist/Settings/CSpellSettingsServer.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/CSpellSettingsServer.js @@ -30,12 +30,12 @@ exports.__testing__ = exports.extractDependencies = exports.getSources = exports const assert_1 = __importDefault(require("assert")); const cspell_glob_1 = require("cspell-glob"); const path = __importStar(require("path")); -const CSpellSettingsInternalDef_1 = require("../Models/CSpellSettingsInternalDef"); -const AutoResolve_1 = require("../util/AutoResolve"); -const util = __importStar(require("../util/util")); -const constants_1 = require("./constants"); -const DictionarySettings_1 = require("./DictionarySettings"); -const patterns_1 = require("./patterns"); +const CSpellSettingsInternalDef_js_1 = require("../Models/CSpellSettingsInternalDef.js"); +const AutoResolve_js_1 = require("../util/AutoResolve.js"); +const util = __importStar(require("../util/util.js")); +const constants_js_1 = require("./constants.js"); +const DictionarySettings_js_1 = require("./DictionarySettings.js"); +const patterns_js_1 = require("./patterns.js"); function _unique(a) { return [...new Set(a)]; } @@ -65,8 +65,8 @@ const emptyWords = []; Object.freeze(emptyWords); const cachedMerges = new WeakMap(); function _mergeWordsCached(left, right) { - const map = (0, AutoResolve_1.autoResolveWeak)(cachedMerges, left, () => new WeakMap()); - return (0, AutoResolve_1.autoResolveWeak)(map, right, () => left.concat(right)); + const map = (0, AutoResolve_js_1.autoResolveWeak)(cachedMerges, left, () => new WeakMap()); + return (0, AutoResolve_js_1.autoResolveWeak)(map, right, () => left.concat(right)); } function mergeWordsCached(left, right) { if (left === undefined) @@ -94,7 +94,7 @@ function replaceIfNotEmpty(left = [], right = []) { return left; } function mergeSettings(left, ...settings) { - const rawSettings = settings.filter((a) => !!a).reduce(merge, toInternalSettings(left)); + const rawSettings = settings.filter(util.isDefined).reduce(merge, toInternalSettings(left)); return util.clean(rawSettings); } exports.mergeSettings = mergeSettings; @@ -102,10 +102,10 @@ exports.mergeSettings = mergeSettings; function isEmpty(obj) { return Object.keys(obj).length === 0 && obj.constructor === Object; } -const mergeCache = new AutoResolve_1.AutoResolveWeakCache(); +const mergeCache = new AutoResolve_js_1.AutoResolveWeakCache(); function merge(left, right) { const map = mergeCache.get(left, () => new WeakMap()); - return (0, AutoResolve_1.autoResolveWeak)(map, right, () => _merge(left, right)); + return (0, AutoResolve_js_1.autoResolveWeak)(map, right, () => _merge(left, right)); } function _merge(left, right) { const _left = toInternalSettings(left); @@ -136,7 +136,7 @@ function _merge(left, right) { import: undefined, __importRef: undefined, }; - const settings = (0, CSpellSettingsInternalDef_1.cleanCSpellSettingsInternal)({ + const settings = (0, CSpellSettingsInternalDef_js_1.cleanCSpellSettingsInternal)({ ..._left, ..._right, ...optionals, @@ -167,7 +167,7 @@ function _merge(left, right) { return settings; } function versionBasedMergeList(left, right, version) { - if (version === constants_1.configSettingsFileVersion0_1) { + if (version === constants_js_1.configSettingsFileVersion0_1) { return takeRightOtherwiseLeft(left, right); } return mergeListUnique(left, right); @@ -236,28 +236,28 @@ function _finalizeSettings(settings) { const finalized = { ...settings, finalized: true, - ignoreRegExpList: (0, patterns_1.resolvePatterns)(settings.ignoreRegExpList, settings.patterns), - includeRegExpList: (0, patterns_1.resolvePatterns)(settings.includeRegExpList, settings.patterns), + ignoreRegExpList: (0, patterns_js_1.resolvePatterns)(settings.ignoreRegExpList, settings.patterns), + includeRegExpList: (0, patterns_js_1.resolvePatterns)(settings.includeRegExpList, settings.patterns), parserFn: resolveParser(settings), }; finalized.name = 'Finalized ' + (finalized.name || ''); finalized.source = { name: settings.name || 'src', sources: [settings] }; return finalized; } -const cacheInternalSettings = new AutoResolve_1.AutoResolveWeakCache(); +const cacheInternalSettings = new AutoResolve_js_1.AutoResolveWeakCache(); function toInternalSettings(settings) { if (settings === undefined) return undefined; - if ((0, CSpellSettingsInternalDef_1.isCSpellSettingsInternal)(settings)) + if ((0, CSpellSettingsInternalDef_js_1.isCSpellSettingsInternal)(settings)) return settings; return cacheInternalSettings.get(settings, _toInternalSettings); } exports.toInternalSettings = toInternalSettings; function _toInternalSettings(settings) { const { dictionaryDefinitions: defs, ...rest } = settings; - const dictionaryDefinitions = (0, DictionarySettings_1.mapDictDefsToInternal)(defs, filenameToDirectory(settings.source?.filename) || resolveCwd()); + const dictionaryDefinitions = (0, DictionarySettings_js_1.mapDictDefsToInternal)(defs, filenameToDirectory(settings.source?.filename) || resolveCwd()); const setting = dictionaryDefinitions ? { ...rest, dictionaryDefinitions } : rest; - return (0, CSpellSettingsInternalDef_1.cleanCSpellSettingsInternal)(setting); + return (0, CSpellSettingsInternalDef_js_1.cleanCSpellSettingsInternal)(setting); } function filenameToDirectory(filename) { return filename ? path.dirname(filename) : undefined; @@ -325,7 +325,7 @@ function mergeImportRefs(left, right = {}) { function extractDependencies(settings) { const settingsI = toInternalSettings(settings); const configFiles = [...(mergeImportRefs(settingsI) || [])].map(([filename]) => filename); - const dictionaryFiles = (0, DictionarySettings_1.calcDictionaryDefsToLoad)(settingsI) + const dictionaryFiles = (0, DictionarySettings_js_1.calcDictionaryDefsToLoad)(settingsI) .map((dict) => dict.path) .filter((file) => !!file); return { @@ -335,7 +335,7 @@ function extractDependencies(settings) { } exports.extractDependencies = extractDependencies; function resolveCwd() { - const envGlobRoot = process.env[constants_1.ENV_CSPELL_GLOB_ROOT]; + const envGlobRoot = process.env[constants_js_1.ENV_CSPELL_GLOB_ROOT]; const cwd = envGlobRoot || process.cwd(); return cwd; } @@ -351,7 +351,7 @@ function resolveParser(settings) { (0, assert_1.default)(parser, `Parser "${parserName}" not found.`); return parser; } -const parserCache = new AutoResolve_1.AutoResolveWeakCache(); +const parserCache = new AutoResolve_js_1.AutoResolveWeakCache(); const emptyParserMap = new Map(); function* parsers(plugins) { for (const plugin of plugins) { diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/ImportError.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/ImportError.js similarity index 82% rename from action/node_modules/cspell-lib/dist/Settings/Controller/ImportError.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/ImportError.js index 008bf4c3e..68fd6493f 100644 --- a/action/node_modules/cspell-lib/dist/Settings/Controller/ImportError.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/ImportError.js @@ -1,11 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UnsupportedPnpFile = exports.UnsupportedSchema = exports.ImportError = void 0; -const errors_1 = require("../../util/errors"); +const errors_js_1 = require("../../util/errors.js"); class ImportError extends Error { constructor(msg, cause) { super(msg); - this.cause = (0, errors_1.isError)(cause) ? cause : undefined; + this.cause = (0, errors_js_1.isError)(cause) ? cause : undefined; } } exports.ImportError = ImportError; diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/SettingsController.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/SettingsController.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Settings/Controller/SettingsController.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/SettingsController.js diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/PnPSettings.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/PnPSettings.js similarity index 88% rename from action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/PnPSettings.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/PnPSettings.js index 15605da19..b104e975c 100644 --- a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/PnPSettings.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/PnPSettings.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizePnPSettings = exports.defaultPnPSettings = void 0; -const util_1 = require("../../../util/util"); +const util_js_1 = require("../../../util/util.js"); exports.defaultPnPSettings = Object.freeze({}); let lastPnP = exports.defaultPnPSettings; /** @@ -16,7 +16,7 @@ function normalizePnPSettings(settings) { if (equal(exports.defaultPnPSettings, settings)) return exports.defaultPnPSettings; const { usePnP, pnpFiles } = settings; - return (lastPnP = (0, util_1.clean)({ usePnP, pnpFiles })); + return (lastPnP = (0, util_js_1.clean)({ usePnP, pnpFiles })); } exports.normalizePnPSettings = normalizePnPSettings; function equal(a, b) { diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/configLoader.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/configLoader.js similarity index 73% rename from action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/configLoader.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/configLoader.js index cb9fec5ac..3077c5318 100644 --- a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/configLoader.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/configLoader.js @@ -28,20 +28,20 @@ const json = __importStar(require("comment-json")); const cosmiconfig_1 = require("cosmiconfig"); const cspell_io_1 = require("cspell-io"); const path = __importStar(require("path")); -const CSpellSettingsInternalDef_1 = require("../../../Models/CSpellSettingsInternalDef"); -const AutoResolveLRUCache_1 = require("../../../util/AutoResolveLRUCache"); -const logger_1 = require("../../../util/logger"); -const resolveFile_1 = require("../../../util/resolveFile"); -const Uri_1 = require("../../../util/Uri"); -const constants_1 = require("../../constants"); -const CSpellSettingsServer_1 = require("../../CSpellSettingsServer"); -const GlobalSettings_1 = require("../../GlobalSettings"); -const ImportError_1 = require("../ImportError"); -const pnpLoader_1 = require("../pnpLoader"); -const defaultSettings_1 = require("./defaultSettings"); -const normalizeRawSettings_1 = require("./normalizeRawSettings"); -const PnPSettings_1 = require("./PnPSettings"); -const supportedCSpellConfigVersions = [constants_1.configSettingsFileVersion0_2]; +const CSpellSettingsInternalDef_js_1 = require("../../../Models/CSpellSettingsInternalDef.js"); +const AutoResolveLRUCache_js_1 = require("../../../util/AutoResolveLRUCache.js"); +const logger_js_1 = require("../../../util/logger.js"); +const resolveFile_js_1 = require("../../../util/resolveFile.js"); +const Uri_js_1 = require("../../../util/Uri.js"); +const constants_js_1 = require("../../constants.js"); +const CSpellSettingsServer_js_1 = require("../../CSpellSettingsServer.js"); +const GlobalSettings_js_1 = require("../../GlobalSettings.js"); +const ImportError_js_1 = require("../ImportError.js"); +const pnpLoader_js_1 = require("../pnpLoader.js"); +const defaultSettings_js_1 = require("./defaultSettings.js"); +const normalizeRawSettings_js_1 = require("./normalizeRawSettings.js"); +const PnPSettings_js_1 = require("./PnPSettings.js"); +const supportedCSpellConfigVersions = [constants_js_1.configSettingsFileVersion0_2]; const setOfSupportedConfigVersions = Object.freeze(new Set(supportedCSpellConfigVersions)); exports.sectionCSpell = 'cSpell'; exports.defaultFileName = 'cspell.json'; @@ -79,6 +79,21 @@ const searchPlaces = Object.freeze([ // Dynamic config is looked for last 'cspell.config.js', 'cspell.config.cjs', + // .config + '.config/.cspell.json', + '.config/cspell.json', + '.config/.cSpell.json', + '.config/cSpell.json', + '.config/.cspell.jsonc', + '.config/cspell.jsonc', + '.config/cspell.config.json', + '.config/cspell.config.jsonc', + '.config/cspell.config.yaml', + '.config/cspell.config.yml', + '.config/cspell.yaml', + '.config/cspell.yml', + '.config/cspell.config.js', + '.config/cspell.config.cjs', ]); const cspellCosmiconfig = { searchPlaces: searchPlaces.concat(), @@ -102,18 +117,18 @@ class ConfigLoader { this.cachedFiles = new Map(); this.cspellConfigExplorer = (0, cosmiconfig_1.cosmiconfig)('cspell', cspellCosmiconfig); this.cspellConfigExplorerSync = (0, cosmiconfig_1.cosmiconfigSync)('cspell', cspellCosmiconfig); - this.searchConfigLRU = new AutoResolveLRUCache_1.AutoResolveLRUCache(CACHE_SIZE_SEARCH_CONFIG, (a, b) => a.searchFrom === b.searchFrom && a.pnpSettings === b.pnpSettings); + this.searchConfigLRU = new AutoResolveLRUCache_js_1.AutoResolveLRUCache(CACHE_SIZE_SEARCH_CONFIG, (a, b) => a.searchFrom === b.searchFrom && a.pnpSettings === b.pnpSettings); } readSettings(filename, relativeToOrDefault, defaultValue) { // console.log('Read Settings: %o', { filename, relativeToOrDefault }); const relativeTo = (typeof relativeToOrDefault === 'string' ? relativeToOrDefault : '') || process.cwd(); defaultValue = defaultValue || (typeof relativeToOrDefault !== 'string' ? relativeToOrDefault : undefined); const ref = resolveFilename(filename, relativeTo); - return this.importSettings(ref, defaultValue, defaultValue || PnPSettings_1.defaultPnPSettings); + return this.importSettings(ref, defaultValue, defaultValue || PnPSettings_js_1.defaultPnPSettings); } async readSettingsAsync(filename, relativeTo, pnpSettings) { const ref = resolveFilename(filename, relativeTo || process.cwd()); - return this.importSettings(ref, undefined, pnpSettings || PnPSettings_1.defaultPnPSettings); + return this.importSettings(ref, undefined, pnpSettings || PnPSettings_js_1.defaultPnPSettings); } /** * @@ -121,8 +136,8 @@ class ConfigLoader { * @param pnpSettings - related to Using Yarn PNP. * @returns the resulting settings */ - searchForConfig(searchFrom, pnpSettings = PnPSettings_1.defaultPnPSettings) { - pnpSettings = (0, PnPSettings_1.normalizePnPSettings)(pnpSettings); + searchForConfig(searchFrom, pnpSettings = PnPSettings_js_1.defaultPnPSettings) { + pnpSettings = (0, PnPSettings_js_1.normalizePnPSettings)(pnpSettings); return this.searchConfigLRU.get({ searchFrom, pnpSettings }, (p) => this._searchForConfig(p)); } _searchForConfig(params) { @@ -133,7 +148,7 @@ class ConfigLoader { } getGlobalSettings() { if (!this.globalSettings) { - const globalConf = (0, GlobalSettings_1.getRawGlobalSettings)(); + const globalConf = (0, GlobalSettings_js_1.getRawGlobalSettings)(); this.globalSettings = { id: 'global_config', ...this.normalizeSettings(globalConf || {}, './global_config', {}), @@ -157,9 +172,9 @@ class ConfigLoader { const { filename, error } = fileRef; if (error) { fileRef.error = - error instanceof ImportError_1.ImportError + error instanceof ImportError_js_1.ImportError ? error - : new ImportError_1.ImportError(`Failed to read config file: "${filename}"`, error); + : new ImportError_js_1.ImportError(`Failed to read config file: "${filename}"`, error); return { __importRef: fileRef }; } const s = {}; @@ -168,18 +183,18 @@ class ConfigLoader { if (!r?.config) throw new Error(`not found: "${filename}"`); Object.assign(s, r.config); - (0, normalizeRawSettings_1.normalizeRawConfig)(s); + (0, normalizeRawSettings_js_1.normalizeRawConfig)(s); validateRawConfig(s, fileRef); } catch (err) { fileRef.error = - err instanceof ImportError_1.ImportError ? err : new ImportError_1.ImportError(`Failed to read config file: "${filename}"`, err); + err instanceof ImportError_js_1.ImportError ? err : new ImportError_js_1.ImportError(`Failed to read config file: "${filename}"`, err); } s.__importRef = fileRef; return s; } importSettings(fileRef, defaultValues, pnpSettings) { - defaultValues = defaultValues ?? defaultSettings_1.defaultSettings; + defaultValues = defaultValues ?? defaultSettings_js_1.defaultSettings; const { filename } = fileRef; const importRef = { ...fileRef }; const cached = this.cachedFiles.get(filename); @@ -191,7 +206,7 @@ class ConfigLoader { } const id = [path.basename(path.dirname(filename)), path.basename(filename)].join('/'); const name = ''; - const finalizeSettings = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({ id, name, __importRef: importRef }); + const finalizeSettings = (0, CSpellSettingsInternalDef_js_1.createCSpellSettingsInternal)({ id, name, __importRef: importRef }); this.cachedFiles.set(filename, finalizeSettings); // add an empty entry to prevent circular references. const settings = { ...defaultValues, id, name, ...this.readConfig(importRef) }; Object.assign(finalizeSettings, this.normalizeSettings(settings, filename, pnpSettings)); @@ -211,31 +226,31 @@ class ConfigLoader { const name = rawSettings.name || id; // Try to load any .pnp files before reading dictionaries or other config files. const { usePnP = pnpSettings.usePnP, pnpFiles = pnpSettings.pnpFiles } = rawSettings; - const pnpSettingsToUse = (0, PnPSettings_1.normalizePnPSettings)({ usePnP, pnpFiles }); + const pnpSettingsToUse = (0, PnPSettings_js_1.normalizePnPSettings)({ usePnP, pnpFiles }); const pathToSettingsDir = path.dirname(pathToSettingsFile); - loadPnPSync(pnpSettingsToUse, (0, Uri_1.toUri)(pathToSettingsDir)); + loadPnPSync(pnpSettingsToUse, (0, Uri_js_1.toUri)(pathToSettingsDir)); // Fix up dictionaryDefinitions const settings = { - version: defaultSettings_1.defaultSettings.version, + version: defaultSettings_js_1.defaultSettings.version, ...rawSettings, id, name, globRoot: resolveGlobRoot(rawSettings, pathToSettingsFile), - languageSettings: (0, normalizeRawSettings_1.normalizeLanguageSettings)(rawSettings.languageSettings), + languageSettings: (0, normalizeRawSettings_js_1.normalizeLanguageSettings)(rawSettings.languageSettings), }; const pathToSettings = path.dirname(pathToSettingsFile); - const normalizedDictionaryDefs = (0, normalizeRawSettings_1.normalizeDictionaryDefs)(settings, pathToSettingsFile); - const normalizedSettingsGlobs = (0, normalizeRawSettings_1.normalizeSettingsGlobs)(settings, pathToSettingsFile); - const normalizedOverrides = (0, normalizeRawSettings_1.normalizeOverrides)(settings, pathToSettingsFile); - const normalizedReporters = (0, normalizeRawSettings_1.normalizeReporters)(settings, pathToSettingsFile); - const normalizedGitignoreRoot = (0, normalizeRawSettings_1.normalizeGitignoreRoot)(settings, pathToSettingsFile); - const normalizedCacheSettings = (0, normalizeRawSettings_1.normalizeCacheSettings)(settings, pathToSettingsDir); + const normalizedDictionaryDefs = (0, normalizeRawSettings_js_1.normalizeDictionaryDefs)(settings, pathToSettingsFile); + const normalizedSettingsGlobs = (0, normalizeRawSettings_js_1.normalizeSettingsGlobs)(settings, pathToSettingsFile); + const normalizedOverrides = (0, normalizeRawSettings_js_1.normalizeOverrides)(settings, pathToSettingsFile); + const normalizedReporters = (0, normalizeRawSettings_js_1.normalizeReporters)(settings, pathToSettingsFile); + const normalizedGitignoreRoot = (0, normalizeRawSettings_js_1.normalizeGitignoreRoot)(settings, pathToSettingsFile); + const normalizedCacheSettings = (0, normalizeRawSettings_js_1.normalizeCacheSettings)(settings, pathToSettingsDir); const imports = typeof settings.import === 'string' ? [settings.import] : settings.import || []; const source = settings.source || { name: settings.name, filename: pathToSettingsFile, }; - const fileSettings = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({ + const fileSettings = (0, CSpellSettingsInternalDef_js_1.createCSpellSettingsInternal)({ ...settings, source, ...normalizedDictionaryDefs, @@ -252,8 +267,8 @@ class ConfigLoader { .map((name) => resolveFilename(name, pathToSettings)) .map((ref) => ((ref.referencedBy = [source]), ref)) .map((ref) => this.importSettings(ref, undefined, pnpSettingsToUse)) - .reduce((a, b) => (0, CSpellSettingsServer_1.mergeSettings)(a, b)); - const finalizeSettings = (0, CSpellSettingsServer_1.mergeSettings)(importedSettings, fileSettings); + .reduce((a, b) => (0, CSpellSettingsServer_js_1.mergeSettings)(a, b)); + const finalizeSettings = (0, CSpellSettingsServer_js_1.mergeSettings)(importedSettings, fileSettings); finalizeSettings.name = settings.name || finalizeSettings.name || ''; finalizeSettings.id = settings.id || finalizeSettings.id || ''; return finalizeSettings; @@ -281,13 +296,13 @@ class ConfigLoaderInternal extends ConfigLoader { result = (await searchResult) || undefined; } catch (cause) { - result = new ImportError_1.ImportError(`Failed to find config file at: "${searchPath}"`, cause); + result = new ImportError_js_1.ImportError(`Failed to find config file at: "${searchPath}"`, cause); } return this.normalizeSearchForConfigResult(searchPath, result, pnpSettings); } normalizeSearchForConfigResult(searchPath, searchResult, pnpSettings) { - const error = searchResult instanceof ImportError_1.ImportError ? searchResult : undefined; - const result = searchResult instanceof ImportError_1.ImportError ? undefined : searchResult; + const error = searchResult instanceof ImportError_js_1.ImportError ? searchResult : undefined; + const result = searchResult instanceof ImportError_js_1.ImportError ? undefined : searchResult; const filepath = result?.filepath; if (filepath) { const cached = cachedFiles().get(filepath); @@ -299,12 +314,12 @@ class ConfigLoaderInternal extends ConfigLoader { }; } } - const { config = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({}) } = result || {}; + const { config = (0, CSpellSettingsInternalDef_js_1.createCSpellSettingsInternal)({}) } = result || {}; const filename = result?.filepath ?? searchPath; const importRef = { filename: filename, error }; const id = [path.basename(path.dirname(filename)), path.basename(filename)].join('/'); const name = result?.filepath ? id : `Config not found: ${id}`; - const finalizeSettings = (0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({ id, name, __importRef: importRef }); + const finalizeSettings = (0, CSpellSettingsInternalDef_js_1.createCSpellSettingsInternal)({ id, name, __importRef: importRef }); const settings = { id, ...config }; cachedFiles().set(filename, finalizeSettings); // add an empty entry to prevent circular references. Object.assign(finalizeSettings, this.normalizeSettings(settings, filename, pnpSettings)); @@ -331,7 +346,7 @@ function mergeSourceList(orig, append) { * @param pnpSettings - related to Using Yarn PNP. * @returns the resulting settings */ -function searchForConfig(searchFrom, pnpSettings = PnPSettings_1.defaultPnPSettings) { +function searchForConfig(searchFrom, pnpSettings = PnPSettings_js_1.defaultPnPSettings) { return gcl().searchForConfig(searchFrom, pnpSettings); } exports.searchForConfig = searchForConfig; @@ -343,14 +358,14 @@ exports.searchForConfig = searchForConfig; * @deprecated * @deprecationMessage Use `searchForConfig`. It is very difficult to support Sync files when settings include web requests. */ -function searchForConfigSync(searchFrom, pnpSettings = PnPSettings_1.defaultPnPSettings) { - pnpSettings = (0, PnPSettings_1.normalizePnPSettings)(pnpSettings); +function searchForConfigSync(searchFrom, pnpSettings = PnPSettings_js_1.defaultPnPSettings) { + pnpSettings = (0, PnPSettings_js_1.normalizePnPSettings)(pnpSettings); let searchResult; try { searchResult = cspellConfigExplorerSync().search(searchFrom) || undefined; } catch (err) { - searchResult = new ImportError_1.ImportError(`Failed to find config file from: "${searchFrom}"`, err); + searchResult = new ImportError_js_1.ImportError(`Failed to find config file from: "${searchFrom}"`, err); } return gcl().normalizeSearchForConfigResult(searchFrom || process.cwd(), searchResult, pnpSettings).config; } @@ -361,7 +376,7 @@ exports.searchForConfigSync = searchForConfigSync; * @param pnpSettings - PnP settings * @returns normalized CSpellSettings */ -async function loadConfig(file, pnpSettings = PnPSettings_1.defaultPnPSettings) { +async function loadConfig(file, pnpSettings = PnPSettings_js_1.defaultPnPSettings) { return gcl().readSettingsAsync(file, undefined, pnpSettings); } exports.loadConfig = loadConfig; @@ -372,8 +387,8 @@ exports.loadConfig = loadConfig; * @returns normalized CSpellSettings * @deprecated */ -function loadConfigSync(filename, pnpSettings = PnPSettings_1.defaultPnPSettings) { - const pnp = (0, PnPSettings_1.normalizePnPSettings)(pnpSettings); +function loadConfigSync(filename, pnpSettings = PnPSettings_js_1.defaultPnPSettings) { + const pnp = (0, PnPSettings_js_1.normalizePnPSettings)(pnpSettings); return gcl().readSettings(filename, pnp); } exports.loadConfigSync = loadConfigSync; @@ -381,7 +396,7 @@ function loadPnP(pnpSettings, searchFrom) { if (!pnpSettings.usePnP) { return Promise.resolve(undefined); } - const loader = (0, pnpLoader_1.pnpLoader)(pnpSettings.pnpFiles); + const loader = (0, pnpLoader_js_1.pnpLoader)(pnpSettings.pnpFiles); return loader.load(searchFrom); } exports.loadPnP = loadPnP; @@ -389,7 +404,7 @@ function loadPnPSync(pnpSettings, searchFrom) { if (!pnpSettings.usePnP) { return undefined; } - const loader = (0, pnpLoader_1.pnpLoader)(pnpSettings.pnpFiles); + const loader = (0, pnpLoader_js_1.pnpLoader)(pnpSettings.pnpFiles); return loader.loadSync(searchFrom); } exports.loadPnPSync = loadPnPSync; @@ -400,7 +415,7 @@ function readRawSettings(filename, relativeTo) { } exports.readRawSettings = readRawSettings; function resolveFilename(filename, relativeTo) { - const r = (0, resolveFile_1.resolveFile)(filename, relativeTo); + const r = (0, resolveFile_js_1.resolveFile)(filename, relativeTo); return { filename: r.filename, error: r.found ? undefined : new Error(`Failed to resolve file: "${filename}"`), @@ -418,14 +433,20 @@ function clearCachedSettingsFiles() { return gcl().clearCachedSettingsFiles(); } exports.clearCachedSettingsFiles = clearCachedSettingsFiles; +const nestedConfigDirectories = { + '.vscode': true, + '.config': true, +}; function resolveGlobRoot(settings, pathToSettingsFile) { const settingsFileDirRaw = path.dirname(pathToSettingsFile); - const isVSCode = path.basename(settingsFileDirRaw) === '.vscode'; - const settingsFileDir = isVSCode ? path.dirname(settingsFileDirRaw) : settingsFileDirRaw; - const envGlobRoot = process.env[constants_1.ENV_CSPELL_GLOB_ROOT]; + const settingsFileDirName = path.basename(settingsFileDirRaw); + const isNestedConfig = settingsFileDirName in nestedConfigDirectories; + const isVSCode = settingsFileDirName === '.vscode'; + const settingsFileDir = isNestedConfig ? path.dirname(settingsFileDirRaw) : settingsFileDirRaw; + const envGlobRoot = process.env[constants_js_1.ENV_CSPELL_GLOB_ROOT]; const defaultGlobRoot = envGlobRoot ?? '${cwd}'; const rawRoot = settings.globRoot ?? - (settings.version === constants_1.configSettingsFileVersion0_1 || + (settings.version === constants_js_1.configSettingsFileVersion0_1 || (envGlobRoot && !settings.version) || (isVSCode && !settings.version) ? defaultGlobRoot @@ -441,23 +462,23 @@ function validateRawConfigVersion(config, fileRef) { if (version === undefined) return; if (typeof version !== 'string') { - (0, logger_1.logError)(validationMessage(`Unsupported config file version: "${version}", string expected`, fileRef)); + (0, logger_js_1.logError)(validationMessage(`Unsupported config file version: "${version}", string expected`, fileRef)); return; } if (setOfSupportedConfigVersions.has(version)) return; if (!/^\d+(\.\d+)*$/.test(version)) { - (0, logger_1.logError)(validationMessage(`Unsupported config file version: "${version}"`, fileRef)); + (0, logger_js_1.logError)(validationMessage(`Unsupported config file version: "${version}"`, fileRef)); return; } - const msg = version > constants_1.currentSettingsFileVersion - ? `Newer config file version found: "${version}". Supported version is "${constants_1.currentSettingsFileVersion}"` - : `Legacy config file version found: "${version}", upgrade to "${constants_1.currentSettingsFileVersion}"`; - (0, logger_1.logWarning)(validationMessage(msg, fileRef)); + const msg = version > constants_js_1.currentSettingsFileVersion + ? `Newer config file version found: "${version}". Supported version is "${constants_js_1.currentSettingsFileVersion}"` + : `Legacy config file version found: "${version}", upgrade to "${constants_js_1.currentSettingsFileVersion}"`; + (0, logger_js_1.logWarning)(validationMessage(msg, fileRef)); } function validateRawConfigExports(config, fileRef) { if (config.default) { - throw new ImportError_1.ImportError(validationMessage('Module `export default` is not supported.\n Use `module.exports =` instead.', fileRef)); + throw new ImportError_js_1.ImportError(validationMessage('Module `export default` is not supported.\n Use `module.exports =` instead.', fileRef)); } } function validateRawConfig(config, fileRef) { @@ -488,7 +509,7 @@ function cspellConfigExplorerSync() { } exports.__testing__ = { getDefaultConfigLoaderInternal, - normalizeCacheSettings: normalizeRawSettings_1.normalizeCacheSettings, + normalizeCacheSettings: normalizeRawSettings_js_1.normalizeCacheSettings, validateRawConfigExports, validateRawConfigVersion, }; diff --git a/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/defaultSettings.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/defaultSettings.js new file mode 100644 index 000000000..a9915bc24 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/defaultSettings.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.defaultSettings = void 0; +const CSpellSettingsInternalDef_js_1 = require("../../../Models/CSpellSettingsInternalDef.js"); +const constants_js_1 = require("../../constants.js"); +exports.defaultSettings = (0, CSpellSettingsInternalDef_js_1.createCSpellSettingsInternal)({ + id: 'default', + name: 'default', + version: constants_js_1.currentSettingsFileVersion, +}); +//# sourceMappingURL=defaultSettings.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/extractImportErrors.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/extractImportErrors.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/extractImportErrors.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/extractImportErrors.js diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/index.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/index.js similarity index 52% rename from action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/index.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/index.js index 5c0b37ab4..9ee06d75d 100644 --- a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/index.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/index.js @@ -1,27 +1,27 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.readSettingsFiles = exports.readSettings = exports.extractImportErrors = exports.sectionCSpell = exports.searchForConfigSync = exports.searchForConfig = exports.readRawSettings = exports.loadPnPSync = exports.loadPnP = exports.loadConfigSync = exports.loadConfig = exports.getGlobalSettings = exports.getCachedFileSize = exports.defaultFileName = exports.defaultConfigFilenames = exports.createConfigLoader = exports.ConfigLoader = exports.clearCachedSettingsFiles = exports.__testing__ = void 0; -var configLoader_1 = require("./configLoader"); -Object.defineProperty(exports, "__testing__", { enumerable: true, get: function () { return configLoader_1.__testing__; } }); -Object.defineProperty(exports, "clearCachedSettingsFiles", { enumerable: true, get: function () { return configLoader_1.clearCachedSettingsFiles; } }); -Object.defineProperty(exports, "ConfigLoader", { enumerable: true, get: function () { return configLoader_1.ConfigLoader; } }); -Object.defineProperty(exports, "createConfigLoader", { enumerable: true, get: function () { return configLoader_1.createConfigLoader; } }); -Object.defineProperty(exports, "defaultConfigFilenames", { enumerable: true, get: function () { return configLoader_1.defaultConfigFilenames; } }); -Object.defineProperty(exports, "defaultFileName", { enumerable: true, get: function () { return configLoader_1.defaultFileName; } }); -Object.defineProperty(exports, "getCachedFileSize", { enumerable: true, get: function () { return configLoader_1.getCachedFileSize; } }); -Object.defineProperty(exports, "getGlobalSettings", { enumerable: true, get: function () { return configLoader_1.getGlobalSettings; } }); -Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return configLoader_1.loadConfig; } }); -Object.defineProperty(exports, "loadConfigSync", { enumerable: true, get: function () { return configLoader_1.loadConfigSync; } }); -Object.defineProperty(exports, "loadPnP", { enumerable: true, get: function () { return configLoader_1.loadPnP; } }); -Object.defineProperty(exports, "loadPnPSync", { enumerable: true, get: function () { return configLoader_1.loadPnPSync; } }); -Object.defineProperty(exports, "readRawSettings", { enumerable: true, get: function () { return configLoader_1.readRawSettings; } }); -Object.defineProperty(exports, "searchForConfig", { enumerable: true, get: function () { return configLoader_1.searchForConfig; } }); -Object.defineProperty(exports, "searchForConfigSync", { enumerable: true, get: function () { return configLoader_1.searchForConfigSync; } }); -Object.defineProperty(exports, "sectionCSpell", { enumerable: true, get: function () { return configLoader_1.sectionCSpell; } }); -var extractImportErrors_1 = require("./extractImportErrors"); -Object.defineProperty(exports, "extractImportErrors", { enumerable: true, get: function () { return extractImportErrors_1.extractImportErrors; } }); -var readSettings_1 = require("./readSettings"); -Object.defineProperty(exports, "readSettings", { enumerable: true, get: function () { return readSettings_1.readSettings; } }); -var readSettingsFiles_1 = require("./readSettingsFiles"); -Object.defineProperty(exports, "readSettingsFiles", { enumerable: true, get: function () { return readSettingsFiles_1.readSettingsFiles; } }); +var configLoader_js_1 = require("./configLoader.js"); +Object.defineProperty(exports, "__testing__", { enumerable: true, get: function () { return configLoader_js_1.__testing__; } }); +Object.defineProperty(exports, "clearCachedSettingsFiles", { enumerable: true, get: function () { return configLoader_js_1.clearCachedSettingsFiles; } }); +Object.defineProperty(exports, "ConfigLoader", { enumerable: true, get: function () { return configLoader_js_1.ConfigLoader; } }); +Object.defineProperty(exports, "createConfigLoader", { enumerable: true, get: function () { return configLoader_js_1.createConfigLoader; } }); +Object.defineProperty(exports, "defaultConfigFilenames", { enumerable: true, get: function () { return configLoader_js_1.defaultConfigFilenames; } }); +Object.defineProperty(exports, "defaultFileName", { enumerable: true, get: function () { return configLoader_js_1.defaultFileName; } }); +Object.defineProperty(exports, "getCachedFileSize", { enumerable: true, get: function () { return configLoader_js_1.getCachedFileSize; } }); +Object.defineProperty(exports, "getGlobalSettings", { enumerable: true, get: function () { return configLoader_js_1.getGlobalSettings; } }); +Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return configLoader_js_1.loadConfig; } }); +Object.defineProperty(exports, "loadConfigSync", { enumerable: true, get: function () { return configLoader_js_1.loadConfigSync; } }); +Object.defineProperty(exports, "loadPnP", { enumerable: true, get: function () { return configLoader_js_1.loadPnP; } }); +Object.defineProperty(exports, "loadPnPSync", { enumerable: true, get: function () { return configLoader_js_1.loadPnPSync; } }); +Object.defineProperty(exports, "readRawSettings", { enumerable: true, get: function () { return configLoader_js_1.readRawSettings; } }); +Object.defineProperty(exports, "searchForConfig", { enumerable: true, get: function () { return configLoader_js_1.searchForConfig; } }); +Object.defineProperty(exports, "searchForConfigSync", { enumerable: true, get: function () { return configLoader_js_1.searchForConfigSync; } }); +Object.defineProperty(exports, "sectionCSpell", { enumerable: true, get: function () { return configLoader_js_1.sectionCSpell; } }); +var extractImportErrors_js_1 = require("./extractImportErrors.js"); +Object.defineProperty(exports, "extractImportErrors", { enumerable: true, get: function () { return extractImportErrors_js_1.extractImportErrors; } }); +var readSettings_js_1 = require("./readSettings.js"); +Object.defineProperty(exports, "readSettings", { enumerable: true, get: function () { return readSettings_js_1.readSettings; } }); +var readSettingsFiles_js_1 = require("./readSettingsFiles.js"); +Object.defineProperty(exports, "readSettingsFiles", { enumerable: true, get: function () { return readSettingsFiles_js_1.readSettingsFiles; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/normalizeRawSettings.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/normalizeRawSettings.js similarity index 86% rename from action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/normalizeRawSettings.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/normalizeRawSettings.js index aa10a6a94..e09645e44 100644 --- a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/normalizeRawSettings.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/normalizeRawSettings.js @@ -25,10 +25,10 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeCacheSettings = exports.normalizeSettingsGlobs = exports.normalizeGitignoreRoot = exports.normalizeLanguageSettings = exports.normalizeReporters = exports.normalizeOverrides = exports.normalizeDictionaryDefs = exports.normalizeRawConfig = void 0; const path = __importStar(require("path")); -const resolveFile_1 = require("../../../util/resolveFile"); -const util = __importStar(require("../../../util/util")); -const DictionarySettings_1 = require("../../DictionarySettings"); -const toGlobDef_1 = require("./toGlobDef"); +const resolveFile_js_1 = require("../../../util/resolveFile.js"); +const util = __importStar(require("../../../util/util.js")); +const DictionarySettings_js_1 = require("../../DictionarySettings.js"); +const toGlobDef_js_1 = require("./toGlobDef.js"); function normalizeRawConfig(config) { if (typeof config.version === 'number') { config.version = config.version.toString(); @@ -36,10 +36,10 @@ function normalizeRawConfig(config) { } exports.normalizeRawConfig = normalizeRawConfig; function normalizeDictionaryDefs(settings, pathToSettingsFile) { - const dictionaryDefinitions = (0, DictionarySettings_1.mapDictDefsToInternal)(settings.dictionaryDefinitions, pathToSettingsFile); + const dictionaryDefinitions = (0, DictionarySettings_js_1.mapDictDefsToInternal)(settings.dictionaryDefinitions, pathToSettingsFile); const languageSettings = settings.languageSettings?.map((langSetting) => util.clean({ ...langSetting, - dictionaryDefinitions: (0, DictionarySettings_1.mapDictDefsToInternal)(langSetting.dictionaryDefinitions, pathToSettingsFile), + dictionaryDefinitions: (0, DictionarySettings_js_1.mapDictDefsToInternal)(langSetting.dictionaryDefinitions, pathToSettingsFile), })); return util.clean({ dictionaryDefinitions, @@ -50,7 +50,7 @@ exports.normalizeDictionaryDefs = normalizeDictionaryDefs; function normalizeOverrides(settings, pathToSettingsFile) { const { globRoot = path.dirname(pathToSettingsFile) } = settings; const overrides = settings.overrides?.map((override) => { - const filename = (0, toGlobDef_1.toGlobDef)(override.filename, globRoot, pathToSettingsFile); + const filename = (0, toGlobDef_js_1.toGlobDef)(override.filename, globRoot, pathToSettingsFile); const { dictionaryDefinitions, languageSettings } = normalizeDictionaryDefs(override, pathToSettingsFile); return util.clean({ ...override, @@ -69,7 +69,7 @@ function normalizeReporters(settings, pathToSettingsFile) { function resolve(s) { if (s === 'default') return s; - const r = (0, resolveFile_1.resolveFile)(s, folder); + const r = (0, resolveFile_js_1.resolveFile)(s, folder); if (!r.found) { throw new Error(`Not found: "${s}"`); } @@ -115,7 +115,7 @@ function normalizeSettingsGlobs(settings, pathToSettingsFile) { const { globRoot } = settings; if (settings.ignorePaths === undefined) return {}; - const ignorePaths = (0, toGlobDef_1.toGlobDef)(settings.ignorePaths, globRoot, pathToSettingsFile); + const ignorePaths = (0, toGlobDef_js_1.toGlobDef)(settings.ignorePaths, globRoot, pathToSettingsFile); return { ignorePaths, }; diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/readSettings.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/readSettings.js similarity index 79% rename from action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/readSettings.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/readSettings.js index 76405e79e..10cdd0892 100644 --- a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/readSettings.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/readSettings.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.readSettings = void 0; -const configLoader_1 = require("./configLoader"); +const configLoader_js_1 = require("./configLoader.js"); function readSettings(filename, relativeToOrDefault, defaultValue) { - const loader = (0, configLoader_1.getDefaultConfigLoader)(); + const loader = (0, configLoader_js_1.getDefaultConfigLoader)(); if (typeof relativeToOrDefault !== 'string' || defaultValue === undefined) return loader.readSettings(filename, relativeToOrDefault); return loader.readSettings(filename, relativeToOrDefault, defaultValue); diff --git a/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/readSettingsFiles.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/readSettingsFiles.js new file mode 100644 index 000000000..3e4381ba3 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/readSettingsFiles.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.readSettingsFiles = void 0; +const CSpellSettingsServer_js_1 = require("../../CSpellSettingsServer.js"); +const defaultSettings_js_1 = require("./defaultSettings.js"); +const readSettings_js_1 = require("./readSettings.js"); +/** + * + * @param filenames - settings files to read + * @returns combined configuration + * @deprecated true + */ +function readSettingsFiles(filenames) { + return filenames.map((filename) => (0, readSettings_js_1.readSettings)(filename)).reduce((a, b) => (0, CSpellSettingsServer_js_1.mergeSettings)(a, b), defaultSettings_js_1.defaultSettings); +} +exports.readSettingsFiles = readSettingsFiles; +//# sourceMappingURL=readSettingsFiles.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/toGlobDef.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/toGlobDef.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/toGlobDef.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/toGlobDef.js diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/types.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/types.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Settings/Controller/configLoader/types.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/configLoader/types.js diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/index.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/index.js similarity index 58% rename from action/node_modules/cspell-lib/dist/Settings/Controller/index.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/index.js index bb0aad662..5aac13ba4 100644 --- a/action/node_modules/cspell-lib/dist/Settings/Controller/index.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SettingsController = void 0; -var SettingsController_1 = require("./SettingsController"); -Object.defineProperty(exports, "SettingsController", { enumerable: true, get: function () { return SettingsController_1.SettingsController; } }); +var SettingsController_js_1 = require("./SettingsController.js"); +Object.defineProperty(exports, "SettingsController", { enumerable: true, get: function () { return SettingsController_js_1.SettingsController; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/Settings/Controller/pnpLoader.js b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/pnpLoader.js similarity index 92% rename from action/node_modules/cspell-lib/dist/Settings/Controller/pnpLoader.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/Controller/pnpLoader.js index 79bf3c615..3f54175c0 100644 --- a/action/node_modules/cspell-lib/dist/Settings/Controller/pnpLoader.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/Controller/pnpLoader.js @@ -10,8 +10,8 @@ exports.clearPnPGlobalCache = exports.pnpLoader = exports.PnpLoader = void 0; const clear_module_1 = __importDefault(require("clear-module")); const find_up_1 = __importDefault(require("find-up")); const import_fresh_1 = __importDefault(require("import-fresh")); -const Uri_1 = require("../../util/Uri"); -const ImportError_1 = require("./ImportError"); +const Uri_js_1 = require("../../util/Uri.js"); +const ImportError_js_1 = require("./ImportError.js"); const defaultPnpFiles = ['.pnp.cjs', '.pnp.js']; const supportedSchemas = new Set(['file']); const cachedRequests = new Map(); @@ -91,14 +91,14 @@ exports.pnpLoader = pnpLoader; * @param uriDirectory - directory to start at. */ async function findPnpAndLoad(uriDirectory, pnpFiles) { - const found = await (0, find_up_1.default)(pnpFiles, { cwd: (0, Uri_1.uriToFilePath)(uriDirectory) }); + const found = await (0, find_up_1.default)(pnpFiles, { cwd: (0, Uri_js_1.uriToFilePath)(uriDirectory) }); return loadPnpIfNeeded(found); } /** * @param uriDirectory - directory to start at. */ function findPnpAndLoadSync(uriDirectory, pnpFiles) { - const found = find_up_1.default.sync(pnpFiles, { cwd: (0, Uri_1.uriToFilePath)(uriDirectory) }); + const found = find_up_1.default.sync(pnpFiles, { cwd: (0, Uri_js_1.uriToFilePath)(uriDirectory) }); return loadPnpIfNeeded(found); } function loadPnpIfNeeded(found) { @@ -115,9 +115,9 @@ function loadPnp(pnpFile) { const pnp = (0, import_fresh_1.default)(pnpFile); if (pnp.setup) { pnp.setup(); - return (0, Uri_1.toUri)(pnpFile); + return (0, Uri_js_1.toUri)(pnpFile); } - throw new ImportError_1.UnsupportedPnpFile(`Unsupported pnp file: "${pnpFile}"`); + throw new ImportError_js_1.UnsupportedPnpFile(`Unsupported pnp file: "${pnpFile}"`); } function clearPnPGlobalCache() { if (lock) @@ -131,7 +131,7 @@ exports.clearPnPGlobalCache = clearPnPGlobalCache; async function _cleanCache() { await Promise.all([...cachedRequests.values()].map(rejectToUndefined)); const modules = [...cachedPnpImportsSync.values()]; - modules.forEach((r) => r && clear_module_1.default.single((0, Uri_1.uriToFilePath)(r))); + modules.forEach((r) => r && clear_module_1.default.single((0, Uri_js_1.uriToFilePath)(r))); cachedRequests.clear(); cachedRequestsSync.clear(); cachedPnpImportsSync.clear(); diff --git a/action/node_modules/cspell-lib/dist/Settings/DefaultSettings.js b/action/node_modules/cspell-lib/dist/cjs/Settings/DefaultSettings.js similarity index 85% rename from action/node_modules/cspell-lib/dist/Settings/DefaultSettings.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/DefaultSettings.js index bf2d57949..ef1d8462c 100644 --- a/action/node_modules/cspell-lib/dist/Settings/DefaultSettings.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/DefaultSettings.js @@ -25,20 +25,21 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.getDefaultBundledSettings = exports.getDefaultSettings = exports._defaultSettings = exports._defaultSettingsBasis = void 0; const cspell_grammar_1 = require("cspell-grammar"); -const CSpellSettingsInternalDef_1 = require("../Models/CSpellSettingsInternalDef"); -const PatternRegExp_1 = require("../Models/PatternRegExp"); -const resolveFile_1 = require("../util/resolveFile"); -const configLoader_1 = require("./Controller/configLoader"); -const CSpellSettingsServer_1 = require("./CSpellSettingsServer"); -const LanguageSettings = __importStar(require("./LanguageSettings")); -const RegPat = __importStar(require("./RegExpPatterns")); +const index_cjs_1 = require("../../lib-cjs/index.cjs"); +const CSpellSettingsInternalDef_js_1 = require("../Models/CSpellSettingsInternalDef.js"); +const PatternRegExp_js_1 = require("../Models/PatternRegExp.js"); +const resolveFile_js_1 = require("../util/resolveFile.js"); +const index_js_1 = require("./Controller/configLoader/index.js"); +const CSpellSettingsServer_js_1 = require("./CSpellSettingsServer.js"); +const LanguageSettings = __importStar(require("./LanguageSettings.js")); +const RegPat = __importStar(require("./RegExpPatterns.js")); const defaultConfigFileModuleRef = '@cspell/cspell-bundled-dicts/cspell-default.json'; // Do not use require.resolve because webpack will mess it up. const defaultConfigFile = resolveConfigModule(defaultConfigFileModuleRef); const regExpSpellCheckerDisable = [ - new PatternRegExp_1.PatternRegExp(RegPat.regExSpellingGuardBlock), - new PatternRegExp_1.PatternRegExp(RegPat.regExSpellingGuardLine), - new PatternRegExp_1.PatternRegExp(RegPat.regExSpellingGuardNext), + new PatternRegExp_js_1.PatternRegExp(RegPat.regExSpellingGuardBlock), + new PatternRegExp_js_1.PatternRegExp(RegPat.regExSpellingGuardLine), + new PatternRegExp_js_1.PatternRegExp(RegPat.regExSpellingGuardNext), ]; // cspell:ignore filetypes const predefinedPatterns = [ @@ -94,7 +95,7 @@ const definedDefaultRegExpExcludeList = [ ]; // This bit of copying is done to have the complier ensure that the defaults exist. const defaultRegExpExcludeList = definedDefaultRegExpExcludeList; -exports._defaultSettingsBasis = Object.freeze((0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({ +exports._defaultSettingsBasis = Object.freeze((0, CSpellSettingsInternalDef_js_1.createCSpellSettingsInternal)({ id: 'static_defaults', language: 'en', name: 'Static Defaults', @@ -115,7 +116,7 @@ exports._defaultSettingsBasis = Object.freeze((0, CSpellSettingsInternalDef_1.cr reporters: [], plugins: [{ parsers: cspell_grammar_1.parsers }], })); -exports._defaultSettings = Object.freeze((0, CSpellSettingsInternalDef_1.createCSpellSettingsInternal)({ +exports._defaultSettings = Object.freeze((0, CSpellSettingsInternalDef_js_1.createCSpellSettingsInternal)({ ...exports._defaultSettingsBasis, enabledLanguageIds: [ 'ada', @@ -153,8 +154,8 @@ const getSettings = (function () { return exports._defaultSettingsBasis; } if (!settings) { - const jsonSettings = (0, configLoader_1.readSettings)(defaultConfigFile); - settings = (0, CSpellSettingsServer_1.mergeSettings)(exports._defaultSettings, jsonSettings); + const jsonSettings = (0, index_js_1.readSettings)(defaultConfigFile); + settings = (0, CSpellSettingsServer_js_1.mergeSettings)(exports._defaultSettings, jsonSettings); if (jsonSettings.name !== undefined) { settings.name = jsonSettings.name; } @@ -166,7 +167,7 @@ const getSettings = (function () { }; })(); function resolveConfigModule(configModuleName) { - return (0, resolveFile_1.resolveFile)(configModuleName, __dirname).filename; + return (0, resolveFile_js_1.resolveFile)(configModuleName, index_cjs_1.srcDirectory).filename; } function normalizePattern(pat) { const { name, pattern, description } = pat; @@ -174,7 +175,7 @@ function normalizePattern(pat) { return pat; return { name, - pattern: new PatternRegExp_1.PatternRegExp(pattern), + pattern: new PatternRegExp_js_1.PatternRegExp(pattern), description, }; } diff --git a/action/node_modules/cspell-lib/dist/Settings/DictionaryReferenceCollection.js b/action/node_modules/cspell-lib/dist/cjs/Settings/DictionaryReferenceCollection.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Settings/DictionaryReferenceCollection.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/DictionaryReferenceCollection.js diff --git a/action/node_modules/cspell-lib/dist/Settings/DictionarySettings.js b/action/node_modules/cspell-lib/dist/cjs/Settings/DictionarySettings.js similarity index 85% rename from action/node_modules/cspell-lib/dist/Settings/DictionarySettings.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/DictionarySettings.js index 8f3f52262..9a636fd45 100644 --- a/action/node_modules/cspell-lib/dist/Settings/DictionarySettings.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/DictionarySettings.js @@ -26,11 +26,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isDictionaryDefinitionInlineInternalWithSource = exports.isDictionaryFileDefinitionInternalWithSource = exports.isDictionaryDefinitionInternal = exports.isDictionaryDefinitionWithSource = exports.calcDictionaryDefsToLoad = exports.mapDictDefToInternal = exports.mapDictDefsToInternal = exports.filterDictDefsToLoad = void 0; const cspell_trie_lib_1 = require("cspell-trie-lib"); const path = __importStar(require("path")); -const CSpellSettingsInternalDef_1 = require("../Models/CSpellSettingsInternalDef"); -const AutoResolve_1 = require("../util/AutoResolve"); -const resolveFile_1 = require("../util/resolveFile"); -const util_1 = require("../util/util"); -const DictionaryReferenceCollection_1 = require("./DictionaryReferenceCollection"); +const CSpellSettingsInternalDef_js_1 = require("../Models/CSpellSettingsInternalDef.js"); +const AutoResolve_js_1 = require("../util/AutoResolve.js"); +const resolveFile_js_1 = require("../util/resolveFile.js"); +const util_js_1 = require("../util/util.js"); +const DictionaryReferenceCollection_js_1 = require("./DictionaryReferenceCollection.js"); /** * Combines the list of desired dictionaries with the list of dictionary * definitions. Order does not matter, but the number of leading `!` does. @@ -67,7 +67,7 @@ function mapDictDefsToInternal(defs, pathToSettingsFile) { return defs?.map((def) => mapDictDefToInternal(def, pathToSettingsFile)); } exports.mapDictDefsToInternal = mapDictDefsToInternal; -const internalDefs = new AutoResolve_1.AutoResolveWeakCache(); +const internalDefs = new AutoResolve_js_1.AutoResolveWeakCache(); function mapDictDefToInternal(def, pathToSettingsFile) { return internalDefs.get(def, (def) => _mapDictDefToInternal(def, pathToSettingsFile)); } @@ -76,7 +76,7 @@ function _mapDictDefToInternal(def, pathToSettingsFile) { if (isDictionaryDefinitionWithSource(def)) { return def; } - if ((0, CSpellSettingsInternalDef_1.isDictionaryDefinitionInlineInternal)(def)) { + if ((0, CSpellSettingsInternalDef_js_1.isDictionaryDefinitionInlineInternal)(def)) { return { ...def, __source: pathToSettingsFile }; } return new _DictionaryDefinitionInternalWithSource(def, pathToSettingsFile); @@ -86,8 +86,8 @@ function determineName(filename, options) { } function calcDictionaryDefsToLoad(settings) { const { dictionaries = [], dictionaryDefinitions = [], noSuggestDictionaries = [] } = settings; - const colNoSug = (0, DictionaryReferenceCollection_1.createDictionaryReferenceCollection)(noSuggestDictionaries); - const colDicts = (0, DictionaryReferenceCollection_1.createDictionaryReferenceCollection)(dictionaries.concat(colNoSug.enabled())); + const colNoSug = (0, DictionaryReferenceCollection_js_1.createDictionaryReferenceCollection)(noSuggestDictionaries); + const colDicts = (0, DictionaryReferenceCollection_js_1.createDictionaryReferenceCollection)(dictionaries.concat(colNoSug.enabled())); const modDefs = dictionaryDefinitions.map((def) => { const enabled = colNoSug.isEnabled(def.name); if (enabled === undefined) @@ -110,7 +110,7 @@ function isDictionaryFileDefinitionInternalWithSource(def) { } exports.isDictionaryFileDefinitionInternalWithSource = isDictionaryFileDefinitionInternalWithSource; function isDictionaryDefinitionInlineInternalWithSource(def) { - return (0, CSpellSettingsInternalDef_1.isDictionaryDefinitionInlineInternal)(def) && !!def.__source; + return (0, CSpellSettingsInternalDef_js_1.isDictionaryDefinitionInlineInternal)(def) && !!def.__source; } exports.isDictionaryDefinitionInlineInternalWithSource = isDictionaryDefinitionInlineInternalWithSource; class _DictionaryDefinitionInternalWithSource { @@ -122,7 +122,7 @@ class _DictionaryDefinitionInternalWithSource { const defaultPath = path.dirname(__source); const filePath = fixDicPath(relPath, file); const name = determineName(filePath, def); - const r = (0, resolveFile_1.resolveFile)(filePath, defaultPath); + const r = (0, resolveFile_js_1.resolveFile)(filePath, defaultPath); const ddi = { name, file: undefined, @@ -136,7 +136,7 @@ class _DictionaryDefinitionInternalWithSource { scope, useCompounds, }; - Object.assign(this, (0, util_1.clean)(ddi)); + Object.assign(this, (0, util_js_1.clean)(ddi)); this.ddi = ddi; this.name = ddi.name; this.file = ddi.file; diff --git a/action/node_modules/cspell-lib/dist/Settings/GlobalSettings.js b/action/node_modules/cspell-lib/dist/cjs/Settings/GlobalSettings.js similarity index 72% rename from action/node_modules/cspell-lib/dist/Settings/GlobalSettings.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/GlobalSettings.js index 6ab03dbbe..b0e1d396e 100644 --- a/action/node_modules/cspell-lib/dist/Settings/GlobalSettings.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/GlobalSettings.js @@ -1,13 +1,10 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.getGlobalConfigPath = exports.writeRawGlobalSettings = exports.getRawGlobalSettings = void 0; -const configstore_1 = __importDefault(require("configstore")); const util_1 = require("util"); -const errors_1 = require("../util/errors"); -const logger_1 = require("../util/logger"); +const errors_js_1 = require("../util/errors.js"); +const logger_js_1 = require("../util/logger.js"); +const cfgStore_js_1 = require("./cfgStore.js"); const packageName = 'cspell'; function getRawGlobalSettings() { const name = 'CSpell Configstore'; @@ -18,7 +15,9 @@ function getRawGlobalSettings() { }, }; try { - const cfgStore = new configstore_1.default(packageName); + // console.warn('%o', ConfigStore); + const cfgStore = new cfgStore_js_1.ConfigStore(packageName); + // console.warn('%o', cfgStore); const cfg = cfgStore.all; // Only populate globalConf is there are values. if (cfg && Object.keys(cfg).length) { @@ -30,10 +29,10 @@ function getRawGlobalSettings() { } } catch (error) { - if (!(0, errors_1.isErrnoException)(error) || + if (!(0, errors_js_1.isErrnoException)(error) || !error.code || !['ENOENT', 'EACCES', 'ENOTDIR', 'EISDIR'].includes(error.code)) { - (0, logger_1.logError)(error); + (0, logger_js_1.logError)(error); } } return globalConf; @@ -44,7 +43,7 @@ function writeRawGlobalSettings(settings) { import: settings.import, }; try { - const cfgStore = new configstore_1.default(packageName); + const cfgStore = new cfgStore_js_1.ConfigStore(packageName); cfgStore.set(toWrite); return undefined; } @@ -56,7 +55,7 @@ function writeRawGlobalSettings(settings) { } exports.writeRawGlobalSettings = writeRawGlobalSettings; function getGlobalConfigPath() { - const cfgStore = new configstore_1.default(packageName); + const cfgStore = new cfgStore_js_1.ConfigStore(packageName); return cfgStore.path; } exports.getGlobalConfigPath = getGlobalConfigPath; diff --git a/action/node_modules/cspell-lib/dist/Settings/InDocSettings.js b/action/node_modules/cspell-lib/dist/cjs/Settings/InDocSettings.js similarity index 95% rename from action/node_modules/cspell-lib/dist/Settings/InDocSettings.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/InDocSettings.js index 273eda8b0..d40c789d1 100644 --- a/action/node_modules/cspell-lib/dist/Settings/InDocSettings.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/InDocSettings.js @@ -26,10 +26,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.internal = exports.getIgnoreRegExpFromDocument = exports.getIgnoreWordsFromDocument = exports.extractInDocDictionary = exports.regExSpellingGuardLine = exports.regExSpellingGuardNext = exports.regExSpellingGuardBlock = exports.validateInDocumentSettings = exports.getInDocumentSettings = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); const gensequence_1 = require("gensequence"); -const SpellingDictionary_1 = require("../SpellingDictionary"); -const Text = __importStar(require("../util/text")); -const util_1 = require("../util/util"); -const CSpellSettingsServer_1 = require("./CSpellSettingsServer"); +const index_js_1 = require("../SpellingDictionary/index.js"); +const Text = __importStar(require("../util/text.js")); +const util_js_1 = require("../util/util.js"); +const CSpellSettingsServer_js_1 = require("./CSpellSettingsServer.js"); // cspell:ignore gimuy const regExMatchRegEx = /\/.*\/[gimuy]*/; const regExCSpellInDocDirective = /\b(?:spell-?checker|c?spell)::?(.*)/gi; @@ -87,7 +87,7 @@ const allDirectives = new Set(preferredDirectives.concat(officialDirectives)); const allDirectiveSuggestions = [ ...(0, sync_1.pipeSync)(allDirectives, (0, sync_1.opMap)((word) => ({ word }))), ]; -const dictInDocSettings = (0, SpellingDictionary_1.createSpellingDictionary)(allDirectives, 'Directives', 'Directive List', { +const dictInDocSettings = (0, index_js_1.createSpellingDictionary)(allDirectives, 'Directives', 'Directive List', { supportNonStrictSearches: false, }); const EmptyWords = []; @@ -97,11 +97,11 @@ function getInDocumentSettings(text) { const collectedSettings = getPossibleInDocSettings(text) .concatMap((a) => parseSettingMatch(a)) .reduce((s, setting) => { - return (0, CSpellSettingsServer_1.mergeInDocSettings)(s, setting); + return (0, CSpellSettingsServer_js_1.mergeInDocSettings)(s, setting); }, { id: 'in-doc-settings' }); const { words, flagWords, ignoreWords, suggestWords, dictionaries = [], dictionaryDefinitions = [], ...rest } = collectedSettings; const dict = (words || flagWords || ignoreWords || suggestWords) && - (0, util_1.clean)({ + (0, util_js_1.clean)({ name: staticInDocumentDictionaryName, words, flagWords, @@ -113,7 +113,7 @@ function getInDocumentSettings(text) { dictionaries: dictionaries.concat(staticInDocumentDictionaryName), dictionaryDefinitions: dictionaryDefinitions.concat(dict), } - : (0, util_1.clean)({ + : (0, util_js_1.clean)({ dictionaries: dictionaries.length ? dictionaries : undefined, dictionaryDefinitions: dictionaryDefinitions.length ? dictionaryDefinitions : undefined, }); @@ -126,7 +126,7 @@ function getInDocumentSettings(text) { } exports.getInDocumentSettings = getInDocumentSettings; function validateInDocumentSettings(docText, _settings) { - return (0, sync_1.pipeSync)(getPossibleInDocSettings(docText), (0, sync_1.opMap)(parseSettingMatchValidation), (0, sync_1.opFilter)(util_1.isDefined)); + return (0, sync_1.pipeSync)(getPossibleInDocSettings(docText), (0, sync_1.opMap)(parseSettingMatchValidation), (0, sync_1.opFilter)(util_js_1.isDefined)); } exports.validateInDocumentSettings = validateInDocumentSettings; const settingParsers = [ diff --git a/action/node_modules/cspell-lib/dist/Settings/LanguageSettings.js b/action/node_modules/cspell-lib/dist/cjs/Settings/LanguageSettings.js similarity index 89% rename from action/node_modules/cspell-lib/dist/Settings/LanguageSettings.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/LanguageSettings.js index 2e3922571..cd0248571 100644 --- a/action/node_modules/cspell-lib/dist/Settings/LanguageSettings.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/LanguageSettings.js @@ -24,10 +24,9 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.calcSettingsForLanguageId = exports.calcUserSettingsForLanguage = exports.calcSettingsForLanguage = exports.isValidLocaleIntlFormat = exports.isLocaleInSet = exports.normalizeLocaleIntl = exports.normalizeLocale = exports.normalizeLanguageId = exports.getDefaultLanguageSettings = void 0; -const AutoResolve_1 = require("../util/AutoResolve"); -const Memorizer_1 = require("../util/Memorizer"); -const util_1 = require("../util/util"); -const SpellSettings = __importStar(require("./CSpellSettingsServer")); +const AutoResolve_js_1 = require("../util/AutoResolve.js"); +const util_js_1 = require("../util/util.js"); +const SpellSettings = __importStar(require("./CSpellSettingsServer.js")); const defaultLocale = 'en'; const defaultLanguageSettings = []; function getDefaultLanguageSettings() { @@ -44,7 +43,11 @@ function stringToList(sList) { .map((s) => s.trim()) .filter((s) => !!s); } -const _normalizeLanguageId = (0, Memorizer_1.memorizerAll)(__normalizeLanguageId); +function memorizer(resolver) { + const cache = (0, AutoResolve_js_1.createAutoResolveCache)(); + return (k) => cache.get(k, resolver); +} +const _normalizeLanguageId = memorizer(__normalizeLanguageId); function __normalizeLanguageId(langId) { const langIds = stringToList(langId); return new Set(langIds.map((a) => a.toLowerCase())); @@ -53,7 +56,7 @@ function normalizeLanguageId(langId) { return _normalizeLanguageId(typeof langId === 'string' ? langId : langId.join(',')); } exports.normalizeLanguageId = normalizeLanguageId; -const _normalizeLocale = (0, Memorizer_1.memorizerAll)(__normalizeLocale); +const _normalizeLocale = memorizer(__normalizeLocale); function __normalizeLocale(locale) { const locales = localesToList(locale); return new Set(locales.map((locale) => locale.toLowerCase().replace(/[^a-z]/g, ''))); @@ -70,7 +73,7 @@ function normalizeLocaleIntl(locale) { exports.normalizeLocaleIntl = normalizeLocaleIntl; function isLocaleInSet(locale, setOfLocals) { const locales = normalizeLocale(locale); - return (0, util_1.doSetsIntersect)(locales, setOfLocals); + return (0, util_js_1.doSetsIntersect)(locales, setOfLocals); } exports.isLocaleInSet = isLocaleInSet; const regExpValidIntlLocaleStrict = /^[a-z]{2}(-[A-Z]{2})?$/; @@ -93,9 +96,9 @@ function isValidLocaleIntlFormat(locale, strict = false) { exports.isValidLocaleIntlFormat = isValidLocaleIntlFormat; const cacheCalcSettingsForLanguage = new WeakMap(); function calcSettingsForLanguage(languageSettings, languageId, locale) { - const mapLang = (0, AutoResolve_1.autoResolveWeak)(cacheCalcSettingsForLanguage, languageSettings, () => new Map()); - const mapLocale = (0, AutoResolve_1.autoResolve)(mapLang, languageId, () => new Map()); - return (0, AutoResolve_1.autoResolve)(mapLocale, locale, () => _calcSettingsForLanguage(languageSettings, languageId, locale)); + const mapLang = (0, AutoResolve_js_1.autoResolveWeak)(cacheCalcSettingsForLanguage, languageSettings, () => new Map()); + const mapLocale = (0, AutoResolve_js_1.autoResolve)(mapLang, languageId, () => new Map()); + return (0, AutoResolve_js_1.autoResolve)(mapLocale, locale, () => _calcSettingsForLanguage(languageSettings, languageId, locale)); } exports.calcSettingsForLanguage = calcSettingsForLanguage; function _calcSettingsForLanguage(languageSettings, languageId, locale) { diff --git a/action/node_modules/cspell-lib/dist/Settings/RegExpPatterns.js b/action/node_modules/cspell-lib/dist/cjs/Settings/RegExpPatterns.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Settings/RegExpPatterns.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/RegExpPatterns.js diff --git a/action/node_modules/cspell-lib/dist/Settings/TextDocumentSettings.js b/action/node_modules/cspell-lib/dist/cjs/Settings/TextDocumentSettings.js similarity index 83% rename from action/node_modules/cspell-lib/dist/Settings/TextDocumentSettings.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/TextDocumentSettings.js index af2ed4db0..1d90b184d 100644 --- a/action/node_modules/cspell-lib/dist/Settings/TextDocumentSettings.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/TextDocumentSettings.js @@ -24,22 +24,22 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractSettingsFromText = exports.combineTextAndLanguageSettings = void 0; -const CSpellSettingsServer = __importStar(require("./CSpellSettingsServer")); -const InDocSettings_1 = require("./InDocSettings"); -const LanguageSettings_1 = require("./LanguageSettings"); +const CSpellSettingsServer = __importStar(require("./CSpellSettingsServer.js")); +const InDocSettings_js_1 = require("./InDocSettings.js"); +const LanguageSettings_js_1 = require("./LanguageSettings.js"); function combineTextAndLanguageSettings(settings, text, languageId) { if (!text) { - return CSpellSettingsServer.toInternalSettings((0, LanguageSettings_1.calcSettingsForLanguageId)(settings, languageId)); + return CSpellSettingsServer.toInternalSettings((0, LanguageSettings_js_1.calcSettingsForLanguageId)(settings, languageId)); } const docSettings = extractSettingsFromText(text); const settingsForText = CSpellSettingsServer.mergeSettings(settings, docSettings); - const langSettings = (0, LanguageSettings_1.calcSettingsForLanguageId)(settingsForText, languageId); + const langSettings = (0, LanguageSettings_js_1.calcSettingsForLanguageId)(settingsForText, languageId); // Merge again, to force In-Doc settings. return CSpellSettingsServer.mergeSettings(langSettings, docSettings); } exports.combineTextAndLanguageSettings = combineTextAndLanguageSettings; function extractSettingsFromText(text) { - return (0, InDocSettings_1.getInDocumentSettings)(text); + return (0, InDocSettings_js_1.getInDocumentSettings)(text); } exports.extractSettingsFromText = extractSettingsFromText; //# sourceMappingURL=TextDocumentSettings.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/cjs/Settings/cfgStore.js b/action/node_modules/cspell-lib/dist/cjs/Settings/cfgStore.js new file mode 100644 index 000000000..7127b5fea --- /dev/null +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/cfgStore.js @@ -0,0 +1,9 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ConfigStore = void 0; +const configstore_1 = __importDefault(require("configstore")); +exports.ConfigStore = configstore_1.default; +//# sourceMappingURL=cfgStore.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/Settings/constants.js b/action/node_modules/cspell-lib/dist/cjs/Settings/constants.js similarity index 100% rename from action/node_modules/cspell-lib/dist/Settings/constants.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/constants.js diff --git a/action/node_modules/cspell-lib/dist/Settings/index.js b/action/node_modules/cspell-lib/dist/cjs/Settings/index.js similarity index 53% rename from action/node_modules/cspell-lib/dist/Settings/index.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/index.js index 584262e77..00be1b6b7 100644 --- a/action/node_modules/cspell-lib/dist/Settings/index.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/index.js @@ -1,35 +1,35 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDefaultSettings = exports.getDefaultBundledSettings = exports.mergeSettings = exports.mergeInDocSettings = exports.getSources = exports.finalizeSettings = exports.extractDependencies = exports.checkFilenameMatchesGlob = exports.calcOverrideSettings = exports.ImportError = 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 = exports.ENV_CSPELL_GLOB_ROOT = exports.currentSettingsFileVersion = void 0; -var constants_1 = require("./constants"); -Object.defineProperty(exports, "currentSettingsFileVersion", { enumerable: true, get: function () { return constants_1.currentSettingsFileVersion; } }); -Object.defineProperty(exports, "ENV_CSPELL_GLOB_ROOT", { enumerable: true, get: function () { return constants_1.ENV_CSPELL_GLOB_ROOT; } }); -var configLoader_1 = require("./Controller/configLoader"); -Object.defineProperty(exports, "clearCachedSettingsFiles", { enumerable: true, get: function () { return configLoader_1.clearCachedSettingsFiles; } }); -Object.defineProperty(exports, "defaultConfigFilenames", { enumerable: true, get: function () { return configLoader_1.defaultConfigFilenames; } }); -Object.defineProperty(exports, "defaultFileName", { enumerable: true, get: function () { return configLoader_1.defaultFileName; } }); -Object.defineProperty(exports, "extractImportErrors", { enumerable: true, get: function () { return configLoader_1.extractImportErrors; } }); -Object.defineProperty(exports, "getCachedFileSize", { enumerable: true, get: function () { return configLoader_1.getCachedFileSize; } }); -Object.defineProperty(exports, "getGlobalSettings", { enumerable: true, get: function () { return configLoader_1.getGlobalSettings; } }); -Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return configLoader_1.loadConfig; } }); -Object.defineProperty(exports, "loadPnP", { enumerable: true, get: function () { return configLoader_1.loadPnP; } }); -Object.defineProperty(exports, "loadPnPSync", { enumerable: true, get: function () { return configLoader_1.loadPnPSync; } }); -Object.defineProperty(exports, "readRawSettings", { enumerable: true, get: function () { return configLoader_1.readRawSettings; } }); -Object.defineProperty(exports, "readSettings", { enumerable: true, get: function () { return configLoader_1.readSettings; } }); -Object.defineProperty(exports, "readSettingsFiles", { enumerable: true, get: function () { return configLoader_1.readSettingsFiles; } }); -Object.defineProperty(exports, "searchForConfig", { enumerable: true, get: function () { return configLoader_1.searchForConfig; } }); -Object.defineProperty(exports, "sectionCSpell", { enumerable: true, get: function () { return configLoader_1.sectionCSpell; } }); -var ImportError_1 = require("./Controller/ImportError"); -Object.defineProperty(exports, "ImportError", { enumerable: true, get: function () { return ImportError_1.ImportError; } }); -var CSpellSettingsServer_1 = require("./CSpellSettingsServer"); -Object.defineProperty(exports, "calcOverrideSettings", { enumerable: true, get: function () { return CSpellSettingsServer_1.calcOverrideSettings; } }); -Object.defineProperty(exports, "checkFilenameMatchesGlob", { enumerable: true, get: function () { return CSpellSettingsServer_1.checkFilenameMatchesGlob; } }); -Object.defineProperty(exports, "extractDependencies", { enumerable: true, get: function () { return CSpellSettingsServer_1.extractDependencies; } }); -Object.defineProperty(exports, "finalizeSettings", { enumerable: true, get: function () { return CSpellSettingsServer_1.finalizeSettings; } }); -Object.defineProperty(exports, "getSources", { enumerable: true, get: function () { return CSpellSettingsServer_1.getSources; } }); -Object.defineProperty(exports, "mergeInDocSettings", { enumerable: true, get: function () { return CSpellSettingsServer_1.mergeInDocSettings; } }); -Object.defineProperty(exports, "mergeSettings", { enumerable: true, get: function () { return CSpellSettingsServer_1.mergeSettings; } }); -var DefaultSettings_1 = require("./DefaultSettings"); -Object.defineProperty(exports, "getDefaultBundledSettings", { enumerable: true, get: function () { return DefaultSettings_1.getDefaultBundledSettings; } }); -Object.defineProperty(exports, "getDefaultSettings", { enumerable: true, get: function () { return DefaultSettings_1.getDefaultSettings; } }); +var constants_js_1 = require("./constants.js"); +Object.defineProperty(exports, "currentSettingsFileVersion", { enumerable: true, get: function () { return constants_js_1.currentSettingsFileVersion; } }); +Object.defineProperty(exports, "ENV_CSPELL_GLOB_ROOT", { enumerable: true, get: function () { return constants_js_1.ENV_CSPELL_GLOB_ROOT; } }); +var index_js_1 = require("./Controller/configLoader/index.js"); +Object.defineProperty(exports, "clearCachedSettingsFiles", { enumerable: true, get: function () { return index_js_1.clearCachedSettingsFiles; } }); +Object.defineProperty(exports, "defaultConfigFilenames", { enumerable: true, get: function () { return index_js_1.defaultConfigFilenames; } }); +Object.defineProperty(exports, "defaultFileName", { enumerable: true, get: function () { return index_js_1.defaultFileName; } }); +Object.defineProperty(exports, "extractImportErrors", { enumerable: true, get: function () { return index_js_1.extractImportErrors; } }); +Object.defineProperty(exports, "getCachedFileSize", { enumerable: true, get: function () { return index_js_1.getCachedFileSize; } }); +Object.defineProperty(exports, "getGlobalSettings", { enumerable: true, get: function () { return index_js_1.getGlobalSettings; } }); +Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return index_js_1.loadConfig; } }); +Object.defineProperty(exports, "loadPnP", { enumerable: true, get: function () { return index_js_1.loadPnP; } }); +Object.defineProperty(exports, "loadPnPSync", { enumerable: true, get: function () { return index_js_1.loadPnPSync; } }); +Object.defineProperty(exports, "readRawSettings", { enumerable: true, get: function () { return index_js_1.readRawSettings; } }); +Object.defineProperty(exports, "readSettings", { enumerable: true, get: function () { return index_js_1.readSettings; } }); +Object.defineProperty(exports, "readSettingsFiles", { enumerable: true, get: function () { return index_js_1.readSettingsFiles; } }); +Object.defineProperty(exports, "searchForConfig", { enumerable: true, get: function () { return index_js_1.searchForConfig; } }); +Object.defineProperty(exports, "sectionCSpell", { enumerable: true, get: function () { return index_js_1.sectionCSpell; } }); +var ImportError_js_1 = require("./Controller/ImportError.js"); +Object.defineProperty(exports, "ImportError", { enumerable: true, get: function () { return ImportError_js_1.ImportError; } }); +var CSpellSettingsServer_js_1 = require("./CSpellSettingsServer.js"); +Object.defineProperty(exports, "calcOverrideSettings", { enumerable: true, get: function () { return CSpellSettingsServer_js_1.calcOverrideSettings; } }); +Object.defineProperty(exports, "checkFilenameMatchesGlob", { enumerable: true, get: function () { return CSpellSettingsServer_js_1.checkFilenameMatchesGlob; } }); +Object.defineProperty(exports, "extractDependencies", { enumerable: true, get: function () { return CSpellSettingsServer_js_1.extractDependencies; } }); +Object.defineProperty(exports, "finalizeSettings", { enumerable: true, get: function () { return CSpellSettingsServer_js_1.finalizeSettings; } }); +Object.defineProperty(exports, "getSources", { enumerable: true, get: function () { return CSpellSettingsServer_js_1.getSources; } }); +Object.defineProperty(exports, "mergeInDocSettings", { enumerable: true, get: function () { return CSpellSettingsServer_js_1.mergeInDocSettings; } }); +Object.defineProperty(exports, "mergeSettings", { enumerable: true, get: function () { return CSpellSettingsServer_js_1.mergeSettings; } }); +var DefaultSettings_js_1 = require("./DefaultSettings.js"); +Object.defineProperty(exports, "getDefaultBundledSettings", { enumerable: true, get: function () { return DefaultSettings_js_1.getDefaultBundledSettings; } }); +Object.defineProperty(exports, "getDefaultSettings", { enumerable: true, get: function () { return DefaultSettings_js_1.getDefaultSettings; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/Settings/index.link.js b/action/node_modules/cspell-lib/dist/cjs/Settings/index.link.js similarity index 59% rename from action/node_modules/cspell-lib/dist/Settings/index.link.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/index.link.js index 011e347f9..2ee676a80 100644 --- a/action/node_modules/cspell-lib/dist/Settings/index.link.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/index.link.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.removePathsFromGlobalImports = exports.listGlobalImports = exports.addPathsToGlobalImports = void 0; -var link_1 = require("./link"); -Object.defineProperty(exports, "addPathsToGlobalImports", { enumerable: true, get: function () { return link_1.addPathsToGlobalImports; } }); -Object.defineProperty(exports, "listGlobalImports", { enumerable: true, get: function () { return link_1.listGlobalImports; } }); -Object.defineProperty(exports, "removePathsFromGlobalImports", { enumerable: true, get: function () { return link_1.removePathsFromGlobalImports; } }); +var link_js_1 = require("./link.js"); +Object.defineProperty(exports, "addPathsToGlobalImports", { enumerable: true, get: function () { return link_js_1.addPathsToGlobalImports; } }); +Object.defineProperty(exports, "listGlobalImports", { enumerable: true, get: function () { return link_js_1.listGlobalImports; } }); +Object.defineProperty(exports, "removePathsFromGlobalImports", { enumerable: true, get: function () { return link_js_1.removePathsFromGlobalImports; } }); //# sourceMappingURL=index.link.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/Settings/link.js b/action/node_modules/cspell-lib/dist/cjs/Settings/link.js similarity index 90% rename from action/node_modules/cspell-lib/dist/Settings/link.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/link.js index 42f2f5a75..e9a1650c7 100644 --- a/action/node_modules/cspell-lib/dist/Settings/link.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/link.js @@ -26,11 +26,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.__testing__ = exports.removePathsFromGlobalImports = exports.addPathsToGlobalImports = exports.listGlobalImports = void 0; const fs = __importStar(require("fs")); const Path = __importStar(require("path")); -const util_1 = require("../util/util"); -const configLoader_1 = require("./Controller/configLoader"); -const GlobalSettings_1 = require("./GlobalSettings"); +const util_js_1 = require("../util/util.js"); +const index_js_1 = require("./Controller/configLoader/index.js"); +const GlobalSettings_js_1 = require("./GlobalSettings.js"); function listGlobalImports() { - const globalSettings = (0, GlobalSettings_1.getRawGlobalSettings)(); + const globalSettings = (0, GlobalSettings_js_1.getRawGlobalSettings)(); const list = resolveImports(globalSettings).map(({ filename, settings, error }) => ({ filename, error, @@ -59,7 +59,7 @@ function addPathsToGlobalImports(paths) { error: 'Unable to resolve files.', }; } - const rawGlobalSettings = (0, GlobalSettings_1.getRawGlobalSettings)(); + const rawGlobalSettings = (0, GlobalSettings_js_1.getRawGlobalSettings)(); const resolvedImports = resolveImports(rawGlobalSettings); const imports = new Set(resolvedImports.map((r) => r.resolvedToFilename || r.filename)); resolvedSettings @@ -69,7 +69,7 @@ function addPathsToGlobalImports(paths) { const globalSettings = { import: [...imports], }; - const error = (0, GlobalSettings_1.writeRawGlobalSettings)(globalSettings); + const error = (0, GlobalSettings_js_1.writeRawGlobalSettings)(globalSettings); return { success: !error, error: error?.message, @@ -120,7 +120,7 @@ function removePathsFromGlobalImports(paths) { const updatedSettings = { import: toImport, }; - const error = toRemove.size > 0 ? (0, GlobalSettings_1.writeRawGlobalSettings)(updatedSettings) : undefined; + const error = toRemove.size > 0 ? (0, GlobalSettings_js_1.writeRawGlobalSettings)(updatedSettings) : undefined; return { success: true, removed: [...toRemove], @@ -129,11 +129,11 @@ function removePathsFromGlobalImports(paths) { } exports.removePathsFromGlobalImports = removePathsFromGlobalImports; function resolveSettings(filename) { - const settings = (0, configLoader_1.readRawSettings)(filename); + const settings = (0, index_js_1.readRawSettings)(filename); const ref = settings.__importRef; const resolvedToFilename = ref?.filename; const error = ref?.error?.message || (!resolvedToFilename && 'File not Found') || undefined; - return (0, util_1.clean)({ + return (0, util_js_1.clean)({ filename, resolvedToFilename, error, diff --git a/action/node_modules/cspell-lib/dist/Settings/patterns.js b/action/node_modules/cspell-lib/dist/cjs/Settings/patterns.js similarity index 78% rename from action/node_modules/cspell-lib/dist/Settings/patterns.js rename to action/node_modules/cspell-lib/dist/cjs/Settings/patterns.js index 9cbe69859..b688b49ef 100644 --- a/action/node_modules/cspell-lib/dist/Settings/patterns.js +++ b/action/node_modules/cspell-lib/dist/cjs/Settings/patterns.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolvePatterns = void 0; -const textRegex_1 = require("../util/textRegex"); -const util_1 = require("../util/util"); +const textRegex_js_1 = require("../util/textRegex.js"); +const util_js_1 = require("../util/util.js"); function resolvePatterns(regExpList = [], patternDefinitions = []) { const patternMap = new Map(patternDefinitions.map((def) => [def.name.toLowerCase(), def.pattern])); const resolved = new Set(); @@ -15,18 +15,18 @@ function resolvePatterns(regExpList = [], patternDefinitions = []) { function* flatten(patterns) { for (const pattern of patterns) { if (Array.isArray(pattern)) { - yield* flatten(pattern.map(resolvePattern).filter(util_1.isDefined)); + yield* flatten(pattern.map(resolvePattern).filter(util_js_1.isDefined)); } else { yield pattern; } } } - const patternList = regExpList.map(resolvePattern).filter(util_1.isDefined); - return [...flatten(patternList)].map(toRegExp).filter(util_1.isDefined); + const patternList = regExpList.map(resolvePattern).filter(util_js_1.isDefined); + return [...flatten(patternList)].map(toRegExp).filter(util_js_1.isDefined); } exports.resolvePatterns = resolvePatterns; function toRegExp(pattern) { - return pattern instanceof RegExp ? new RegExp(pattern) : (0, textRegex_1.stringToRegExp)(pattern, 'gim', 'g'); + return pattern instanceof RegExp ? new RegExp(pattern) : (0, textRegex_js_1.stringToRegExp)(pattern, 'gim', 'g'); } //# sourceMappingURL=patterns.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/SpellingDictionary/Dictionaries.js b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/Dictionaries.js similarity index 82% rename from action/node_modules/cspell-lib/dist/SpellingDictionary/Dictionaries.js rename to action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/Dictionaries.js index 08ee1c83b..9f8c93b79 100644 --- a/action/node_modules/cspell-lib/dist/SpellingDictionary/Dictionaries.js +++ b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/Dictionaries.js @@ -2,29 +2,29 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.getDictionaryInternalSync = exports.getDictionaryInternal = exports.refreshDictionaryCache = exports.loadDictionaryDefsSync = exports.loadDictionaryDefs = void 0; const cspell_dictionary_1 = require("cspell-dictionary"); -const DictionarySettings_1 = require("../Settings/DictionarySettings"); -const util_1 = require("../util/util"); -const DictionaryLoader_1 = require("./DictionaryLoader"); +const DictionarySettings_js_1 = require("../Settings/DictionarySettings.js"); +const util_js_1 = require("../util/util.js"); +const DictionaryLoader_js_1 = require("./DictionaryLoader.js"); function loadDictionaryDefs(defsToLoad) { - return defsToLoad.map(DictionaryLoader_1.loadDictionary); + return defsToLoad.map(DictionaryLoader_js_1.loadDictionary); } exports.loadDictionaryDefs = loadDictionaryDefs; function loadDictionaryDefsSync(defsToLoad) { - return defsToLoad.map(DictionaryLoader_1.loadDictionarySync); + return defsToLoad.map(DictionaryLoader_js_1.loadDictionarySync); } exports.loadDictionaryDefsSync = loadDictionaryDefsSync; function refreshDictionaryCache(maxAge) { - return (0, DictionaryLoader_1.refreshCacheEntries)(maxAge); + return (0, DictionaryLoader_js_1.refreshCacheEntries)(maxAge); } exports.refreshDictionaryCache = refreshDictionaryCache; const emptyWords = Object.freeze([]); async function getDictionaryInternal(settings) { - const spellDictionaries = await Promise.all(loadDictionaryDefs((0, DictionarySettings_1.calcDictionaryDefsToLoad)(settings))); + const spellDictionaries = await Promise.all(loadDictionaryDefs((0, DictionarySettings_js_1.calcDictionaryDefsToLoad)(settings))); return _getDictionaryInternal(settings, spellDictionaries); } exports.getDictionaryInternal = getDictionaryInternal; function getDictionaryInternalSync(settings) { - const spellDictionaries = loadDictionaryDefsSync((0, DictionarySettings_1.calcDictionaryDefsToLoad)(settings)); + const spellDictionaries = loadDictionaryDefsSync((0, DictionarySettings_js_1.calcDictionaryDefsToLoad)(settings)); return _getDictionaryInternal(settings, spellDictionaries); } exports.getDictionaryInternalSync = getDictionaryInternalSync; @@ -50,7 +50,7 @@ function _getDictionaryInternal(settings, spellDictionaries) { ignoreWordsDictionary, flagWordsDictionary, suggestWordsDictionary, - ].filter(util_1.isDefined); + ].filter(util_js_1.isDefined); return (0, cspell_dictionary_1.createCollection)(dictionaries, 'dictionary collection'); } //# sourceMappingURL=Dictionaries.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/SpellingDictionary/DictionaryController/DictionaryLoader.js b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/DictionaryController/DictionaryLoader.js similarity index 91% rename from action/node_modules/cspell-lib/dist/SpellingDictionary/DictionaryController/DictionaryLoader.js rename to action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/DictionaryController/DictionaryLoader.js index 6ef5b34c9..1baee50ab 100644 --- a/action/node_modules/cspell-lib/dist/SpellingDictionary/DictionaryController/DictionaryLoader.js +++ b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/DictionaryController/DictionaryLoader.js @@ -4,10 +4,10 @@ exports.DictionaryLoader = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); const strong_weak_map_1 = require("@cspell/strong-weak-map"); const cspell_dictionary_1 = require("cspell-dictionary"); -const CSpellSettingsInternalDef_1 = require("../../Models/CSpellSettingsInternalDef"); -const AutoResolve_1 = require("../../util/AutoResolve"); -const errors_1 = require("../../util/errors"); -const SpellingDictionaryError_1 = require("../SpellingDictionaryError"); +const CSpellSettingsInternalDef_js_1 = require("../../Models/CSpellSettingsInternalDef.js"); +const AutoResolve_js_1 = require("../../util/AutoResolve.js"); +const errors_js_1 = require("../../util/errors.js"); +const SpellingDictionaryError_js_1 = require("../SpellingDictionaryError.js"); const MAX_AGE = 10000; const loaders = { S: loadSimpleWordList, @@ -32,13 +32,13 @@ class DictionaryLoader { constructor(cspellIO) { this.cspellIO = cspellIO; this.dictionaryCache = new strong_weak_map_1.StrongWeakMap(); - this.inlineDictionaryCache = new AutoResolve_1.AutoResolveWeakCache(); + this.inlineDictionaryCache = new AutoResolve_js_1.AutoResolveWeakCache(); this.dictionaryCacheByDef = new strong_weak_map_1.StrongWeakMap(); this.reader = toReader(cspellIO); this.readerSync = toReaderSync(cspellIO); } loadDictionary(def) { - if ((0, CSpellSettingsInternalDef_1.isDictionaryDefinitionInlineInternal)(def)) { + if ((0, CSpellSettingsInternalDef_js_1.isDictionaryDefinitionInlineInternal)(def)) { return Promise.resolve(this.loadInlineDict(def)); } const { key, entry } = this.getCacheEntry(def); @@ -50,7 +50,7 @@ class DictionaryLoader { return loadedEntry.pending.then(([dictionary]) => dictionary); } loadDictionarySync(def) { - if ((0, CSpellSettingsInternalDef_1.isDictionaryDefinitionInlineInternal)(def)) { + if ((0, CSpellSettingsInternalDef_js_1.isDictionaryDefinitionInlineInternal)(def)) { return this.loadInlineDict(def); } const { key, entry } = this.getCacheEntry(def); @@ -107,7 +107,7 @@ class DictionaryLoader { } loadEntry(uri, options, now = Date.now()) { options = this.normalizeOptions(uri, options); - const pDictionary = load(this.reader, uri, options).catch((e) => (0, cspell_dictionary_1.createFailedToLoadDictionary)(options.name, uri, new SpellingDictionaryError_1.SpellingDictionaryLoadError(uri, options, e, 'failed to load'), options)); + const pDictionary = load(this.reader, uri, options).catch((e) => (0, cspell_dictionary_1.createFailedToLoadDictionary)(options.name, uri, new SpellingDictionaryError_js_1.SpellingDictionaryLoadError(uri, options, e, 'failed to load'), options)); const pStat = this.getStat(uri); const pending = Promise.all([pDictionary, pStat]); const sig = now + Math.random(); @@ -149,8 +149,8 @@ class DictionaryLoader { }; } catch (e) { - const error = (0, errors_1.toError)(e); - const dictionary = (0, cspell_dictionary_1.createFailedToLoadDictionary)(options.name, uri, new SpellingDictionaryError_1.SpellingDictionaryLoadError(uri, options, error, 'failed to load'), options); + const error = (0, errors_js_1.toError)(e); + const dictionary = (0, cspell_dictionary_1.createFailedToLoadDictionary)(options.name, uri, new SpellingDictionaryError_js_1.SpellingDictionaryLoadError(uri, options, error, 'failed to load'), options); const pending = Promise.resolve([dictionary, stat]); return { uri, @@ -165,14 +165,14 @@ class DictionaryLoader { } } getStat(uri) { - return this.cspellIO.getStat(uri).catch(errors_1.toError); + return this.cspellIO.getStat(uri).catch(errors_js_1.toError); } getStatSync(uri) { try { return this.cspellIO.getStatSync(uri); } catch (e) { - return (0, errors_1.toError)(e); + return (0, errors_js_1.toError)(e); } } isEqual(a, b) { diff --git a/action/node_modules/cspell-lib/dist/SpellingDictionary/DictionaryController/index.js b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/DictionaryController/index.js similarity index 59% rename from action/node_modules/cspell-lib/dist/SpellingDictionary/DictionaryController/index.js rename to action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/DictionaryController/index.js index 8c77b3b54..347442041 100644 --- a/action/node_modules/cspell-lib/dist/SpellingDictionary/DictionaryController/index.js +++ b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/DictionaryController/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DictionaryLoader = void 0; -var DictionaryLoader_1 = require("./DictionaryLoader"); -Object.defineProperty(exports, "DictionaryLoader", { enumerable: true, get: function () { return DictionaryLoader_1.DictionaryLoader; } }); +var DictionaryLoader_js_1 = require("./DictionaryLoader.js"); +Object.defineProperty(exports, "DictionaryLoader", { enumerable: true, get: function () { return DictionaryLoader_js_1.DictionaryLoader; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/SpellingDictionary/DictionaryLoader.js b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/DictionaryLoader.js similarity index 83% rename from action/node_modules/cspell-lib/dist/SpellingDictionary/DictionaryLoader.js rename to action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/DictionaryLoader.js index 0ebd1217d..cd88186b3 100644 --- a/action/node_modules/cspell-lib/dist/SpellingDictionary/DictionaryLoader.js +++ b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/DictionaryLoader.js @@ -1,13 +1,13 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.refreshCacheEntries = exports.loadDictionarySync = exports.loadDictionary = exports.getDictionaryLoader = void 0; -const static_1 = require("../static"); -const DictionaryController_1 = require("./DictionaryController"); +const static_js_1 = require("../static.js"); +const index_js_1 = require("./DictionaryController/index.js"); let loader; function getDictionaryLoader(cspellIO) { if (loader) return loader; - return (loader = new DictionaryController_1.DictionaryLoader(cspellIO || (0, static_1.getCSpellIO)())); + return (loader = new index_js_1.DictionaryLoader(cspellIO || (0, static_js_1.getCSpellIO)())); } exports.getDictionaryLoader = getDictionaryLoader; function loadDictionary(def) { diff --git a/action/node_modules/cspell-lib/dist/SpellingDictionary/SpellingDictionary.js b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SpellingDictionary.js similarity index 100% rename from action/node_modules/cspell-lib/dist/SpellingDictionary/SpellingDictionary.js rename to action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SpellingDictionary.js diff --git a/action/node_modules/cspell-lib/dist/SpellingDictionary/SpellingDictionaryError.js b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SpellingDictionaryError.js similarity index 100% rename from action/node_modules/cspell-lib/dist/SpellingDictionary/SpellingDictionaryError.js rename to action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SpellingDictionaryError.js diff --git a/action/node_modules/cspell-lib/dist/SpellingDictionary/SuggestExperimental/SuggestionCollector.js b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SuggestExperimental/SuggestionCollector.js similarity index 80% rename from action/node_modules/cspell-lib/dist/SpellingDictionary/SuggestExperimental/SuggestionCollector.js rename to action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SuggestExperimental/SuggestionCollector.js index 5fb439c74..7c7667699 100644 --- a/action/node_modules/cspell-lib/dist/SpellingDictionary/SuggestExperimental/SuggestionCollector.js +++ b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SuggestExperimental/SuggestionCollector.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SuggestionCollector = void 0; -const helpers_1 = require("./helpers"); +const helpers_js_1 = require("./helpers.js"); class SuggestionCollector { constructor(size, minScore) { this.size = size; @@ -12,7 +12,7 @@ class SuggestionCollector { return this.results.concat(); } get sortedCollection() { - return this.collection.sort(helpers_1.compareResults); + return this.collection.sort(helpers_js_1.compareResults); } } exports.SuggestionCollector = SuggestionCollector; diff --git a/action/node_modules/cspell-lib/dist/SpellingDictionary/SuggestExperimental/entities.js b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SuggestExperimental/entities.js similarity index 100% rename from action/node_modules/cspell-lib/dist/SpellingDictionary/SuggestExperimental/entities.js rename to action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SuggestExperimental/entities.js diff --git a/action/node_modules/cspell-lib/dist/SpellingDictionary/SuggestExperimental/helpers.js b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SuggestExperimental/helpers.js similarity index 100% rename from action/node_modules/cspell-lib/dist/SpellingDictionary/SuggestExperimental/helpers.js rename to action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SuggestExperimental/helpers.js diff --git a/action/node_modules/cspell-lib/dist/SpellingDictionary/SuggestExperimental/suggest.js b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SuggestExperimental/suggest.js similarity index 80% rename from action/node_modules/cspell-lib/dist/SpellingDictionary/SuggestExperimental/suggest.js rename to action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SuggestExperimental/suggest.js index 86c117f76..ba9712ad4 100644 --- a/action/node_modules/cspell-lib/dist/SpellingDictionary/SuggestExperimental/suggest.js +++ b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/SuggestExperimental/suggest.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.suggestIteration = exports.suggest = void 0; -const helpers_1 = require("./helpers"); +const helpers_js_1 = require("./helpers.js"); const defaultMinScore = 0.35; const wPrefix = '^'; const wSuffix = '$'; @@ -11,15 +11,15 @@ function* suggest(trie, word, minScore = defaultMinScore) { exports.suggest = suggest; function* suggestIteration(i, word, minScore = defaultMinScore) { let goDeeper = true; - const fA = (0, helpers_1.wordToFeatures)(wPrefix + word + wSuffix); + const fA = (0, helpers_js_1.wordToFeatures)(wPrefix + word + wSuffix); for (let r = i.next(goDeeper); !r.done; r = i.next(goDeeper)) { const { text, node } = r.value; - const fB = (0, helpers_1.wordToFeatures)(wPrefix + text); + const fB = (0, helpers_js_1.wordToFeatures)(wPrefix + text); const rawScore = fA.intersectionScore(fB); const bestPossibleScore = fA.count / (fA.count + fB.count - rawScore); goDeeper = bestPossibleScore > minScore; if (goDeeper && node.f) { - const fB = (0, helpers_1.wordToFeatures)(wPrefix + text + wSuffix); + const fB = (0, helpers_js_1.wordToFeatures)(wPrefix + text + wSuffix); const rawScore = fA.intersectionScore(fB); const score = rawScore / (fA.count + fB.count - rawScore); if (score >= minScore) { diff --git a/action/node_modules/cspell-lib/dist/SpellingDictionary/index.js b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/index.js similarity index 81% rename from action/node_modules/cspell-lib/dist/SpellingDictionary/index.js rename to action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/index.js index 5f1be0ecd..c65968960 100644 --- a/action/node_modules/cspell-lib/dist/SpellingDictionary/index.js +++ b/action/node_modules/cspell-lib/dist/cjs/SpellingDictionary/index.js @@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); -__exportStar(require("./Dictionaries"), exports); -__exportStar(require("./SpellingDictionary"), exports); -__exportStar(require("./SpellingDictionaryError"), exports); +__exportStar(require("./Dictionaries.js"), exports); +__exportStar(require("./SpellingDictionary.js"), exports); +__exportStar(require("./SpellingDictionaryError.js"), exports); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/clearCachedFiles.js b/action/node_modules/cspell-lib/dist/cjs/clearCachedFiles.js similarity index 51% rename from action/node_modules/cspell-lib/dist/clearCachedFiles.js rename to action/node_modules/cspell-lib/dist/cjs/clearCachedFiles.js index f6c7b37e2..0210b7b74 100644 --- a/action/node_modules/cspell-lib/dist/clearCachedFiles.js +++ b/action/node_modules/cspell-lib/dist/cjs/clearCachedFiles.js @@ -1,10 +1,10 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clearCachedFiles = void 0; -const Settings_1 = require("./Settings"); -const SpellingDictionary_1 = require("./SpellingDictionary"); +const index_js_1 = require("./Settings/index.js"); +const index_js_2 = require("./SpellingDictionary/index.js"); async function clearCachedFiles() { - await Promise.all([(0, Settings_1.clearCachedSettingsFiles)(), (0, SpellingDictionary_1.refreshDictionaryCache)(0)]); + await Promise.all([(0, index_js_1.clearCachedSettingsFiles)(), (0, index_js_2.refreshDictionaryCache)(0)]); } exports.clearCachedFiles = clearCachedFiles; //# sourceMappingURL=clearCachedFiles.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/exclusionHelper.js b/action/node_modules/cspell-lib/dist/cjs/exclusionHelper.js similarity index 93% rename from action/node_modules/cspell-lib/dist/exclusionHelper.js rename to action/node_modules/cspell-lib/dist/cjs/exclusionHelper.js index 896dcf22a..26226c73b 100644 --- a/action/node_modules/cspell-lib/dist/exclusionHelper.js +++ b/action/node_modules/cspell-lib/dist/cjs/exclusionHelper.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.generateExclusionFunctionForFiles = exports.generateExclusionFunctionForUri = exports.extractGlobsFromExcludeFilesGlobMap = void 0; const cspell_glob_1 = require("cspell-glob"); -const Uri_1 = require("./util/Uri"); +const Uri_js_1 = require("./util/Uri.js"); const defaultAllowedSchemes = new Set(['file', 'untitled']); function extractGlobsFromExcludeFilesGlobMap(globMap) { const globs = Object.getOwnPropertyNames(globMap).filter((glob) => globMap[glob]); @@ -34,10 +34,10 @@ function generateExclusionFunctionForUri(globs, root, allowedSchemes = defaultAl if (!allowedSchemes.has(uri.scheme)) { return true; } - return matchFn(uri.scheme === 'file' || uri.scheme === 'stdin' ? (0, Uri_1.uriToFilePath)(uri) : uri.path); + return matchFn(uri.scheme === 'file' || uri.scheme === 'stdin' ? (0, Uri_js_1.uriToFilePath)(uri) : uri.path); } function testUriPath(uriPath) { - const uri = (0, Uri_1.toUri)(uriPath); + const uri = (0, Uri_js_1.toUri)(uriPath); return testUri(uri); } return testUriPath; diff --git a/action/node_modules/cspell-lib/dist/getDictionary.js b/action/node_modules/cspell-lib/dist/cjs/getDictionary.js similarity index 63% rename from action/node_modules/cspell-lib/dist/getDictionary.js rename to action/node_modules/cspell-lib/dist/cjs/getDictionary.js index d59533b21..d9caf07e4 100644 --- a/action/node_modules/cspell-lib/dist/getDictionary.js +++ b/action/node_modules/cspell-lib/dist/cjs/getDictionary.js @@ -1,15 +1,15 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDictionary = void 0; -const CSpellSettingsServer_1 = require("./Settings/CSpellSettingsServer"); -const SpellingDictionary_1 = require("./SpellingDictionary"); +const CSpellSettingsServer_js_1 = require("./Settings/CSpellSettingsServer.js"); +const index_js_1 = require("./SpellingDictionary/index.js"); /** * Load a dictionary collection defined by the settings. * @param settings - that defines the dictionaries and the ones to load. * @returns a dictionary collection that represents all the enabled dictionaries. */ function getDictionary(settings) { - return (0, SpellingDictionary_1.getDictionaryInternal)((0, CSpellSettingsServer_1.toInternalSettings)(settings)); + return (0, index_js_1.getDictionaryInternal)((0, CSpellSettingsServer_js_1.toInternalSettings)(settings)); } exports.getDictionary = getDictionary; //# sourceMappingURL=getDictionary.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/index.js b/action/node_modules/cspell-lib/dist/cjs/index.js similarity index 61% rename from action/node_modules/cspell-lib/dist/index.js rename to action/node_modules/cspell-lib/dist/cjs/index.js index fee1b5ba2..3b23690a9 100644 --- a/action/node_modules/cspell-lib/dist/index.js +++ b/action/node_modules/cspell-lib/dist/cjs/index.js @@ -28,89 +28,89 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { Object.defineProperty(exports, "__esModule", { value: true }); exports.suggestionsForWord = exports.SuggestionError = exports.SpellingDictionaryLoadError = exports.refreshDictionaryCache = exports.isSpellingDictionaryLoadError = exports.createSpellingDictionaryCollection = exports.createSpellingDictionary = exports.CompoundWordsMethod = exports.spellCheckFile = exports.spellCheckDocument = exports.determineFinalDocumentSettings = exports.constructSettingsForText = exports.combineTextAndLanguageSettings = exports.defaultSettingsFilename = exports.sectionCSpell = exports.searchForConfig = exports.readSettingsFiles = exports.readSettings = exports.readRawSettings = exports.mergeSettings = exports.mergeInDocSettings = exports.loadPnPSync = exports.loadPnP = exports.loadConfig = exports.ImportError = exports.getSources = exports.getGlobalSettings = exports.getDefaultSettings = exports.getDefaultBundledSettings = exports.getCachedFileSize = exports.finalizeSettings = exports.extractImportErrors = exports.extractDependencies = exports.ENV_CSPELL_GLOB_ROOT = exports.defaultFileName = exports.defaultConfigFilenames = exports.currentSettingsFileVersion = exports.clearCachedSettingsFiles = exports.checkFilenameMatchesGlob = exports.calcOverrideSettings = exports.updateTextDocument = exports.createTextDocument = exports.getLanguagesForExt = exports.getLanguageIdsForBaseFilename = exports.UnknownFeatureFlagError = exports.getSystemFeatureFlags = exports.FeatureFlags = exports.isBinaryFile = exports.fileToTextDocument = exports.fileToDocument = void 0; exports.getDictionary = exports.clearCachedFiles = exports.ExclusionHelper = exports.Text = exports.Link = exports.writeToFileIterableP = exports.writeToFileIterable = exports.writeToFile = exports.readFileSync = exports.readFile = exports.asyncIterableToArray = exports.validateText = exports.IncludeExcludeFlag = exports.checkTextDocument = exports.checkText = exports.resolveFile = exports.setLogger = exports.getLogger = exports.traceWordsAsync = exports.traceWords = exports.shouldCheckDocument = exports.DocumentValidator = exports.suggestionsForWords = void 0; -const ExclusionHelper = __importStar(require("./exclusionHelper")); +const ExclusionHelper = __importStar(require("./exclusionHelper.js")); exports.ExclusionHelper = ExclusionHelper; -const Link = __importStar(require("./Settings/index.link")); +const Link = __importStar(require("./Settings/index.link.js")); exports.Link = Link; -const Text = __importStar(require("./util/text")); +const Text = __importStar(require("./util/text.js")); exports.Text = Text; -var Document_1 = require("./Document"); -Object.defineProperty(exports, "fileToDocument", { enumerable: true, get: function () { return Document_1.fileToDocument; } }); -Object.defineProperty(exports, "fileToTextDocument", { enumerable: true, get: function () { return Document_1.fileToTextDocument; } }); -Object.defineProperty(exports, "isBinaryFile", { enumerable: true, get: function () { return Document_1.isBinaryFile; } }); -var FeatureFlags_1 = require("./FeatureFlags"); -Object.defineProperty(exports, "FeatureFlags", { enumerable: true, get: function () { return FeatureFlags_1.FeatureFlags; } }); -Object.defineProperty(exports, "getSystemFeatureFlags", { enumerable: true, get: function () { return FeatureFlags_1.getSystemFeatureFlags; } }); -Object.defineProperty(exports, "UnknownFeatureFlagError", { enumerable: true, get: function () { return FeatureFlags_1.UnknownFeatureFlagError; } }); -var LanguageIds_1 = require("./LanguageIds"); -Object.defineProperty(exports, "getLanguageIdsForBaseFilename", { enumerable: true, get: function () { return LanguageIds_1.getLanguagesForBasename; } }); -Object.defineProperty(exports, "getLanguagesForExt", { enumerable: true, get: function () { return LanguageIds_1.getLanguagesForExt; } }); -var TextDocument_1 = require("./Models/TextDocument"); -Object.defineProperty(exports, "createTextDocument", { enumerable: true, get: function () { return TextDocument_1.createTextDocument; } }); -Object.defineProperty(exports, "updateTextDocument", { enumerable: true, get: function () { return TextDocument_1.updateTextDocument; } }); -var Settings_1 = require("./Settings"); -Object.defineProperty(exports, "calcOverrideSettings", { enumerable: true, get: function () { return Settings_1.calcOverrideSettings; } }); -Object.defineProperty(exports, "checkFilenameMatchesGlob", { enumerable: true, get: function () { return Settings_1.checkFilenameMatchesGlob; } }); -Object.defineProperty(exports, "clearCachedSettingsFiles", { enumerable: true, get: function () { return Settings_1.clearCachedSettingsFiles; } }); -Object.defineProperty(exports, "currentSettingsFileVersion", { enumerable: true, get: function () { return Settings_1.currentSettingsFileVersion; } }); -Object.defineProperty(exports, "defaultConfigFilenames", { enumerable: true, get: function () { return Settings_1.defaultConfigFilenames; } }); -Object.defineProperty(exports, "defaultFileName", { enumerable: true, get: function () { return Settings_1.defaultFileName; } }); -Object.defineProperty(exports, "ENV_CSPELL_GLOB_ROOT", { enumerable: true, get: function () { return Settings_1.ENV_CSPELL_GLOB_ROOT; } }); -Object.defineProperty(exports, "extractDependencies", { enumerable: true, get: function () { return Settings_1.extractDependencies; } }); -Object.defineProperty(exports, "extractImportErrors", { enumerable: true, get: function () { return Settings_1.extractImportErrors; } }); -Object.defineProperty(exports, "finalizeSettings", { enumerable: true, get: function () { return Settings_1.finalizeSettings; } }); -Object.defineProperty(exports, "getCachedFileSize", { enumerable: true, get: function () { return Settings_1.getCachedFileSize; } }); -Object.defineProperty(exports, "getDefaultBundledSettings", { enumerable: true, get: function () { return Settings_1.getDefaultBundledSettings; } }); -Object.defineProperty(exports, "getDefaultSettings", { enumerable: true, get: function () { return Settings_1.getDefaultSettings; } }); -Object.defineProperty(exports, "getGlobalSettings", { enumerable: true, get: function () { return Settings_1.getGlobalSettings; } }); -Object.defineProperty(exports, "getSources", { enumerable: true, get: function () { return Settings_1.getSources; } }); -Object.defineProperty(exports, "ImportError", { enumerable: true, get: function () { return Settings_1.ImportError; } }); -Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return Settings_1.loadConfig; } }); -Object.defineProperty(exports, "loadPnP", { enumerable: true, get: function () { return Settings_1.loadPnP; } }); -Object.defineProperty(exports, "loadPnPSync", { enumerable: true, get: function () { return Settings_1.loadPnPSync; } }); -Object.defineProperty(exports, "mergeInDocSettings", { enumerable: true, get: function () { return Settings_1.mergeInDocSettings; } }); -Object.defineProperty(exports, "mergeSettings", { enumerable: true, get: function () { return Settings_1.mergeSettings; } }); -Object.defineProperty(exports, "readRawSettings", { enumerable: true, get: function () { return Settings_1.readRawSettings; } }); -Object.defineProperty(exports, "readSettings", { enumerable: true, get: function () { return Settings_1.readSettings; } }); -Object.defineProperty(exports, "readSettingsFiles", { enumerable: true, get: function () { return Settings_1.readSettingsFiles; } }); -Object.defineProperty(exports, "searchForConfig", { enumerable: true, get: function () { return Settings_1.searchForConfig; } }); -Object.defineProperty(exports, "sectionCSpell", { enumerable: true, get: function () { return Settings_1.sectionCSpell; } }); -var Settings_2 = require("./Settings"); -Object.defineProperty(exports, "defaultSettingsFilename", { enumerable: true, get: function () { return Settings_2.defaultFileName; } }); -var TextDocumentSettings_1 = require("./Settings/TextDocumentSettings"); -Object.defineProperty(exports, "combineTextAndLanguageSettings", { enumerable: true, get: function () { return TextDocumentSettings_1.combineTextAndLanguageSettings; } }); -Object.defineProperty(exports, "constructSettingsForText", { enumerable: true, get: function () { return TextDocumentSettings_1.combineTextAndLanguageSettings; } }); -var spellCheckFile_1 = require("./spellCheckFile"); -Object.defineProperty(exports, "determineFinalDocumentSettings", { enumerable: true, get: function () { return spellCheckFile_1.determineFinalDocumentSettings; } }); -Object.defineProperty(exports, "spellCheckDocument", { enumerable: true, get: function () { return spellCheckFile_1.spellCheckDocument; } }); -Object.defineProperty(exports, "spellCheckFile", { enumerable: true, get: function () { return spellCheckFile_1.spellCheckFile; } }); -var SpellingDictionary_1 = require("./SpellingDictionary"); -Object.defineProperty(exports, "CompoundWordsMethod", { enumerable: true, get: function () { return SpellingDictionary_1.CompoundWordsMethod; } }); -Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createSpellingDictionary; } }); -Object.defineProperty(exports, "createSpellingDictionaryCollection", { enumerable: true, get: function () { return SpellingDictionary_1.createCollection; } }); -Object.defineProperty(exports, "isSpellingDictionaryLoadError", { enumerable: true, get: function () { return SpellingDictionary_1.isSpellingDictionaryLoadError; } }); -Object.defineProperty(exports, "refreshDictionaryCache", { enumerable: true, get: function () { return SpellingDictionary_1.refreshDictionaryCache; } }); -Object.defineProperty(exports, "SpellingDictionaryLoadError", { enumerable: true, get: function () { return SpellingDictionary_1.SpellingDictionaryLoadError; } }); -var suggestions_1 = require("./suggestions"); -Object.defineProperty(exports, "SuggestionError", { enumerable: true, get: function () { return suggestions_1.SuggestionError; } }); -Object.defineProperty(exports, "suggestionsForWord", { enumerable: true, get: function () { return suggestions_1.suggestionsForWord; } }); -Object.defineProperty(exports, "suggestionsForWords", { enumerable: true, get: function () { return suggestions_1.suggestionsForWords; } }); -var textValidation_1 = require("./textValidation"); -Object.defineProperty(exports, "DocumentValidator", { enumerable: true, get: function () { return textValidation_1.DocumentValidator; } }); -Object.defineProperty(exports, "shouldCheckDocument", { enumerable: true, get: function () { return textValidation_1.shouldCheckDocument; } }); -var trace_1 = require("./trace"); -Object.defineProperty(exports, "traceWords", { enumerable: true, get: function () { return trace_1.traceWords; } }); -Object.defineProperty(exports, "traceWordsAsync", { enumerable: true, get: function () { return trace_1.traceWordsAsync; } }); -var logger_1 = require("./util/logger"); -Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return logger_1.getLogger; } }); -Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return logger_1.setLogger; } }); -var resolveFile_1 = require("./util/resolveFile"); -Object.defineProperty(exports, "resolveFile", { enumerable: true, get: function () { return resolveFile_1.resolveFile; } }); -var validator_1 = require("./validator"); -Object.defineProperty(exports, "checkText", { enumerable: true, get: function () { return validator_1.checkText; } }); -Object.defineProperty(exports, "checkTextDocument", { enumerable: true, get: function () { return validator_1.checkTextDocument; } }); -Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return validator_1.IncludeExcludeFlag; } }); -Object.defineProperty(exports, "validateText", { enumerable: true, get: function () { return validator_1.validateText; } }); +var index_js_1 = require("./Document/index.js"); +Object.defineProperty(exports, "fileToDocument", { enumerable: true, get: function () { return index_js_1.fileToDocument; } }); +Object.defineProperty(exports, "fileToTextDocument", { enumerable: true, get: function () { return index_js_1.fileToTextDocument; } }); +Object.defineProperty(exports, "isBinaryFile", { enumerable: true, get: function () { return index_js_1.isBinaryFile; } }); +var index_js_2 = require("./FeatureFlags/index.js"); +Object.defineProperty(exports, "FeatureFlags", { enumerable: true, get: function () { return index_js_2.FeatureFlags; } }); +Object.defineProperty(exports, "getSystemFeatureFlags", { enumerable: true, get: function () { return index_js_2.getSystemFeatureFlags; } }); +Object.defineProperty(exports, "UnknownFeatureFlagError", { enumerable: true, get: function () { return index_js_2.UnknownFeatureFlagError; } }); +var LanguageIds_js_1 = require("./LanguageIds.js"); +Object.defineProperty(exports, "getLanguageIdsForBaseFilename", { enumerable: true, get: function () { return LanguageIds_js_1.getLanguagesForBasename; } }); +Object.defineProperty(exports, "getLanguagesForExt", { enumerable: true, get: function () { return LanguageIds_js_1.getLanguagesForExt; } }); +var TextDocument_js_1 = require("./Models/TextDocument.js"); +Object.defineProperty(exports, "createTextDocument", { enumerable: true, get: function () { return TextDocument_js_1.createTextDocument; } }); +Object.defineProperty(exports, "updateTextDocument", { enumerable: true, get: function () { return TextDocument_js_1.updateTextDocument; } }); +var index_js_3 = require("./Settings/index.js"); +Object.defineProperty(exports, "calcOverrideSettings", { enumerable: true, get: function () { return index_js_3.calcOverrideSettings; } }); +Object.defineProperty(exports, "checkFilenameMatchesGlob", { enumerable: true, get: function () { return index_js_3.checkFilenameMatchesGlob; } }); +Object.defineProperty(exports, "clearCachedSettingsFiles", { enumerable: true, get: function () { return index_js_3.clearCachedSettingsFiles; } }); +Object.defineProperty(exports, "currentSettingsFileVersion", { enumerable: true, get: function () { return index_js_3.currentSettingsFileVersion; } }); +Object.defineProperty(exports, "defaultConfigFilenames", { enumerable: true, get: function () { return index_js_3.defaultConfigFilenames; } }); +Object.defineProperty(exports, "defaultFileName", { enumerable: true, get: function () { return index_js_3.defaultFileName; } }); +Object.defineProperty(exports, "ENV_CSPELL_GLOB_ROOT", { enumerable: true, get: function () { return index_js_3.ENV_CSPELL_GLOB_ROOT; } }); +Object.defineProperty(exports, "extractDependencies", { enumerable: true, get: function () { return index_js_3.extractDependencies; } }); +Object.defineProperty(exports, "extractImportErrors", { enumerable: true, get: function () { return index_js_3.extractImportErrors; } }); +Object.defineProperty(exports, "finalizeSettings", { enumerable: true, get: function () { return index_js_3.finalizeSettings; } }); +Object.defineProperty(exports, "getCachedFileSize", { enumerable: true, get: function () { return index_js_3.getCachedFileSize; } }); +Object.defineProperty(exports, "getDefaultBundledSettings", { enumerable: true, get: function () { return index_js_3.getDefaultBundledSettings; } }); +Object.defineProperty(exports, "getDefaultSettings", { enumerable: true, get: function () { return index_js_3.getDefaultSettings; } }); +Object.defineProperty(exports, "getGlobalSettings", { enumerable: true, get: function () { return index_js_3.getGlobalSettings; } }); +Object.defineProperty(exports, "getSources", { enumerable: true, get: function () { return index_js_3.getSources; } }); +Object.defineProperty(exports, "ImportError", { enumerable: true, get: function () { return index_js_3.ImportError; } }); +Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return index_js_3.loadConfig; } }); +Object.defineProperty(exports, "loadPnP", { enumerable: true, get: function () { return index_js_3.loadPnP; } }); +Object.defineProperty(exports, "loadPnPSync", { enumerable: true, get: function () { return index_js_3.loadPnPSync; } }); +Object.defineProperty(exports, "mergeInDocSettings", { enumerable: true, get: function () { return index_js_3.mergeInDocSettings; } }); +Object.defineProperty(exports, "mergeSettings", { enumerable: true, get: function () { return index_js_3.mergeSettings; } }); +Object.defineProperty(exports, "readRawSettings", { enumerable: true, get: function () { return index_js_3.readRawSettings; } }); +Object.defineProperty(exports, "readSettings", { enumerable: true, get: function () { return index_js_3.readSettings; } }); +Object.defineProperty(exports, "readSettingsFiles", { enumerable: true, get: function () { return index_js_3.readSettingsFiles; } }); +Object.defineProperty(exports, "searchForConfig", { enumerable: true, get: function () { return index_js_3.searchForConfig; } }); +Object.defineProperty(exports, "sectionCSpell", { enumerable: true, get: function () { return index_js_3.sectionCSpell; } }); +var index_js_4 = require("./Settings/index.js"); +Object.defineProperty(exports, "defaultSettingsFilename", { enumerable: true, get: function () { return index_js_4.defaultFileName; } }); +var TextDocumentSettings_js_1 = require("./Settings/TextDocumentSettings.js"); +Object.defineProperty(exports, "combineTextAndLanguageSettings", { enumerable: true, get: function () { return TextDocumentSettings_js_1.combineTextAndLanguageSettings; } }); +Object.defineProperty(exports, "constructSettingsForText", { enumerable: true, get: function () { return TextDocumentSettings_js_1.combineTextAndLanguageSettings; } }); +var spellCheckFile_js_1 = require("./spellCheckFile.js"); +Object.defineProperty(exports, "determineFinalDocumentSettings", { enumerable: true, get: function () { return spellCheckFile_js_1.determineFinalDocumentSettings; } }); +Object.defineProperty(exports, "spellCheckDocument", { enumerable: true, get: function () { return spellCheckFile_js_1.spellCheckDocument; } }); +Object.defineProperty(exports, "spellCheckFile", { enumerable: true, get: function () { return spellCheckFile_js_1.spellCheckFile; } }); +var index_js_5 = require("./SpellingDictionary/index.js"); +Object.defineProperty(exports, "CompoundWordsMethod", { enumerable: true, get: function () { return index_js_5.CompoundWordsMethod; } }); +Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return index_js_5.createSpellingDictionary; } }); +Object.defineProperty(exports, "createSpellingDictionaryCollection", { enumerable: true, get: function () { return index_js_5.createCollection; } }); +Object.defineProperty(exports, "isSpellingDictionaryLoadError", { enumerable: true, get: function () { return index_js_5.isSpellingDictionaryLoadError; } }); +Object.defineProperty(exports, "refreshDictionaryCache", { enumerable: true, get: function () { return index_js_5.refreshDictionaryCache; } }); +Object.defineProperty(exports, "SpellingDictionaryLoadError", { enumerable: true, get: function () { return index_js_5.SpellingDictionaryLoadError; } }); +var suggestions_js_1 = require("./suggestions.js"); +Object.defineProperty(exports, "SuggestionError", { enumerable: true, get: function () { return suggestions_js_1.SuggestionError; } }); +Object.defineProperty(exports, "suggestionsForWord", { enumerable: true, get: function () { return suggestions_js_1.suggestionsForWord; } }); +Object.defineProperty(exports, "suggestionsForWords", { enumerable: true, get: function () { return suggestions_js_1.suggestionsForWords; } }); +var index_js_6 = require("./textValidation/index.js"); +Object.defineProperty(exports, "DocumentValidator", { enumerable: true, get: function () { return index_js_6.DocumentValidator; } }); +Object.defineProperty(exports, "shouldCheckDocument", { enumerable: true, get: function () { return index_js_6.shouldCheckDocument; } }); +var trace_js_1 = require("./trace.js"); +Object.defineProperty(exports, "traceWords", { enumerable: true, get: function () { return trace_js_1.traceWords; } }); +Object.defineProperty(exports, "traceWordsAsync", { enumerable: true, get: function () { return trace_js_1.traceWordsAsync; } }); +var logger_js_1 = require("./util/logger.js"); +Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return logger_js_1.getLogger; } }); +Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return logger_js_1.setLogger; } }); +var resolveFile_js_1 = require("./util/resolveFile.js"); +Object.defineProperty(exports, "resolveFile", { enumerable: true, get: function () { return resolveFile_js_1.resolveFile; } }); +var validator_js_1 = require("./validator.js"); +Object.defineProperty(exports, "checkText", { enumerable: true, get: function () { return validator_js_1.checkText; } }); +Object.defineProperty(exports, "checkTextDocument", { enumerable: true, get: function () { return validator_js_1.checkTextDocument; } }); +Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return validator_js_1.IncludeExcludeFlag; } }); +Object.defineProperty(exports, "validateText", { enumerable: true, get: function () { return validator_js_1.validateText; } }); __exportStar(require("@cspell/cspell-types"), exports); var cspell_io_1 = require("cspell-io"); Object.defineProperty(exports, "asyncIterableToArray", { enumerable: true, get: function () { return cspell_io_1.asyncIterableToArray; } }); @@ -119,8 +119,8 @@ Object.defineProperty(exports, "readFileSync", { enumerable: true, get: function Object.defineProperty(exports, "writeToFile", { enumerable: true, get: function () { return cspell_io_1.writeToFile; } }); Object.defineProperty(exports, "writeToFileIterable", { enumerable: true, get: function () { return cspell_io_1.writeToFileIterable; } }); Object.defineProperty(exports, "writeToFileIterableP", { enumerable: true, get: function () { return cspell_io_1.writeToFileIterableP; } }); -var clearCachedFiles_1 = require("./clearCachedFiles"); -Object.defineProperty(exports, "clearCachedFiles", { enumerable: true, get: function () { return clearCachedFiles_1.clearCachedFiles; } }); -var getDictionary_1 = require("./getDictionary"); -Object.defineProperty(exports, "getDictionary", { enumerable: true, get: function () { return getDictionary_1.getDictionary; } }); +var clearCachedFiles_js_1 = require("./clearCachedFiles.js"); +Object.defineProperty(exports, "clearCachedFiles", { enumerable: true, get: function () { return clearCachedFiles_js_1.clearCachedFiles; } }); +var getDictionary_js_1 = require("./getDictionary.js"); +Object.defineProperty(exports, "getDictionary", { enumerable: true, get: function () { return getDictionary_js_1.getDictionary; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/spellCheckFile.js b/action/node_modules/cspell-lib/dist/cjs/spellCheckFile.js similarity index 78% rename from action/node_modules/cspell-lib/dist/spellCheckFile.js rename to action/node_modules/cspell-lib/dist/cjs/spellCheckFile.js index 75733e001..3d04c806b 100644 --- a/action/node_modules/cspell-lib/dist/spellCheckFile.js +++ b/action/node_modules/cspell-lib/dist/cjs/spellCheckFile.js @@ -1,13 +1,13 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.determineFinalDocumentSettings = exports.spellCheckDocument = exports.spellCheckFile = void 0; -const isBinaryDoc_1 = require("./Document/isBinaryDoc"); -const resolveDocument_1 = require("./Document/resolveDocument"); -const TextDocument_1 = require("./Models/TextDocument"); -const textValidation_1 = require("./textValidation"); -const determineTextDocumentSettings_1 = require("./textValidation/determineTextDocumentSettings"); -const errors_1 = require("./util/errors"); -const Uri_1 = require("./util/Uri"); +const isBinaryDoc_js_1 = require("./Document/isBinaryDoc.js"); +const resolveDocument_js_1 = require("./Document/resolveDocument.js"); +const TextDocument_js_1 = require("./Models/TextDocument.js"); +const determineTextDocumentSettings_js_1 = require("./textValidation/determineTextDocumentSettings.js"); +const index_js_1 = require("./textValidation/index.js"); +const errors_js_1 = require("./util/errors.js"); +const Uri_js_1 = require("./util/Uri.js"); /** * Spell Check a file * @param file - absolute path to file to read and check. @@ -16,7 +16,7 @@ const Uri_1 = require("./util/Uri"); */ function spellCheckFile(file, options, settings) { const doc = { - uri: (0, Uri_1.toUri)(file).toString(), + uri: (0, Uri_js_1.toUri)(file).toString(), }; return spellCheckDocument(doc, options, settings); } @@ -28,7 +28,7 @@ exports.spellCheckFile = spellCheckFile; * @param settings - default settings to use. */ async function spellCheckDocument(document, options, settings) { - if ((0, isBinaryDoc_1.isBinaryDoc)(document)) { + if ((0, isBinaryDoc_js_1.isBinaryDoc)(document)) { return { document, options, @@ -40,10 +40,10 @@ async function spellCheckDocument(document, options, settings) { }; } try { - return spellCheckFullDocument(await (0, resolveDocument_1.resolveDocument)(document), options, settings); + return spellCheckFullDocument(await (0, resolveDocument_js_1.resolveDocument)(document), options, settings); } catch (e) { - const errors = (0, errors_1.isError)(e) ? [e] : []; + const errors = (0, errors_js_1.isError)(e) ? [e] : []; return { document, options, @@ -57,9 +57,9 @@ async function spellCheckDocument(document, options, settings) { } exports.spellCheckDocument = spellCheckDocument; async function spellCheckFullDocument(document, options, settings) { - const doc = (0, resolveDocument_1.documentToTextDocument)(document); + const doc = (0, resolveDocument_js_1.documentToTextDocument)(document); const docValOptions = options; - const docValidator = new textValidation_1.DocumentValidator(doc, docValOptions, settings); + const docValidator = new index_js_1.DocumentValidator(doc, docValOptions, settings); await docValidator.prepare(); const prep = docValidator._getPreparations(); if (docValidator.errors.length) { @@ -98,7 +98,7 @@ async function spellCheckFullDocument(document, options, settings) { * @param settings - The near final settings. Should already be the combination of all configuration files. */ function determineFinalDocumentSettings(document, settings) { - const doc = (0, TextDocument_1.createTextDocument)({ + const doc = (0, TextDocument_js_1.createTextDocument)({ uri: document.uri, content: document.text, languageId: document.languageId, @@ -106,7 +106,7 @@ function determineFinalDocumentSettings(document, settings) { }); return { document, - settings: (0, determineTextDocumentSettings_1.determineTextDocumentSettings)(doc, settings), + settings: (0, determineTextDocumentSettings_js_1.determineTextDocumentSettings)(doc, settings), }; } exports.determineFinalDocumentSettings = determineFinalDocumentSettings; diff --git a/action/node_modules/cspell-lib/dist/static.js b/action/node_modules/cspell-lib/dist/cjs/static.js similarity index 100% rename from action/node_modules/cspell-lib/dist/static.js rename to action/node_modules/cspell-lib/dist/cjs/static.js diff --git a/action/node_modules/cspell-lib/dist/suggestions.js b/action/node_modules/cspell-lib/dist/cjs/suggestions.js similarity index 84% rename from action/node_modules/cspell-lib/dist/suggestions.js rename to action/node_modules/cspell-lib/dist/cjs/suggestions.js index 98caab8c4..8ec7eda54 100644 --- a/action/node_modules/cspell-lib/dist/suggestions.js +++ b/action/node_modules/cspell-lib/dist/cjs/suggestions.js @@ -28,12 +28,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.SuggestionError = exports.calcSuggestionAdjustedToToMatchCase = exports.suggestionsForWord = exports.suggestionsForWords = void 0; const assert_1 = __importDefault(require("assert")); -const Settings_1 = require("./Settings"); -const LanguageSettings_1 = require("./Settings/LanguageSettings"); -const SpellingDictionary_1 = require("./SpellingDictionary"); -const AutoResolve_1 = require("./util/AutoResolve"); -const memorizeLastCall_1 = require("./util/memorizeLastCall"); -const util = __importStar(require("./util/util")); +const index_js_1 = require("./Settings/index.js"); +const LanguageSettings_js_1 = require("./Settings/LanguageSettings.js"); +const index_js_2 = require("./SpellingDictionary/index.js"); +const AutoResolve_js_1 = require("./util/AutoResolve.js"); +const memorizeLastCall_js_1 = require("./util/memorizeLastCall.js"); +const util = __importStar(require("./util/util.js")); const emptySuggestionOptions = Object.freeze({}); const emptyCSpellSettings = Object.freeze({}); async function* suggestionsForWords(words, options, settings) { @@ -42,9 +42,9 @@ async function* suggestionsForWords(words, options, settings) { } } exports.suggestionsForWords = suggestionsForWords; -const memorizeSuggestions = (0, memorizeLastCall_1.memorizeLastCall)(cacheSuggestionsForWord); +const memorizeSuggestions = (0, memorizeLastCall_js_1.memorizeLastCall)(cacheSuggestionsForWord); function cacheSuggestionsForWord(options, settings) { - const cache = (0, AutoResolve_1.createAutoResolveCache)(); + const cache = (0, AutoResolve_js_1.createAutoResolveCache)(); return (word) => cache.get(word, (word) => _suggestionsForWord(word, options, settings)); } function suggestionsForWord(word, options = emptySuggestionOptions, settings = emptyCSpellSettings) { @@ -54,25 +54,25 @@ exports.suggestionsForWord = suggestionsForWord; async function _suggestionsForWord(word, options, settings) { const { languageId, locale: language, includeDefaultConfig = true, dictionaries } = options; async function determineDictionaries(config) { - const withLocale = (0, Settings_1.mergeSettings)(config, util.clean({ + const withLocale = (0, index_js_1.mergeSettings)(config, util.clean({ language: language || config.language, // dictionaries: dictionaries?.length ? dictionaries : config.dictionaries, })); - const withLanguageId = (0, LanguageSettings_1.calcSettingsForLanguageId)(withLocale, languageId ?? withLocale.languageId ?? 'plaintext'); - const settings = (0, Settings_1.finalizeSettings)(withLanguageId); + const withLanguageId = (0, LanguageSettings_js_1.calcSettingsForLanguageId)(withLocale, languageId ?? withLocale.languageId ?? 'plaintext'); + const settings = (0, index_js_1.finalizeSettings)(withLanguageId); settings.dictionaries = dictionaries?.length ? dictionaries : settings.dictionaries || []; validateDictionaries(settings, dictionaries); - const dictionaryCollection = await (0, SpellingDictionary_1.getDictionaryInternal)(settings); + const dictionaryCollection = await (0, index_js_2.getDictionaryInternal)(settings); settings.dictionaries = settings.dictionaryDefinitions?.map((def) => def.name) || []; - const allDictionaryCollection = await (0, SpellingDictionary_1.getDictionaryInternal)(settings); + const allDictionaryCollection = await (0, index_js_2.getDictionaryInternal)(settings); return { dictionaryCollection, allDictionaryCollection, }; } - await (0, SpellingDictionary_1.refreshDictionaryCache)(); + await (0, index_js_2.refreshDictionaryCache)(); const config = includeDefaultConfig - ? (0, Settings_1.mergeSettings)((0, Settings_1.getDefaultSettings)(settings.loadDefaultConfiguration ?? true), (0, Settings_1.getGlobalSettings)(), settings) + ? (0, index_js_1.mergeSettings)((0, index_js_1.getDefaultSettings)(settings.loadDefaultConfiguration ?? true), (0, index_js_1.getGlobalSettings)(), settings) : settings; const { dictionaryCollection, allDictionaryCollection } = await determineDictionaries(config); return _suggestionsForWordSync(word, options, settings, dictionaryCollection, allDictionaryCollection); @@ -82,7 +82,7 @@ function _suggestionsForWordSync(word, options, settings, dictionaryCollection, const { locale: language, strict = true, numChanges = 4, numSuggestions = 8, includeTies = true, includeDefaultConfig = true, } = options; const ignoreCase = !strict; const config = includeDefaultConfig - ? (0, Settings_1.mergeSettings)((0, Settings_1.getDefaultSettings)(settings.loadDefaultConfiguration ?? true), (0, Settings_1.getGlobalSettings)(), settings) + ? (0, index_js_1.mergeSettings)((0, index_js_1.getDefaultSettings)(settings.loadDefaultConfiguration ?? true), (0, index_js_1.getGlobalSettings)(), settings) : settings; const opts = { ignoreCase, numChanges, numSuggestions, includeTies }; const suggestionsByDictionary = dictionaryCollection.dictionaries.flatMap((dict) => dict.suggest(word, opts).map((r) => ({ ...r, dictName: dict.name }))); @@ -118,7 +118,7 @@ function combine(suggestions) { function adjustLocale(locale) { if (!locale) return undefined; - const locales = [...(0, LanguageSettings_1.normalizeLocaleIntl)(locale)].filter((locale) => (0, LanguageSettings_1.isValidLocaleIntlFormat)(locale)); + const locales = [...(0, LanguageSettings_js_1.normalizeLocaleIntl)(locale)].filter((locale) => (0, LanguageSettings_js_1.isValidLocaleIntlFormat)(locale)); if (!locales.length) return undefined; if (locales.length === 1) diff --git a/action/node_modules/cspell-lib/dist/textValidation/ValidateTextOptions.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/ValidateTextOptions.js similarity index 100% rename from action/node_modules/cspell-lib/dist/textValidation/ValidateTextOptions.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/ValidateTextOptions.js diff --git a/action/node_modules/cspell-lib/dist/textValidation/ValidationTypes.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/ValidationTypes.js similarity index 100% rename from action/node_modules/cspell-lib/dist/textValidation/ValidationTypes.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/ValidationTypes.js diff --git a/action/node_modules/cspell-lib/dist/textValidation/checkText.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/checkText.js similarity index 85% rename from action/node_modules/cspell-lib/dist/textValidation/checkText.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/checkText.js index 8ce07a8d2..918872c8c 100644 --- a/action/node_modules/cspell-lib/dist/textValidation/checkText.js +++ b/action/node_modules/cspell-lib/dist/cjs/textValidation/checkText.js @@ -28,13 +28,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.genCheckText = exports.checkTextDocument = exports.IncludeExcludeFlag = exports.checkTextOld = exports.checkText = void 0; const assert_1 = __importDefault(require("assert")); -const resolveDocument_1 = require("../Document/resolveDocument"); -const TextDocument_1 = require("../Models/TextDocument"); -const Settings = __importStar(require("../Settings")); -const util_1 = require("../util/util"); -const docValidator_1 = require("./docValidator"); -const textValidator_1 = require("./textValidator"); -const validator_1 = require("./validator"); +const resolveDocument_js_1 = require("../Document/resolveDocument.js"); +const TextDocument_js_1 = require("../Models/TextDocument.js"); +const Settings = __importStar(require("../Settings/index.js")); +const util_js_1 = require("../util/util.js"); +const docValidator_js_1 = require("./docValidator.js"); +const textValidator_js_1 = require("./textValidator.js"); +const validator_js_1 = require("./validator.js"); /** * Annotate text with issues and include / exclude zones. * @param text - the text to annotate. @@ -43,7 +43,7 @@ const validator_1 = require("./validator"); * @deprecated */ async function checkText(text, settings) { - const doc = (0, util_1.clean)({ + const doc = (0, util_js_1.clean)({ uri: '', text, languageId: settings.languageId || 'plaintext', @@ -60,9 +60,9 @@ exports.checkText = checkText; * @deprecated */ async function checkTextOld(text, settings) { - const validationResult = (0, validator_1.validateText)(text, settings); + const validationResult = (0, validator_js_1.validateText)(text, settings); const finalSettings = Settings.finalizeSettings(settings); - const includeRanges = (0, textValidator_1.calcTextInclusionRanges)(text, finalSettings); + const includeRanges = (0, textValidator_js_1.calcTextInclusionRanges)(text, finalSettings); const issues = await validationResult; return genResult(text, issues, includeRanges); } @@ -80,8 +80,8 @@ var IncludeExcludeFlag; * @returns */ async function checkTextDocument(doc, options, settings = {}) { - doc = (0, TextDocument_1.isTextDocument)(doc) ? doc : await (0, resolveDocument_1.resolveDocumentToTextDocument)(doc); - return genCheckText(new docValidator_1.DocumentValidator(doc, options, settings)); + doc = (0, TextDocument_js_1.isTextDocument)(doc) ? doc : await (0, resolveDocument_js_1.resolveDocumentToTextDocument)(doc); + return genCheckText(new docValidator_js_1.DocumentValidator(doc, options, settings)); } exports.checkTextDocument = checkTextDocument; async function genCheckText(docValidator) { diff --git a/action/node_modules/cspell-lib/dist/textValidation/defaultConstants.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/defaultConstants.js similarity index 100% rename from action/node_modules/cspell-lib/dist/textValidation/defaultConstants.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/defaultConstants.js diff --git a/action/node_modules/cspell-lib/dist/textValidation/determineTextDocumentSettings.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/determineTextDocumentSettings.js similarity index 78% rename from action/node_modules/cspell-lib/dist/textValidation/determineTextDocumentSettings.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/determineTextDocumentSettings.js index 09a001260..313ca5699 100644 --- a/action/node_modules/cspell-lib/dist/textValidation/determineTextDocumentSettings.js +++ b/action/node_modules/cspell-lib/dist/cjs/textValidation/determineTextDocumentSettings.js @@ -25,10 +25,10 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.determineTextDocumentSettings = void 0; const path = __importStar(require("path")); -const LanguageIds_1 = require("../LanguageIds"); -const Settings_1 = require("../Settings"); -const TextDocumentSettings_1 = require("../Settings/TextDocumentSettings"); -const Uri_1 = require("../util/Uri"); +const LanguageIds_js_1 = require("../LanguageIds.js"); +const index_js_1 = require("../Settings/index.js"); +const TextDocumentSettings_js_1 = require("../Settings/TextDocumentSettings.js"); +const Uri_js_1 = require("../util/Uri.js"); /** * Combines all relevant setting values into a final configuration to be used for spell checking. * It applies any overrides and appropriate language settings by taking into account the document type (languageId) @@ -42,9 +42,9 @@ const Uri_1 = require("../util/Uri"); * @param settings - The near final settings. Should already be the combination of all configuration files. */ function determineTextDocumentSettings(doc, settings) { - const filename = (0, Uri_1.uriToFilePath)(doc.uri); - const settingsWithDefaults = (0, Settings_1.mergeSettings)((0, Settings_1.getDefaultSettings)(settings.loadDefaultConfiguration ?? true), (0, Settings_1.getGlobalSettings)(), settings); - const fileSettings = (0, Settings_1.calcOverrideSettings)(settingsWithDefaults, filename); + const filename = (0, Uri_js_1.uriToFilePath)(doc.uri); + const settingsWithDefaults = (0, index_js_1.mergeSettings)((0, index_js_1.getDefaultSettings)(settings.loadDefaultConfiguration ?? true), (0, index_js_1.getGlobalSettings)(), settings); + const fileSettings = (0, index_js_1.calcOverrideSettings)(settingsWithDefaults, filename); const languageIds = fileSettings?.languageId?.length ? fileSettings.languageId : doc.languageId @@ -53,11 +53,11 @@ function determineTextDocumentSettings(doc, settings) { if (doc.locale) { fileSettings.language = doc.locale; } - return (0, TextDocumentSettings_1.combineTextAndLanguageSettings)(fileSettings, doc.text, languageIds); + return (0, TextDocumentSettings_js_1.combineTextAndLanguageSettings)(fileSettings, doc.text, languageIds); } exports.determineTextDocumentSettings = determineTextDocumentSettings; function getLanguageForFilename(filename) { const basename = path.basename(filename); - return (0, LanguageIds_1.getLanguagesForBasename)(basename); + return (0, LanguageIds_js_1.getLanguagesForBasename)(basename); } //# sourceMappingURL=determineTextDocumentSettings.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/textValidation/docValidator.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/docValidator.js similarity index 71% rename from action/node_modules/cspell-lib/dist/textValidation/docValidator.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/docValidator.js index e83f4fb8a..0ce649854 100644 --- a/action/node_modules/cspell-lib/dist/textValidation/docValidator.js +++ b/action/node_modules/cspell-lib/dist/cjs/textValidation/docValidator.js @@ -9,22 +9,22 @@ const cspell_types_1 = require("@cspell/cspell-types"); const assert_1 = __importDefault(require("assert")); const cspell_glob_1 = require("cspell-glob"); const path_1 = __importDefault(require("path")); -const TextDocument_1 = require("../Models/TextDocument"); -const Settings_1 = require("../Settings"); -const configLoader_1 = require("../Settings/Controller/configLoader"); -const InDocSettings_1 = require("../Settings/InDocSettings"); -const SpellingDictionary_1 = require("../SpellingDictionary"); -const suggestions_1 = require("../suggestions"); -const errors_1 = require("../util/errors"); -const simpleCache_1 = require("../util/simpleCache"); -const timer_1 = require("../util/timer"); -const Uri_1 = require("../util/Uri"); -const defaultConstants_1 = require("./defaultConstants"); -const determineTextDocumentSettings_1 = require("./determineTextDocumentSettings"); -const lineValidatorFactory_1 = require("./lineValidatorFactory"); -const parsedText_1 = require("./parsedText"); -const settingsToValidateOptions_1 = require("./settingsToValidateOptions"); -const textValidator_1 = require("./textValidator"); +const TextDocument_js_1 = require("../Models/TextDocument.js"); +const index_js_1 = require("../Settings/Controller/configLoader/index.js"); +const index_js_2 = require("../Settings/index.js"); +const InDocSettings_js_1 = require("../Settings/InDocSettings.js"); +const index_js_3 = require("../SpellingDictionary/index.js"); +const suggestions_js_1 = require("../suggestions.js"); +const errors_js_1 = require("../util/errors.js"); +const simpleCache_js_1 = require("../util/simpleCache.js"); +const timer_js_1 = require("../util/timer.js"); +const Uri_js_1 = require("../util/Uri.js"); +const defaultConstants_js_1 = require("./defaultConstants.js"); +const determineTextDocumentSettings_js_1 = require("./determineTextDocumentSettings.js"); +const lineValidatorFactory_js_1 = require("./lineValidatorFactory.js"); +const parsedText_js_1 = require("./parsedText.js"); +const settingsToValidateOptions_js_1 = require("./settingsToValidateOptions.js"); +const textValidator_js_1 = require("./textValidator.js"); const ERROR_NOT_PREPARED = 'Validator Must be prepared before calling this function.'; const skipValidation = false; class DocumentValidator { @@ -37,7 +37,7 @@ class DocumentValidator { this._ready = false; this.errors = []; this._preparationTime = -1; - this._suggestions = new simpleCache_1.AutoCache((text) => this.genSuggestions(text), 1000); + this._suggestions = new simpleCache_js_1.AutoCache((text) => this.genSuggestions(text), 1000); this._document = doc; this.options = { ...options }; const numSuggestions = this.options.numSuggestions ?? settings.numSuggestions; @@ -63,28 +63,28 @@ class DocumentValidator { // Load dictionaries if (this._ready) return; - const timer = (0, timer_1.createTimer)(); + const timer = (0, timer_js_1.createTimer)(); const { options, settings } = this; const useSearchForConfig = (!options.noConfigSearch && !settings.noConfigSearch) || options.noConfigSearch === false; const optionsConfigFile = options.configFile; const localConfigFn = optionsConfigFile - ? () => (0, configLoader_1.loadConfigSync)(optionsConfigFile, settings) + ? () => (0, index_js_1.loadConfigSync)(optionsConfigFile, settings) : useSearchForConfig ? () => searchForDocumentConfigSync(this._document, settings, settings) : undefined; - const localConfig = localConfigFn && (0, errors_1.wrapCall)(localConfigFn, (e) => this.addPossibleError(e))(); + const localConfig = localConfigFn && (0, errors_js_1.wrapCall)(localConfigFn, (e) => this.addPossibleError(e))(); this.addPossibleError(localConfig?.__importRef?.error); - const config = (0, Settings_1.mergeSettings)(settings, localConfig); - const docSettings = (0, determineTextDocumentSettings_1.determineTextDocumentSettings)(this._document, config); - const dict = (0, SpellingDictionary_1.getDictionaryInternalSync)(docSettings); + const config = (0, index_js_2.mergeSettings)(settings, localConfig); + const docSettings = (0, determineTextDocumentSettings_js_1.determineTextDocumentSettings)(this._document, config); + const dict = (0, index_js_3.getDictionaryInternalSync)(docSettings); const matcher = new cspell_glob_1.GlobMatcher(localConfig?.ignorePaths || [], { root: process.cwd(), dot: true }); const uri = this._document.uri; - const shouldCheck = !matcher.match((0, Uri_1.uriToFilePath)(uri)) && (docSettings.enabled ?? true); - const finalSettings = (0, Settings_1.finalizeSettings)(docSettings); - const validateOptions = (0, settingsToValidateOptions_1.settingsToValidateOptions)(finalSettings); - const includeRanges = (0, textValidator_1.calcTextInclusionRanges)(this._document.text, validateOptions); - const segmenter = (0, parsedText_1.createMappedTextSegmenter)(includeRanges); - const textValidator = (0, lineValidatorFactory_1.textValidatorFactory)(dict, validateOptions); + const shouldCheck = !matcher.match((0, Uri_js_1.uriToFilePath)(uri)) && (docSettings.enabled ?? true); + const finalSettings = (0, index_js_2.finalizeSettings)(docSettings); + const validateOptions = (0, settingsToValidateOptions_js_1.settingsToValidateOptions)(finalSettings); + const includeRanges = (0, textValidator_js_1.calcTextInclusionRanges)(this._document.text, validateOptions); + const segmenter = (0, parsedText_js_1.createMappedTextSegmenter)(includeRanges); + const textValidator = (0, lineValidatorFactory_js_1.textValidatorFactory)(dict, validateOptions); this._preparations = { config, dictionary: dict, @@ -112,27 +112,27 @@ class DocumentValidator { } async _prepareAsync() { (0, assert_1.default)(!this._ready); - const timer = (0, timer_1.createTimer)(); + const timer = (0, timer_js_1.createTimer)(); const { options, settings } = this; const useSearchForConfig = (!options.noConfigSearch && !settings.noConfigSearch) || options.noConfigSearch === false; const pLocalConfig = options.configFile - ? (0, Settings_1.loadConfig)(options.configFile, settings) + ? (0, index_js_2.loadConfig)(options.configFile, settings) : useSearchForConfig ? searchForDocumentConfig(this._document, settings, settings) : undefined; - const localConfig = (await (0, errors_1.catchPromiseError)(pLocalConfig, (e) => this.addPossibleError(e))) || {}; + const localConfig = (await (0, errors_js_1.catchPromiseError)(pLocalConfig, (e) => this.addPossibleError(e))) || {}; this.addPossibleError(localConfig?.__importRef?.error); - const config = (0, Settings_1.mergeSettings)(settings, localConfig); - const docSettings = (0, determineTextDocumentSettings_1.determineTextDocumentSettings)(this._document, config); - const dict = await (0, SpellingDictionary_1.getDictionaryInternal)(docSettings); + const config = (0, index_js_2.mergeSettings)(settings, localConfig); + const docSettings = (0, determineTextDocumentSettings_js_1.determineTextDocumentSettings)(this._document, config); + const dict = await (0, index_js_3.getDictionaryInternal)(docSettings); const matcher = new cspell_glob_1.GlobMatcher(localConfig?.ignorePaths || [], { root: process.cwd(), dot: true }); const uri = this._document.uri; - const shouldCheck = !matcher.match((0, Uri_1.uriToFilePath)(uri)) && (docSettings.enabled ?? true); - const finalSettings = (0, Settings_1.finalizeSettings)(docSettings); - const validateOptions = (0, settingsToValidateOptions_1.settingsToValidateOptions)(finalSettings); - const includeRanges = (0, textValidator_1.calcTextInclusionRanges)(this._document.text, validateOptions); - const segmenter = (0, parsedText_1.createMappedTextSegmenter)(includeRanges); - const textValidator = (0, lineValidatorFactory_1.textValidatorFactory)(dict, validateOptions); + const shouldCheck = !matcher.match((0, Uri_js_1.uriToFilePath)(uri)) && (docSettings.enabled ?? true); + const finalSettings = (0, index_js_2.finalizeSettings)(docSettings); + const validateOptions = (0, settingsToValidateOptions_js_1.settingsToValidateOptions)(finalSettings); + const includeRanges = (0, textValidator_js_1.calcTextInclusionRanges)(this._document.text, validateOptions); + const segmenter = (0, parsedText_js_1.createMappedTextSegmenter)(includeRanges); + const textValidator = (0, lineValidatorFactory_js_1.textValidatorFactory)(dict, validateOptions); this._preparations = { config, dictionary: dict, @@ -151,16 +151,16 @@ class DocumentValidator { } _updatePrep() { (0, assert_1.default)(this._preparations, ERROR_NOT_PREPARED); - const timer = (0, timer_1.createTimer)(); + const timer = (0, timer_js_1.createTimer)(); const prep = this._preparations; - const docSettings = (0, determineTextDocumentSettings_1.determineTextDocumentSettings)(this._document, prep.config); - const dict = (0, SpellingDictionary_1.getDictionaryInternalSync)(docSettings); + const docSettings = (0, determineTextDocumentSettings_js_1.determineTextDocumentSettings)(this._document, prep.config); + const dict = (0, index_js_3.getDictionaryInternalSync)(docSettings); const shouldCheck = docSettings.enabled ?? true; - const finalSettings = (0, Settings_1.finalizeSettings)(docSettings); - const validateOptions = (0, settingsToValidateOptions_1.settingsToValidateOptions)(finalSettings); - const includeRanges = (0, textValidator_1.calcTextInclusionRanges)(this._document.text, validateOptions); - const segmenter = (0, parsedText_1.createMappedTextSegmenter)(includeRanges); - const textValidator = (0, lineValidatorFactory_1.textValidatorFactory)(dict, validateOptions); + const finalSettings = (0, index_js_2.finalizeSettings)(docSettings); + const validateOptions = (0, settingsToValidateOptions_js_1.settingsToValidateOptions)(finalSettings); + const includeRanges = (0, textValidator_js_1.calcTextInclusionRanges)(this._document.text, validateOptions); + const segmenter = (0, parsedText_js_1.createMappedTextSegmenter)(includeRanges); + const textValidator = (0, lineValidatorFactory_js_1.textValidatorFactory)(dict, validateOptions); this._preparations = { ...prep, dictionary: dict, @@ -262,13 +262,13 @@ class DocumentValidator { const issue = { text, offset, line, suggestions, suggestionsEx, message, issueType }; return issue; } - return [...(0, InDocSettings_1.validateInDocumentSettings)(this.document.text, this._preparations.config)].map(toValidationIssue); + return [...(0, InDocSettings_js_1.validateInDocumentSettings)(this.document.text, this._preparations.config)].map(toValidationIssue); } get document() { return this._document; } updateDocumentText(text) { - (0, TextDocument_1.updateTextDocument)(this._document, [{ text }]); + (0, TextDocument_js_1.updateTextDocument)(this._document, [{ text }]); this._updatePrep(); } defaultParser() { @@ -280,7 +280,7 @@ class DocumentValidator { } *_checkParsedText(parsedTexts) { (0, assert_1.default)(this._preparations, ERROR_NOT_PREPARED); - const { maxNumberOfProblems = defaultConstants_1.defaultMaxNumberOfProblems, maxDuplicateProblems = defaultConstants_1.defaultMaxDuplicateProblems } = this._preparations.validateOptions; + const { maxNumberOfProblems = defaultConstants_js_1.defaultMaxNumberOfProblems, maxDuplicateProblems = defaultConstants_js_1.defaultMaxDuplicateProblems } = this._preparations.validateOptions; let numProblems = 0; const mapOfProblems = new Map(); for (const pText of parsedTexts) { @@ -299,7 +299,7 @@ class DocumentValidator { addPossibleError(error) { if (!error) return; - error = this.errors.push((0, errors_1.toError)(error)); + error = this.errors.push((0, errors_js_1.toError)(error)); } _parse() { (0, assert_1.default)(this._preparations, ERROR_NOT_PREPARED); @@ -325,7 +325,7 @@ class DocumentValidator { }; const locale = this._preparations.config.language; const rawSuggestions = dict.suggest(text, sugOptions); - const sugsWithAlt = (0, suggestions_1.calcSuggestionAdjustedToToMatchCase)(text, rawSuggestions, locale, sugOptions.ignoreCase, dict); + const sugsWithAlt = (0, suggestions_js_1.calcSuggestionAdjustedToToMatchCase)(text, rawSuggestions, locale, sugOptions.ignoreCase, dict); return sugsWithAlt.map(sanitizeSuggestion); } getFinalizedDocSettings() { @@ -366,36 +366,36 @@ async function searchForDocumentConfig(document, defaultConfig, pnpSettings) { const { uri } = document; if (uri.scheme !== 'file') return Promise.resolve(defaultConfig); - return (0, Settings_1.searchForConfig)(path_1.default.dirname((0, Uri_1.uriToFilePath)(uri)), pnpSettings).then((s) => s || defaultConfig); + return (0, index_js_2.searchForConfig)(path_1.default.dirname((0, Uri_js_1.uriToFilePath)(uri)), pnpSettings).then((s) => s || defaultConfig); } function searchForDocumentConfigSync(document, defaultConfig, pnpSettings) { const { uri } = document; if (uri.scheme !== 'file') defaultConfig; - return (0, configLoader_1.searchForConfigSync)((0, Uri_1.uriToFilePath)(uri), pnpSettings) || defaultConfig; + return (0, index_js_1.searchForConfigSync)((0, Uri_js_1.uriToFilePath)(uri), pnpSettings) || defaultConfig; } async function shouldCheckDocument(doc, options, settings) { const errors = []; function addPossibleError(error) { if (!error) return undefined; - error = errors.push((0, errors_1.toError)(error)); + error = errors.push((0, errors_js_1.toError)(error)); return undefined; } async function shouldCheck() { const useSearchForConfig = (!options.noConfigSearch && !settings.noConfigSearch) || options.noConfigSearch === false; const pLocalConfig = options.configFile - ? (0, Settings_1.loadConfig)(options.configFile, settings) + ? (0, index_js_2.loadConfig)(options.configFile, settings) : useSearchForConfig ? searchForDocumentConfig(doc, settings, settings) : undefined; - const localConfig = (await (0, errors_1.catchPromiseError)(pLocalConfig, addPossibleError)) || {}; + const localConfig = (await (0, errors_js_1.catchPromiseError)(pLocalConfig, addPossibleError)) || {}; addPossibleError(localConfig?.__importRef?.error); - const config = (0, Settings_1.mergeSettings)(settings, localConfig); + const config = (0, index_js_2.mergeSettings)(settings, localConfig); const matcher = new cspell_glob_1.GlobMatcher(localConfig?.ignorePaths || [], { root: process.cwd(), dot: true }); - const docSettings = (0, determineTextDocumentSettings_1.determineTextDocumentSettings)(doc, config); + const docSettings = (0, determineTextDocumentSettings_js_1.determineTextDocumentSettings)(doc, config); const uri = doc.uri; - return !matcher.match((0, Uri_1.uriToFilePath)(uri)) && (docSettings.enabled ?? true); + return !matcher.match((0, Uri_js_1.uriToFilePath)(uri)) && (docSettings.enabled ?? true); } return { errors, shouldCheck: await shouldCheck() }; } diff --git a/action/node_modules/cspell-lib/dist/textValidation/index.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/index.js similarity index 51% rename from action/node_modules/cspell-lib/dist/textValidation/index.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/index.js index 475812047..da971aea6 100644 --- a/action/node_modules/cspell-lib/dist/textValidation/index.js +++ b/action/node_modules/cspell-lib/dist/cjs/textValidation/index.js @@ -1,15 +1,15 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateText = exports.calcTextInclusionRanges = exports.shouldCheckDocument = exports.DocumentValidator = exports.IncludeExcludeFlag = exports.checkTextDocument = exports.checkText = void 0; -var checkText_1 = require("./checkText"); -Object.defineProperty(exports, "checkText", { enumerable: true, get: function () { return checkText_1.checkText; } }); -Object.defineProperty(exports, "checkTextDocument", { enumerable: true, get: function () { return checkText_1.checkTextDocument; } }); -Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return checkText_1.IncludeExcludeFlag; } }); -var docValidator_1 = require("./docValidator"); -Object.defineProperty(exports, "DocumentValidator", { enumerable: true, get: function () { return docValidator_1.DocumentValidator; } }); -Object.defineProperty(exports, "shouldCheckDocument", { enumerable: true, get: function () { return docValidator_1.shouldCheckDocument; } }); -var textValidator_1 = require("./textValidator"); -Object.defineProperty(exports, "calcTextInclusionRanges", { enumerable: true, get: function () { return textValidator_1.calcTextInclusionRanges; } }); -var validator_1 = require("./validator"); -Object.defineProperty(exports, "validateText", { enumerable: true, get: function () { return validator_1.validateText; } }); +var checkText_js_1 = require("./checkText.js"); +Object.defineProperty(exports, "checkText", { enumerable: true, get: function () { return checkText_js_1.checkText; } }); +Object.defineProperty(exports, "checkTextDocument", { enumerable: true, get: function () { return checkText_js_1.checkTextDocument; } }); +Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return checkText_js_1.IncludeExcludeFlag; } }); +var docValidator_js_1 = require("./docValidator.js"); +Object.defineProperty(exports, "DocumentValidator", { enumerable: true, get: function () { return docValidator_js_1.DocumentValidator; } }); +Object.defineProperty(exports, "shouldCheckDocument", { enumerable: true, get: function () { return docValidator_js_1.shouldCheckDocument; } }); +var textValidator_js_1 = require("./textValidator.js"); +Object.defineProperty(exports, "calcTextInclusionRanges", { enumerable: true, get: function () { return textValidator_js_1.calcTextInclusionRanges; } }); +var validator_js_1 = require("./validator.js"); +Object.defineProperty(exports, "validateText", { enumerable: true, get: function () { return validator_js_1.validateText; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/textValidation/isWordValid.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/isWordValid.js similarity index 100% rename from action/node_modules/cspell-lib/dist/textValidation/isWordValid.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/isWordValid.js diff --git a/action/node_modules/cspell-lib/dist/textValidation/lineValidatorFactory.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/lineValidatorFactory.js similarity index 85% rename from action/node_modules/cspell-lib/dist/textValidation/lineValidatorFactory.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/lineValidatorFactory.js index 517a45268..0a5f4cb3b 100644 --- a/action/node_modules/cspell-lib/dist/textValidation/lineValidatorFactory.js +++ b/action/node_modules/cspell-lib/dist/cjs/textValidation/lineValidatorFactory.js @@ -27,15 +27,15 @@ exports.textValidatorFactory = exports.lineValidatorFactory = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); const cspell_dictionary_1 = require("cspell-dictionary"); const gensequence_1 = require("gensequence"); -const RxPat = __importStar(require("../Settings/RegExpPatterns")); -const Text = __importStar(require("../util/text")); -const util_1 = require("../util/util"); -const wordSplitter_1 = require("../util/wordSplitter"); -const defaultConstants_1 = require("./defaultConstants"); -const isWordValid_1 = require("./isWordValid"); -const parsedText_1 = require("./parsedText"); +const RxPat = __importStar(require("../Settings/RegExpPatterns.js")); +const Text = __importStar(require("../util/text.js")); +const util_js_1 = require("../util/util.js"); +const wordSplitter_js_1 = require("../util/wordSplitter.js"); +const defaultConstants_js_1 = require("./defaultConstants.js"); +const isWordValid_js_1 = require("./isWordValid.js"); +const parsedText_js_1 = require("./parsedText.js"); function lineValidatorFactory(sDict, options) { - const { minWordLength = defaultConstants_1.defaultMinWordLength, flagWords = [], allowCompoundWords = false, ignoreCase = true, } = options; + const { minWordLength = defaultConstants_js_1.defaultMinWordLength, flagWords = [], allowCompoundWords = false, ignoreCase = true, } = options; const hasWordOptions = { ignoreCase, useCompounds: allowCompoundWords || undefined, // let the dictionaries decide on useCompounds if allow is false @@ -72,13 +72,13 @@ function lineValidatorFactory(sDict, options) { function checkWord(word) { const isIgnored = isWordIgnored(word.text); const { isFlagged = !isIgnored && testForFlaggedWord(word) } = word; - const isFound = isFlagged ? undefined : isIgnored || (0, isWordValid_1.isWordValidWithEscapeRetry)(dictCol, word, word.line); - return (0, util_1.clean)({ ...word, isFlagged, isFound }); + const isFound = isFlagged ? undefined : isIgnored || (0, isWordValid_js_1.isWordValidWithEscapeRetry)(dictCol, word, word.line); + return (0, util_js_1.clean)({ ...word, isFlagged, isFound }); } const fn = (lineSegment) => { function splitterIsValid(word) { return (setOfKnownSuccessfulWords.has(word.text) || - (!testForFlaggedWord(word) && (0, isWordValid_1.isWordValidWithEscapeRetry)(dictCol, word, lineSegment.line))); + (!testForFlaggedWord(word) && (0, isWordValid_js_1.isWordValidWithEscapeRetry)(dictCol, word, lineSegment.line))); } function checkFullWord(vr) { if (vr.isFlagged) { @@ -108,7 +108,7 @@ function lineValidatorFactory(sDict, options) { const mismatches = (0, sync_1.toArray)((0, sync_1.pipe)(Text.extractWordsFromTextOffset(possibleWord), (0, sync_1.opFilter)(filterAlreadyChecked), (0, sync_1.opMap)((wo) => ({ ...wo, line: lineSegment.line })), (0, sync_1.opMap)(checkFlagWords), (0, sync_1.opFilter)(rememberFilter((wo) => wo.text.length >= minWordLength || !!wo.isFlagged)), (0, sync_1.opConcatMap)(checkFullWord))); if (mismatches.length) { // Try the more expensive word splitter - const splitResult = (0, wordSplitter_1.split)(lineSegment.segment, possibleWord.offset, splitterIsValid); + const splitResult = (0, wordSplitter_js_1.split)(lineSegment.segment, possibleWord.offset, splitterIsValid); const nonMatching = splitResult.words.filter((w) => !w.isFound); if (nonMatching.length < mismatches.length) { return nonMatching.map((w) => ({ ...w, line: lineSegment.line })).map(checkFlagWords); @@ -132,7 +132,7 @@ function textValidatorFactory(dict, options) { const lineSegment = { line: segment, segment }; function mapBackToOriginSimple(vr) { const { text, offset, isFlagged, isFound } = vr; - const r = (0, parsedText_1.mapRangeBackToOriginalPos)([offset, offset + text.length], map); + const r = (0, parsedText_js_1.mapRangeBackToOriginalPos)([offset, offset + text.length], map); const range = [r[0] + srcOffset, r[1] + srcOffset]; return { text, range, isFlagged, isFound }; } diff --git a/action/node_modules/cspell-lib/dist/textValidation/parsedText.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/parsedText.js similarity index 96% rename from action/node_modules/cspell-lib/dist/textValidation/parsedText.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/parsedText.js index 968a61f28..587b5f88e 100644 --- a/action/node_modules/cspell-lib/dist/textValidation/parsedText.js +++ b/action/node_modules/cspell-lib/dist/cjs/textValidation/parsedText.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createMappedTextSegmenter = exports.mapRangeToLocal = exports.mapRangeBackToOriginalPos = exports.mapIssueBackToOriginalPos = void 0; -const TextMap_1 = require("../util/TextMap"); +const TextMap_js_1 = require("../util/TextMap.js"); function mapIssueBackToOriginalPos(mappedText, issue) { if (!mappedText.map || mappedText.map.length === 0) return issue; @@ -99,7 +99,7 @@ function createMappedTextSegmenter(includeRanges) { const a = Math.max(textStartPos, startPos); const b = Math.min(textEndPos, endPos); if (a !== b) { - yield (0, TextMap_1.extractTextMapRangeOrigin)(pText, [a, b]); + yield (0, TextMap_js_1.extractTextMapRangeOrigin)(pText, [a, b]); } textStartPos = b; } diff --git a/action/node_modules/cspell-lib/dist/textValidation/settingsToValidateOptions.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/settingsToValidateOptions.js similarity index 100% rename from action/node_modules/cspell-lib/dist/textValidation/settingsToValidateOptions.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/settingsToValidateOptions.js diff --git a/action/node_modules/cspell-lib/dist/textValidation/textValidator.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/textValidator.js similarity index 90% rename from action/node_modules/cspell-lib/dist/textValidation/textValidator.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/textValidator.js index b41495133..7e3ffb6b9 100644 --- a/action/node_modules/cspell-lib/dist/textValidation/textValidator.js +++ b/action/node_modules/cspell-lib/dist/cjs/textValidation/textValidator.js @@ -26,19 +26,19 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports._testMethods = exports.mapLineSegmentAgainstRangesFactory = exports.calcTextInclusionRanges = exports.validateText = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); const gensequence_1 = require("gensequence"); -const Text = __importStar(require("../util/text")); -const TextRange = __importStar(require("../util/TextRange")); -const defaultConstants_1 = require("./defaultConstants"); -const lineValidatorFactory_1 = require("./lineValidatorFactory"); +const Text = __importStar(require("../util/text.js")); +const TextRange = __importStar(require("../util/TextRange.js")); +const defaultConstants_js_1 = require("./defaultConstants.js"); +const lineValidatorFactory_js_1 = require("./lineValidatorFactory.js"); /** * @deprecated * @deprecation Use spellCheckDocument */ function validateText(text, dict, options) { - const { maxNumberOfProblems = defaultConstants_1.defaultMaxNumberOfProblems, maxDuplicateProblems = defaultConstants_1.defaultMaxDuplicateProblems } = options; + const { maxNumberOfProblems = defaultConstants_js_1.defaultMaxNumberOfProblems, maxDuplicateProblems = defaultConstants_js_1.defaultMaxDuplicateProblems } = options; const mapOfProblems = new Map(); const includeRanges = calcTextInclusionRanges(text, options); - const lineValidator = (0, lineValidatorFactory_1.lineValidatorFactory)(dict, options); + const lineValidator = (0, lineValidatorFactory_js_1.lineValidatorFactory)(dict, options); const validator = lineValidator.fn; const iter = (0, sync_1.pipe)(Text.extractLinesOfText(text), (0, sync_1.opConcatMap)(mapLineToLineSegments(includeRanges)), (0, sync_1.opConcatMap)(validator), (0, sync_1.opFilter)((wo) => { const word = wo.text; diff --git a/action/node_modules/cspell-lib/dist/textValidation/validator.js b/action/node_modules/cspell-lib/dist/cjs/textValidation/validator.js similarity index 77% rename from action/node_modules/cspell-lib/dist/textValidation/validator.js rename to action/node_modules/cspell-lib/dist/cjs/textValidation/validator.js index a1a1c8ee0..32f7fc0e5 100644 --- a/action/node_modules/cspell-lib/dist/textValidation/validator.js +++ b/action/node_modules/cspell-lib/dist/cjs/textValidation/validator.js @@ -25,12 +25,12 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.validateText = exports.diagSource = void 0; const cspell_types_1 = require("@cspell/cspell-types"); -const TextDocument_1 = require("../Models/TextDocument"); -const Settings = __importStar(require("../Settings")); -const InDocSettings_1 = require("../Settings/InDocSettings"); -const SpellingDictionary_1 = require("../SpellingDictionary"); -const settingsToValidateOptions_1 = require("./settingsToValidateOptions"); -const textValidator_1 = require("./textValidator"); +const TextDocument_js_1 = require("../Models/TextDocument.js"); +const Settings = __importStar(require("../Settings/index.js")); +const InDocSettings_js_1 = require("../Settings/InDocSettings.js"); +const index_js_1 = require("../SpellingDictionary/index.js"); +const settingsToValidateOptions_js_1 = require("./settingsToValidateOptions.js"); +const textValidator_js_1 = require("./textValidator.js"); exports.diagSource = 'cSpell Checker'; /** * @deprecated @@ -38,10 +38,10 @@ exports.diagSource = 'cSpell Checker'; */ async function validateText(text, settings, options = {}) { const finalSettings = Settings.finalizeSettings(settings); - const dict = await (0, SpellingDictionary_1.getDictionaryInternal)(finalSettings); - const spellingIssues = [...(0, textValidator_1.validateText)(text, dict, (0, settingsToValidateOptions_1.settingsToValidateOptions)(finalSettings))]; + const dict = await (0, index_js_1.getDictionaryInternal)(finalSettings); + const spellingIssues = [...(0, textValidator_js_1.validateText)(text, dict, (0, settingsToValidateOptions_js_1.settingsToValidateOptions)(finalSettings))]; const validationIssues = options.validateDirectives || finalSettings.validateDirectives - ? (0, InDocSettings_1.validateInDocumentSettings)(text, settings) + ? (0, InDocSettings_js_1.validateInDocumentSettings)(text, settings) : []; const issues = spellingIssues.concat(mapValidationIssues(text, validationIssues)); if (!options.generateSuggestions) { @@ -49,7 +49,7 @@ async function validateText(text, settings, options = {}) { } const sugOptions = { numSuggestions: options.numSuggestions, - compoundMethod: SpellingDictionary_1.CompoundWordsMethod.NONE, + compoundMethod: index_js_1.CompoundWordsMethod.NONE, includeTies: false, ignoreCase: !(settings.caseSensitive ?? false), timeout: settings.suggestionsTimeout, @@ -71,7 +71,7 @@ function mapValidationIssues(text, valIssues) { const issues = [...valIssues]; if (!issues.length) return []; - const document = (0, TextDocument_1.createTextDocument)({ uri: '', content: text }); + const document = (0, TextDocument_js_1.createTextDocument)({ uri: '', content: text }); const issueType = cspell_types_1.IssueType.directive; function toValidationIssue(dirIssue) { const { text, range, suggestions, suggestionsEx, message } = dirIssue; diff --git a/action/node_modules/cspell-lib/dist/trace.js b/action/node_modules/cspell-lib/dist/cjs/trace.js similarity index 78% rename from action/node_modules/cspell-lib/dist/trace.js rename to action/node_modules/cspell-lib/dist/cjs/trace.js index e3491f4f5..e08c0618a 100644 --- a/action/node_modules/cspell-lib/dist/trace.js +++ b/action/node_modules/cspell-lib/dist/cjs/trace.js @@ -25,11 +25,11 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.traceWordsAsync = exports.traceWords = void 0; const gensequence_1 = require("gensequence"); -const Settings_1 = require("./Settings"); -const CSpellSettingsServer_1 = require("./Settings/CSpellSettingsServer"); -const LanguageSettings_1 = require("./Settings/LanguageSettings"); -const SpellingDictionary_1 = require("./SpellingDictionary"); -const util = __importStar(require("./util/util")); +const CSpellSettingsServer_js_1 = require("./Settings/CSpellSettingsServer.js"); +const index_js_1 = require("./Settings/index.js"); +const LanguageSettings_js_1 = require("./Settings/LanguageSettings.js"); +const index_js_2 = require("./SpellingDictionary/index.js"); +const util = __importStar(require("./util/util.js")); async function traceWords(words, settings, options) { const results = await util.asyncIterableToArray(traceWordsAsync(words, settings, options)); const s = (0, gensequence_1.genSequence)(results) @@ -41,18 +41,18 @@ exports.traceWords = traceWords; async function* traceWordsAsync(words, settings, options) { const { languageId, locale: language, ignoreCase = true, allowCompoundWords } = options || {}; async function finalize(config) { - const withLocale = (0, Settings_1.mergeSettings)(config, util.clean({ + const withLocale = (0, index_js_1.mergeSettings)(config, util.clean({ language: language || config.language, allowCompoundWords: allowCompoundWords ?? config.allowCompoundWords, })); - const withLanguageId = (0, LanguageSettings_1.calcSettingsForLanguageId)(withLocale, languageId ?? withLocale.languageId ?? 'plaintext'); - const settings = (0, Settings_1.finalizeSettings)(withLanguageId); + const withLanguageId = (0, LanguageSettings_js_1.calcSettingsForLanguageId)(withLocale, languageId ?? withLocale.languageId ?? 'plaintext'); + const settings = (0, index_js_1.finalizeSettings)(withLanguageId); const dictionaries = (settings.dictionaries || []) .concat((settings.dictionaryDefinitions || []).map((d) => d.name)) .filter(util.uniqueFn); - const dictSettings = (0, CSpellSettingsServer_1.toInternalSettings)({ ...settings, dictionaries }); - const dictBase = await (0, SpellingDictionary_1.getDictionaryInternal)(settings); - const dicts = await (0, SpellingDictionary_1.getDictionaryInternal)(dictSettings); + const dictSettings = (0, CSpellSettingsServer_js_1.toInternalSettings)({ ...settings, dictionaries }); + const dictBase = await (0, index_js_2.getDictionaryInternal)(settings); + const dicts = await (0, index_js_2.getDictionaryInternal)(dictSettings); const activeDictionaries = dictBase.dictionaries.map((d) => d.name); return { activeDictionaries, @@ -60,7 +60,7 @@ async function* traceWordsAsync(words, settings, options) { dicts, }; } - await (0, SpellingDictionary_1.refreshDictionaryCache)(); + await (0, index_js_2.refreshDictionaryCache)(); const { config, dicts, activeDictionaries } = await finalize(settings); const setOfActiveDicts = new Set(activeDictionaries); const opts = util.clean({ ignoreCase, useCompounds: config.allowCompoundWords }); diff --git a/action/node_modules/cspell-lib/dist/util/AutoResolve.js b/action/node_modules/cspell-lib/dist/cjs/util/AutoResolve.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/AutoResolve.js rename to action/node_modules/cspell-lib/dist/cjs/util/AutoResolve.js diff --git a/action/node_modules/cspell-lib/dist/util/AutoResolveLRUCache.js b/action/node_modules/cspell-lib/dist/cjs/util/AutoResolveLRUCache.js similarity index 97% rename from action/node_modules/cspell-lib/dist/util/AutoResolveLRUCache.js rename to action/node_modules/cspell-lib/dist/cjs/util/AutoResolveLRUCache.js index 3953581f3..ea40fbc37 100644 --- a/action/node_modules/cspell-lib/dist/util/AutoResolveLRUCache.js +++ b/action/node_modules/cspell-lib/dist/cjs/util/AutoResolveLRUCache.js @@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.AutoResolveLastNCalls = exports.assertValidateLL = exports.AutoResolveLRUCache = void 0; const assert_1 = __importDefault(require("assert")); -const util_1 = require("./util"); +const util_js_1 = require("./util.js"); class AutoResolveLRUCache { constructor(maxSize, isEqual) { this.maxSize = maxSize; @@ -131,7 +131,7 @@ function assertValidateLL(list) { exports.assertValidateLL = assertValidateLL; class AutoResolveLastNCalls extends AutoResolveLRUCache { constructor(maxSize) { - super(maxSize, util_1.isArrayEqual); + super(maxSize, util_js_1.isArrayEqual); } } exports.AutoResolveLastNCalls = AutoResolveLastNCalls; diff --git a/action/node_modules/cspell-lib/dist/util/Comparable.js b/action/node_modules/cspell-lib/dist/cjs/util/Comparable.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/Comparable.js rename to action/node_modules/cspell-lib/dist/cjs/util/Comparable.js diff --git a/action/node_modules/cspell-lib/dist/util/FreqCounter.js b/action/node_modules/cspell-lib/dist/cjs/util/FreqCounter.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/FreqCounter.js rename to action/node_modules/cspell-lib/dist/cjs/util/FreqCounter.js diff --git a/action/node_modules/cspell-lib/dist/util/IterableLike.js b/action/node_modules/cspell-lib/dist/cjs/util/IterableLike.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/IterableLike.js rename to action/node_modules/cspell-lib/dist/cjs/util/IterableLike.js diff --git a/action/node_modules/cspell-lib/dist/util/MinHeapQueue.js b/action/node_modules/cspell-lib/dist/cjs/util/MinHeapQueue.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/MinHeapQueue.js rename to action/node_modules/cspell-lib/dist/cjs/util/MinHeapQueue.js diff --git a/action/node_modules/cspell-lib/dist/util/PairingHeap.js b/action/node_modules/cspell-lib/dist/cjs/util/PairingHeap.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/PairingHeap.js rename to action/node_modules/cspell-lib/dist/cjs/util/PairingHeap.js diff --git a/action/node_modules/cspell-lib/dist/util/TextMap.js b/action/node_modules/cspell-lib/dist/cjs/util/TextMap.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/TextMap.js rename to action/node_modules/cspell-lib/dist/cjs/util/TextMap.js diff --git a/action/node_modules/cspell-lib/dist/util/TextRange.js b/action/node_modules/cspell-lib/dist/cjs/util/TextRange.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/TextRange.js rename to action/node_modules/cspell-lib/dist/cjs/util/TextRange.js diff --git a/action/node_modules/cspell-lib/dist/util/Uri.js b/action/node_modules/cspell-lib/dist/cjs/util/Uri.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/Uri.js rename to action/node_modules/cspell-lib/dist/cjs/util/Uri.js diff --git a/action/node_modules/cspell-lib/dist/util/debugPerf.js b/action/node_modules/cspell-lib/dist/cjs/util/debugPerf.js similarity index 87% rename from action/node_modules/cspell-lib/dist/util/debugPerf.js rename to action/node_modules/cspell-lib/dist/cjs/util/debugPerf.js index 863a89349..dfce9d747 100644 --- a/action/node_modules/cspell-lib/dist/util/debugPerf.js +++ b/action/node_modules/cspell-lib/dist/cjs/util/debugPerf.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.perfFn = void 0; -const timer_1 = require("./timer"); +const timer_js_1 = require("./timer.js"); /** * Measure and log result. * @param fn - function to measure. @@ -12,7 +12,7 @@ const timer_1 = require("./timer"); // eslint-disable-next-line @typescript-eslint/no-explicit-any function perfFn(fn, message, callback = (message, time) => console.error(`${message}: ${time.toFixed(2)}ms`)) { return (...args) => { - const timer = (0, timer_1.createTimer)(); + const timer = (0, timer_js_1.createTimer)(); const r = fn(...args); callback(message, timer.elapsed()); return r; diff --git a/action/node_modules/cspell-lib/dist/util/errors.js b/action/node_modules/cspell-lib/dist/cjs/util/errors.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/errors.js rename to action/node_modules/cspell-lib/dist/cjs/util/errors.js diff --git a/action/node_modules/cspell-lib/dist/util/fileReader.js b/action/node_modules/cspell-lib/dist/cjs/util/fileReader.js similarity index 80% rename from action/node_modules/cspell-lib/dist/util/fileReader.js rename to action/node_modules/cspell-lib/dist/cjs/util/fileReader.js index 6306a37fd..949283134 100644 --- a/action/node_modules/cspell-lib/dist/util/fileReader.js +++ b/action/node_modules/cspell-lib/dist/cjs/util/fileReader.js @@ -2,11 +2,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.readLinesSync = exports.readLines = void 0; const cspell_io_1 = require("cspell-io"); -const iterableIteratorLib_1 = require("./iterableIteratorLib"); +const iterableIteratorLib_js_1 = require("./iterableIteratorLib.js"); async function readLines(filename, encoding = 'utf8') { try { const content = await (0, cspell_io_1.readFile)(filename, encoding); - return (0, iterableIteratorLib_1.toIterableIterator)(content.split(/\r?\n/g)); + return (0, iterableIteratorLib_js_1.toIterableIterator)(content.split(/\r?\n/g)); } catch (e) { return Promise.reject(e); diff --git a/action/node_modules/cspell-lib/dist/util/iterableIteratorLib.js b/action/node_modules/cspell-lib/dist/cjs/util/iterableIteratorLib.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/iterableIteratorLib.js rename to action/node_modules/cspell-lib/dist/cjs/util/iterableIteratorLib.js diff --git a/action/node_modules/cspell-lib/dist/util/logger.js b/action/node_modules/cspell-lib/dist/cjs/util/logger.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/logger.js rename to action/node_modules/cspell-lib/dist/cjs/util/logger.js diff --git a/action/node_modules/cspell-lib/dist/util/memorizeLastCall.js b/action/node_modules/cspell-lib/dist/cjs/util/memorizeLastCall.js similarity index 80% rename from action/node_modules/cspell-lib/dist/util/memorizeLastCall.js rename to action/node_modules/cspell-lib/dist/cjs/util/memorizeLastCall.js index 905dc4a5a..3a139224a 100644 --- a/action/node_modules/cspell-lib/dist/util/memorizeLastCall.js +++ b/action/node_modules/cspell-lib/dist/cjs/util/memorizeLastCall.js @@ -1,11 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.memorizeLastCall = void 0; -const util_1 = require("./util"); +const util_js_1 = require("./util.js"); function memorizeLastCall(fn) { let last; return (...p) => { - if (last && (0, util_1.isArrayEqual)(last.args, p)) { + if (last && (0, util_js_1.isArrayEqual)(last.args, p)) { return last.value; } const args = p; diff --git a/action/node_modules/cspell-lib/dist/util/memorizerWeak.js b/action/node_modules/cspell-lib/dist/cjs/util/memorizerWeak.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/memorizerWeak.js rename to action/node_modules/cspell-lib/dist/cjs/util/memorizerWeak.js diff --git a/action/node_modules/cspell-lib/dist/util/regexHelper.js b/action/node_modules/cspell-lib/dist/cjs/util/regexHelper.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/regexHelper.js rename to action/node_modules/cspell-lib/dist/cjs/util/regexHelper.js diff --git a/action/node_modules/cspell-lib/dist/util/repMap.js b/action/node_modules/cspell-lib/dist/cjs/util/repMap.js similarity index 91% rename from action/node_modules/cspell-lib/dist/util/repMap.js rename to action/node_modules/cspell-lib/dist/cjs/util/repMap.js index 8c397b3fb..94a50aa77 100644 --- a/action/node_modules/cspell-lib/dist/util/repMap.js +++ b/action/node_modules/cspell-lib/dist/cjs/util/repMap.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createMapper = void 0; -const regexHelper_1 = require("./regexHelper"); +const regexHelper_js_1 = require("./regexHelper.js"); function createMapper(repMap) { const filteredMap = repMap.filter(([match, _]) => !!match); if (!filteredMap.length) { @@ -18,7 +18,7 @@ function createMapper(repMap) { s = r; } catch (err) { - return (0, regexHelper_1.escapeRegEx)(s); + return (0, regexHelper_js_1.escapeRegEx)(s); } return s; }) diff --git a/action/node_modules/cspell-lib/dist/util/resolveFile.js b/action/node_modules/cspell-lib/dist/cjs/util/resolveFile.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/resolveFile.js rename to action/node_modules/cspell-lib/dist/cjs/util/resolveFile.js diff --git a/action/node_modules/cspell-lib/dist/util/search.js b/action/node_modules/cspell-lib/dist/cjs/util/search.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/search.js rename to action/node_modules/cspell-lib/dist/cjs/util/search.js diff --git a/action/node_modules/cspell-lib/dist/util/simpleCache.js b/action/node_modules/cspell-lib/dist/cjs/util/simpleCache.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/simpleCache.js rename to action/node_modules/cspell-lib/dist/cjs/util/simpleCache.js diff --git a/action/node_modules/cspell-lib/dist/util/text.js b/action/node_modules/cspell-lib/dist/cjs/util/text.js similarity index 77% rename from action/node_modules/cspell-lib/dist/util/text.js rename to action/node_modules/cspell-lib/dist/cjs/util/text.js index 6e5d7c6e8..23e03fee8 100644 --- a/action/node_modules/cspell-lib/dist/util/text.js +++ b/action/node_modules/cspell-lib/dist/cjs/util/text.js @@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.__testing__ = exports.removeAccents = exports.calculateTextDocumentOffsets = exports.extractText = exports.textOffset = exports.matchCase = exports.camelToSnake = exports.snakeToCamel = exports.lcFirst = exports.ucFirst = exports.isFirstCharacterLower = exports.isFirstCharacterUpper = exports.isLowerCase = exports.isUpperCase = exports.extractWordsFromCodeTextOffset = exports.extractWordsFromCode = exports.extractPossibleWordsFromTextOffset = exports.cleanTextOffset = exports.cleanText = exports.extractWordsFromTextOffset = exports.extractWordsFromText = exports.extractLinesOfText = exports.matchToTextOffset = exports.matchStringToTextOffset = exports.match = exports.splitCamelCaseWord = exports.splitCamelCaseWordWithOffset = exports.stringToRegExp = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); const gensequence_1 = require("gensequence"); -const search_1 = require("./search"); -const textRegex_1 = require("./textRegex"); -const Uri_1 = require("./Uri"); -const util_1 = require("./util"); -var textRegex_2 = require("./textRegex"); -Object.defineProperty(exports, "stringToRegExp", { enumerable: true, get: function () { return textRegex_2.stringToRegExp; } }); +const search_js_1 = require("./search.js"); +const textRegex_js_1 = require("./textRegex.js"); +const Uri_js_1 = require("./Uri.js"); +const util_js_1 = require("./util.js"); +var textRegex_js_2 = require("./textRegex.js"); +Object.defineProperty(exports, "stringToRegExp", { enumerable: true, get: function () { return textRegex_js_2.stringToRegExp; } }); // CSpell:ignore ings ning gimuy tsmerge function splitCamelCaseWordWithOffset(wo) { - return splitCamelCaseWord(wo.text).map((0, util_1.scanMap)((last, text) => ({ text, offset: last.offset + last.text.length }), { + return splitCamelCaseWord(wo.text).map((0, util_js_1.scanMap)((last, text) => ({ text, offset: last.offset + last.text.length }), { text: '', offset: wo.offset, })); @@ -21,10 +21,10 @@ exports.splitCamelCaseWordWithOffset = splitCamelCaseWordWithOffset; * Split camelCase words into an array of strings. */ function splitCamelCaseWord(word) { - const wPrime = word.replace(textRegex_1.regExUpperSOrIng, (s) => s[0] + s.slice(1).toLowerCase()); + const wPrime = word.replace(textRegex_js_1.regExUpperSOrIng, (s) => s[0] + s.slice(1).toLowerCase()); const separator = '_<^*_*^>_'; - const pass1 = wPrime.replace(textRegex_1.regExSplitWords, '$1' + separator + '$2'); - const pass2 = pass1.replace(textRegex_1.regExSplitWords2, '$1' + separator + '$2'); + const pass1 = wPrime.replace(textRegex_js_1.regExSplitWords, '$1' + separator + '$2'); + const pass2 = pass1.replace(textRegex_js_1.regExSplitWords2, '$1' + separator + '$2'); return pass2.split(separator); } exports.splitCamelCaseWord = splitCamelCaseWord; @@ -46,8 +46,14 @@ function matchToTextOffset(reg, text) { return (0, sync_1.pipe)(match(reg, textOffset.text), (0, sync_1.opMap)((m) => fnOffsetMap({ text: m[0], offset: m.index || 0 }))); } exports.matchToTextOffset = matchToTextOffset; -function extractLinesOfText(text) { - return matchStringToTextOffset(textRegex_1.regExLines, text); +function* extractLinesOfText(text) { + let i = 0; + for (let j = text.indexOf('\n', i); j >= 0; j = text.indexOf('\n', i)) { + const end = j + 1; + yield { text: text.slice(i, end), offset: i }; + i = end; + } + yield { text: text.slice(i, text.length), offset: i }; } exports.extractLinesOfText = extractLinesOfText; /** @@ -61,12 +67,12 @@ exports.extractWordsFromText = extractWordsFromText; * Extract out whole words from a string of text. */ function extractWordsFromTextOffset(text) { - const reg = new RegExp(textRegex_1.regExWords); + const reg = new RegExp(textRegex_js_1.regExWords); return matchToTextOffset(reg, cleanTextOffset(text)); } exports.extractWordsFromTextOffset = extractWordsFromTextOffset; function cleanText(text) { - text = text.replace(textRegex_1.regExIgnoreCharacters, (match) => ' '.repeat(match.length)); + text = text.replace(textRegex_js_1.regExIgnoreCharacters, (match) => ' '.repeat(match.length)); return text; } exports.cleanText = cleanText; @@ -81,7 +87,7 @@ exports.cleanTextOffset = cleanTextOffset; * Extract out whole words and words containing numbers from a string of text. */ function extractPossibleWordsFromTextOffset(text) { - const reg = new RegExp(textRegex_1.regExWordsAndDigits); + const reg = new RegExp(textRegex_js_1.regExWordsAndDigits); return matchToTextOffset(reg, text); } exports.extractPossibleWordsFromTextOffset = extractPossibleWordsFromTextOffset; @@ -94,11 +100,11 @@ function extractWordsFromCodeTextOffset(textOffset) { } exports.extractWordsFromCodeTextOffset = extractWordsFromCodeTextOffset; function isUpperCase(word) { - return !!word.match(textRegex_1.regExAllUpper); + return !!word.match(textRegex_js_1.regExAllUpper); } exports.isUpperCase = isUpperCase; function isLowerCase(word) { - return !!word.match(textRegex_1.regExAllLower); + return !!word.match(textRegex_js_1.regExAllLower); } exports.isLowerCase = isLowerCase; function isFirstCharacterUpper(word) { @@ -126,13 +132,13 @@ function camelToSnake(word) { } exports.camelToSnake = camelToSnake; function matchCase(example, word) { - if (example.match(textRegex_1.regExFirstUpper)) { + if (example.match(textRegex_js_1.regExFirstUpper)) { return word.slice(0, 1).toUpperCase() + word.slice(1).toLowerCase(); } - if (example.match(textRegex_1.regExAllLower)) { + if (example.match(textRegex_js_1.regExAllLower)) { return word.toLowerCase(); } - if (example.match(textRegex_1.regExAllUpper)) { + if (example.match(textRegex_js_1.regExAllUpper)) { return word.toUpperCase(); } if (isFirstCharacterUpper(example)) { @@ -169,7 +175,7 @@ function calculateTextDocumentOffsets(uri, doc, wordOffsets) { let lastLineRow = -1; let lastLine; function findRowCol(offset) { - const row = (0, search_1.binarySearch)(lines, offset, offset >= lastOffset ? lastRow : undefined); + const row = (0, search_js_1.binarySearch)(lines, offset, offset >= lastOffset ? lastRow : undefined); const col = offset - lines[Math.max(0, row - 1)]; lastOffset = offset; lastRow = row; @@ -187,7 +193,7 @@ function calculateTextDocumentOffsets(uri, doc, wordOffsets) { lastLine = r; return r; } - const _uri = (0, Uri_1.toUri)(uri).toString(); + const _uri = (0, Uri_js_1.toUri)(uri).toString(); return wordOffsets.map((wo) => { const [row, col] = findRowCol(wo.offset); return { ...wo, row, col, doc, uri: _uri, line: calcLine(row) }; @@ -195,11 +201,11 @@ function calculateTextDocumentOffsets(uri, doc, wordOffsets) { } exports.calculateTextDocumentOffsets = calculateTextDocumentOffsets; function removeAccents(text) { - return text.normalize('NFD').replace(textRegex_1.regExAccents, ''); + return text.normalize('NFD').replace(textRegex_js_1.regExAccents, ''); } exports.removeAccents = removeAccents; exports.__testing__ = { - regExWords: textRegex_1.regExWords, - regExWordsAndDigits: textRegex_1.regExWordsAndDigits, + regExWords: textRegex_js_1.regExWords, + regExWordsAndDigits: textRegex_js_1.regExWordsAndDigits, }; //# sourceMappingURL=text.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/util/textRegex.js b/action/node_modules/cspell-lib/dist/cjs/util/textRegex.js similarity index 97% rename from action/node_modules/cspell-lib/dist/util/textRegex.js rename to action/node_modules/cspell-lib/dist/cjs/util/textRegex.js index fbd0d80fe..193079fd6 100644 --- a/action/node_modules/cspell-lib/dist/util/textRegex.js +++ b/action/node_modules/cspell-lib/dist/cjs/util/textRegex.js @@ -1,8 +1,7 @@ "use strict"; // cspell:ignore ings ning gimuy anrvtbf gimuxy Object.defineProperty(exports, "__esModule", { value: true }); -exports.stringToRegExp = exports.regExTrailingEndings = exports.regExDanglingQuote = exports.regExEscapeCharacters = exports.regExAccents = exports.regExMatchRegExParts = exports.regExPossibleWordBreaks = exports.regExAllLower = exports.regExAllUpper = exports.regExFirstUpper = exports.regExIgnoreCharacters = exports.regExWordsAndDigits = exports.regExWords = exports.regExSplitWords2 = exports.regExSplitWords = exports.regExUpperSOrIng = exports.regExLines = void 0; -exports.regExLines = /.*(\r?\n|$)/g; +exports.stringToRegExp = exports.regExTrailingEndings = exports.regExDanglingQuote = exports.regExEscapeCharacters = exports.regExAccents = exports.regExMatchRegExParts = exports.regExPossibleWordBreaks = exports.regExAllLower = exports.regExAllUpper = exports.regExFirstUpper = exports.regExIgnoreCharacters = exports.regExWordsAndDigits = exports.regExWords = exports.regExSplitWords2 = exports.regExSplitWords = exports.regExUpperSOrIng = void 0; exports.regExUpperSOrIng = /([\p{Lu}\p{M}]+\\?['’]?(?:s|ing|ies|es|ings|ed|ning))(?!\p{Ll})/gu; exports.regExSplitWords = /(\p{Ll}\p{M}?)(\p{Lu})/gu; exports.regExSplitWords2 = /(\p{Lu}\p{M}?)(\p{Lu}\p{M}?\p{Ll})/gu; diff --git a/action/node_modules/cspell-lib/dist/util/timer.js b/action/node_modules/cspell-lib/dist/cjs/util/timer.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/timer.js rename to action/node_modules/cspell-lib/dist/cjs/util/timer.js diff --git a/action/node_modules/cspell-lib/dist/util/types.js b/action/node_modules/cspell-lib/dist/cjs/util/types.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/types.js rename to action/node_modules/cspell-lib/dist/cjs/util/types.js diff --git a/action/node_modules/cspell-lib/dist/util/util.js b/action/node_modules/cspell-lib/dist/cjs/util/util.js similarity index 100% rename from action/node_modules/cspell-lib/dist/util/util.js rename to action/node_modules/cspell-lib/dist/cjs/util/util.js diff --git a/action/node_modules/cspell-lib/dist/util/wordSplitter.js b/action/node_modules/cspell-lib/dist/cjs/util/wordSplitter.js similarity index 91% rename from action/node_modules/cspell-lib/dist/util/wordSplitter.js rename to action/node_modules/cspell-lib/dist/cjs/util/wordSplitter.js index 9ce140c86..b4f2310ac 100644 --- a/action/node_modules/cspell-lib/dist/util/wordSplitter.js +++ b/action/node_modules/cspell-lib/dist/cjs/util/wordSplitter.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.__testing__ = exports.split = void 0; -const PairingHeap_1 = require("./PairingHeap"); -const regexHelper_1 = require("./regexHelper"); -const textRegex_1 = require("./textRegex"); +const PairingHeap_js_1 = require("./PairingHeap.js"); +const regexHelper_js_1 = require("./regexHelper.js"); +const textRegex_js_1 = require("./textRegex.js"); const ignoreBreak = Object.freeze([]); function split(line, offset, isValidWord, options = {}) { const relWordToSplit = findNextWordText({ text: line.text, offset: offset - line.offset }); @@ -75,7 +75,7 @@ function split(line, offset, isValidWord, options = {}) { } exports.split = split; function findNextWordText({ text, offset }) { - const reg = new RegExp(textRegex_1.regExWordsAndDigits); + const reg = new RegExp(textRegex_js_1.regExWordsAndDigits); reg.lastIndex = offset; const m = reg.exec(text); if (!m) { @@ -104,7 +104,7 @@ function genWordBreakCamel(line) { const breaksCamel1 = []; const text = line.line.text.slice(0, line.relEnd); // lower,Upper: camelCase -> camel|Case - for (const m of text.matchAll(offsetRegEx(textRegex_1.regExSplitWords, line.relStart))) { + for (const m of text.matchAll(offsetRegEx(textRegex_js_1.regExSplitWords, line.relStart))) { if (m.index === undefined) break; const i = m.index + 1; @@ -116,7 +116,7 @@ function genWordBreakCamel(line) { const breaksCamel2 = []; // cspell:ignore ERRORC // Upper,Upper,lower: ERRORCodes -> ERROR|Codes, ERRORC|odes - for (const m of text.matchAll(offsetRegEx(textRegex_1.regExSplitWords2, line.relStart))) { + for (const m of text.matchAll(offsetRegEx(textRegex_js_1.regExSplitWords2, line.relStart))) { if (m.index === undefined) break; const i = m.index + m[1].length; @@ -154,11 +154,11 @@ function genOptionalWordBreaks(line, optionalBreakCharacters) { }; } const breaks = [ - calcBreaksForRegEx(line, textRegex_1.regExDanglingQuote, calcBreaks), - calcBreaksForRegEx(line, textRegex_1.regExTrailingEndings, calcBreaks), + calcBreaksForRegEx(line, textRegex_js_1.regExDanglingQuote, calcBreaks), + calcBreaksForRegEx(line, textRegex_js_1.regExTrailingEndings, calcBreaks), ]; if (optionalBreakCharacters) { - const regex = new RegExp(`[${(0, regexHelper_1.escapeRegEx)(optionalBreakCharacters)}]`, 'gu'); + const regex = new RegExp(`[${(0, regexHelper_js_1.escapeRegEx)(optionalBreakCharacters)}]`, 'gu'); breaks.push(calcBreaksForRegEx(line, regex, calcBreaks)); } return breaks; @@ -180,9 +180,9 @@ function genSymbolBreaks(line) { }; } return [ - calcBreaksForRegEx(line, textRegex_1.regExPossibleWordBreaks, calcBreaks), + calcBreaksForRegEx(line, textRegex_js_1.regExPossibleWordBreaks, calcBreaks), calcBreaksForRegEx(line, /\d+/g, calcBreaks), - calcBreaksForRegEx(line, textRegex_1.regExEscapeCharacters, calcBreaks), + calcBreaksForRegEx(line, textRegex_js_1.regExEscapeCharacters, calcBreaks), ]; } function splitIntoWords(lineSeg, breaks, has) { @@ -262,7 +262,7 @@ function splitIntoWords(lineSeg, breaks, has) { return path; } let maxCost = lineSeg.relEnd - lineSeg.relStart; - const candidates = new PairingHeap_1.PairingHeap(compare); + const candidates = new PairingHeap_js_1.PairingHeap(compare); const text = lineSeg.line.text; candidates.concat(makeCandidates(undefined, lineSeg.relStart, 0, 0)); let attempts = 0; diff --git a/action/node_modules/cspell-lib/dist/validator.js b/action/node_modules/cspell-lib/dist/cjs/validator.js similarity index 59% rename from action/node_modules/cspell-lib/dist/validator.js rename to action/node_modules/cspell-lib/dist/cjs/validator.js index 7161e2a81..08e1c317c 100644 --- a/action/node_modules/cspell-lib/dist/validator.js +++ b/action/node_modules/cspell-lib/dist/cjs/validator.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateText = exports.IncludeExcludeFlag = exports.checkTextDocument = exports.checkText = void 0; -var textValidation_1 = require("./textValidation"); -Object.defineProperty(exports, "checkText", { enumerable: true, get: function () { return textValidation_1.checkText; } }); -Object.defineProperty(exports, "checkTextDocument", { enumerable: true, get: function () { return textValidation_1.checkTextDocument; } }); -Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return textValidation_1.IncludeExcludeFlag; } }); -Object.defineProperty(exports, "validateText", { enumerable: true, get: function () { return textValidation_1.validateText; } }); +var index_js_1 = require("./textValidation/index.js"); +Object.defineProperty(exports, "checkText", { enumerable: true, get: function () { return index_js_1.checkText; } }); +Object.defineProperty(exports, "checkTextDocument", { enumerable: true, get: function () { return index_js_1.checkTextDocument; } }); +Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return index_js_1.IncludeExcludeFlag; } }); +Object.defineProperty(exports, "validateText", { enumerable: true, get: function () { return index_js_1.validateText; } }); //# sourceMappingURL=validator.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/wordListHelper.js b/action/node_modules/cspell-lib/dist/cjs/wordListHelper.js similarity index 77% rename from action/node_modules/cspell-lib/dist/wordListHelper.js rename to action/node_modules/cspell-lib/dist/cjs/wordListHelper.js index 67f7ad7f8..f956bf35c 100644 --- a/action/node_modules/cspell-lib/dist/wordListHelper.js +++ b/action/node_modules/cspell-lib/dist/cjs/wordListHelper.js @@ -25,17 +25,17 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.splitLineIntoWords = exports.splitLineIntoCodeWords = exports.splitCodeWords = exports.splitLine = exports.loadWordsNoError = void 0; // cSpell:enableCompoundWords -const fileReader_1 = require("./util/fileReader"); -const iterableIteratorLib_1 = require("./util/iterableIteratorLib"); -const logger_1 = require("./util/logger"); -const Text = __importStar(require("./util/text")); +const fileReader_js_1 = require("./util/fileReader.js"); +const iterableIteratorLib_js_1 = require("./util/iterableIteratorLib.js"); +const logger_js_1 = require("./util/logger.js"); +const Text = __importStar(require("./util/text.js")); const regExpWordsWithSpaces = /^\s*\p{L}+(?:\s+\p{L}+){0,3}$/u; /** * Reads words from a file. It will not throw and error. * @param filename the file to read */ function loadWordsNoError(filename) { - return (0, fileReader_1.readLines)(filename).catch((e) => ((0, logger_1.logError)(e), (0, iterableIteratorLib_1.toIterableIterator)([]))); + return (0, fileReader_js_1.readLines)(filename).catch((e) => ((0, logger_js_1.logError)(e), (0, iterableIteratorLib_js_1.toIterableIterator)([]))); } exports.loadWordsNoError = loadWordsNoError; function splitLine(line) { @@ -50,13 +50,13 @@ function splitLineIntoCodeWords(line) { const asMultiWord = regExpWordsWithSpaces.test(line) ? [line] : []; const asWords = splitLine(line); const splitWords = splitCodeWords(asWords); - const wordsToAdd = new Set((0, iterableIteratorLib_1.concatIterables)(asMultiWord, asWords, splitWords)); - return (0, iterableIteratorLib_1.toIterableIterator)(wordsToAdd); + const wordsToAdd = new Set((0, iterableIteratorLib_js_1.concatIterables)(asMultiWord, asWords, splitWords)); + return (0, iterableIteratorLib_js_1.toIterableIterator)(wordsToAdd); } exports.splitLineIntoCodeWords = splitLineIntoCodeWords; function splitLineIntoWords(line) { const asWords = splitLine(line); - return (0, iterableIteratorLib_1.concatIterables)([line], asWords); + return (0, iterableIteratorLib_js_1.concatIterables)([line], asWords); } exports.splitLineIntoWords = splitLineIntoWords; //# sourceMappingURL=wordListHelper.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Cache/cspell.cache.d.mts b/action/node_modules/cspell-lib/dist/esm/Cache/cspell.cache.d.mts new file mode 100644 index 000000000..41a93e40f --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Cache/cspell.cache.d.mts @@ -0,0 +1,42 @@ +/** + * Proposed CSpell Cache file. + * To be stored at `./.cspell/cache/cache.json` + */ +export interface CSpellCache { + version: Version; + signature: Hash; + files: CachedFile[]; +} +export type Version = '0.1'; +/** + * Hash used. Starts with hash id. i.e. `sha1-` or `sha512-`. + */ +export type Hash = string; +export type UriRelPath = string; +export declare enum IssueCode { + UnknownWord = 1, + ForbiddenWord = 2, + KnownIssue = 4, + ALL = 7 +} +export interface CachedFile { + hash: Hash; + path: UriRelPath; + issues: Issue[]; +} +export type Issue = IssueEntry | IssueLine; +export interface IssueEntry { + line: number; + character: number; + code: IssueCode; + text: string; + len: number; +} +export type IssueLine = [ + line: IssueEntry['line'], + character: IssueEntry['character'], + code: IssueEntry['code'], + text: IssueEntry['text'], + len: IssueEntry['len'] +]; +//# sourceMappingURL=cspell.cache.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Cache/cspell.cache.mjs b/action/node_modules/cspell-lib/dist/esm/Cache/cspell.cache.mjs new file mode 100644 index 000000000..11d0bd394 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Cache/cspell.cache.mjs @@ -0,0 +1,11 @@ +/** + * Proposed CSpell Cache file. + * To be stored at `./.cspell/cache/cache.json` + */ +export var IssueCode; +(function (IssueCode) { + IssueCode[IssueCode["UnknownWord"] = 1] = "UnknownWord"; + IssueCode[IssueCode["ForbiddenWord"] = 2] = "ForbiddenWord"; + IssueCode[IssueCode["KnownIssue"] = 4] = "KnownIssue"; + IssueCode[IssueCode["ALL"] = 7] = "ALL"; +})(IssueCode || (IssueCode = {})); diff --git a/action/node_modules/cspell-lib/dist/esm/Cache/index.d.mts b/action/node_modules/cspell-lib/dist/esm/Cache/index.d.mts new file mode 100644 index 000000000..c5215050e --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Cache/index.d.mts @@ -0,0 +1,2 @@ +export type { CSpellCache } from './cspell.cache.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Cache/index.mjs b/action/node_modules/cspell-lib/dist/esm/Cache/index.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Cache/index.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-lib/dist/esm/Document/Document.d.mts b/action/node_modules/cspell-lib/dist/esm/Document/Document.d.mts new file mode 100644 index 000000000..291e74de2 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Document/Document.d.mts @@ -0,0 +1,13 @@ +import type { Uri } from '../util/Uri.mjs'; +export interface Document { + uri: UriString; + text?: string; + languageId?: string; + locale?: string; +} +export type UriString = string; +export type UriOrString = UriString | Uri; +export interface DocumentWithText extends Document { + text: string; +} +//# sourceMappingURL=Document.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Document/Document.mjs b/action/node_modules/cspell-lib/dist/esm/Document/Document.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Document/Document.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-lib/dist/esm/Document/index.d.mts b/action/node_modules/cspell-lib/dist/esm/Document/index.d.mts new file mode 100644 index 000000000..6b960a649 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Document/index.d.mts @@ -0,0 +1,4 @@ +export type { Document, DocumentWithText, UriString } from './Document.mjs'; +export { isBinaryFile } from './isBinaryDoc.mjs'; +export { fileToDocument, fileToTextDocument } from './resolveDocument.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Document/index.mjs b/action/node_modules/cspell-lib/dist/esm/Document/index.mjs new file mode 100644 index 000000000..05faf6ec2 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Document/index.mjs @@ -0,0 +1,2 @@ +export { isBinaryFile } from './isBinaryDoc.mjs'; +export { fileToDocument, fileToTextDocument } from './resolveDocument.mjs'; diff --git a/action/node_modules/cspell-lib/dist/esm/Document/isBinaryDoc.d.mts b/action/node_modules/cspell-lib/dist/esm/Document/isBinaryDoc.d.mts new file mode 100644 index 000000000..783514b78 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Document/isBinaryDoc.d.mts @@ -0,0 +1,5 @@ +import type { Uri } from '../util/Uri.mjs'; +import type { Document } from './Document.mjs'; +export declare function isBinaryDoc(document: Document): boolean; +export declare function isBinaryFile(filename: Uri | URL | string, languageId?: string | string[]): boolean; +//# sourceMappingURL=isBinaryDoc.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Document/isBinaryDoc.mjs b/action/node_modules/cspell-lib/dist/esm/Document/isBinaryDoc.mjs new file mode 100644 index 000000000..6a0268a3c --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Document/isBinaryDoc.mjs @@ -0,0 +1,16 @@ +import { isGenerated, isGeneratedFile } from '../LanguageIds.mjs'; +import { basename, toUri } from '../util/Uri.mjs'; +import { normalizeLanguageIds } from './normalizeLanguageIds.mjs'; +export function isBinaryDoc(document) { + return isBinaryFile(toUri(document.uri), document.languageId); +} +export function isBinaryFile(filename, languageId) { + const filenameUri = toUri(filename); + if (languageId) { + const ids = normalizeLanguageIds(languageId); + if (ids.length) + return isGenerated(ids); + } + const file = basename(filenameUri); + return isGeneratedFile(file); +} diff --git a/action/node_modules/cspell-lib/dist/esm/Document/normalizeLanguageIds.d.mts b/action/node_modules/cspell-lib/dist/esm/Document/normalizeLanguageIds.d.mts new file mode 100644 index 000000000..c54f03078 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Document/normalizeLanguageIds.d.mts @@ -0,0 +1,2 @@ +export declare function normalizeLanguageIds(languageId: string | string[]): string[]; +//# sourceMappingURL=normalizeLanguageIds.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Document/normalizeLanguageIds.mjs b/action/node_modules/cspell-lib/dist/esm/Document/normalizeLanguageIds.mjs new file mode 100644 index 000000000..40a2ce728 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Document/normalizeLanguageIds.mjs @@ -0,0 +1,3 @@ +export function normalizeLanguageIds(languageId) { + return (Array.isArray(languageId) ? languageId.join(',') : languageId).split(',').map((s) => s.trim()); +} diff --git a/action/node_modules/cspell-lib/dist/esm/Document/resolveDocument.d.mts b/action/node_modules/cspell-lib/dist/esm/Document/resolveDocument.d.mts new file mode 100644 index 000000000..366eace9f --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Document/resolveDocument.d.mts @@ -0,0 +1,11 @@ +/// +import type { TextDocument } from '../Models/TextDocument.mjs'; +import type { Document, DocumentWithText } from './Document.mjs'; +export declare function fileToDocument(file: string): Document; +export declare function fileToDocument(file: string, text: string, languageId?: string, locale?: string): DocumentWithText; +export declare function fileToDocument(file: string, text?: string, languageId?: string, locale?: string): Document | DocumentWithText; +export declare function fileToTextDocument(file: string): Promise; +export declare function documentToTextDocument(document: DocumentWithText): TextDocument; +export declare function resolveDocumentToTextDocument(doc: Document): Promise; +export declare function resolveDocument(document: DocumentWithText | Document, encoding?: BufferEncoding): Promise; +//# sourceMappingURL=resolveDocument.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Document/resolveDocument.mjs b/action/node_modules/cspell-lib/dist/esm/Document/resolveDocument.mjs new file mode 100644 index 000000000..9b865d26f --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Document/resolveDocument.mjs @@ -0,0 +1,43 @@ +import { readFile } from 'fs/promises'; +import { createTextDocument } from '../Models/TextDocument.mjs'; +import * as Uri from '../util/Uri.mjs'; +import { clean } from '../util/util.mjs'; +const defaultEncoding = 'utf8'; +export function fileToDocument(file, text, languageId, locale) { + return clean({ + uri: Uri.toUri(file).toString(), + text, + languageId, + locale, + }); +} +export async function fileToTextDocument(file) { + return documentToTextDocument(await resolveDocument(fileToDocument(file))); +} +export function documentToTextDocument(document) { + const { uri, text: content, languageId, locale } = document; + return createTextDocument({ uri, content, languageId, locale }); +} +export async function resolveDocumentToTextDocument(doc) { + return documentToTextDocument(await resolveDocument(doc)); +} +async function readDocument(filename, encoding = defaultEncoding) { + const text = await readFile(filename, encoding); + const uri = Uri.toUri(filename).toString(); + return { + uri, + text, + }; +} +export function resolveDocument(document, encoding) { + if (isDocumentWithText(document)) + return Promise.resolve(document); + const uri = Uri.toUri(document.uri); + if (uri.scheme !== 'file') { + throw new Error(`Unsupported schema: "${uri.scheme}", open "${uri.toString()}"`); + } + return readDocument(Uri.uriToFilePath(uri), encoding); +} +function isDocumentWithText(doc) { + return doc.text !== undefined; +} diff --git a/action/node_modules/cspell-lib/dist/esm/FeatureFlags/FeatureFlags.d.mts b/action/node_modules/cspell-lib/dist/esm/FeatureFlags/FeatureFlags.d.mts new file mode 100644 index 000000000..776e7bfeb --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/FeatureFlags/FeatureFlags.d.mts @@ -0,0 +1,30 @@ +export interface FeatureFlag { + name: string; + description: string; +} +type FlagTypes = string | boolean; +/** + * Feature Flags are used to turn on/off features. + * These are primarily used before a feature has been fully released. + */ +export declare class FeatureFlags { + private flags; + private flagValues; + constructor(flags?: FeatureFlag[]); + register(flag: FeatureFlag): this; + register(name: string, description: string): this; + getFlag(flag: string): FlagTypes | undefined; + getFlagBool(flag: string): boolean | undefined; + setFlag(flag: string, value?: FlagTypes): this; + getFlagInfo(flag: string): FeatureFlag | undefined; + getFlags(): FeatureFlag[]; + getFlagValues(): Map; + reset(): this; +} +export declare class UnknownFeatureFlagError extends Error { + readonly flag: string; + constructor(flag: string); +} +export declare function getSystemFeatureFlags(): FeatureFlags; +export {}; +//# sourceMappingURL=FeatureFlags.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/FeatureFlags/FeatureFlags.mjs b/action/node_modules/cspell-lib/dist/esm/FeatureFlags/FeatureFlags.mjs new file mode 100644 index 000000000..a86c51862 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/FeatureFlags/FeatureFlags.mjs @@ -0,0 +1,70 @@ +let systemFeatureFlags; +/** + * Feature Flags are used to turn on/off features. + * These are primarily used before a feature has been fully released. + */ +export class FeatureFlags { + constructor(flags = []) { + this.flagValues = new Map(); + this.flags = new Map(flags.map((f) => [f.name, f])); + } + register(flagOrName, description) { + if (typeof flagOrName === 'string') { + return this.register({ name: flagOrName, description: description || '' }); + } + this.flags.set(flagOrName.name, flagOrName); + return this; + } + getFlag(flag) { + return this.flagValues.get(flag); + } + getFlagBool(flag) { + return toBool(this.getFlag(flag)); + } + setFlag(flag, value = true) { + if (!this.flags.has(flag)) { + throw new UnknownFeatureFlagError(flag); + } + this.flagValues.set(flag, value); + return this; + } + getFlagInfo(flag) { + return this.flags.get(flag); + } + getFlags() { + return [...this.flags.values()]; + } + getFlagValues() { + return new Map(this.flagValues); + } + reset() { + this.flagValues.clear(); + return this; + } +} +export class UnknownFeatureFlagError extends Error { + constructor(flag) { + super(`Unknown feature flag: ${flag}`); + this.flag = flag; + } +} +export function getSystemFeatureFlags() { + return systemFeatureFlags || (systemFeatureFlags = new FeatureFlags()); +} +const boolValues = { + 0: false, + 1: true, + f: false, + false: false, + n: false, + no: false, + t: true, + true: true, + y: true, + yes: true, +}; +function toBool(value) { + if (typeof value !== 'string') + return value; + return boolValues[value.toLowerCase()]; +} diff --git a/action/node_modules/cspell-lib/dist/esm/FeatureFlags/index.d.mts b/action/node_modules/cspell-lib/dist/esm/FeatureFlags/index.d.mts new file mode 100644 index 000000000..0ba26816f --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/FeatureFlags/index.d.mts @@ -0,0 +1,2 @@ +export { FeatureFlag, FeatureFlags, getSystemFeatureFlags, UnknownFeatureFlagError } from './FeatureFlags.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/FeatureFlags/index.mjs b/action/node_modules/cspell-lib/dist/esm/FeatureFlags/index.mjs new file mode 100644 index 000000000..c914635a7 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/FeatureFlags/index.mjs @@ -0,0 +1 @@ +export { FeatureFlags, getSystemFeatureFlags, UnknownFeatureFlagError } from './FeatureFlags.mjs'; diff --git a/action/node_modules/cspell-lib/dist/esm/LanguageIds.d.mts b/action/node_modules/cspell-lib/dist/esm/LanguageIds.d.mts new file mode 100644 index 000000000..aedb6cbc6 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/LanguageIds.d.mts @@ -0,0 +1,37 @@ +/** + * The data for this file was constructed from: + * ``` + * cd ~/projects/clones/vscode/extensions + * find . -type f -iname package.json -exec pcregrep -M '(?:"id":.*)|(?:"extensions":[^\]]+)' {} \; > ~/projects/cspell/src/languageIds.txt` + * ``` + */ +export interface LanguageExtensionDefinition { + id: string; + /** List of extensions starting with '.' */ + extensions: string[]; + /** Filenames that do not have an extension or have a different type than their implied extension */ + filenames?: string[]; + /** Indicates that it is a Text or Binary file type. */ + format?: 'Text' | 'Binary'; + /** Optional Description */ + description?: string; +} +export type LanguageDefinition = LanguageExtensionDefinition; +export type LanguageDefinitions = LanguageDefinition[]; +export type ExtensionToLanguageIdMapSet = Map>; +export type ExtensionToLanguageIdMap = Map; +export declare const languageExtensionDefinitions: LanguageDefinitions; +export type LanguageId = string; +export declare const binaryLanguages: Set; +export declare const generatedFiles: Set; +export declare const languageIds: LanguageId[]; +export declare function isBinaryExt(ext: string): boolean; +export declare function isBinaryFile(basename: string): boolean; +export declare function isBinary(languageId: LanguageId | LanguageId[] | Iterable): boolean; +export declare function isGeneratedExt(ext: string): boolean; +export declare function isGeneratedFile(basename: string): boolean; +export declare function isGenerated(languageId: LanguageId | LanguageId[] | Iterable): boolean; +export declare function buildLanguageExtensionMapSet(defs: LanguageDefinitions): ExtensionToLanguageIdMapSet; +export declare function getLanguagesForExt(ext: string): string[]; +export declare function getLanguagesForBasename(basename: string): string[]; +//# sourceMappingURL=LanguageIds.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/LanguageIds.mjs b/action/node_modules/cspell-lib/dist/esm/LanguageIds.mjs new file mode 100644 index 000000000..a7a960c7d --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/LanguageIds.mjs @@ -0,0 +1,303 @@ +/** + * The data for this file was constructed from: + * ``` + * cd ~/projects/clones/vscode/extensions + * find . -type f -iname package.json -exec pcregrep -M '(?:"id":.*)|(?:"extensions":[^\]]+)' {} \; > ~/projects/cspell/src/languageIds.txt` + * ``` + */ +import { autoResolve } from './util/AutoResolve.mjs'; +export const languageExtensionDefinitions = [ + { id: 'ada', extensions: ['.adb', '.ads'] }, + { id: 'apiblueprint', extensions: ['.apib', '.apiblueprint'] }, + { id: 'asciidoc', extensions: ['.adoc', '.asc', '.asciidoc'] }, + { id: 'bat', extensions: ['.bat', '.cmd'] }, + { id: 'clojure', extensions: ['.clj', '.cljs', '.cljx', '.clojure', '.edn'] }, + { id: 'coffeescript', extensions: ['.coffee', '.cson'] }, + { id: 'c', extensions: ['.c'] }, + // cspell:ignore cmake + { id: 'cmake', extensions: ['.cmake'], filenames: ['CMakeLists.txt'] }, + { + id: 'cpp', + extensions: ['.cpp', '.cc', '.cxx', '.hpp', '.hh', '.hxx', '.h', '.mm', '.ino', '.inl'], + }, + { id: 'csharp', extensions: ['.cs'] }, + { id: 'css', extensions: ['.css'] }, + { id: 'dhall', extensions: ['.dhall'] }, + { id: 'diff', extensions: ['.diff', '.patch', '.rej'] }, + { id: 'dockerfile', extensions: ['.dockerfile'], filenames: ['Dockerfile'] }, + { id: 'elixir', extensions: ['.ex', '.exs'] }, + { id: 'fsharp', extensions: ['.fs', '.fsi', '.fsx', '.fsscript'] }, + { id: 'go', extensions: ['.go'] }, + { id: 'groovy', extensions: ['.groovy', '.gvy', '.gradle'] }, + { id: 'handlebars', extensions: ['.handlebars', '.hbs'] }, + { id: 'haskell', extensions: ['.hs', '.lhs'] }, + { + id: 'html', + extensions: ['.html', '.htm', '.shtml', '.xhtml', '.mdoc', '.jsp', '.asp', '.aspx', '.jshtm', '.volt', '.vue'], + }, + { id: 'ini', extensions: ['.ini', '.conf'] }, + { id: 'properties', extensions: ['.properties', '.gitconfig', '.cfg', '.conf'] }, + { id: 'jade', extensions: ['.jade', '.pug'] }, + { id: 'java', extensions: ['.java', '.jav'] }, + { id: 'javascriptreact', extensions: ['.jsx'] }, + { id: 'javascript', extensions: ['.js', '.mjs', '.es6', '.cjs'] }, + { + id: 'json', + extensions: ['.json', '.jsonc', '.bowerrc', '.jshintrc', '.jscsrc', '.eslintrc', '.babelrc', '.webmanifest'], + }, + { id: 'jsonc', extensions: ['.jsonc'] }, + { id: 'jsonc', extensions: ['.code-workspace'], filenames: ['.code-workspace'] }, + { id: 'jungle', extensions: ['.jungle'] }, + { id: 'less', extensions: ['.less'] }, + { id: 'literate haskell', extensions: ['.lhs'] }, + { id: 'lua', extensions: ['.lua'] }, + { id: 'makefile', extensions: ['.mk'] }, + { id: 'markdown', extensions: ['.md', '.mdown', '.markdown', '.markdn'] }, + { id: 'mdx', extensions: ['.mdx'] }, + { id: 'monkeyc', extensions: ['.mc', '.mb'] }, + { id: 'objective-c', extensions: ['.m'] }, + { id: 'perl', extensions: ['.pl', '.pm', '.pod', '.t', '.PL', '.psgi'] }, + { id: 'perl6', extensions: ['.p6', '.pl6', '.pm6', '.nqp'] }, + { id: 'php', extensions: ['.php', '.php4', '.php5', '.phtml', '.ctp'] }, + { id: 'plaintext', extensions: ['.txt'] }, + { id: 'powershell', extensions: ['.ps1', '.psm1', '.psd1', '.pssc', '.psrc'] }, + { id: 'purescript', extensions: ['.purs'] }, + { id: 'python', extensions: ['.py', '.rpy', '.pyw', '.cpy', '.gyp', '.gypi'] }, + { id: 'r', extensions: ['.r', '.R', '.rhistory', '.rprofile', '.rt'] }, + { id: 'razor', extensions: ['.cshtml'] }, + { id: 'ruby', extensions: ['.rb', '.rbx', '.rjs', '.gemspec', '.rake', '.ru'] }, + { id: 'ruby', extensions: [], filenames: ['Gemfile'] }, + { id: 'rust', extensions: ['.rs'] }, + { id: 'scala', extensions: ['.scala', '.sc', '.sbt'] }, + { id: 'scss', extensions: ['.scss'] }, + { id: 'shaderlab', extensions: ['.shader', '.cginc'] }, + { + id: 'shellscript', + extensions: [ + '.sh', + '.bash', + '.bashrc', + '.bash_aliases', + '.bash_profile', + '.bash_login', + '.ebuild', + '.install', + '.profile', + '.bash_logout', + '.zsh', + '.zshrc', + '.zprofile', + '.zlogin', + '.zlogout', + '.zshenv', + '.zsh-theme', + ], + }, + { id: 'sql', extensions: ['.sql', '.dsql'] }, + { id: 'svelte', extensions: ['.svelte'] }, + { id: 'swift', extensions: ['.swift'] }, + { id: 'toml', extensions: ['.toml'] }, + { id: 'typescript', extensions: ['.ts', '.cts', '.mts'] }, + { id: 'typescriptreact', extensions: ['.tsx'] }, + { id: 'vb', extensions: ['.vb', '.brs', '.vbs', '.bas'] }, + { id: 'vue', extensions: ['.vue'] }, + { + id: 'xml', + extensions: [ + '.ascx', + '.atom', + '.axml', + '.bpmn', + '.config', + '.cpt', + '.csl', + '.csproj.user', + '.csproj', + '.dita', + '.ditamap', + '.dtd', + '.dtml', + '.ent', + '.fsproj', + '.fxml', + '.iml', + '.isml', + '.jmx', + '.launch', + '.menu', + '.mod', + '.mxml', + '.nuspec', + '.opml', + '.owl', + '.proj', + '.pt', + '.pubxml.user', + '.pubxml', + '.rdf', + '.rng', + '.rss', + '.shproj', + '.storyboard', + '.svg', + '.targets', + '.tld', + '.tmx', + '.vbproj.user', + '.vbproj', + '.vcxproj.filters', + '.vcxproj', + '.wsdl', + '.wxi', + '.wxl', + '.wxs', + '.xaml', + '.xbl', + '.xib', + '.xlf', + '.xliff', + '.xml', + '.xoml', + '.xpdl', + '.xsd', + '.xul', + ], + }, + { id: 'wheel', extensions: ['.whl'], format: 'Binary' }, + { id: 'xsl', extensions: ['.xsl', '.xslt'] }, + { id: 'yaml', extensions: ['.eyaml', '.eyml', '.yaml', '.yml'] }, + { id: 'latex', extensions: ['.tex'] }, + { id: 'map', extensions: ['.map'] }, + { id: 'pdf', extensions: ['.pdf'] }, + { id: 'rsa', extensions: ['.pub'], filenames: ['id_rsa', 'id_rsa.pub'] }, + { id: 'pem', extensions: ['.private-key.pem', '.pem'] }, + { id: 'pem-private-key', extensions: ['.private-key.pem'] }, + // + // Special file types used to prevent spell checking. + // + { + id: 'image', + extensions: [ + '.bmp', + '.exr', + '.gif', + '.ico', + '.jpeg', + '.jpg', + '.pbm', + '.pgm', + '.png', + '.ppm', + '.ras', + '.sgi', + '.tiff', + '.webp', + '.xbm', + ], + format: 'Binary', + description: 'Some image extensions', + }, + // cspell:ignore woff + { + id: 'binary', + extensions: ['.gz', '.exe', '.dll', '.lib', '.obj', '.o', '.eot', '.cur', '.zip'], + format: 'Binary', + }, + { + id: 'fonts', + extensions: ['.ttf', '.woff', '.woff2'], + format: 'Binary', + }, + { + id: 'video', + extensions: ['.mov', '.mpg'], + format: 'Binary', + }, + { + id: 'lock', + extensions: ['.lock'], + filenames: ['package-lock.json'], + }, + { + id: 'cache_files', + extensions: [], + // cspell:ignore eslintcache + filenames: ['.cspellcache', '.DS_Store', '.eslintcache'], + }, + { id: 'dll', extensions: ['.dll'], format: 'Binary' }, + { id: 'exe', extensions: ['.exe'], format: 'Binary' }, + { id: 'object-file', extensions: ['.o', '.obj'], format: 'Binary' }, + { id: 'jar', extensions: ['.jar'], format: 'Binary' }, + { id: 'spv', extensions: ['.spv'], format: 'Binary', description: 'SPSS Output Document' }, + { id: 'mdb', extensions: ['.mdb'], format: 'Binary', description: 'Microsoft Access DB' }, + { id: 'webm', extensions: ['.webm'], format: 'Binary', description: 'WebM is an audiovisual media file format.' }, + { id: 'trie', extensions: ['.trie'], format: 'Binary', description: 'CSpell dictionary file.' }, +]; +const binaryFormatIds = languageExtensionDefinitions.filter((d) => d.format === 'Binary').map((d) => d.id); +export const binaryLanguages = new Set(['binary', 'image', 'video', 'fonts'].concat(binaryFormatIds)); +export const generatedFiles = new Set([...binaryLanguages, 'map', 'lock', 'pdf', 'cache_files', 'rsa', 'pem', 'trie']); +export const languageIds = languageExtensionDefinitions.map(({ id }) => id); +const mapExtensionToSetOfLanguageIds = buildLanguageExtensionMapSet(languageExtensionDefinitions); +const mapExtensionToLanguageIds = buildExtensionToLanguageIdMap(mapExtensionToSetOfLanguageIds); +export function isBinaryExt(ext) { + return isBinary(getLanguagesForExt(ext)); +} +export function isBinaryFile(basename) { + return isBinary(getLanguagesForBasename(basename)); +} +export function isBinary(languageId) { + return doesSetContainAnyOf(binaryLanguages, languageId); +} +export function isGeneratedExt(ext) { + return isGenerated(getLanguagesForExt(ext)); +} +export function isGeneratedFile(basename) { + return isGenerated(getLanguagesForBasename(basename)); +} +export function isGenerated(languageId) { + return doesSetContainAnyOf(generatedFiles, languageId); +} +function doesSetContainAnyOf(setOfIds, languageId) { + if (typeof languageId === 'string') { + return setOfIds.has(languageId); + } + for (const id of languageId) { + if (setOfIds.has(id)) { + return true; + } + } + return false; +} +export function buildLanguageExtensionMapSet(defs) { + return defs.reduce((map, def) => { + function addId(value) { + autoResolve(map, value, () => new Set()).add(def.id); + } + def.extensions.forEach(addId); + def.filenames?.forEach(addId); + return map; + }, new Map()); +} +function buildExtensionToLanguageIdMap(map) { + return new Map([...map].map(([k, s]) => [k, [...s]])); +} +function _getLanguagesForExt(ext) { + return mapExtensionToLanguageIds.get(ext) || mapExtensionToLanguageIds.get('.' + ext); +} +export function getLanguagesForExt(ext) { + return _getLanguagesForExt(ext) || _getLanguagesForExt(ext.toLowerCase()) || []; +} +function _getLanguagesForBasename(basename) { + const found = mapExtensionToLanguageIds.get(basename); + if (found) + return found; + for (let pos = basename.indexOf('.'); pos >= 0; pos = basename.indexOf('.', pos + 1)) { + const ids = mapExtensionToLanguageIds.get(basename.slice(pos)); + if (ids) + return ids; + } + return undefined; +} +export function getLanguagesForBasename(basename) { + return _getLanguagesForBasename(basename) || _getLanguagesForBasename(basename.toLowerCase()) || []; +} diff --git a/action/node_modules/cspell-lib/dist/esm/Models/CSpellSettingsInternalDef.d.mts b/action/node_modules/cspell-lib/dist/esm/Models/CSpellSettingsInternalDef.d.mts new file mode 100644 index 000000000..21abe53ad --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/CSpellSettingsInternalDef.d.mts @@ -0,0 +1,40 @@ +import type { AdvancedCSpellSettingsWithSourceTrace, CSpellSettingsWithSourceTrace, DictionaryDefinition, DictionaryDefinitionAugmented, DictionaryDefinitionCustom, DictionaryDefinitionInline, DictionaryDefinitionPreferred, Parser } from '@cspell/cspell-types'; +import type { WeightMap } from 'cspell-trie-lib'; +import type { OptionalOrUndefined } from '../util/types.mjs'; +export declare const SymbolCSpellSettingsInternal: unique symbol; +export interface CSpellSettingsInternal extends Omit { + [SymbolCSpellSettingsInternal]: true; + dictionaryDefinitions?: DictionaryDefinitionInternal[]; +} +export interface CSpellSettingsInternalFinalized extends CSpellSettingsInternal { + parserFn: Parser | undefined; + finalized: true; + ignoreRegExpList: RegExp[]; + includeRegExpList: RegExp[]; +} +type DictionaryDefinitionCustomUniqueFields = Omit; +export type DictionaryDefinitionInternal = DictionaryFileDefinitionInternal | DictionaryDefinitionInlineInternal; +export type DictionaryDefinitionInlineInternal = DictionaryDefinitionInline & { + /** The path to the config file that contains this dictionary definition */ + readonly __source?: string | undefined; +}; +export interface DictionaryFileDefinitionInternal extends Readonly, Readonly>, Readonly { + /** + * Optional weight map used to improve suggestions. + */ + readonly weightMap?: WeightMap | undefined; + /** The path to the config file that contains this dictionary definition */ + readonly __source?: string | undefined; +} +export interface DictionaryFileDefinitionInternalWithSource extends DictionaryFileDefinitionInternal { + readonly __source: string; +} +export type DictionaryDefinitionInternalWithSource = DictionaryDefinitionInternal & { + readonly __source: string; +}; +export declare function cleanCSpellSettingsInternal(parts?: OptionalOrUndefined>): CSpellSettingsInternal; +export declare function createCSpellSettingsInternal(parts?: OptionalOrUndefined>): CSpellSettingsInternal; +export declare function isCSpellSettingsInternal(cs: CSpellSettingsInternal | CSpellSettingsWithSourceTrace | OptionalOrUndefined): cs is CSpellSettingsInternal; +export declare function isDictionaryDefinitionInlineInternal(def: DictionaryDefinitionInternal | DictionaryDefinitionInline | DictionaryDefinition): def is DictionaryDefinitionInlineInternal; +export {}; +//# sourceMappingURL=CSpellSettingsInternalDef.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Models/CSpellSettingsInternalDef.mjs b/action/node_modules/cspell-lib/dist/esm/Models/CSpellSettingsInternalDef.mjs new file mode 100644 index 000000000..3af305e2f --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/CSpellSettingsInternalDef.mjs @@ -0,0 +1,22 @@ +import { clean } from '../util/util.mjs'; +export const SymbolCSpellSettingsInternal = Symbol('CSpellSettingsInternal'); +export function cleanCSpellSettingsInternal(parts = {}) { + const csi = clean(parts); + Object.assign(csi, { [SymbolCSpellSettingsInternal]: true }); + return csi; +} +export function createCSpellSettingsInternal(parts = {}) { + return clean({ + ...parts, + [SymbolCSpellSettingsInternal]: true, + }); +} +export function isCSpellSettingsInternal(cs) { + return !!cs[SymbolCSpellSettingsInternal]; +} +export function isDictionaryDefinitionInlineInternal(def) { + if (def.path) + return false; + const defInline = def; + return !!(defInline.words || defInline.flagWords || defInline.ignoreWords || defInline.suggestWords); +} diff --git a/action/node_modules/cspell-lib/dist/esm/Models/PatternRegExp.d.mts b/action/node_modules/cspell-lib/dist/esm/Models/PatternRegExp.d.mts new file mode 100644 index 000000000..e8137a8da --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/PatternRegExp.d.mts @@ -0,0 +1,5 @@ +export declare class PatternRegExp extends RegExp { + constructor(pattern: RegExp | string); + toJSON(): string; +} +//# sourceMappingURL=PatternRegExp.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Models/PatternRegExp.mjs b/action/node_modules/cspell-lib/dist/esm/Models/PatternRegExp.mjs new file mode 100644 index 000000000..eec184cfb --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/PatternRegExp.mjs @@ -0,0 +1,8 @@ +export class PatternRegExp extends RegExp { + constructor(pattern) { + super(pattern); + } + toJSON() { + return this.toString(); + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/Models/Suggestion.d.mts b/action/node_modules/cspell-lib/dist/esm/Models/Suggestion.d.mts new file mode 100644 index 000000000..3770bab2a --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/Suggestion.d.mts @@ -0,0 +1,15 @@ +export interface ExtendedSuggestion { + /** + * The suggestion. + */ + word: string; + /** + * The word is preferred above others, except other "preferred" words. + */ + isPreferred?: boolean; + /** + * The suggested word adjusted to match the original case. + */ + wordAdjustedToMatchCase?: string; +} +//# sourceMappingURL=Suggestion.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Models/Suggestion.mjs b/action/node_modules/cspell-lib/dist/esm/Models/Suggestion.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/Suggestion.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-lib/dist/esm/Models/TextDocument.d.mts b/action/node_modules/cspell-lib/dist/esm/Models/TextDocument.d.mts new file mode 100644 index 000000000..b9a17a59d --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/TextDocument.d.mts @@ -0,0 +1,85 @@ +import * as Uri from '../util/Uri.mjs'; +export type DocumentUri = Uri.Uri; +export interface Position { + line: number; + character: number; +} +/** + * Range offset tuple. + */ +export type SimpleRange = [start: number, end: number]; +export interface TextDocumentLine { + readonly text: string; + readonly offset: number; + readonly position: Position; +} +export interface TextDocumentRef { + /** + * The associated URI for this document. Most documents have the __file__-scheme, indicating that they + * represent files on disk. However, some documents may have other schemes indicating that they are not + * available on disk. + */ + readonly uri: DocumentUri; + /** + * The identifier of the language associated with this document. + */ + readonly languageId?: string | string[] | undefined; + /** + * the raw Document Text + */ + readonly text?: string | undefined; + /** + * The natural language locale. + */ + readonly locale?: string | undefined; +} +/** + * A simple text document. Not to be implemented. The document keeps the content + * as string. + */ +export interface TextDocument { + /** + * The associated URI for this document. Most documents have the __file__-scheme, indicating that they + * represent files on disk. However, some documents may have other schemes indicating that they are not + * available on disk. + */ + readonly uri: DocumentUri; + /** + * The identifier of the language associated with this document. + */ + readonly languageId: string | string[]; + /** + * The version number of this document (it will increase after each + * change, including undo/redo). + */ + readonly version: number; + /** + * the raw Document Text + */ + readonly text: string; + /** + * The natural language locale. + */ + readonly locale?: string | undefined; + positionAt(offset: number): Position; + offsetAt(position: Position): number; + lineAt(offset: number): TextDocumentLine; + getLine(lineNum: number): TextDocumentLine; + getLines(): Iterable; +} +export interface CreateTextDocumentParams { + uri: DocumentUri | string; + content: string; + languageId?: string | string[] | undefined; + locale?: string | undefined; + version?: number | undefined; +} +export interface TextDocumentContentChangeEvent { + range?: SimpleRange; + text: string; +} +export declare function createTextDocument({ uri, content, languageId, locale, version, }: CreateTextDocumentParams): TextDocument; +export declare function updateTextDocument(doc: TextDocument, edits: TextDocumentContentChangeEvent[], version?: number): TextDocument; +export declare function loadTextDocument(filename: string | DocumentUri, languageId?: string): Promise; +export declare const isTextDocument: (doc: TextDocument | unknown) => doc is TextDocument; +//# sourceMappingURL=TextDocument.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Models/TextDocument.mjs b/action/node_modules/cspell-lib/dist/esm/Models/TextDocument.mjs new file mode 100644 index 000000000..0cde1b90e --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/TextDocument.mjs @@ -0,0 +1,105 @@ +import assert from 'assert'; +import { promises as fs } from 'fs'; +import { TextDocument as VsTextDocument } from 'vscode-languageserver-textdocument'; +import { getLanguagesForBasename } from '../LanguageIds.mjs'; +import * as Uri from '../util/Uri.mjs'; +class TextDocumentImpl { + constructor(uri, text, languageId, locale, version) { + this.uri = uri; + this.languageId = languageId; + this.locale = locale; + const primaryLanguageId = typeof languageId === 'string' ? languageId : languageId[0] || 'plaintext'; + this.vsTextDoc = VsTextDocument.create(uri.toString(), primaryLanguageId, version, text); + } + get version() { + return this.vsTextDoc.version; + } + get text() { + return this.vsTextDoc.getText(); + } + positionAt(offset) { + return this.vsTextDoc.positionAt(offset); + } + offsetAt(position) { + return this.vsTextDoc.offsetAt(position); + } + lineAt(offset) { + const position = this.vsTextDoc.positionAt(offset); + return this.getLine(position.line); + } + getLine(lineNum) { + const position = { line: lineNum, character: 0 }; + const end = { line: lineNum + 1, character: 0 }; + const range = { + start: position, + end, + }; + const lineOffset = this.vsTextDoc.offsetAt(position); + const text = this.vsTextDoc.getText(range); + return { + text, + offset: lineOffset, + position, + }; + } + /** + * Iterate over the lines of a document one-by-one. + * Changing the document between iterations can change the result + */ + *getLines() { + const range = { + start: { line: 0, character: 0 }, + end: { line: 1, character: 0 }, + }; + while (this.vsTextDoc.offsetAt(range.end) > this.vsTextDoc.offsetAt(range.start)) { + const offset = this.vsTextDoc.offsetAt(range.start); + yield { + text: this.vsTextDoc.getText(range), + offset, + position: range.start, + }; + ++range.start.line; + ++range.end.line; + } + } + /** + * Apply edits to the text. + * Note: the edits are applied one after the other. + * @param edits - changes to the text + * @param version - optional version to use. + * @returns this + */ + update(edits, version) { + version = version ?? this.version + 1; + for (const edit of edits) { + const vsEdit = edit.range + ? { + range: { start: this.positionAt(edit.range[0]), end: this.positionAt(edit.range[1]) }, + text: edit.text, + } + : edit; + VsTextDocument.update(this.vsTextDoc, [vsEdit], version); + } + return this; + } +} +export function createTextDocument({ uri, content, languageId, locale, version, }) { + version = version ?? 1; + uri = Uri.toUri(uri); + languageId = languageId ?? getLanguagesForBasename(Uri.basename(uri)); + languageId = languageId.length === 0 ? 'text' : languageId; + return new TextDocumentImpl(uri, content, languageId, locale, version); +} +export function updateTextDocument(doc, edits, version) { + assert(isTextDocumentImpl(doc), 'Unknown TextDocument type'); + return doc.update(edits, version); +} +function isTextDocumentImpl(doc) { + return doc instanceof TextDocumentImpl; +} +export async function loadTextDocument(filename, languageId) { + const uri = Uri.toUri(filename); + const content = await fs.readFile(Uri.uriToFilePath(uri), 'utf8'); + return createTextDocument({ uri, languageId, content }); +} +export const isTextDocument = isTextDocumentImpl; diff --git a/action/node_modules/cspell-lib/dist/esm/Models/ValidationIssue.d.mts b/action/node_modules/cspell-lib/dist/esm/Models/ValidationIssue.d.mts new file mode 100644 index 000000000..3ba169ab0 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/ValidationIssue.d.mts @@ -0,0 +1,7 @@ +import type { ExtendedSuggestion } from './Suggestion.mjs'; +import type { ValidationResult } from './ValidationResult.mjs'; +export interface ValidationIssue extends ValidationResult { + suggestions?: string[]; + suggestionsEx?: ExtendedSuggestion[]; +} +//# sourceMappingURL=ValidationIssue.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Models/ValidationIssue.mjs b/action/node_modules/cspell-lib/dist/esm/Models/ValidationIssue.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/ValidationIssue.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-lib/dist/esm/Models/ValidationResult.d.mts b/action/node_modules/cspell-lib/dist/esm/Models/ValidationResult.d.mts new file mode 100644 index 000000000..67c1759ca --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/ValidationResult.d.mts @@ -0,0 +1,7 @@ +import type { Issue, TextOffset as TextOffsetRW } from '@cspell/cspell-types'; +export interface ValidationResult extends TextOffsetRW, Pick { + line: TextOffsetRW; + isFlagged?: boolean | undefined; + isFound?: boolean | undefined; +} +//# sourceMappingURL=ValidationResult.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Models/ValidationResult.mjs b/action/node_modules/cspell-lib/dist/esm/Models/ValidationResult.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Models/ValidationResult.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/CSpellSettingsServer.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/CSpellSettingsServer.d.mts new file mode 100644 index 000000000..d2b7db62e --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/CSpellSettingsServer.d.mts @@ -0,0 +1,48 @@ +import type { AdvancedCSpellSettingsWithSourceTrace, Glob, ImportFileRef } from '@cspell/cspell-types'; +import type { CSpellSettingsInternal, CSpellSettingsInternalFinalized } from '../Models/CSpellSettingsInternalDef.mjs'; +import type { OptionalOrUndefined } from '../util/types.mjs'; +type CSpellSettingsWST = AdvancedCSpellSettingsWithSourceTrace; +type CSpellSettingsWSTO = OptionalOrUndefined; +type CSpellSettingsI = CSpellSettingsInternal; +declare function mergeObjects(left: undefined, right: undefined): undefined; +declare function mergeObjects(left: T, right: undefined): T; +declare function mergeObjects(left: T, right: T): T; +declare function mergeObjects(left: undefined, right: T): T; +export declare function mergeSettings(left: CSpellSettingsWSTO | CSpellSettingsI, ...settings: (CSpellSettingsWSTO | CSpellSettingsI | undefined)[]): CSpellSettingsI; +export declare function mergeInDocSettings(left: CSpellSettingsWSTO, right: CSpellSettingsWSTO): CSpellSettingsWST; +export declare function calcOverrideSettings(settings: CSpellSettingsWSTO, filename: string): CSpellSettingsI; +/** + * + * @param settings - settings to finalize + * @returns settings where all globs and file paths have been resolved. + */ +export declare function finalizeSettings(settings: CSpellSettingsWSTO | CSpellSettingsI): CSpellSettingsInternalFinalized; +export declare function toInternalSettings(settings: undefined): undefined; +export declare function toInternalSettings(settings: CSpellSettingsI | CSpellSettingsWSTO): CSpellSettingsI; +export declare function toInternalSettings(settings?: CSpellSettingsI | CSpellSettingsWSTO): CSpellSettingsI | undefined; +/** + * @param filename - filename + * @param globs - globs + * @returns true if it matches + * @deprecated true + * @deprecationMessage No longer actively supported. Use package: `cspell-glob`. + */ +export declare function checkFilenameMatchesGlob(filename: string, globs: Glob | Glob[]): boolean; +/** + * Return a list of Setting Sources used to create this Setting. + * @param settings the settings to search + */ +export declare function getSources(settings: CSpellSettingsWSTO): CSpellSettingsWSTO[]; +export interface ImportFileRefWithError extends ImportFileRef { + error: Error; +} +export interface ConfigurationDependencies { + configFiles: string[]; + dictionaryFiles: string[]; +} +export declare function extractDependencies(settings: CSpellSettingsWSTO | CSpellSettingsI): ConfigurationDependencies; +export declare const __testing__: { + mergeObjects: typeof mergeObjects; +}; +export {}; +//# sourceMappingURL=CSpellSettingsServer.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/CSpellSettingsServer.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/CSpellSettingsServer.mjs new file mode 100644 index 000000000..3994814da --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/CSpellSettingsServer.mjs @@ -0,0 +1,338 @@ +import assert from 'assert'; +import { GlobMatcher } from 'cspell-glob'; +import * as path from 'path'; +import { cleanCSpellSettingsInternal as csi, isCSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.mjs'; +import { autoResolveWeak, AutoResolveWeakCache } from '../util/AutoResolve.mjs'; +import * as util from '../util/util.mjs'; +import { configSettingsFileVersion0_1, ENV_CSPELL_GLOB_ROOT } from './constants.mjs'; +import { calcDictionaryDefsToLoad, mapDictDefsToInternal } from './DictionarySettings.mjs'; +import { resolvePatterns } from './patterns.mjs'; +function _unique(a) { + return [...new Set(a)]; +} +function mergeListUnique(left, right) { + if (left === undefined) + return right; + if (right === undefined) + return left; + if (!right.length) + return left; + if (!left.length) + return right; + return _unique([...left, ...right]); +} +function mergeList(left, right) { + if (left === undefined) + return right; + if (right === undefined) + return left; + if (!left.length) + return right; + if (!right.length) + return left; + return left.concat(right); +} +const emptyWords = []; +Object.freeze(emptyWords); +const cachedMerges = new WeakMap(); +function _mergeWordsCached(left, right) { + const map = autoResolveWeak(cachedMerges, left, () => new WeakMap()); + return autoResolveWeak(map, right, () => left.concat(right)); +} +function mergeWordsCached(left, right) { + if (left === undefined) + return !right || right.length ? right : emptyWords; + if (right === undefined) + return !left || left.length ? left : emptyWords; + if (!left.length) + return !right || right.length ? right : emptyWords; + if (!right.length) + return !left || left.length ? left : emptyWords; + return _mergeWordsCached(left, right); +} +function mergeObjects(left, right) { + if (left === undefined) + return right; + if (right === undefined) + return left; + return { ...left, ...right }; +} +function replaceIfNotEmpty(left = [], right = []) { + const filtered = right.filter((a) => !!a); + if (filtered.length) { + return filtered; + } + return left; +} +export function mergeSettings(left, ...settings) { + const rawSettings = settings.filter(util.isDefined).reduce(merge, toInternalSettings(left)); + return util.clean(rawSettings); +} +// eslint-disable-next-line @typescript-eslint/ban-types +function isEmpty(obj) { + return Object.keys(obj).length === 0 && obj.constructor === Object; +} +const mergeCache = new AutoResolveWeakCache(); +function merge(left, right) { + const map = mergeCache.get(left, () => new WeakMap()); + return autoResolveWeak(map, right, () => _merge(left, right)); +} +function _merge(left, right) { + const _left = toInternalSettings(left); + const _right = toInternalSettings(right); + if (left === right) { + return _left; + } + if (isEmpty(right)) { + return _left; + } + if (isEmpty(left)) { + return _right; + } + if (isLeftAncestorOfRight(_left, _right)) { + return _right; + } + if (doesLeftHaveRightAncestor(_left, _right)) { + return _left; + } + const includeRegExpList = takeRightOtherwiseLeft(_left.includeRegExpList, _right.includeRegExpList); + const optionals = includeRegExpList?.length ? { includeRegExpList } : {}; + const version = max(_left.version, _right.version); + const valuesToClear = { + name: undefined, + id: undefined, + description: undefined, + globRoot: undefined, + import: undefined, + __importRef: undefined, + }; + const settings = csi({ + ..._left, + ..._right, + ...optionals, + ...valuesToClear, + version, + words: mergeWordsCached(_left.words, _right.words), + userWords: mergeWordsCached(_left.userWords, _right.userWords), + flagWords: mergeWordsCached(_left.flagWords, _right.flagWords), + ignoreWords: mergeWordsCached(_left.ignoreWords, _right.ignoreWords), + suggestWords: mergeWordsCached(_left.suggestWords, _right.suggestWords), + enabledLanguageIds: replaceIfNotEmpty(_left.enabledLanguageIds, _right.enabledLanguageIds), + enableFiletypes: mergeList(_left.enableFiletypes, _right.enableFiletypes), + ignoreRegExpList: mergeListUnique(_left.ignoreRegExpList, _right.ignoreRegExpList), + patterns: mergeListUnique(_left.patterns, _right.patterns), + dictionaryDefinitions: mergeListUnique(_left.dictionaryDefinitions, _right.dictionaryDefinitions), + dictionaries: mergeListUnique(_left.dictionaries, _right.dictionaries), + noSuggestDictionaries: mergeListUnique(_left.noSuggestDictionaries, _right.noSuggestDictionaries), + languageSettings: mergeList(_left.languageSettings, _right.languageSettings), + enabled: _right.enabled !== undefined ? _right.enabled : _left.enabled, + files: mergeListUnique(_left.files, _right.files), + ignorePaths: versionBasedMergeList(_left.ignorePaths, _right.ignorePaths, version), + overrides: versionBasedMergeList(_left.overrides, _right.overrides, version), + features: mergeObjects(_left.features, _right.features), + source: mergeSources(_left, _right), + plugins: mergeList(_left.plugins, _right.plugins), + __imports: mergeImportRefs(_left, _right), + }); + return settings; +} +function versionBasedMergeList(left, right, version) { + if (version === configSettingsFileVersion0_1) { + return takeRightOtherwiseLeft(left, right); + } + return mergeListUnique(left, right); +} +/** + * Check to see if left is a left ancestor of right. + * If that is the case, merging is not necessary: + * @param left - setting on the left side of a merge + * @param right - setting on the right side of a merge + */ +function isLeftAncestorOfRight(left, right) { + return hasAncestor(right, left, 0); +} +/** + * Check to see if left has right as an ancestor to the right. + * If that is the case, merging is not necessary: + * @param left - setting on the left side of a merge + * @param right - setting on the right side of a merge + */ +function doesLeftHaveRightAncestor(left, right) { + return hasAncestor(left, right, 1); +} +function hasAncestor(s, ancestor, side) { + const sources = s.source?.sources; + if (!sources) + return false; + // calc the first or last index of the source array. + const i = side ? sources.length - 1 : 0; + const src = sources[i]; + return src === ancestor || (src && hasAncestor(src, ancestor, side)) || false; +} +export function mergeInDocSettings(left, right) { + const merged = { + ...mergeSettings(left, right), + includeRegExpList: mergeListUnique(left.includeRegExpList, right.includeRegExpList), + }; + return util.clean(merged); +} +function takeRightOtherwiseLeft(left, right) { + if (right?.length) { + return right; + } + return left || right; +} +export function calcOverrideSettings(settings, filename) { + const _settings = toInternalSettings(settings); + const overrides = _settings.overrides || []; + const result = overrides + .filter((override) => checkFilenameMatchesGlob(filename, override.filename)) + .reduce((settings, override) => mergeSettings(settings, override), _settings); + return result; +} +/** + * + * @param settings - settings to finalize + * @returns settings where all globs and file paths have been resolved. + */ +export function finalizeSettings(settings) { + return _finalizeSettings(toInternalSettings(settings)); +} +function _finalizeSettings(settings) { + // apply patterns to any RegExpLists. + const finalized = { + ...settings, + finalized: true, + ignoreRegExpList: resolvePatterns(settings.ignoreRegExpList, settings.patterns), + includeRegExpList: resolvePatterns(settings.includeRegExpList, settings.patterns), + parserFn: resolveParser(settings), + }; + finalized.name = 'Finalized ' + (finalized.name || ''); + finalized.source = { name: settings.name || 'src', sources: [settings] }; + return finalized; +} +const cacheInternalSettings = new AutoResolveWeakCache(); +export function toInternalSettings(settings) { + if (settings === undefined) + return undefined; + if (isCSpellSettingsInternal(settings)) + return settings; + return cacheInternalSettings.get(settings, _toInternalSettings); +} +function _toInternalSettings(settings) { + const { dictionaryDefinitions: defs, ...rest } = settings; + const dictionaryDefinitions = mapDictDefsToInternal(defs, filenameToDirectory(settings.source?.filename) || resolveCwd()); + const setting = dictionaryDefinitions ? { ...rest, dictionaryDefinitions } : rest; + return csi(setting); +} +function filenameToDirectory(filename) { + return filename ? path.dirname(filename) : undefined; +} +/** + * @param filename - filename + * @param globs - globs + * @returns true if it matches + * @deprecated true + * @deprecationMessage No longer actively supported. Use package: `cspell-glob`. + */ +export function checkFilenameMatchesGlob(filename, globs) { + const m = new GlobMatcher(globs); + return m.match(filename); +} +function mergeSources(left, right) { + return { + name: 'merged', + sources: [left, right], + }; +} +function max(a, b) { + if (a === undefined || a === null) + return b; + if (b === undefined || b === null) + return a; + return a > b ? a : b; +} +/** + * Return a list of Setting Sources used to create this Setting. + * @param settings the settings to search + */ +export function getSources(settings) { + const visited = new Set(); + const sources = []; + function _walkSourcesTree(settings) { + if (!settings || visited.has(settings)) + return; + visited.add(settings); + if (!settings.source?.sources?.length) { + sources.push(settings); + return; + } + settings.source.sources.forEach(_walkSourcesTree); + } + _walkSourcesTree(settings); + return sources; +} +function mergeImportRefs(left, right = {}) { + const imports = new Map(left.__imports || []); + if (left.__importRef) { + imports.set(left.__importRef.filename, left.__importRef); + } + if (right.__importRef) { + imports.set(right.__importRef.filename, right.__importRef); + } + const rightImports = right.__imports?.values() || []; + for (const ref of rightImports) { + imports.set(ref.filename, ref); + } + return imports.size ? imports : undefined; +} +export function extractDependencies(settings) { + const settingsI = toInternalSettings(settings); + const configFiles = [...(mergeImportRefs(settingsI) || [])].map(([filename]) => filename); + const dictionaryFiles = calcDictionaryDefsToLoad(settingsI) + .map((dict) => dict.path) + .filter((file) => !!file); + return { + configFiles, + dictionaryFiles, + }; +} +function resolveCwd() { + const envGlobRoot = process.env[ENV_CSPELL_GLOB_ROOT]; + const cwd = envGlobRoot || process.cwd(); + return cwd; +} +function resolveParser(settings) { + if (!settings.parser) + return undefined; + if (typeof settings.parser === 'function') + return settings.parser; + const parserName = settings.parser; + assert(typeof parserName === 'string'); + const parsers = extractParsers(settings.plugins); + const parser = parsers.get(parserName); + assert(parser, `Parser "${parserName}" not found.`); + return parser; +} +const parserCache = new AutoResolveWeakCache(); +const emptyParserMap = new Map(); +function* parsers(plugins) { + for (const plugin of plugins) { + if (!plugin.parsers) + continue; + for (const parser of plugin.parsers) { + yield [parser.name, parser]; + } + } +} +function mapPlugins(plugins) { + return new Map(parsers(plugins)); +} +function extractParsers(plugins) { + if (!plugins || !plugins.length) + return emptyParserMap; + return parserCache.get(plugins, mapPlugins); +} +export const __testing__ = { + mergeObjects, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/ImportError.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/ImportError.d.mts new file mode 100644 index 000000000..49efa6cc3 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/ImportError.d.mts @@ -0,0 +1,11 @@ +export declare class ImportError extends Error { + readonly cause: Error | undefined; + constructor(msg: string, cause?: Error | unknown); +} +export declare class UnsupportedSchema extends Error { + constructor(msg: string); +} +export declare class UnsupportedPnpFile extends Error { + constructor(msg: string); +} +//# sourceMappingURL=ImportError.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/ImportError.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/ImportError.mjs new file mode 100644 index 000000000..263ee3853 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/ImportError.mjs @@ -0,0 +1,17 @@ +import { isError } from '../../util/errors.mjs'; +export class ImportError extends Error { + constructor(msg, cause) { + super(msg); + this.cause = isError(cause) ? cause : undefined; + } +} +export class UnsupportedSchema extends Error { + constructor(msg) { + super(msg); + } +} +export class UnsupportedPnpFile extends Error { + constructor(msg) { + super(msg); + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/SettingsController.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/SettingsController.d.mts new file mode 100644 index 000000000..fa599dc87 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/SettingsController.d.mts @@ -0,0 +1,9 @@ +import type { CSpellIO } from 'cspell-io'; +/** + * The settings controller manages requests to resolve configuration settings and files. + */ +export declare class SettingsController { + readonly cspellIO: CSpellIO; + constructor(cspellIO: CSpellIO); +} +//# sourceMappingURL=SettingsController.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/SettingsController.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/SettingsController.mjs new file mode 100644 index 000000000..94c8877f5 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/SettingsController.mjs @@ -0,0 +1,8 @@ +/** + * The settings controller manages requests to resolve configuration settings and files. + */ +export class SettingsController { + constructor(cspellIO) { + this.cspellIO = cspellIO; + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/PnPSettings.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/PnPSettings.d.mts new file mode 100644 index 000000000..1a3906fd0 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/PnPSettings.d.mts @@ -0,0 +1,12 @@ +import type { CSpellSettings, PnPSettings } from '@cspell/cspell-types'; +import type { OptionalOrUndefined } from '../../../util/types.mjs'; +export type PnPSettingsOptional = OptionalOrUndefined; +export declare const defaultPnPSettings: PnPSettings; +/** + * create PnPSettings object that can be used to compare to the last call. + * This is to reduce object churn and unnecessary configuration loading. + * @param settings - value to normalize + * @returns + */ +export declare function normalizePnPSettings(settings: PnPSettingsOptional | CSpellSettings): PnPSettings; +//# sourceMappingURL=PnPSettings.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/PnPSettings.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/PnPSettings.mjs new file mode 100644 index 000000000..a4627849b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/PnPSettings.mjs @@ -0,0 +1,21 @@ +import { clean } from '../../../util/util.mjs'; +export const defaultPnPSettings = Object.freeze({}); +let lastPnP = defaultPnPSettings; +/** + * create PnPSettings object that can be used to compare to the last call. + * This is to reduce object churn and unnecessary configuration loading. + * @param settings - value to normalize + * @returns + */ +export function normalizePnPSettings(settings) { + if (equal(lastPnP, settings)) + return lastPnP; + if (equal(defaultPnPSettings, settings)) + return defaultPnPSettings; + const { usePnP, pnpFiles } = settings; + return (lastPnP = clean({ usePnP, pnpFiles })); +} +function equal(a, b) { + return (a === b || + (a.usePnP === b.usePnP && (a.pnpFiles === b.pnpFiles || a.pnpFiles?.join('|') === b.pnpFiles?.join('|')))); +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/configLoader.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/configLoader.d.mts new file mode 100644 index 000000000..7b82b8794 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/configLoader.d.mts @@ -0,0 +1,141 @@ +import type { CSpellUserSettings, ImportFileRef } from '@cspell/cspell-types'; +import type { CSpellIO } from 'cspell-io'; +import type { Uri } from '../../../util/Uri.mjs'; +import { ImportError } from '../ImportError.mjs'; +import type { LoaderResult } from '../pnpLoader.mjs'; +import { normalizeCacheSettings } from './normalizeRawSettings.mjs'; +import type { PnPSettingsOptional } from './PnPSettings.mjs'; +import type { CSpellSettingsI, CSpellSettingsWST } from './types.mjs'; +export declare const sectionCSpell = "cSpell"; +export declare const defaultFileName = "cspell.json"; +export declare const defaultConfigFilenames: readonly string[]; +export declare class ConfigLoader { + readonly cspellIO: CSpellIO; + /** + * Use `createConfigLoader` + * @param cspellIO - CSpellIO interface for reading files. + */ + protected constructor(cspellIO: CSpellIO); + protected cachedFiles: Map; + protected cspellConfigExplorer: import("cosmiconfig").PublicExplorer; + protected cspellConfigExplorerSync: import("cosmiconfig").PublicExplorerSync; + protected globalSettings: CSpellSettingsI | undefined; + /** + * Read / import a cspell configuration file. + * @param filename - the path to the file. + * Supported types: json, yaml, js, and cjs. ES Modules are not supported. + * - absolute path `/absolute/path/to/file` + * - relative path `./path/to/file` (relative to the current working directory) + * - package `@cspell/dict-typescript/cspell-ext.json` + */ + readSettings(filename: string): CSpellSettingsI; + readSettings(filename: string, defaultValues: CSpellSettingsWST): CSpellSettingsI; + /** + * Read / import a cspell configuration file. + * @param filename - the path to the file. + * Supported types: json, yaml, js, and cjs. ES Modules are not supported. + * - absolute path `/absolute/path/to/file` + * - relative path `./path/to/file` (relative to `relativeTo`) + * - package `@cspell/dict-typescript/cspell-ext.json` searches for node_modules relative to `relativeTo` + * @param relativeTo - absolute path to start searching for relative files or node_modules. + */ + readSettings(filename: string, relativeTo?: string): CSpellSettingsI; + readSettings(filename: string, relativeTo: string, defaultValues: CSpellSettingsWST): CSpellSettingsI; + readSettings(filename: string, relativeToOrDefault?: CSpellSettingsWST | string): CSpellSettingsI; + readSettingsAsync(filename: string, relativeTo?: string, pnpSettings?: PnPSettingsOptional): Promise; + /** + * + * @param searchFrom the directory / file to start searching from. + * @param pnpSettings - related to Using Yarn PNP. + * @returns the resulting settings + */ + searchForConfig(searchFrom: string | undefined, pnpSettings?: PnPSettingsOptional): Promise; + private searchConfigLRU; + private _searchForConfig; + getGlobalSettings(): CSpellSettingsI; + clearCachedSettingsFiles(): void; + /** + * Read a config file and inject the fileRef. + * @param fileRef - filename plus context, injected into the resulting config. + */ + protected readConfig(fileRef: ImportFileRef): CSpellSettingsWST; + protected importSettings(fileRef: ImportFileRef, defaultValues: CSpellSettingsWST | undefined, pnpSettings: PnPSettingsOptional): CSpellSettingsI; + /** + * normalizeSettings handles correcting all relative paths, anchoring globs, and importing other config files. + * @param rawSettings - raw configuration settings + * @param pathToSettingsFile - path to the source file of the configuration settings. + */ + protected normalizeSettings(rawSettings: CSpellSettingsWST, pathToSettingsFile: string, pnpSettings: PnPSettingsOptional): CSpellSettingsI; +} +declare class ConfigLoaderInternal extends ConfigLoader { + constructor(cspellIO: CSpellIO); + get _cachedFiles(): Map; + get _cspellConfigExplorer(): import("cosmiconfig").PublicExplorer; + get _cspellConfigExplorerSync(): import("cosmiconfig").PublicExplorerSync; + readonly _readConfig: (fileRef: ImportFileRef) => import("@cspell/cspell-types").CSpellSettingsWithSourceTrace; + readonly _normalizeSettings: (rawSettings: import("@cspell/cspell-types").CSpellSettingsWithSourceTrace, pathToSettingsFile: string, pnpSettings: import("../../../util/types.js").OptionalOrUndefined) => import("../../../Models/CSpellSettingsInternalDef.js").CSpellSettingsInternal; + normalizeSearchForConfigResultAsync(searchPath: string, searchResult: Promise, pnpSettings: PnPSettingsOptional): Promise; + normalizeSearchForConfigResult(searchPath: string, searchResult: SearchForConfigResult | ImportError | undefined, pnpSettings: PnPSettingsOptional): NormalizeSearchForConfigResult; +} +interface SearchForConfigResult { + config: CSpellSettingsI | undefined; + filepath: string; + isEmpty?: boolean; +} +interface NormalizeSearchForConfigResult { + config: CSpellSettingsI; + filepath: string | undefined; + error: ImportError | undefined; +} +/** + * + * @param searchFrom the directory / file to start searching from. + * @param pnpSettings - related to Using Yarn PNP. + * @returns the resulting settings + */ +export declare function searchForConfig(searchFrom: string | undefined, pnpSettings?: PnPSettingsOptional): Promise; +/** + * + * @param searchFrom the directory / file to start searching from. + * @param pnpSettings - related to Using Yarn PNP. + * @returns the resulting settings + * @deprecated + * @deprecationMessage Use `searchForConfig`. It is very difficult to support Sync files when settings include web requests. + */ +export declare function searchForConfigSync(searchFrom: string | undefined, pnpSettings?: PnPSettingsOptional): CSpellSettingsI | undefined; +/** + * Load a CSpell configuration files. + * @param file - path or package reference to load. + * @param pnpSettings - PnP settings + * @returns normalized CSpellSettings + */ +export declare function loadConfig(file: string, pnpSettings?: PnPSettingsOptional): Promise; +/** + * Load a CSpell configuration files. + * @param filename - path or package reference to load. + * @param pnpSettings - PnP settings + * @returns normalized CSpellSettings + * @deprecated + */ +export declare function loadConfigSync(filename: string, pnpSettings?: PnPSettingsOptional): CSpellSettingsI; +export declare function loadPnP(pnpSettings: PnPSettingsOptional, searchFrom: Uri): Promise; +export declare function loadPnPSync(pnpSettings: PnPSettingsOptional, searchFrom: Uri): LoaderResult; +export declare function readRawSettings(filename: string, relativeTo?: string): CSpellSettingsWST; +export declare function getGlobalSettings(): CSpellSettingsI; +export declare function getCachedFileSize(): number; +export declare function clearCachedSettingsFiles(): void; +declare function validateRawConfigVersion(config: CSpellUserSettings | { + version: unknown; +}, fileRef: ImportFileRef): void; +declare function validateRawConfigExports(config: CSpellUserSettings, fileRef: ImportFileRef): void; +export declare function createConfigLoader(cspellIO?: CSpellIO): ConfigLoader; +declare function getDefaultConfigLoaderInternal(): ConfigLoaderInternal; +export declare function getDefaultConfigLoader(): ConfigLoader; +export declare const __testing__: { + getDefaultConfigLoaderInternal: typeof getDefaultConfigLoaderInternal; + normalizeCacheSettings: typeof normalizeCacheSettings; + validateRawConfigExports: typeof validateRawConfigExports; + validateRawConfigVersion: typeof validateRawConfigVersion; +}; +export {}; +//# sourceMappingURL=configLoader.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/configLoader.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/configLoader.mjs new file mode 100644 index 000000000..4659ba6ae --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/configLoader.mjs @@ -0,0 +1,476 @@ +import * as json from 'comment-json'; +import { cosmiconfig, cosmiconfigSync } from 'cosmiconfig'; +import { getDefaultCSpellIO } from 'cspell-io'; +import * as path from 'path'; +import { createCSpellSettingsInternal as csi } from '../../../Models/CSpellSettingsInternalDef.mjs'; +import { AutoResolveLRUCache } from '../../../util/AutoResolveLRUCache.mjs'; +import { logError, logWarning } from '../../../util/logger.mjs'; +import { resolveFile } from '../../../util/resolveFile.mjs'; +import { toUri } from '../../../util/Uri.mjs'; +import { configSettingsFileVersion0_1, configSettingsFileVersion0_2, currentSettingsFileVersion, ENV_CSPELL_GLOB_ROOT, } from '../../constants.mjs'; +import { mergeSettings } from '../../CSpellSettingsServer.mjs'; +import { getRawGlobalSettings } from '../../GlobalSettings.mjs'; +import { ImportError } from '../ImportError.mjs'; +import { pnpLoader } from '../pnpLoader.mjs'; +import { defaultSettings } from './defaultSettings.mjs'; +import { normalizeCacheSettings, normalizeDictionaryDefs, normalizeGitignoreRoot, normalizeLanguageSettings, normalizeOverrides, normalizeRawConfig, normalizeReporters, normalizeSettingsGlobs, } from './normalizeRawSettings.mjs'; +import { defaultPnPSettings, normalizePnPSettings } from './PnPSettings.mjs'; +const supportedCSpellConfigVersions = [configSettingsFileVersion0_2]; +const setOfSupportedConfigVersions = Object.freeze(new Set(supportedCSpellConfigVersions)); +export const sectionCSpell = 'cSpell'; +export const defaultFileName = 'cspell.json'; +const gcl = getDefaultConfigLoaderInternal; +const CACHE_SIZE_SEARCH_CONFIG = 32; +/** + * Logic of the locations: + * - Support backward compatibility with the VS Code Spell Checker + * the spell checker extension can only write to `.json` files because + * it would be too difficult to automatically modify a `.js` or `.cjs` file. + * - To support `cspell.config.js` in a VS Code environment, have a `cspell.json` import + * the `cspell.config.js`. + */ +const searchPlaces = Object.freeze([ + 'package.json', + // Original locations + '.cspell.json', + 'cspell.json', + '.cSpell.json', + 'cSpell.json', + // Original locations jsonc + '.cspell.jsonc', + 'cspell.jsonc', + // Alternate locations + '.vscode/cspell.json', + '.vscode/cSpell.json', + '.vscode/.cspell.json', + // Standard Locations + 'cspell.config.json', + 'cspell.config.jsonc', + 'cspell.config.yaml', + 'cspell.config.yml', + 'cspell.yaml', + 'cspell.yml', + // Dynamic config is looked for last + 'cspell.config.js', + 'cspell.config.cjs', + // .config + '.config/.cspell.json', + '.config/cspell.json', + '.config/.cSpell.json', + '.config/cSpell.json', + '.config/.cspell.jsonc', + '.config/cspell.jsonc', + '.config/cspell.config.json', + '.config/cspell.config.jsonc', + '.config/cspell.config.yaml', + '.config/cspell.config.yml', + '.config/cspell.yaml', + '.config/cspell.yml', + '.config/cspell.config.js', + '.config/cspell.config.cjs', +]); +const cspellCosmiconfig = { + searchPlaces: searchPlaces.concat(), + loaders: { + '.json': parseJson, + '.jsonc': parseJson, + }, +}; +function parseJson(_filename, content) { + return json.parse(content); +} +export const defaultConfigFilenames = Object.freeze(searchPlaces.concat()); +let defaultConfigLoader = undefined; +export class ConfigLoader { + /** + * Use `createConfigLoader` + * @param cspellIO - CSpellIO interface for reading files. + */ + constructor(cspellIO) { + this.cspellIO = cspellIO; + this.cachedFiles = new Map(); + this.cspellConfigExplorer = cosmiconfig('cspell', cspellCosmiconfig); + this.cspellConfigExplorerSync = cosmiconfigSync('cspell', cspellCosmiconfig); + this.searchConfigLRU = new AutoResolveLRUCache(CACHE_SIZE_SEARCH_CONFIG, (a, b) => a.searchFrom === b.searchFrom && a.pnpSettings === b.pnpSettings); + } + readSettings(filename, relativeToOrDefault, defaultValue) { + // console.log('Read Settings: %o', { filename, relativeToOrDefault }); + const relativeTo = (typeof relativeToOrDefault === 'string' ? relativeToOrDefault : '') || process.cwd(); + defaultValue = defaultValue || (typeof relativeToOrDefault !== 'string' ? relativeToOrDefault : undefined); + const ref = resolveFilename(filename, relativeTo); + return this.importSettings(ref, defaultValue, defaultValue || defaultPnPSettings); + } + async readSettingsAsync(filename, relativeTo, pnpSettings) { + const ref = resolveFilename(filename, relativeTo || process.cwd()); + return this.importSettings(ref, undefined, pnpSettings || defaultPnPSettings); + } + /** + * + * @param searchFrom the directory / file to start searching from. + * @param pnpSettings - related to Using Yarn PNP. + * @returns the resulting settings + */ + searchForConfig(searchFrom, pnpSettings = defaultPnPSettings) { + pnpSettings = normalizePnPSettings(pnpSettings); + return this.searchConfigLRU.get({ searchFrom, pnpSettings }, (p) => this._searchForConfig(p)); + } + _searchForConfig(params) { + // console.log('_searchForConfig: %o', { params, stats: this.searchConfigLRU.stats() }); + return gcl() + .normalizeSearchForConfigResultAsync(params.searchFrom || process.cwd(), this.cspellConfigExplorer.search(params.searchFrom), params.pnpSettings) + .then((r) => (r.filepath ? r.config : undefined)); + } + getGlobalSettings() { + if (!this.globalSettings) { + const globalConf = getRawGlobalSettings(); + this.globalSettings = { + id: 'global_config', + ...this.normalizeSettings(globalConf || {}, './global_config', {}), + }; + } + return this.globalSettings; + } + clearCachedSettingsFiles() { + this.searchConfigLRU.clear(); + this.globalSettings = undefined; + this.cachedFiles.clear(); + this.cspellConfigExplorer.clearCaches(); + this.cspellConfigExplorerSync.clearCaches(); + } + /** + * Read a config file and inject the fileRef. + * @param fileRef - filename plus context, injected into the resulting config. + */ + readConfig(fileRef) { + // cspellConfigExplorerSync + const { filename, error } = fileRef; + if (error) { + fileRef.error = + error instanceof ImportError + ? error + : new ImportError(`Failed to read config file: "${filename}"`, error); + return { __importRef: fileRef }; + } + const s = {}; + try { + const r = this.cspellConfigExplorerSync.load(filename); + if (!r?.config) + throw new Error(`not found: "${filename}"`); + Object.assign(s, r.config); + normalizeRawConfig(s); + validateRawConfig(s, fileRef); + } + catch (err) { + fileRef.error = + err instanceof ImportError ? err : new ImportError(`Failed to read config file: "${filename}"`, err); + } + s.__importRef = fileRef; + return s; + } + importSettings(fileRef, defaultValues, pnpSettings) { + defaultValues = defaultValues ?? defaultSettings; + const { filename } = fileRef; + const importRef = { ...fileRef }; + const cached = this.cachedFiles.get(filename); + if (cached) { + const cachedImportRef = cached.__importRef || importRef; + cachedImportRef.referencedBy = mergeSourceList(cachedImportRef.referencedBy || [], importRef.referencedBy); + cached.__importRef = cachedImportRef; + return cached; + } + const id = [path.basename(path.dirname(filename)), path.basename(filename)].join('/'); + const name = ''; + const finalizeSettings = csi({ id, name, __importRef: importRef }); + this.cachedFiles.set(filename, finalizeSettings); // add an empty entry to prevent circular references. + const settings = { ...defaultValues, id, name, ...this.readConfig(importRef) }; + Object.assign(finalizeSettings, this.normalizeSettings(settings, filename, pnpSettings)); + const finalizeSrc = { name: path.basename(filename), ...finalizeSettings.source }; + finalizeSettings.source = { ...finalizeSrc, filename }; + this.cachedFiles.set(filename, finalizeSettings); + return finalizeSettings; + } + /** + * normalizeSettings handles correcting all relative paths, anchoring globs, and importing other config files. + * @param rawSettings - raw configuration settings + * @param pathToSettingsFile - path to the source file of the configuration settings. + */ + normalizeSettings(rawSettings, pathToSettingsFile, pnpSettings) { + const id = rawSettings.id || + [path.basename(path.dirname(pathToSettingsFile)), path.basename(pathToSettingsFile)].join('/'); + const name = rawSettings.name || id; + // Try to load any .pnp files before reading dictionaries or other config files. + const { usePnP = pnpSettings.usePnP, pnpFiles = pnpSettings.pnpFiles } = rawSettings; + const pnpSettingsToUse = normalizePnPSettings({ usePnP, pnpFiles }); + const pathToSettingsDir = path.dirname(pathToSettingsFile); + loadPnPSync(pnpSettingsToUse, toUri(pathToSettingsDir)); + // Fix up dictionaryDefinitions + const settings = { + version: defaultSettings.version, + ...rawSettings, + id, + name, + globRoot: resolveGlobRoot(rawSettings, pathToSettingsFile), + languageSettings: normalizeLanguageSettings(rawSettings.languageSettings), + }; + const pathToSettings = path.dirname(pathToSettingsFile); + const normalizedDictionaryDefs = normalizeDictionaryDefs(settings, pathToSettingsFile); + const normalizedSettingsGlobs = normalizeSettingsGlobs(settings, pathToSettingsFile); + const normalizedOverrides = normalizeOverrides(settings, pathToSettingsFile); + const normalizedReporters = normalizeReporters(settings, pathToSettingsFile); + const normalizedGitignoreRoot = normalizeGitignoreRoot(settings, pathToSettingsFile); + const normalizedCacheSettings = normalizeCacheSettings(settings, pathToSettingsDir); + const imports = typeof settings.import === 'string' ? [settings.import] : settings.import || []; + const source = settings.source || { + name: settings.name, + filename: pathToSettingsFile, + }; + const fileSettings = csi({ + ...settings, + source, + ...normalizedDictionaryDefs, + ...normalizedSettingsGlobs, + ...normalizedOverrides, + ...normalizedReporters, + ...normalizedGitignoreRoot, + ...normalizedCacheSettings, + }); + if (!imports.length) { + return fileSettings; + } + const importedSettings = imports + .map((name) => resolveFilename(name, pathToSettings)) + .map((ref) => ((ref.referencedBy = [source]), ref)) + .map((ref) => this.importSettings(ref, undefined, pnpSettingsToUse)) + .reduce((a, b) => mergeSettings(a, b)); + const finalizeSettings = mergeSettings(importedSettings, fileSettings); + finalizeSettings.name = settings.name || finalizeSettings.name || ''; + finalizeSettings.id = settings.id || finalizeSettings.id || ''; + return finalizeSettings; + } +} +class ConfigLoaderInternal extends ConfigLoader { + constructor(cspellIO) { + super(cspellIO); + this._readConfig = this.readConfig.bind(this); + this._normalizeSettings = this.normalizeSettings.bind(this); + } + get _cachedFiles() { + return this.cachedFiles; + } + get _cspellConfigExplorer() { + return this.cspellConfigExplorer; + } + get _cspellConfigExplorerSync() { + return this.cspellConfigExplorerSync; + } + async normalizeSearchForConfigResultAsync(searchPath, searchResult, pnpSettings) { + let result; + try { + result = (await searchResult) || undefined; + } + catch (cause) { + result = new ImportError(`Failed to find config file at: "${searchPath}"`, cause); + } + return this.normalizeSearchForConfigResult(searchPath, result, pnpSettings); + } + normalizeSearchForConfigResult(searchPath, searchResult, pnpSettings) { + const error = searchResult instanceof ImportError ? searchResult : undefined; + const result = searchResult instanceof ImportError ? undefined : searchResult; + const filepath = result?.filepath; + if (filepath) { + const cached = cachedFiles().get(filepath); + if (cached) { + return { + config: cached, + filepath, + error, + }; + } + } + const { config = csi({}) } = result || {}; + const filename = result?.filepath ?? searchPath; + const importRef = { filename: filename, error }; + const id = [path.basename(path.dirname(filename)), path.basename(filename)].join('/'); + const name = result?.filepath ? id : `Config not found: ${id}`; + const finalizeSettings = csi({ id, name, __importRef: importRef }); + const settings = { id, ...config }; + cachedFiles().set(filename, finalizeSettings); // add an empty entry to prevent circular references. + Object.assign(finalizeSettings, this.normalizeSettings(settings, filename, pnpSettings)); + return { + config: finalizeSettings, + filepath, + error, + }; + } +} +function mergeSourceList(orig, append) { + const collection = new Map(orig.map((s) => [s.name + (s.filename || ''), s])); + for (const s of append || []) { + const key = s.name + (s.filename || ''); + if (!collection.has(key)) { + collection.set(key, s); + } + } + return [...collection.values()]; +} +/** + * + * @param searchFrom the directory / file to start searching from. + * @param pnpSettings - related to Using Yarn PNP. + * @returns the resulting settings + */ +export function searchForConfig(searchFrom, pnpSettings = defaultPnPSettings) { + return gcl().searchForConfig(searchFrom, pnpSettings); +} +/** + * + * @param searchFrom the directory / file to start searching from. + * @param pnpSettings - related to Using Yarn PNP. + * @returns the resulting settings + * @deprecated + * @deprecationMessage Use `searchForConfig`. It is very difficult to support Sync files when settings include web requests. + */ +export function searchForConfigSync(searchFrom, pnpSettings = defaultPnPSettings) { + pnpSettings = normalizePnPSettings(pnpSettings); + let searchResult; + try { + searchResult = cspellConfigExplorerSync().search(searchFrom) || undefined; + } + catch (err) { + searchResult = new ImportError(`Failed to find config file from: "${searchFrom}"`, err); + } + return gcl().normalizeSearchForConfigResult(searchFrom || process.cwd(), searchResult, pnpSettings).config; +} +/** + * Load a CSpell configuration files. + * @param file - path or package reference to load. + * @param pnpSettings - PnP settings + * @returns normalized CSpellSettings + */ +export async function loadConfig(file, pnpSettings = defaultPnPSettings) { + return gcl().readSettingsAsync(file, undefined, pnpSettings); +} +/** + * Load a CSpell configuration files. + * @param filename - path or package reference to load. + * @param pnpSettings - PnP settings + * @returns normalized CSpellSettings + * @deprecated + */ +export function loadConfigSync(filename, pnpSettings = defaultPnPSettings) { + const pnp = normalizePnPSettings(pnpSettings); + return gcl().readSettings(filename, pnp); +} +export function loadPnP(pnpSettings, searchFrom) { + if (!pnpSettings.usePnP) { + return Promise.resolve(undefined); + } + const loader = pnpLoader(pnpSettings.pnpFiles); + return loader.load(searchFrom); +} +export function loadPnPSync(pnpSettings, searchFrom) { + if (!pnpSettings.usePnP) { + return undefined; + } + const loader = pnpLoader(pnpSettings.pnpFiles); + return loader.loadSync(searchFrom); +} +export function readRawSettings(filename, relativeTo) { + relativeTo = relativeTo || process.cwd(); + const ref = resolveFilename(filename, relativeTo); + return gcl()._readConfig(ref); +} +function resolveFilename(filename, relativeTo) { + const r = resolveFile(filename, relativeTo); + return { + filename: r.filename, + error: r.found ? undefined : new Error(`Failed to resolve file: "${filename}"`), + }; +} +export function getGlobalSettings() { + return gcl().getGlobalSettings(); +} +export function getCachedFileSize() { + return cachedFiles().size; +} +export function clearCachedSettingsFiles() { + return gcl().clearCachedSettingsFiles(); +} +const nestedConfigDirectories = { + '.vscode': true, + '.config': true, +}; +function resolveGlobRoot(settings, pathToSettingsFile) { + const settingsFileDirRaw = path.dirname(pathToSettingsFile); + const settingsFileDirName = path.basename(settingsFileDirRaw); + const isNestedConfig = settingsFileDirName in nestedConfigDirectories; + const isVSCode = settingsFileDirName === '.vscode'; + const settingsFileDir = isNestedConfig ? path.dirname(settingsFileDirRaw) : settingsFileDirRaw; + const envGlobRoot = process.env[ENV_CSPELL_GLOB_ROOT]; + const defaultGlobRoot = envGlobRoot ?? '${cwd}'; + const rawRoot = settings.globRoot ?? + (settings.version === configSettingsFileVersion0_1 || + (envGlobRoot && !settings.version) || + (isVSCode && !settings.version) + ? defaultGlobRoot + : settingsFileDir); + const globRoot = rawRoot.startsWith('${cwd}') ? rawRoot : path.resolve(settingsFileDir, rawRoot); + return globRoot; +} +function validationMessage(msg, fileRef) { + return msg + `\n File: "${fileRef.filename}"`; +} +function validateRawConfigVersion(config, fileRef) { + const { version } = config; + if (version === undefined) + return; + if (typeof version !== 'string') { + logError(validationMessage(`Unsupported config file version: "${version}", string expected`, fileRef)); + return; + } + if (setOfSupportedConfigVersions.has(version)) + return; + if (!/^\d+(\.\d+)*$/.test(version)) { + logError(validationMessage(`Unsupported config file version: "${version}"`, fileRef)); + return; + } + const msg = version > currentSettingsFileVersion + ? `Newer config file version found: "${version}". Supported version is "${currentSettingsFileVersion}"` + : `Legacy config file version found: "${version}", upgrade to "${currentSettingsFileVersion}"`; + logWarning(validationMessage(msg, fileRef)); +} +function validateRawConfigExports(config, fileRef) { + if (config.default) { + throw new ImportError(validationMessage('Module `export default` is not supported.\n Use `module.exports =` instead.', fileRef)); + } +} +function validateRawConfig(config, fileRef) { + const validations = [validateRawConfigExports, validateRawConfigVersion]; + validations.forEach((fn) => fn(config, fileRef)); +} +function createConfigLoaderInternal(cspellIO) { + return new ConfigLoaderInternal(cspellIO ?? getDefaultCSpellIO()); +} +export function createConfigLoader(cspellIO) { + return createConfigLoaderInternal(cspellIO); +} +function getDefaultConfigLoaderInternal() { + if (defaultConfigLoader) + return defaultConfigLoader; + return (defaultConfigLoader = createConfigLoaderInternal()); +} +export function getDefaultConfigLoader() { + return getDefaultConfigLoaderInternal(); +} +function cachedFiles() { + return gcl()._cachedFiles; +} +function cspellConfigExplorerSync() { + return gcl()._cspellConfigExplorerSync; +} +export const __testing__ = { + getDefaultConfigLoaderInternal, + normalizeCacheSettings, + validateRawConfigExports, + validateRawConfigVersion, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/defaultSettings.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/defaultSettings.d.mts new file mode 100644 index 000000000..9e13749c9 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/defaultSettings.d.mts @@ -0,0 +1,3 @@ +import type { CSpellSettingsI } from './types.mjs'; +export declare const defaultSettings: CSpellSettingsI; +//# sourceMappingURL=defaultSettings.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/defaultSettings.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/defaultSettings.mjs new file mode 100644 index 000000000..27296bd6b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/defaultSettings.mjs @@ -0,0 +1,7 @@ +import { createCSpellSettingsInternal as csi } from '../../../Models/CSpellSettingsInternalDef.mjs'; +import { currentSettingsFileVersion } from '../../constants.mjs'; +export const defaultSettings = csi({ + id: 'default', + name: 'default', + version: currentSettingsFileVersion, +}); diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/extractImportErrors.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/extractImportErrors.d.mts new file mode 100644 index 000000000..de2f09b41 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/extractImportErrors.d.mts @@ -0,0 +1,7 @@ +import type { ImportFileRef } from '@cspell/cspell-types'; +import type { CSpellSettingsWST } from './types.mjs'; +export declare function extractImportErrors(settings: CSpellSettingsWST): ImportFileRefWithError[]; +export interface ImportFileRefWithError extends ImportFileRef { + error: Error; +} +//# sourceMappingURL=extractImportErrors.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/extractImportErrors.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/extractImportErrors.mjs new file mode 100644 index 000000000..8e3d97f3b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/extractImportErrors.mjs @@ -0,0 +1,21 @@ +export function extractImportErrors(settings) { + const imports = mergeImportRefs(settings); + return !imports ? [] : [...imports.values()].filter(isImportFileRefWithError); +} +function mergeImportRefs(left, right = {}) { + const imports = new Map(left.__imports || []); + if (left.__importRef) { + imports.set(left.__importRef.filename, left.__importRef); + } + if (right.__importRef) { + imports.set(right.__importRef.filename, right.__importRef); + } + const rightImports = right.__imports?.values() || []; + for (const ref of rightImports) { + imports.set(ref.filename, ref); + } + return imports.size ? imports : undefined; +} +function isImportFileRefWithError(ref) { + return !!ref.error; +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/index.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/index.d.mts new file mode 100644 index 000000000..a6afe91c1 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/index.d.mts @@ -0,0 +1,5 @@ +export { __testing__, clearCachedSettingsFiles, ConfigLoader, createConfigLoader, defaultConfigFilenames, defaultFileName, getCachedFileSize, getGlobalSettings, loadConfig, loadConfigSync, loadPnP, loadPnPSync, readRawSettings, searchForConfig, searchForConfigSync, sectionCSpell, } from './configLoader.mjs'; +export { extractImportErrors, ImportFileRefWithError } from './extractImportErrors.mjs'; +export { readSettings } from './readSettings.mjs'; +export { readSettingsFiles } from './readSettingsFiles.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/index.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/index.mjs new file mode 100644 index 000000000..84d1e61fc --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/index.mjs @@ -0,0 +1,4 @@ +export { __testing__, clearCachedSettingsFiles, ConfigLoader, createConfigLoader, defaultConfigFilenames, defaultFileName, getCachedFileSize, getGlobalSettings, loadConfig, loadConfigSync, loadPnP, loadPnPSync, readRawSettings, searchForConfig, searchForConfigSync, sectionCSpell, } from './configLoader.mjs'; +export { extractImportErrors } from './extractImportErrors.mjs'; +export { readSettings } from './readSettings.mjs'; +export { readSettingsFiles } from './readSettingsFiles.mjs'; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/normalizeRawSettings.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/normalizeRawSettings.d.mts new file mode 100644 index 000000000..e780c0f73 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/normalizeRawSettings.d.mts @@ -0,0 +1,51 @@ +import type { CSpellUserSettings, GlobDef, LanguageSetting } from '@cspell/cspell-types'; +import type { OptionalOrUndefined } from '../../../util/types.mjs'; +interface NormalizableFields { + version?: string | number; +} +export declare function normalizeRawConfig(config: CSpellUserSettings | NormalizableFields): void; +type NormalizeDictionaryDefsParams = OptionalOrUndefined>; +export declare function normalizeDictionaryDefs(settings: NormalizeDictionaryDefsParams, pathToSettingsFile: string): import("../../../util/types.js").RemoveUndefined<{ + dictionaryDefinitions: import("../../../Models/CSpellSettingsInternalDef.js").DictionaryDefinitionInternalWithSource[] | undefined; + languageSettings: import("../../../util/types.js").RemoveUndefined<{ + dictionaryDefinitions: import("../../../Models/CSpellSettingsInternalDef.js").DictionaryDefinitionInternalWithSource[] | undefined; + languageId: string | string[]; + locale?: string | string[]; + local?: string | string[]; + id?: string; + name?: string; + description?: string; + enabled?: boolean; + allowCompoundWords?: boolean; + caseSensitive?: boolean; + dictionaries?: string[]; + noSuggestDictionaries?: string[]; + ignoreRegExpList?: import("@cspell/cspell-types").RegExpPatternList; + includeRegExpList?: import("@cspell/cspell-types").RegExpPatternList; + patterns?: import("@cspell/cspell-types").RegExpPatternDefinition[]; + words?: string[]; + flagWords?: string[]; + ignoreWords?: string[]; + suggestWords?: string[]; + parser?: string; + }>[] | undefined; +}>; +type NormalizeOverrides = Pick; +type NormalizeOverridesResult = Pick; +export declare function normalizeOverrides(settings: NormalizeOverrides, pathToSettingsFile: string): NormalizeOverridesResult; +type NormalizeReporters = Pick; +export declare function normalizeReporters(settings: NormalizeReporters, pathToSettingsFile: string): NormalizeReporters; +export declare function normalizeLanguageSettings(languageSettings: LanguageSetting[] | undefined): LanguageSetting[] | undefined; +type NormalizeGitignoreRoot = Pick; +export declare function normalizeGitignoreRoot(settings: NormalizeGitignoreRoot, pathToSettingsFile: string): NormalizeGitignoreRoot; +interface NormalizeSettingsGlobs { + globRoot?: CSpellUserSettings['globRoot']; + ignorePaths?: CSpellUserSettings['ignorePaths']; +} +interface NormalizeSettingsGlobsResult { + ignorePaths?: GlobDef[]; +} +export declare function normalizeSettingsGlobs(settings: NormalizeSettingsGlobs, pathToSettingsFile: string): NormalizeSettingsGlobsResult; +export declare function normalizeCacheSettings(settings: Pick, pathToSettingsDir: string): Pick; +export {}; +//# sourceMappingURL=normalizeRawSettings.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/normalizeRawSettings.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/normalizeRawSettings.mjs new file mode 100644 index 000000000..4b4e1ef6b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/normalizeRawSettings.mjs @@ -0,0 +1,103 @@ +import * as path from 'path'; +import { resolveFile } from '../../../util/resolveFile.mjs'; +import * as util from '../../../util/util.mjs'; +import { mapDictDefsToInternal } from '../../DictionarySettings.mjs'; +import { toGlobDef } from './toGlobDef.mjs'; +export function normalizeRawConfig(config) { + if (typeof config.version === 'number') { + config.version = config.version.toString(); + } +} +export function normalizeDictionaryDefs(settings, pathToSettingsFile) { + const dictionaryDefinitions = mapDictDefsToInternal(settings.dictionaryDefinitions, pathToSettingsFile); + const languageSettings = settings.languageSettings?.map((langSetting) => util.clean({ + ...langSetting, + dictionaryDefinitions: mapDictDefsToInternal(langSetting.dictionaryDefinitions, pathToSettingsFile), + })); + return util.clean({ + dictionaryDefinitions, + languageSettings, + }); +} +export function normalizeOverrides(settings, pathToSettingsFile) { + const { globRoot = path.dirname(pathToSettingsFile) } = settings; + const overrides = settings.overrides?.map((override) => { + const filename = toGlobDef(override.filename, globRoot, pathToSettingsFile); + const { dictionaryDefinitions, languageSettings } = normalizeDictionaryDefs(override, pathToSettingsFile); + return util.clean({ + ...override, + filename, + dictionaryDefinitions, + languageSettings: normalizeLanguageSettings(languageSettings), + }); + }); + return overrides ? { overrides } : {}; +} +export function normalizeReporters(settings, pathToSettingsFile) { + if (settings.reporters === undefined) + return {}; + const folder = path.dirname(pathToSettingsFile); + function resolve(s) { + if (s === 'default') + return s; + const r = resolveFile(s, folder); + if (!r.found) { + throw new Error(`Not found: "${s}"`); + } + return r.filename; + } + function resolveReporter(s) { + if (typeof s === 'string') { + return resolve(s); + } + if (!Array.isArray(s) || typeof s[0] !== 'string') + throw new Error('Invalid Reporter'); + // Preserve the shape of Reporter Setting while resolving the reporter file. + const [r, ...rest] = s; + return [resolve(r), ...rest]; + } + return { + reporters: settings.reporters.map(resolveReporter), + }; +} +export function normalizeLanguageSettings(languageSettings) { + if (!languageSettings) + return undefined; + function fixLocale(s) { + const { local: locale, ...rest } = s; + return util.clean({ locale, ...rest }); + } + return languageSettings.map(fixLocale); +} +export function normalizeGitignoreRoot(settings, pathToSettingsFile) { + const { gitignoreRoot } = settings; + if (!gitignoreRoot) + return {}; + const dir = path.dirname(pathToSettingsFile); + const roots = Array.isArray(gitignoreRoot) ? gitignoreRoot : [gitignoreRoot]; + return { + gitignoreRoot: roots.map((p) => path.resolve(dir, p)), + }; +} +export function normalizeSettingsGlobs(settings, pathToSettingsFile) { + const { globRoot } = settings; + if (settings.ignorePaths === undefined) + return {}; + const ignorePaths = toGlobDef(settings.ignorePaths, globRoot, pathToSettingsFile); + return { + ignorePaths, + }; +} +export function normalizeCacheSettings(settings, pathToSettingsDir) { + const { cache } = settings; + if (cache === undefined) + return {}; + const { cacheLocation } = cache; + if (cacheLocation === undefined) + return { cache }; + return { cache: { ...cache, cacheLocation: resolveFilePath(cacheLocation, pathToSettingsDir) } }; +} +function resolveFilePath(filename, pathToSettingsFile) { + const cwd = process.cwd(); + return path.resolve(pathToSettingsFile, filename.replace('${cwd}', cwd)); +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettings.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettings.d.mts new file mode 100644 index 000000000..50b85af0e --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettings.d.mts @@ -0,0 +1,23 @@ +import type { CSpellSettingsI, CSpellSettingsWST } from './types.mjs'; +/** + * Read / import a cspell configuration file. + * @param filename - the path to the file. + * Supported types: json, yaml, js, and cjs. ES Modules are not supported. + * - absolute path `/absolute/path/to/file` + * - relative path `./path/to/file` (relative to the current working directory) + * - package `@cspell/dict-typescript/cspell-ext.json` + */ +export declare function readSettings(filename: string): CSpellSettingsI; +export declare function readSettings(filename: string, defaultValues: CSpellSettingsWST): CSpellSettingsI; +/** + * Read / import a cspell configuration file. + * @param filename - the path to the file. + * Supported types: json, yaml, js, and cjs. ES Modules are not supported. + * - absolute path `/absolute/path/to/file` + * - relative path `./path/to/file` (relative to `relativeTo`) + * - package `@cspell/dict-typescript/cspell-ext.json` searches for node_modules relative to `relativeTo` + * @param relativeTo - absolute path to start searching for relative files or node_modules. + */ +export declare function readSettings(filename: string, relativeTo: string): CSpellSettingsI; +export declare function readSettings(filename: string, relativeTo: string, defaultValues: CSpellSettingsWST): CSpellSettingsI; +//# sourceMappingURL=readSettings.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettings.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettings.mjs new file mode 100644 index 000000000..3348e2377 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettings.mjs @@ -0,0 +1,7 @@ +import { getDefaultConfigLoader } from './configLoader.mjs'; +export function readSettings(filename, relativeToOrDefault, defaultValue) { + const loader = getDefaultConfigLoader(); + if (typeof relativeToOrDefault !== 'string' || defaultValue === undefined) + return loader.readSettings(filename, relativeToOrDefault); + return loader.readSettings(filename, relativeToOrDefault, defaultValue); +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettingsFiles.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettingsFiles.d.mts new file mode 100644 index 000000000..1893a859e --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettingsFiles.d.mts @@ -0,0 +1,9 @@ +import type { CSpellSettingsI } from './types.mjs'; +/** + * + * @param filenames - settings files to read + * @returns combined configuration + * @deprecated true + */ +export declare function readSettingsFiles(filenames: string[]): CSpellSettingsI; +//# sourceMappingURL=readSettingsFiles.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettingsFiles.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettingsFiles.mjs new file mode 100644 index 000000000..b142fb607 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/readSettingsFiles.mjs @@ -0,0 +1,12 @@ +import { mergeSettings } from '../../CSpellSettingsServer.mjs'; +import { defaultSettings } from './defaultSettings.mjs'; +import { readSettings } from './readSettings.mjs'; +/** + * + * @param filenames - settings files to read + * @returns combined configuration + * @deprecated true + */ +export function readSettingsFiles(filenames) { + return filenames.map((filename) => readSettings(filename)).reduce((a, b) => mergeSettings(a, b), defaultSettings); +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/toGlobDef.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/toGlobDef.d.mts new file mode 100644 index 000000000..ba8333e80 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/toGlobDef.d.mts @@ -0,0 +1,6 @@ +import type { Glob, GlobDef } from '@cspell/cspell-types'; +export declare function toGlobDef(g: undefined, root: string | undefined, source: string | undefined): undefined; +export declare function toGlobDef(g: Glob, root: string | undefined, source: string | undefined): GlobDef; +export declare function toGlobDef(g: Glob[], root: string | undefined, source: string | undefined): GlobDef[]; +export declare function toGlobDef(g: Glob | Glob[], root: string | undefined, source: string | undefined): GlobDef | GlobDef[]; +//# sourceMappingURL=toGlobDef.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/toGlobDef.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/toGlobDef.mjs new file mode 100644 index 000000000..011c0b0c3 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/toGlobDef.mjs @@ -0,0 +1,18 @@ +export function toGlobDef(g, root, source) { + if (g === undefined) + return undefined; + if (Array.isArray(g)) { + return g.map((g) => toGlobDef(g, root, source)); + } + if (typeof g === 'string') { + const glob = { glob: g }; + if (root !== undefined) { + glob.root = root; + } + return toGlobDef(glob, root, source); + } + if (source) { + return { ...g, source }; + } + return g; +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/types.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/types.d.mts new file mode 100644 index 000000000..a266954ae --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/types.d.mts @@ -0,0 +1,5 @@ +import type { CSpellSettingsWithSourceTrace } from '@cspell/cspell-types'; +import type { CSpellSettingsInternal } from '../../../Models/CSpellSettingsInternalDef.mjs'; +export type CSpellSettingsWST = CSpellSettingsWithSourceTrace; +export type CSpellSettingsI = CSpellSettingsInternal; +//# sourceMappingURL=types.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/types.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/types.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/configLoader/types.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/index.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/index.d.mts new file mode 100644 index 000000000..1a9d7cb37 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/index.d.mts @@ -0,0 +1,2 @@ +export { SettingsController } from './SettingsController.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/index.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/index.mjs new file mode 100644 index 000000000..e547385e3 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/index.mjs @@ -0,0 +1 @@ +export { SettingsController } from './SettingsController.mjs'; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/pnpLoader.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/pnpLoader.d.mts new file mode 100644 index 000000000..deffc1d4e --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/pnpLoader.d.mts @@ -0,0 +1,29 @@ +import type { Uri } from '../../util/Uri.mjs'; +export type LoaderResult = Uri | undefined; +export declare class PnpLoader { + readonly pnpFiles: string[]; + private cacheKeySuffix; + constructor(pnpFiles?: string[]); + /** + * Request that the nearest .pnp file gets loaded + * @param uriDirectory starting directory + * @returns promise - rejects on error - success if loaded or not found. + */ + load(uriDirectory: Uri): Promise; + peek(uriDirectory: Uri): Promise; + /** + * Request that the nearest .pnp file gets loaded + * @param uriDirectory starting directory + * @returns promise - rejects on error - success if loaded or not found. + */ + loadSync(uriDirectory: Uri): LoaderResult; + peekSync(uriDirectory: Uri): LoaderResult; + /** + * Clears the cached so .pnp files will get reloaded on request. + */ + clearCache(): Promise; + private calcKey; +} +export declare function pnpLoader(pnpFiles?: string[]): PnpLoader; +export declare function clearPnPGlobalCache(): Promise; +//# sourceMappingURL=pnpLoader.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/Controller/pnpLoader.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/pnpLoader.mjs new file mode 100644 index 000000000..958643d1d --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/Controller/pnpLoader.mjs @@ -0,0 +1,133 @@ +/** + * Handles loading of `.pnp.js` and `.pnp.js` files. + */ +import clearModule from 'clear-module'; +import findUp from 'find-up'; +import importFresh from 'import-fresh'; +import { toUri, uriToFilePath } from '../../util/Uri.mjs'; +import { UnsupportedPnpFile } from './ImportError.mjs'; +const defaultPnpFiles = ['.pnp.cjs', '.pnp.js']; +const supportedSchemas = new Set(['file']); +const cachedRequests = new Map(); +let lock = undefined; +const cachedPnpImportsSync = new Map(); +const cachedRequestsSync = new Map(); +export class PnpLoader { + constructor(pnpFiles = defaultPnpFiles) { + this.pnpFiles = pnpFiles; + this.cacheKeySuffix = ':' + pnpFiles.join(); + } + /** + * Request that the nearest .pnp file gets loaded + * @param uriDirectory starting directory + * @returns promise - rejects on error - success if loaded or not found. + */ + async load(uriDirectory) { + if (!supportedSchemas.has(uriDirectory.scheme)) + return undefined; + await lock; + const cacheKey = this.calcKey(uriDirectory); + const cached = cachedRequests.get(cacheKey); + if (cached) + return cached; + const r = findPnpAndLoad(uriDirectory, this.pnpFiles); + cachedRequests.set(cacheKey, r); + const result = await r; + cachedRequestsSync.set(cacheKey, result); + return result; + } + async peek(uriDirectory) { + if (!supportedSchemas.has(uriDirectory.scheme)) + return undefined; + await lock; + const cacheKey = this.calcKey(uriDirectory); + return cachedRequests.get(cacheKey) ?? Promise.resolve(undefined); + } + /** + * Request that the nearest .pnp file gets loaded + * @param uriDirectory starting directory + * @returns promise - rejects on error - success if loaded or not found. + */ + loadSync(uriDirectory) { + if (!supportedSchemas.has(uriDirectory.scheme)) + return undefined; + const cacheKey = this.calcKey(uriDirectory); + const cached = cachedRequestsSync.get(cacheKey); + if (cached) + return cached; + const r = findPnpAndLoadSync(uriDirectory, this.pnpFiles); + cachedRequestsSync.set(cacheKey, r); + cachedRequests.set(cacheKey, Promise.resolve(r)); + return r; + } + peekSync(uriDirectory) { + if (!supportedSchemas.has(uriDirectory.scheme)) + return undefined; + const cacheKey = this.calcKey(uriDirectory); + return cachedRequestsSync.get(cacheKey); + } + /** + * Clears the cached so .pnp files will get reloaded on request. + */ + clearCache() { + return clearPnPGlobalCache(); + } + calcKey(uriDirectory) { + return uriDirectory.toString() + this.cacheKeySuffix; + } +} +export function pnpLoader(pnpFiles) { + return new PnpLoader(pnpFiles); +} +/** + * @param uriDirectory - directory to start at. + */ +async function findPnpAndLoad(uriDirectory, pnpFiles) { + const found = await findUp(pnpFiles, { cwd: uriToFilePath(uriDirectory) }); + return loadPnpIfNeeded(found); +} +/** + * @param uriDirectory - directory to start at. + */ +function findPnpAndLoadSync(uriDirectory, pnpFiles) { + const found = findUp.sync(pnpFiles, { cwd: uriToFilePath(uriDirectory) }); + return loadPnpIfNeeded(found); +} +function loadPnpIfNeeded(found) { + if (!found) + return undefined; + const c = cachedPnpImportsSync.get(found); + if (c || cachedPnpImportsSync.has(found)) + return c; + const r = loadPnp(found); + cachedPnpImportsSync.set(found, r); + return r; +} +function loadPnp(pnpFile) { + const pnp = importFresh(pnpFile); + if (pnp.setup) { + pnp.setup(); + return toUri(pnpFile); + } + throw new UnsupportedPnpFile(`Unsupported pnp file: "${pnpFile}"`); +} +export function clearPnPGlobalCache() { + if (lock) + return lock; + lock = _cleanCache().finally(() => { + lock = undefined; + }); + return lock; +} +async function _cleanCache() { + await Promise.all([...cachedRequests.values()].map(rejectToUndefined)); + const modules = [...cachedPnpImportsSync.values()]; + modules.forEach((r) => r && clearModule.single(uriToFilePath(r))); + cachedRequests.clear(); + cachedRequestsSync.clear(); + cachedPnpImportsSync.clear(); + return undefined; +} +function rejectToUndefined(p) { + return p.catch(() => undefined); +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/DefaultSettings.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/DefaultSettings.d.mts new file mode 100644 index 000000000..e1d9d44e2 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/DefaultSettings.d.mts @@ -0,0 +1,6 @@ +import type { CSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.mjs'; +export declare const _defaultSettingsBasis: Readonly; +export declare const _defaultSettings: Readonly; +export declare function getDefaultSettings(useDefaultDictionaries?: boolean): CSpellSettingsInternal; +export declare function getDefaultBundledSettings(): CSpellSettingsInternal; +//# sourceMappingURL=DefaultSettings.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/DefaultSettings.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/DefaultSettings.mjs new file mode 100644 index 000000000..05702fa23 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/DefaultSettings.mjs @@ -0,0 +1,161 @@ +import { parsers } from 'cspell-grammar'; +import { srcDirectory } from '../../lib-cjs/index.cjs'; +import { createCSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.mjs'; +import { PatternRegExp } from '../Models/PatternRegExp.mjs'; +import { resolveFile } from '../util/resolveFile.mjs'; +import { readSettings } from './Controller/configLoader/index.mjs'; +import { mergeSettings } from './CSpellSettingsServer.mjs'; +import * as LanguageSettings from './LanguageSettings.mjs'; +import * as RegPat from './RegExpPatterns.mjs'; +const defaultConfigFileModuleRef = '@cspell/cspell-bundled-dicts/cspell-default.json'; +// Do not use require.resolve because webpack will mess it up. +const defaultConfigFile = resolveConfigModule(defaultConfigFileModuleRef); +const regExpSpellCheckerDisable = [ + new PatternRegExp(RegPat.regExSpellingGuardBlock), + new PatternRegExp(RegPat.regExSpellingGuardLine), + new PatternRegExp(RegPat.regExSpellingGuardNext), +]; +// cspell:ignore filetypes +const predefinedPatterns = [ + // Exclude patterns + { name: 'CommitHash', pattern: RegPat.regExCommitHash }, + { name: 'CommitHashLink', pattern: RegPat.regExCommitHashLink }, + { name: 'CStyleHexValue', pattern: RegPat.regExCStyleHexValue }, + { name: 'CSSHexValue', pattern: RegPat.regExCSSHexValue }, + { name: 'Urls', pattern: RegPat.regExMatchUrls }, + { name: 'HexValues', pattern: RegPat.regExMatchCommonHexFormats }, + { name: 'SpellCheckerDisable', pattern: regExpSpellCheckerDisable }, + { name: 'PublicKey', pattern: RegPat.regExPublicKey }, + { name: 'RsaCert', pattern: RegPat.regExCert }, + { name: 'SshRsa', pattern: RegPat.regExSshRSA }, + { name: 'EscapeCharacters', pattern: RegPat.regExEscapeCharacters }, + { name: 'Base64', pattern: RegPat.regExBase64 }, + { name: 'Base64SingleLine', pattern: RegPat.regExBase64SingleLine }, + { name: 'Base64MultiLine', pattern: RegPat.regExBase64MultiLine }, + { name: 'Email', pattern: RegPat.regExEmail }, + { name: 'SHA', pattern: RegPat.regExSha }, + { name: 'HashStrings', pattern: RegPat.regExHashStrings }, + { name: 'UnicodeRef', pattern: RegPat.regExUnicodeRef }, + { name: 'UUID', pattern: RegPat.regExUUID }, + { name: 'href', pattern: RegPat.regExHRef }, + { name: 'SpellCheckerDisableBlock', pattern: RegPat.regExSpellingGuardBlock }, + { name: 'SpellCheckerDisableLine', pattern: RegPat.regExSpellingGuardLine }, + { name: 'SpellCheckerDisableNext', pattern: RegPat.regExSpellingGuardNext }, + { name: 'SpellCheckerIgnoreInDocSetting', pattern: RegPat.regExIgnoreSpellingDirectives }, + // Include Patterns + { name: 'PhpHereDoc', pattern: RegPat.regExPhpHereDoc }, + { name: 'string', pattern: RegPat.regExString }, + { name: 'CStyleComment', pattern: RegPat.regExCStyleComments }, + { name: 'Everything', pattern: '.*' }, +]; +const defaultRegExpPatterns = [...predefinedPatterns].map(normalizePattern); +const definedDefaultRegExpExcludeList = [ + 'SpellCheckerDisable', + 'SpellCheckerIgnoreInDocSetting', + 'Urls', + 'Email', + 'RsaCert', + 'SshRsa', + 'Base64MultiLine', + 'Base64SingleLine', + 'CommitHash', + 'CommitHashLink', + 'CStyleHexValue', + 'CSSHexValue', + 'SHA', + 'HashStrings', + 'UnicodeRef', + 'UUID', +]; +// This bit of copying is done to have the complier ensure that the defaults exist. +const defaultRegExpExcludeList = definedDefaultRegExpExcludeList; +export const _defaultSettingsBasis = Object.freeze(createCSpellSettingsInternal({ + id: 'static_defaults', + language: 'en', + name: 'Static Defaults', + enabled: true, + enabledLanguageIds: [], + maxNumberOfProblems: 100, + numSuggestions: 10, + suggestionsTimeout: 500, + suggestionNumChanges: 3, + words: [], + userWords: [], + ignorePaths: [], + allowCompoundWords: false, + patterns: defaultRegExpPatterns, + ignoreRegExpList: [], + languageSettings: [], + source: { name: 'defaultSettings' }, + reporters: [], + plugins: [{ parsers }], +})); +export const _defaultSettings = Object.freeze(createCSpellSettingsInternal({ + ..._defaultSettingsBasis, + enabledLanguageIds: [ + 'ada', + 'csharp', + 'go', + 'javascript', + 'javascriptreact', + 'json', + 'markdown', + 'mdx', + 'php', + 'plaintext', + 'python', + 'text', + 'typescript', + 'typescriptreact', + 'haskell', + 'html', + 'css', + 'less', + 'scss', + 'latex', + 'ruby', + 'rust', + 'shellscript', + 'toml', + ], + ignoreRegExpList: defaultRegExpExcludeList, + languageSettings: LanguageSettings.getDefaultLanguageSettings(), +})); +const getSettings = (function () { + let settings = undefined; + return function (useDefaultDictionaries) { + if (!useDefaultDictionaries) { + return _defaultSettingsBasis; + } + if (!settings) { + const jsonSettings = readSettings(defaultConfigFile); + settings = mergeSettings(_defaultSettings, jsonSettings); + if (jsonSettings.name !== undefined) { + settings.name = jsonSettings.name; + } + else { + delete settings.name; + } + } + return settings; + }; +})(); +function resolveConfigModule(configModuleName) { + return resolveFile(configModuleName, srcDirectory).filename; +} +function normalizePattern(pat) { + const { name, pattern, description } = pat; + if (!(pattern instanceof RegExp)) + return pat; + return { + name, + pattern: new PatternRegExp(pattern), + description, + }; +} +export function getDefaultSettings(useDefaultDictionaries = true) { + return getSettings(useDefaultDictionaries); +} +export function getDefaultBundledSettings() { + return getDefaultSettings(); +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/DictionaryReferenceCollection.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/DictionaryReferenceCollection.d.mts new file mode 100644 index 000000000..27959487f --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/DictionaryReferenceCollection.d.mts @@ -0,0 +1,10 @@ +import type { DictionaryId, DictionaryReference } from '@cspell/cspell-types'; +export interface DictionaryReferenceCollection { + isEnabled(name: DictionaryId): boolean | undefined; + isBlocked(name: DictionaryId): boolean | undefined; + enabled(): DictionaryId[]; + blocked(): DictionaryId[]; + dictionaryIds: DictionaryId[]; +} +export declare function createDictionaryReferenceCollection(dictionaries: DictionaryReference[]): DictionaryReferenceCollection; +//# sourceMappingURL=DictionaryReferenceCollection.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/DictionaryReferenceCollection.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/DictionaryReferenceCollection.mjs new file mode 100644 index 000000000..6c4f5955c --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/DictionaryReferenceCollection.mjs @@ -0,0 +1,42 @@ +export function createDictionaryReferenceCollection(dictionaries) { + return new _DictionaryReferenceCollection(dictionaries); +} +class _DictionaryReferenceCollection { + constructor(dictionaries) { + this.dictionaries = dictionaries; + this.collection = collect(dictionaries); + } + isEnabled(name) { + const entry = this.collection[name]; + return entry === undefined ? undefined : !!(entry & 0x1); + } + isBlocked(name) { + const entry = this.collection[name]; + return entry === undefined ? undefined : !(entry & 0x1); + } + enabled() { + return this.dictionaryIds.filter((n) => this.isEnabled(n)); + } + blocked() { + return this.dictionaryIds.filter((n) => this.isBlocked(n)); + } + get dictionaryIds() { + return Object.keys(this.collection); + } +} +function collect(dictionaries) { + const refs = dictionaries.map(normalizeName).map(mapReference); + const col = {}; + for (const ref of refs) { + col[ref.name] = Math.max(ref.weight, col[ref.name] || 0); + } + return col; +} +function normalizeName(entry) { + return entry.normalize().trim(); +} +function mapReference(ref) { + const name = ref.replace(/^!+/, ''); + const weight = ref.length - name.length + 1; + return { name: name.trim(), weight }; +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/DictionarySettings.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/DictionarySettings.d.mts new file mode 100644 index 000000000..1cadf8d54 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/DictionarySettings.d.mts @@ -0,0 +1,27 @@ +import type { DictionaryDefinition } from '@cspell/cspell-types'; +import type { CSpellSettingsInternal, DictionaryDefinitionInternal, DictionaryDefinitionInternalWithSource, DictionaryFileDefinitionInternalWithSource } from '../Models/CSpellSettingsInternalDef.mjs'; +import type { DictionaryReferenceCollection } from './DictionaryReferenceCollection.mjs'; +export type DefMapArrayItem = [string, DictionaryDefinitionInternal]; +/** + * Combines the list of desired dictionaries with the list of dictionary + * definitions. Order does not matter, but the number of leading `!` does. + * + * Excluding dictionaries. + * - Adding `!` to a dictId will remove the dictionary. + * - Adding `!!` will add it back. + * + * @param dictRefCol - dictionaries desired + * @param defs - dictionary definitions + * @returns map from dictIds to definitions + */ +export declare function filterDictDefsToLoad(dictRefCol: DictionaryReferenceCollection, defs: DictionaryDefinitionInternal[]): DictionaryDefinitionInternal[]; +export declare function mapDictDefsToInternal(defs: undefined, pathToSettingsFile: string): undefined; +export declare function mapDictDefsToInternal(defs: DictionaryDefinition[], pathToSettingsFile: string): DictionaryDefinitionInternalWithSource[]; +export declare function mapDictDefsToInternal(defs: DictionaryDefinition[] | undefined, pathToSettingsFile: string): DictionaryDefinitionInternalWithSource[] | undefined; +export declare function mapDictDefToInternal(def: DictionaryDefinition, pathToSettingsFile: string): DictionaryDefinitionInternalWithSource; +export declare function calcDictionaryDefsToLoad(settings: CSpellSettingsInternal): DictionaryDefinitionInternal[]; +export declare function isDictionaryDefinitionWithSource(d: DictionaryDefinition | DictionaryDefinitionInternalWithSource): d is DictionaryDefinitionInternalWithSource; +export declare function isDictionaryDefinitionInternal(def: DictionaryDefinition | DictionaryDefinitionInternal): def is DictionaryDefinitionInternal; +export declare function isDictionaryFileDefinitionInternalWithSource(def: DictionaryDefinition | DictionaryDefinitionInternal): def is DictionaryFileDefinitionInternalWithSource; +export declare function isDictionaryDefinitionInlineInternalWithSource(def: DictionaryDefinition | DictionaryDefinitionInternal): def is DictionaryDefinitionInternalWithSource; +//# sourceMappingURL=DictionarySettings.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/DictionarySettings.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/DictionarySettings.mjs new file mode 100644 index 000000000..af75b74ca --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/DictionarySettings.mjs @@ -0,0 +1,120 @@ +import { mapDictionaryInformationToWeightMap } from 'cspell-trie-lib'; +import * as path from 'path'; +import { isDictionaryDefinitionInlineInternal } from '../Models/CSpellSettingsInternalDef.mjs'; +import { AutoResolveWeakCache } from '../util/AutoResolve.mjs'; +import { resolveFile } from '../util/resolveFile.mjs'; +import { clean } from '../util/util.mjs'; +import { createDictionaryReferenceCollection } from './DictionaryReferenceCollection.mjs'; +/** + * Combines the list of desired dictionaries with the list of dictionary + * definitions. Order does not matter, but the number of leading `!` does. + * + * Excluding dictionaries. + * - Adding `!` to a dictId will remove the dictionary. + * - Adding `!!` will add it back. + * + * @param dictRefCol - dictionaries desired + * @param defs - dictionary definitions + * @returns map from dictIds to definitions + */ +export function filterDictDefsToLoad(dictRefCol, defs) { + const allActiveDefs = defs.filter(({ name }) => dictRefCol.isEnabled(name)).map(fixPath); + return [...new Map(allActiveDefs.map((d) => [d.name, d])).values()]; +} +function fixPath(def) { + if (def instanceof _DictionaryDefinitionInternalWithSource) { + return def; + } + const newPath = fixDicPath(def.path, def.file); + return { + ...def, + file: undefined, + path: newPath, + }; +} +function fixDicPath(defPath, defFile) { + const parts = [defPath || '', defFile || ''].filter((p) => !!p); + return parts.length > 1 ? path.join(...parts) : parts[0] || ''; +} +export function mapDictDefsToInternal(defs, pathToSettingsFile) { + return defs?.map((def) => mapDictDefToInternal(def, pathToSettingsFile)); +} +const internalDefs = new AutoResolveWeakCache(); +export function mapDictDefToInternal(def, pathToSettingsFile) { + return internalDefs.get(def, (def) => _mapDictDefToInternal(def, pathToSettingsFile)); +} +function _mapDictDefToInternal(def, pathToSettingsFile) { + if (isDictionaryDefinitionWithSource(def)) { + return def; + } + if (isDictionaryDefinitionInlineInternal(def)) { + return { ...def, __source: pathToSettingsFile }; + } + return new _DictionaryDefinitionInternalWithSource(def, pathToSettingsFile); +} +function determineName(filename, options) { + return options.name || path.basename(filename); +} +export function calcDictionaryDefsToLoad(settings) { + const { dictionaries = [], dictionaryDefinitions = [], noSuggestDictionaries = [] } = settings; + const colNoSug = createDictionaryReferenceCollection(noSuggestDictionaries); + const colDicts = createDictionaryReferenceCollection(dictionaries.concat(colNoSug.enabled())); + const modDefs = dictionaryDefinitions.map((def) => { + const enabled = colNoSug.isEnabled(def.name); + if (enabled === undefined) + return def; + return { ...def, noSuggest: enabled }; + }); + return filterDictDefsToLoad(colDicts, modDefs); +} +export function isDictionaryDefinitionWithSource(d) { + return isDictionaryFileDefinitionInternalWithSource(d) || isDictionaryDefinitionInlineInternalWithSource(d); +} +export function isDictionaryDefinitionInternal(def) { + return def instanceof _DictionaryDefinitionInternalWithSource; +} +export function isDictionaryFileDefinitionInternalWithSource(def) { + return def instanceof _DictionaryDefinitionInternalWithSource; +} +export function isDictionaryDefinitionInlineInternalWithSource(def) { + return isDictionaryDefinitionInlineInternal(def) && !!def.__source; +} +class _DictionaryDefinitionInternalWithSource { + constructor(def, __source) { + this.__source = __source; + // this bit of assignment is to have the compiler help use if any new fields are added. + const defAll = def; + const { path: relPath = '', file = '', addWords, description, dictionaryInformation, type, repMap, noSuggest, scope, useCompounds, } = defAll; + const defaultPath = path.dirname(__source); + const filePath = fixDicPath(relPath, file); + const name = determineName(filePath, def); + const r = resolveFile(filePath, defaultPath); + const ddi = { + name, + file: undefined, + path: r.filename, + addWords, + description, + dictionaryInformation, + type, + repMap, + noSuggest, + scope, + useCompounds, + }; + Object.assign(this, clean(ddi)); + this.ddi = ddi; + this.name = ddi.name; + this.file = ddi.file; + this.path = ddi.path; + this._weightMap = this.dictionaryInformation + ? mapDictionaryInformationToWeightMap(this.dictionaryInformation) + : undefined; + } + get weightMap() { + return this._weightMap; + } + toJSON() { + return this.ddi; + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/GlobalSettings.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/GlobalSettings.d.mts new file mode 100644 index 000000000..6eedef54f --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/GlobalSettings.d.mts @@ -0,0 +1,11 @@ +import type { CSpellSettings, CSpellSettingsWithSourceTrace } from '@cspell/cspell-types'; +export interface GlobalSettingsWithSource extends Partial { + source: CSpellSettingsWithSourceTrace['source']; +} +export interface GlobalCSpellSettings { + import: CSpellSettings['import']; +} +export declare function getRawGlobalSettings(): GlobalSettingsWithSource; +export declare function writeRawGlobalSettings(settings: GlobalCSpellSettings): Error | undefined; +export declare function getGlobalConfigPath(): string; +//# sourceMappingURL=GlobalSettings.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/GlobalSettings.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/GlobalSettings.mjs new file mode 100644 index 000000000..88874379c --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/GlobalSettings.mjs @@ -0,0 +1,55 @@ +import { format } from 'util'; +import { isErrnoException } from '../util/errors.mjs'; +import { logError } from '../util/logger.mjs'; +import { ConfigStore } from './cfgStore.mjs'; +const packageName = 'cspell'; +export function getRawGlobalSettings() { + const name = 'CSpell Configstore'; + const globalConf = { + source: { + name, + filename: undefined, + }, + }; + try { + // console.warn('%o', ConfigStore); + const cfgStore = new ConfigStore(packageName); + // console.warn('%o', cfgStore); + const cfg = cfgStore.all; + // Only populate globalConf is there are values. + if (cfg && Object.keys(cfg).length) { + Object.assign(globalConf, cfg); + globalConf.source = { + name, + filename: cfgStore.path, + }; + } + } + catch (error) { + if (!isErrnoException(error) || + !error.code || + !['ENOENT', 'EACCES', 'ENOTDIR', 'EISDIR'].includes(error.code)) { + logError(error); + } + } + return globalConf; +} +export function writeRawGlobalSettings(settings) { + const toWrite = { + import: settings.import, + }; + try { + const cfgStore = new ConfigStore(packageName); + cfgStore.set(toWrite); + return undefined; + } + catch (error) { + if (error instanceof Error) + return error; + return new Error(format(error)); + } +} +export function getGlobalConfigPath() { + const cfgStore = new ConfigStore(packageName); + return cfgStore.path; +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/InDocSettings.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/InDocSettings.d.mts new file mode 100644 index 000000000..7d7306c2a --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/InDocSettings.d.mts @@ -0,0 +1,45 @@ +import type { CSpellUserSettings, DictionaryDefinitionInline } from '@cspell/cspell-types'; +import type { Sequence } from 'gensequence'; +import type { ExtendedSuggestion } from '../Models/Suggestion.mjs'; +export type CSpellUserSettingsKeys = keyof CSpellUserSettings; +export interface DirectiveIssue { + /** + * the start and end offsets within the document of the issue. + */ + range: [start: number, end: number]; + /** + * The text causing the issue. + */ + text: string; + message: string; + suggestions: string[]; + suggestionsEx: ExtendedSuggestion[]; +} +export declare function getInDocumentSettings(text: string): CSpellUserSettings; +export declare function validateInDocumentSettings(docText: string, _settings: CSpellUserSettings): Iterable; +export declare const regExSpellingGuardBlock: RegExp; +export declare const regExSpellingGuardNext: RegExp; +export declare const regExSpellingGuardLine: RegExp; +declare function parseCompoundWords(match: string): CSpellUserSettings; +declare function parseWords(match: string): CSpellUserSettings; +declare function parseIgnoreWords(match: string): CSpellUserSettings; +declare function parseIgnoreRegExp(match: string): CSpellUserSettings; +declare function getPossibleInDocSettings(text: string): Sequence; +declare function getWordsFromDocument(text: string): string[]; +export declare function extractInDocDictionary(settings: CSpellUserSettings): DictionaryDefinitionInline | undefined; +export declare function getIgnoreWordsFromDocument(text: string): string[]; +export declare function getIgnoreRegExpFromDocument(text: string): (string | RegExp)[]; +/** + * These internal functions are used exposed for unit testing. + */ +export declare const internal: { + getPossibleInDocSettings: typeof getPossibleInDocSettings; + getWordsFromDocument: typeof getWordsFromDocument; + parseWords: typeof parseWords; + parseCompoundWords: typeof parseCompoundWords; + parseIgnoreRegExp: typeof parseIgnoreRegExp; + parseIgnoreWords: typeof parseIgnoreWords; + staticInDocumentDictionaryName: string; +}; +export {}; +//# sourceMappingURL=InDocSettings.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/InDocSettings.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/InDocSettings.mjs new file mode 100644 index 000000000..735663b1d --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/InDocSettings.mjs @@ -0,0 +1,272 @@ +import { opAppend, opFilter, opMap, pipeSync } from '@cspell/cspell-pipe/sync'; +import { genSequence } from 'gensequence'; +import { createSpellingDictionary } from '../SpellingDictionary/index.mjs'; +import * as Text from '../util/text.mjs'; +import { clean, isDefined } from '../util/util.mjs'; +import { mergeInDocSettings } from './CSpellSettingsServer.mjs'; +// cspell:ignore gimuy +const regExMatchRegEx = /\/.*\/[gimuy]*/; +const regExCSpellInDocDirective = /\b(?:spell-?checker|c?spell)::?(.*)/gi; +const regExCSpellDirectiveKey = /(?<=\b(?:spell-?checker|c?spell)::?)(?!:)(.*)/i; +const regExInFileSettings = [regExCSpellInDocDirective, /\b(LocalWords:?.*)/g]; +const officialDirectives = [ + 'enable', + 'disable', + 'disable-line', + 'disable-next', + 'disable-next-line', + 'word', + 'words', + 'ignore', + 'ignoreWord', + 'ignoreWords', + 'ignore-word', + 'ignore-words', + 'includeRegExp', + 'ignoreRegExp', + 'local', + 'locale', + 'language', + 'dictionaries', + 'dictionary', + 'forbid', + 'forbidWord', + 'forbid-word', + 'flag', + 'flagWord', + 'flag-word', + 'enableCompoundWords', + 'enableAllowCompoundWords', + 'disableCompoundWords', + 'disableAllowCompoundWords', + 'enableCaseSensitive', + 'disableCaseSensitive', +]; +const noSuggestDirectives = new Set(['local']); +const preferredDirectives = [ + 'enable', + 'disable', + 'disable-line', + 'disable-next-line', + 'words', + 'ignore', + 'forbid', + 'locale', + 'dictionary', + 'dictionaries', + 'enableCaseSensitive', + 'disableCaseSensitive', +]; +const allDirectives = new Set(preferredDirectives.concat(officialDirectives)); +const allDirectiveSuggestions = [ + ...pipeSync(allDirectives, opMap((word) => ({ word }))), +]; +const dictInDocSettings = createSpellingDictionary(allDirectives, 'Directives', 'Directive List', { + supportNonStrictSearches: false, +}); +const EmptyWords = []; +Object.freeze(EmptyWords); +const staticInDocumentDictionaryName = `[in-document-dict]`; +export function getInDocumentSettings(text) { + const collectedSettings = getPossibleInDocSettings(text) + .concatMap((a) => parseSettingMatch(a)) + .reduce((s, setting) => { + return mergeInDocSettings(s, setting); + }, { id: 'in-doc-settings' }); + const { words, flagWords, ignoreWords, suggestWords, dictionaries = [], dictionaryDefinitions = [], ...rest } = collectedSettings; + const dict = (words || flagWords || ignoreWords || suggestWords) && + clean({ + name: staticInDocumentDictionaryName, + words, + flagWords, + ignoreWords, + suggestWords, + }); + const dictSettings = dict + ? { + dictionaries: dictionaries.concat(staticInDocumentDictionaryName), + dictionaryDefinitions: dictionaryDefinitions.concat(dict), + } + : clean({ + dictionaries: dictionaries.length ? dictionaries : undefined, + dictionaryDefinitions: dictionaryDefinitions.length ? dictionaryDefinitions : undefined, + }); + const settings = { + ...rest, + ...dictSettings, + }; + // console.log('InDocSettings: %o', settings); + return settings; +} +export function validateInDocumentSettings(docText, _settings) { + return pipeSync(getPossibleInDocSettings(docText), opMap(parseSettingMatchValidation), opFilter(isDefined)); +} +const settingParsers = [ + [/^(?:enable|disable)(?:allow)?CompoundWords\b(?!-)/i, parseCompoundWords], + [/^(?:enable|disable)CaseSensitive\b(?!-)/i, parseCaseSensitive], + [/^enable\b(?!-)/i, parseEnable], + [/^disable(-line|-next(-line)?)?\b(?!-)/i, parseDisable], + [/^words?\b(?!-)/i, parseWords], + [/^ignore(?:-?words?)?\b(?!-)/i, parseIgnoreWords], + [/^(?:flag|forbid)(?:-?words?)?\b(?!-)/i, parseFlagWords], + [/^ignore_?Reg_?Exp\s+.+$/i, parseIgnoreRegExp], + [/^include_?Reg_?Exp\s+.+$/i, parseIncludeRegExp], + [/^locale?\b(?!-)/i, parseLocale], + [/^language\s\b(?!-)/i, parseLocale], + [/^dictionar(?:y|ies)\b(?!-)/i, parseDictionaries], + [/^LocalWords:/, (w) => parseWords(w.replace(/^LocalWords:?/gi, ' '))], +]; +export const regExSpellingGuardBlock = /(\bc?spell(?:-?checker)?::?)\s*disable(?!-line|-next)\b[\s\S]*?((?:\1\s*enable\b)|$)/gi; +export const regExSpellingGuardNext = /\bc?spell(?:-?checker)?::?\s*disable-next\b.*\s\s?.*/gi; +export const regExSpellingGuardLine = /^.*\bc?spell(?:-?checker)?::?\s*disable-line\b.*/gim; +const emptySettings = Object.freeze({}); +const issueMessages = { + unknownDirective: 'Unknown CSpell directive', +}; +function parseSettingMatchValidation(matchArray) { + const [fullMatch = ''] = matchArray; + const directiveMatch = fullMatch.match(regExCSpellDirectiveKey); + if (!directiveMatch) + return undefined; + const match = directiveMatch[1]; + const possibleSetting = match.trim(); + if (!possibleSetting) + return undefined; + const start = (matchArray.index || 0) + (directiveMatch.index || 0) + (match.length - match.trimStart().length); + const text = possibleSetting.replace(/^([-\w]+)?.*/, '$1'); + const end = start + text.length; + if (!text) + return undefined; + const matchingParsers = settingParsers.filter(([regex]) => regex.test(possibleSetting)); + if (matchingParsers.length > 0) + return undefined; + // No matches were found, let make some suggestions. + const dictSugs = dictInDocSettings + .suggest(text, { ignoreCase: false }) + .map(({ word, isPreferred }) => (isPreferred ? { word, isPreferred } : { word })) + .filter((a) => !noSuggestDirectives.has(a.word)); + const sugs = pipeSync(dictSugs, opAppend(allDirectiveSuggestions), filterUniqueSuggestions); + const suggestionsEx = [...sugs].slice(0, 8); + const suggestions = suggestionsEx.map((s) => s.word); + const issue = { + range: [start, end], + text, + message: issueMessages.unknownDirective, + suggestions, + suggestionsEx, + }; + return issue; +} +function* filterUniqueSuggestions(sugs) { + const map = new Map(); + for (const sug of sugs) { + const existing = map.get(sug.word); + if (existing) { + if (sug.isPreferred) { + existing.isPreferred = true; + } + } + yield sug; + } +} +function parseSettingMatch(matchArray) { + const [, match = ''] = matchArray; + const possibleSetting = match.trim(); + return settingParsers + .filter(([regex]) => regex.test(possibleSetting)) + .map(([, fn]) => fn) + .map((fn) => fn(possibleSetting)); +} +function parseCompoundWords(match) { + const allowCompoundWords = /enable/i.test(match); + return { allowCompoundWords }; +} +function parseCaseSensitive(match) { + const caseSensitive = /enable/i.test(match); + return { caseSensitive }; +} +function parseWords(match) { + const words = match + // .replace(/[@#$%^&={}/"]/g, ' ') + .split(/[,\s;]+/g) + .slice(1) + .filter((a) => !!a); + return { words }; +} +function parseLocale(match) { + const parts = match.trim().split(/[\s,]+/); + const language = parts.slice(1).join(','); + return language ? { language } : emptySettings; +} +function parseIgnoreWords(match) { + const wordsSetting = parseWords(match); + const ignoreWords = wordsSetting.words; + return ignoreWords && ignoreWords.length ? { ignoreWords } : emptySettings; +} +function parseFlagWords(match) { + const wordsSetting = parseWords(match); + const flagWords = wordsSetting.words; + return flagWords && flagWords.length ? { flagWords } : emptySettings; +} +function parseRegEx(match) { + const patterns = [match.replace(/^[^\s]+\s+/, '')].map((a) => { + const m = a.match(regExMatchRegEx); + if (m && m[0]) { + return m[0]; + } + return a.replace(/((?:[^\s]|\\ )+).*/, '$1'); + }); + return patterns; +} +function parseIgnoreRegExp(match) { + const ignoreRegExpList = parseRegEx(match); + return { ignoreRegExpList }; +} +function parseIncludeRegExp(match) { + const includeRegExpList = parseRegEx(match); + return { includeRegExpList }; +} +function parseDictionaries(match) { + const dictionaries = match.split(/[,\s]+/g).slice(1); + return { dictionaries }; +} +function getPossibleInDocSettings(text) { + return genSequence(regExInFileSettings).concatMap((regexp) => Text.match(regexp, text)); +} +function getWordsFromDocument(text) { + const dict = extractInDocDictionary(getInDocumentSettings(text)); + return dict?.words || EmptyWords; +} +function parseEnable(_match) { + // Do nothing. Enable / Disable is handled in a different way. + return {}; +} +function parseDisable(_match) { + // Do nothing. Enable / Disable is handled in a different way. + return {}; +} +export function extractInDocDictionary(settings) { + const inDocDicts = settings.dictionaryDefinitions?.filter((def) => def.name === staticInDocumentDictionaryName); + const dict = inDocDicts?.[0]; + return dict; +} +export function getIgnoreWordsFromDocument(text) { + const dict = extractInDocDictionary(getInDocumentSettings(text)); + return dict?.ignoreWords || EmptyWords; +} +export function getIgnoreRegExpFromDocument(text) { + const { ignoreRegExpList = [] } = getInDocumentSettings(text); + return ignoreRegExpList; +} +/** + * These internal functions are used exposed for unit testing. + */ +export const internal = { + getPossibleInDocSettings, + getWordsFromDocument, + parseWords, + parseCompoundWords, + parseIgnoreRegExp, + parseIgnoreWords, + staticInDocumentDictionaryName, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/LanguageSettings.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/LanguageSettings.d.mts new file mode 100644 index 000000000..7bf511385 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/LanguageSettings.d.mts @@ -0,0 +1,18 @@ +import type { BaseSetting, CSpellUserSettings, LanguageId, LanguageSetting, LocaleId } from '@cspell/cspell-types'; +export type LanguageSettings = LanguageSetting[]; +export declare function getDefaultLanguageSettings(): LanguageSettings; +export declare function normalizeLanguageId(langId: LanguageId | LanguageId[]): Set; +export declare function normalizeLocale(locale: LocaleId | LocaleId[]): Set; +export declare function normalizeLocaleIntl(locale: LocaleId | LocaleId[]): Set; +export declare function isLocaleInSet(locale: LocaleId | LocaleId[], setOfLocals: Set): boolean; +/** + * Test if a locale should be ok with Intl + * @param locale - locale string + * @param strict - case must match + * @returns true if it matches the standard 2 letter or 4 letter forms. + */ +export declare function isValidLocaleIntlFormat(locale: LocaleId | LocaleId[], strict?: boolean): boolean; +export declare function calcSettingsForLanguage(languageSettings: LanguageSettings, languageId: LanguageId, locale: LocaleId): BaseSetting; +export declare function calcUserSettingsForLanguage(settings: CSpellUserSettings, languageId: string): CSpellUserSettings; +export declare function calcSettingsForLanguageId(baseSettings: CSpellUserSettings, languageId: LanguageId[] | LanguageId): CSpellUserSettings; +//# sourceMappingURL=LanguageSettings.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/LanguageSettings.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/LanguageSettings.mjs new file mode 100644 index 000000000..dfcc23419 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/LanguageSettings.mjs @@ -0,0 +1,125 @@ +import { autoResolve, autoResolveWeak, createAutoResolveCache } from '../util/AutoResolve.mjs'; +import { doSetsIntersect } from '../util/util.mjs'; +import * as SpellSettings from './CSpellSettingsServer.mjs'; +const defaultLocale = 'en'; +const defaultLanguageSettings = []; +export function getDefaultLanguageSettings() { + return defaultLanguageSettings; +} +function localesToList(locales) { + return stringToList(locales.replace(/\s+/g, ',')); +} +function stringToList(sList) { + return sList + .replace(/[|;]/g, ',') + .split(',') + .map((s) => s.trim()) + .filter((s) => !!s); +} +function memorizer(resolver) { + const cache = createAutoResolveCache(); + return (k) => cache.get(k, resolver); +} +const _normalizeLanguageId = memorizer(__normalizeLanguageId); +function __normalizeLanguageId(langId) { + const langIds = stringToList(langId); + return new Set(langIds.map((a) => a.toLowerCase())); +} +export function normalizeLanguageId(langId) { + return _normalizeLanguageId(typeof langId === 'string' ? langId : langId.join(',')); +} +const _normalizeLocale = memorizer(__normalizeLocale); +function __normalizeLocale(locale) { + const locales = localesToList(locale); + return new Set(locales.map((locale) => locale.toLowerCase().replace(/[^a-z]/g, ''))); +} +export function normalizeLocale(locale) { + locale = typeof locale === 'string' ? locale : locale.join(','); + return _normalizeLocale(locale); +} +export function normalizeLocaleIntl(locale) { + const values = [...normalizeLocale(locale)].map((locale) => locale.replace(/^([a-z]{2})-?([a-z]{2})$/, (_, lang, locale) => locale ? `${lang}-${locale.toUpperCase()}` : lang)); + return new Set(values); +} +export function isLocaleInSet(locale, setOfLocals) { + const locales = normalizeLocale(locale); + return doSetsIntersect(locales, setOfLocals); +} +const regExpValidIntlLocaleStrict = /^[a-z]{2}(-[A-Z]{2})?$/; +const regExpValidIntlLocale = new RegExp(regExpValidIntlLocaleStrict, 'i'); +/** + * Test if a locale should be ok with Intl + * @param locale - locale string + * @param strict - case must match + * @returns true if it matches the standard 2 letter or 4 letter forms. + */ +export function isValidLocaleIntlFormat(locale, strict = false) { + if (typeof locale === 'string') + return strict ? regExpValidIntlLocaleStrict.test(locale) : regExpValidIntlLocale.test(locale); + for (const item of locale) { + if (!isValidLocaleIntlFormat(item, strict)) + return false; + } + return locale.length > 0; +} +const cacheCalcSettingsForLanguage = new WeakMap(); +export function calcSettingsForLanguage(languageSettings, languageId, locale) { + const mapLang = autoResolveWeak(cacheCalcSettingsForLanguage, languageSettings, () => new Map()); + const mapLocale = autoResolve(mapLang, languageId, () => new Map()); + return autoResolve(mapLocale, locale, () => _calcSettingsForLanguage(languageSettings, languageId, locale)); +} +function _calcSettingsForLanguage(languageSettings, languageId, locale) { + languageId = languageId.toLowerCase(); + const allowedLocals = normalizeLocale(locale); + const ls = languageSettings + .filter((s) => doesLanguageSettingMatchLanguageId(s, languageId)) + .filter((s) => !s.locale || s.locale === '*' || isLocaleInSet(s.locale, allowedLocals)) + .map((langSetting) => { + const { languageId: _languageId, locale: _locale, ...s } = langSetting; + return s; + }) + .reduce((langSetting, setting) => SpellSettings.mergeSettings(langSetting, setting), {}); + ls.languageId = languageId; + ls.locale = locale; + return ls; +} +const cacheDoesLanguageSettingMatchLanguageId = new WeakMap(); +function doesLanguageSettingMatchLanguageId(s, languageId) { + const r = cacheDoesLanguageSettingMatchLanguageId.get(s) ?? new Map(); + const f = r.get(languageId); + if (f !== undefined) { + return f; + } + const v = _doesLanguageSettingMatchLanguageId(s, languageId); + r.set(languageId, v); + cacheDoesLanguageSettingMatchLanguageId.set(s, r); + return v; +} +function _doesLanguageSettingMatchLanguageId(s, languageId) { + const languageSettingsLanguageIds = s.languageId; + if (!languageSettingsLanguageIds || languageSettingsLanguageIds === '*') + return true; + const ids = normalizeLanguageId(languageSettingsLanguageIds); + if (ids.has(languageId)) + return true; + if (ids.has('!' + languageId)) + return false; + const numExcludes = [...ids].filter((id) => id.startsWith('!')).length; + return numExcludes === ids.size; +} +export function calcUserSettingsForLanguage(settings, languageId) { + const { languageSettings = [], language: locale = defaultLocale, allowCompoundWords, enabled } = settings; + const langSettings = { + allowCompoundWords, + enabled, + ...calcSettingsForLanguage(languageSettings, languageId, locale), + }; + return SpellSettings.mergeSettings(settings, langSettings); +} +export function calcSettingsForLanguageId(baseSettings, languageId) { + const langIds = ['*'].concat(languageId instanceof Array ? languageId : [languageId]); + const langSettings = langIds.reduce((settings, languageId) => { + return calcUserSettingsForLanguage(settings, languageId); + }, baseSettings); + return langSettings; +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/RegExpPatterns.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/RegExpPatterns.d.mts new file mode 100644 index 000000000..f7f0f6d1c --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/RegExpPatterns.d.mts @@ -0,0 +1,46 @@ +export declare const regExMatchUrls: RegExp; +export declare const regExHRef: RegExp; +export declare const regExMatchCommonHexFormats: RegExp; +export declare const regExCommitHash: RegExp; +export declare const regExCommitHashLink: RegExp; +export declare const regExCStyleHexValue: RegExp; +export declare const regExCSSHexValue: RegExp; +export declare const regExUUID: RegExp; +export declare const regExUnicodeRef: RegExp; +export declare const regExSpellingGuardBlock: RegExp; +export declare const regExSpellingGuardNext: RegExp; +export declare const regExSpellingGuardLine: RegExp; +export declare const regExIgnoreSpellingDirectives: RegExp; +export declare const regExPublicKey: RegExp; +export declare const regExCert: RegExp; +export declare const regExSshRSA: RegExp; +export declare const regExEscapeCharacters: RegExp; +export declare const regExBase64: RegExp; +/** + * Detect a string of characters that look like a Base64 string. + * + * It must be: + * - at least 40 characters + * - contain at least 1 of [0-9+=] + * - end at the end of the line or with [,"'\] + */ +export declare const regExBase64SingleLine: RegExp; +export declare const regExBase64MultiLine: RegExp; +export declare const regExPhpHereDoc: RegExp; +export declare const regExString: RegExp; +export declare const regExCStyleComments: RegExp; +export declare const rexExPythonStyleComments: RegExp; +export declare const regExEmail: RegExp; +export declare const regExRepeatedChar: RegExp; +export declare const regExSha: RegExp; +/** + * Detect common hash strings like: + * - `sha1`, `sha256`, `sha512` + * - `md5` + * - `base64` - used in email + * - `crypt`, `bcrypt`, `script` + * - `token` + * - `assertion` - use with jwt + */ +export declare const regExHashStrings: RegExp; +//# sourceMappingURL=RegExpPatterns.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/RegExpPatterns.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/RegExpPatterns.mjs new file mode 100644 index 000000000..046c69857 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/RegExpPatterns.mjs @@ -0,0 +1,53 @@ +// Exclude Expressions +// cSpell:ignore anrvtbf +export const regExMatchUrls = /(?:https?|ftp):\/\/[^\s"]+/gi; +export const regExHRef = /\bhref\s*=\s*".*?"/gi; +export const regExMatchCommonHexFormats = /(?:#[0-9a-f]{3,8})|(?:0x[0-9a-f]+)|(?:\\u[0-9a-f]{4})|(?:\\x\{[0-9a-f]{4}\})/gi; +export const regExCommitHash = /\b(?![a-f]+\b)(?:0x)?[0-9a-f]{7,}\b/gi; // Match Commit Hashes that contain at least one digit. +export const regExCommitHashLink = /\[[0-9a-f]{7,}\]/gi; // Match Commit Hash Markdown link: [abcdef0]. +export const regExCStyleHexValue = /\b0x[0-9a-f]+\b/gi; +export const regExCSSHexValue = /#[0-9a-f]{3,8}\b/gi; +export const regExUUID = /\b[0-9a-fx]{8}-[0-9a-fx]{4}-[0-9a-fx]{4}-[0-9a-fx]{4}-[0-9a-fx]{12}\b/gi; // x - represents placeholder values +export const regExUnicodeRef = /\bU\+[0-9a-f]{4,5}(?:-[0-9a-f]{4,5})?/gi; +export const regExSpellingGuardBlock = /(\bc?spell(?:-?checker)?::?)\s*disable(?!-line|-next)\b(?!-)[\s\S]*?((?:\1\s*enable\b)|$)/gi; +export const regExSpellingGuardNext = /\bc?spell(?:-?checker)?::?\s*disable-next\b.*\s\s?.*/gi; +export const regExSpellingGuardLine = /^.*\bc?spell(?:-?checker)?::?\s*disable-line\b.*/gim; +export const regExIgnoreSpellingDirectives = /\bc?spell(?:-?checker)?::?\s*ignoreRegExp.*/gim; +export const regExPublicKey = /-{5}BEGIN\s+((?:RSA\s+)?PUBLIC\s+KEY)[\w=+\-/=\\\s]+?END\s+\1-{5}/g; +export const regExCert = /-{5}BEGIN\s+(CERTIFICATE|(?:RSA\s+)?(?:PRIVATE|PUBLIC)\s+KEY)[\w=+\-/=\\\s]+?END\s+\1-{5}/g; +export const regExSshRSA = /ssh-rsa\s+[a-z0-9/+]{28,}={0,3}(?![a-z0-9/+=])/gi; +export const regExEscapeCharacters = /\\(?:[anrvtbf]|[xu][a-f0-9]+)/gi; +export const regExBase64 = /(??/gi; +export const regExRepeatedChar = /^(\w)\1{3,}$/i; +export const regExSha = /\bsha\d+-[a-z0-9+/]{25,}={0,3}/gi; +/** + * Detect common hash strings like: + * - `sha1`, `sha256`, `sha512` + * - `md5` + * - `base64` - used in email + * - `crypt`, `bcrypt`, `script` + * - `token` + * - `assertion` - use with jwt + */ +export const regExHashStrings = /(?:\b(?:sha\d+|md5|base64|crypt|bcrypt|scrypt|security-token|assertion)[-,:$=]|#code[/])[-\w/+%.]{25,}={0,3}(?:(['"])\s*\+?\s*\1?[-\w/+%.]+={0,3})*(?![-\w/+=%.])/gi; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/TextDocumentSettings.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/TextDocumentSettings.d.mts new file mode 100644 index 000000000..43d65c44b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/TextDocumentSettings.d.mts @@ -0,0 +1,5 @@ +import type { CSpellSettings, CSpellUserSettings } from '@cspell/cspell-types'; +import type { CSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.mjs'; +export declare function combineTextAndLanguageSettings(settings: CSpellUserSettings, text: string | undefined, languageId: string | string[]): CSpellSettingsInternal; +export declare function extractSettingsFromText(text: string): CSpellSettings; +//# sourceMappingURL=TextDocumentSettings.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/TextDocumentSettings.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/TextDocumentSettings.mjs new file mode 100644 index 000000000..eb3bf0c14 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/TextDocumentSettings.mjs @@ -0,0 +1,16 @@ +import * as CSpellSettingsServer from './CSpellSettingsServer.mjs'; +import { getInDocumentSettings } from './InDocSettings.mjs'; +import { calcSettingsForLanguageId } from './LanguageSettings.mjs'; +export function combineTextAndLanguageSettings(settings, text, languageId) { + if (!text) { + return CSpellSettingsServer.toInternalSettings(calcSettingsForLanguageId(settings, languageId)); + } + const docSettings = extractSettingsFromText(text); + const settingsForText = CSpellSettingsServer.mergeSettings(settings, docSettings); + const langSettings = calcSettingsForLanguageId(settingsForText, languageId); + // Merge again, to force In-Doc settings. + return CSpellSettingsServer.mergeSettings(langSettings, docSettings); +} +export function extractSettingsFromText(text) { + return getInDocumentSettings(text); +} diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/cfgStore.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/cfgStore.d.mts new file mode 100644 index 000000000..44303b455 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/cfgStore.d.mts @@ -0,0 +1,4 @@ +import ConfigStoreExport from 'configstore'; +export type ConfigStore = typeof ConfigStoreExport; +export declare const ConfigStore: typeof ConfigStoreExport; +//# sourceMappingURL=cfgStore.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/cfgStore.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/cfgStore.mjs new file mode 100644 index 000000000..bc66e2ba8 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/cfgStore.mjs @@ -0,0 +1,2 @@ +import ConfigStoreExport from 'configstore'; +export const ConfigStore = ConfigStoreExport; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/constants.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/constants.d.mts new file mode 100644 index 000000000..426ea8429 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/constants.d.mts @@ -0,0 +1,5 @@ +export declare const configSettingsFileVersion0_1 = "0.1"; +export declare const configSettingsFileVersion0_2 = "0.2"; +export declare const currentSettingsFileVersion = "0.2"; +export declare const ENV_CSPELL_GLOB_ROOT = "CSPELL_GLOB_ROOT"; +//# sourceMappingURL=constants.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/constants.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/constants.mjs new file mode 100644 index 000000000..c9441a450 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/constants.mjs @@ -0,0 +1,4 @@ +export const configSettingsFileVersion0_1 = '0.1'; +export const configSettingsFileVersion0_2 = '0.2'; +export const currentSettingsFileVersion = configSettingsFileVersion0_2; +export const ENV_CSPELL_GLOB_ROOT = 'CSPELL_GLOB_ROOT'; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/index.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/index.d.mts new file mode 100644 index 000000000..c4dfbef98 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/index.d.mts @@ -0,0 +1,7 @@ +export { currentSettingsFileVersion, ENV_CSPELL_GLOB_ROOT } from './constants.mjs'; +export { clearCachedSettingsFiles, defaultConfigFilenames, defaultFileName, extractImportErrors, getCachedFileSize, getGlobalSettings, loadConfig, loadPnP, loadPnPSync, readRawSettings, readSettings, readSettingsFiles, searchForConfig, sectionCSpell, } from './Controller/configLoader/index.mjs'; +export { ImportError } from './Controller/ImportError.mjs'; +export type { ConfigurationDependencies, ImportFileRefWithError } from './CSpellSettingsServer.mjs'; +export { calcOverrideSettings, checkFilenameMatchesGlob, extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, } from './CSpellSettingsServer.mjs'; +export { getDefaultBundledSettings, getDefaultSettings } from './DefaultSettings.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/index.link.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/index.link.d.mts new file mode 100644 index 000000000..6aea5bae4 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/index.link.d.mts @@ -0,0 +1,3 @@ +export type { AddPathsToGlobalImportsResults, ListGlobalImportsResult, ListGlobalImportsResults, RemovePathsFromGlobalImportsResult, ResolveSettingsResult, } from './link.mjs'; +export { addPathsToGlobalImports, listGlobalImports, removePathsFromGlobalImports } from './link.mjs'; +//# sourceMappingURL=index.link.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/index.link.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/index.link.mjs new file mode 100644 index 000000000..189c4204d --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/index.link.mjs @@ -0,0 +1 @@ +export { addPathsToGlobalImports, listGlobalImports, removePathsFromGlobalImports } from './link.mjs'; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/index.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/index.mjs new file mode 100644 index 000000000..2fb32ce77 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/index.mjs @@ -0,0 +1,5 @@ +export { currentSettingsFileVersion, ENV_CSPELL_GLOB_ROOT } from './constants.mjs'; +export { clearCachedSettingsFiles, defaultConfigFilenames, defaultFileName, extractImportErrors, getCachedFileSize, getGlobalSettings, loadConfig, loadPnP, loadPnPSync, readRawSettings, readSettings, readSettingsFiles, searchForConfig, sectionCSpell, } from './Controller/configLoader/index.mjs'; +export { ImportError } from './Controller/ImportError.mjs'; +export { calcOverrideSettings, checkFilenameMatchesGlob, extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, } from './CSpellSettingsServer.mjs'; +export { getDefaultBundledSettings, getDefaultSettings } from './DefaultSettings.mjs'; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/link.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/link.d.mts new file mode 100644 index 000000000..dde233e24 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/link.d.mts @@ -0,0 +1,50 @@ +import type { CSpellSettingsWithSourceTrace } from '@cspell/cspell-types'; +export interface ListGlobalImportsResult { + filename: string; + name: string | undefined; + id: string | undefined; + error: string | undefined; + dictionaryDefinitions: CSpellSettingsWithSourceTrace['dictionaryDefinitions']; + languageSettings: CSpellSettingsWithSourceTrace['languageSettings']; + package: NodePackage | undefined; +} +export interface ListGlobalImportsResults { + list: ListGlobalImportsResult[]; + globalSettings: CSpellSettingsWithSourceTrace; +} +interface NodePackage { + name: string | undefined; + filename: string; +} +export declare function listGlobalImports(): ListGlobalImportsResults; +export interface AddPathsToGlobalImportsResults { + success: boolean; + resolvedSettings: ResolveSettingsResult[]; + error: string | undefined; +} +export declare function addPathsToGlobalImports(paths: string[]): AddPathsToGlobalImportsResults; +export interface RemovePathsFromGlobalImportsResult { + success: boolean; + error: string | undefined; + removed: string[]; +} +/** + * Remove files from the global setting. + * @param paths match against the partial file path, or package name, or id. + * To match against a partial file path, it must match against the subdirectory and filename. + * Note: for Idempotent reasons, asking to remove a path that is not in the global settings is considered a success. + * It is possible to check for this by looking at the returned list of removed paths. + */ +export declare function removePathsFromGlobalImports(paths: string[]): RemovePathsFromGlobalImportsResult; +export interface ResolveSettingsResult { + filename: string; + resolvedToFilename: string | undefined; + error?: string; + settings: CSpellSettingsWithSourceTrace; +} +declare function findPackageForCSpellConfig(pathToConfig: string): NodePackage | undefined; +export declare const __testing__: { + findPackageForCSpellConfig: typeof findPackageForCSpellConfig; +}; +export {}; +//# sourceMappingURL=link.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/link.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/link.mjs new file mode 100644 index 000000000..b921e4092 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/link.mjs @@ -0,0 +1,136 @@ +import * as fs from 'fs'; +import * as Path from 'path'; +import { clean } from '../util/util.mjs'; +import { readRawSettings } from './Controller/configLoader/index.mjs'; +import { getRawGlobalSettings, writeRawGlobalSettings } from './GlobalSettings.mjs'; +export function listGlobalImports() { + const globalSettings = getRawGlobalSettings(); + const list = resolveImports(globalSettings).map(({ filename, settings, error }) => ({ + filename, + error, + id: settings.id, + name: settings.name, + dictionaryDefinitions: settings.dictionaryDefinitions, + languageSettings: settings.languageSettings, + package: findPackageForCSpellConfig(Path.dirname(filename)), + })); + return { + list, + globalSettings, + }; +} +function isString(s) { + return s !== undefined; +} +export function addPathsToGlobalImports(paths) { + const resolvedSettings = paths.map(resolveSettings); + const hasError = resolvedSettings.filter((r) => !!r.error).length > 0; + if (hasError) { + return { + success: false, + resolvedSettings, + error: 'Unable to resolve files.', + }; + } + const rawGlobalSettings = getRawGlobalSettings(); + const resolvedImports = resolveImports(rawGlobalSettings); + const imports = new Set(resolvedImports.map((r) => r.resolvedToFilename || r.filename)); + resolvedSettings + .map((s) => s.resolvedToFilename) + .filter(isString) + .reduce((imports, s) => imports.add(s), imports); + const globalSettings = { + import: [...imports], + }; + const error = writeRawGlobalSettings(globalSettings); + return { + success: !error, + error: error?.message, + resolvedSettings, + }; +} +/** + * Remove files from the global setting. + * @param paths match against the partial file path, or package name, or id. + * To match against a partial file path, it must match against the subdirectory and filename. + * Note: for Idempotent reasons, asking to remove a path that is not in the global settings is considered a success. + * It is possible to check for this by looking at the returned list of removed paths. + */ +export function removePathsFromGlobalImports(paths) { + const listResult = listGlobalImports(); + const toRemove = new Set(); + function matchPackage(pathToRemove) { + return ({ package: pkg, id }) => pathToRemove === pkg?.name || pathToRemove === id; + } + function compareFilenames(fullPath, partialPath) { + if (fullPath === partialPath) + return true; + if (!fullPath.endsWith(partialPath)) + return false; + const c = fullPath[fullPath.length - partialPath.length - 1]; + return c === Path.sep || c === Path.posix.sep; + } + function matchFilename(pathToRemove) { + return Path.dirname(pathToRemove) != '.' + ? ({ filename }) => compareFilenames(filename, pathToRemove) + : () => false; + } + paths + .map((a) => a.trim()) + .filter((a) => !!a) + .forEach((pathToRemove) => { + const excludePackage = matchPackage(pathToRemove); + const excludeFilename = matchFilename(pathToRemove); + const shouldExclude = (r) => excludePackage(r) || excludeFilename(r); + for (const r of listResult.list) { + if (shouldExclude(r)) { + toRemove.add(r.filename); + } + } + }); + const toImport = normalizeImports(listResult.globalSettings.import).filter((p) => !toRemove.has(p)); + const updatedSettings = { + import: toImport, + }; + const error = toRemove.size > 0 ? writeRawGlobalSettings(updatedSettings) : undefined; + return { + success: true, + removed: [...toRemove], + error: error?.toString(), + }; +} +function resolveSettings(filename) { + const settings = readRawSettings(filename); + const ref = settings.__importRef; + const resolvedToFilename = ref?.filename; + const error = ref?.error?.message || (!resolvedToFilename && 'File not Found') || undefined; + return clean({ + filename, + resolvedToFilename, + error, + settings, + }); +} +function normalizeImports(imports) { + return typeof imports === 'string' ? [imports] : imports || []; +} +function resolveImports(s) { + const imported = normalizeImports(s.import); + return imported.map(resolveSettings); +} +function findPackageForCSpellConfig(pathToConfig) { + try { + const filename = Path.join(pathToConfig, 'package.json'); + const pkg = JSON.parse(fs.readFileSync(filename, 'utf8')); + return { + filename, + name: pkg['name'], + }; + } + catch (e) { + return undefined; + } +} +export const __testing__ = { + findPackageForCSpellConfig, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/patterns.d.mts b/action/node_modules/cspell-lib/dist/esm/Settings/patterns.d.mts new file mode 100644 index 000000000..17026098c --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/patterns.d.mts @@ -0,0 +1,3 @@ +import type { RegExpPatternDefinition } from '@cspell/cspell-types'; +export declare function resolvePatterns(regExpList?: (string | RegExp)[], patternDefinitions?: RegExpPatternDefinition[]): RegExp[]; +//# sourceMappingURL=patterns.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/Settings/patterns.mjs b/action/node_modules/cspell-lib/dist/esm/Settings/patterns.mjs new file mode 100644 index 000000000..0bcc13160 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/Settings/patterns.mjs @@ -0,0 +1,27 @@ +import { stringToRegExp } from '../util/textRegex.mjs'; +import { isDefined } from '../util/util.mjs'; +export function resolvePatterns(regExpList = [], patternDefinitions = []) { + const patternMap = new Map(patternDefinitions.map((def) => [def.name.toLowerCase(), def.pattern])); + const resolved = new Set(); + function resolvePattern(p) { + if (resolved.has(p)) + return undefined; + resolved.add(p); + return patternMap.get(p.toString().toLowerCase()) || p; + } + function* flatten(patterns) { + for (const pattern of patterns) { + if (Array.isArray(pattern)) { + yield* flatten(pattern.map(resolvePattern).filter(isDefined)); + } + else { + yield pattern; + } + } + } + const patternList = regExpList.map(resolvePattern).filter(isDefined); + return [...flatten(patternList)].map(toRegExp).filter(isDefined); +} +function toRegExp(pattern) { + return pattern instanceof RegExp ? new RegExp(pattern) : stringToRegExp(pattern, 'gim', 'g'); +} diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/Dictionaries.d.mts b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/Dictionaries.d.mts new file mode 100644 index 000000000..181755d1f --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/Dictionaries.d.mts @@ -0,0 +1,8 @@ +import type { SpellingDictionary, SpellingDictionaryCollection } from 'cspell-dictionary'; +import type { CSpellSettingsInternal, DictionaryDefinitionInternal } from '../Models/CSpellSettingsInternalDef.mjs'; +export declare function loadDictionaryDefs(defsToLoad: DictionaryDefinitionInternal[]): Promise[]; +export declare function loadDictionaryDefsSync(defsToLoad: DictionaryDefinitionInternal[]): SpellingDictionary[]; +export declare function refreshDictionaryCache(maxAge?: number): Promise; +export declare function getDictionaryInternal(settings: CSpellSettingsInternal): Promise; +export declare function getDictionaryInternalSync(settings: CSpellSettingsInternal): SpellingDictionaryCollection; +//# sourceMappingURL=Dictionaries.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/Dictionaries.mjs b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/Dictionaries.mjs new file mode 100644 index 000000000..bccb12a19 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/Dictionaries.mjs @@ -0,0 +1,47 @@ +import { createCollection, createForbiddenWordsDictionary, createIgnoreWordsDictionary, createSpellingDictionary, createSuggestDictionary, } from 'cspell-dictionary'; +import { calcDictionaryDefsToLoad } from '../Settings/DictionarySettings.mjs'; +import { isDefined } from '../util/util.mjs'; +import { loadDictionary, loadDictionarySync, refreshCacheEntries } from './DictionaryLoader.mjs'; +export function loadDictionaryDefs(defsToLoad) { + return defsToLoad.map(loadDictionary); +} +export function loadDictionaryDefsSync(defsToLoad) { + return defsToLoad.map(loadDictionarySync); +} +export function refreshDictionaryCache(maxAge) { + return refreshCacheEntries(maxAge); +} +const emptyWords = Object.freeze([]); +export async function getDictionaryInternal(settings) { + const spellDictionaries = await Promise.all(loadDictionaryDefs(calcDictionaryDefsToLoad(settings))); + return _getDictionaryInternal(settings, spellDictionaries); +} +export function getDictionaryInternalSync(settings) { + const spellDictionaries = loadDictionaryDefsSync(calcDictionaryDefsToLoad(settings)); + return _getDictionaryInternal(settings, spellDictionaries); +} +function _getDictionaryInternal(settings, spellDictionaries) { + const { words = emptyWords, userWords = emptyWords, flagWords = emptyWords, ignoreWords = emptyWords, suggestWords = emptyWords, } = settings; + const settingsWordsDictionary = createSpellingDictionary(words, '[words]', 'From Settings `words`', { + caseSensitive: true, + weightMap: undefined, + }); + const settingsUserWordsDictionary = userWords.length + ? createSpellingDictionary(userWords, '[userWords]', 'From Settings `userWords`', { + caseSensitive: true, + weightMap: undefined, + }) + : undefined; + const ignoreWordsDictionary = createIgnoreWordsDictionary(ignoreWords, '[ignoreWords]', 'From Settings `ignoreWords`'); + const flagWordsDictionary = createForbiddenWordsDictionary(flagWords, '[flagWords]', 'From Settings `flagWords`'); + const suggestWordsDictionary = createSuggestDictionary(suggestWords, '[suggestWords]', 'From Settings `suggestWords`'); + const dictionaries = [ + ...spellDictionaries, + settingsWordsDictionary, + settingsUserWordsDictionary, + ignoreWordsDictionary, + flagWordsDictionary, + suggestWordsDictionary, + ].filter(isDefined); + return createCollection(dictionaries, 'dictionary collection'); +} diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.d.mts b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.d.mts new file mode 100644 index 000000000..1daf87409 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.d.mts @@ -0,0 +1,32 @@ +import type { SpellingDictionary } from 'cspell-dictionary'; +import type { CSpellIO } from 'cspell-io'; +import type { DictionaryDefinitionInternal } from '../../Models/CSpellSettingsInternalDef.mjs'; +export type LoadOptions = DictionaryDefinitionInternal; +export declare class DictionaryLoader { + private cspellIO; + private dictionaryCache; + private inlineDictionaryCache; + private dictionaryCacheByDef; + private reader; + private readerSync; + constructor(cspellIO: CSpellIO); + loadDictionary(def: DictionaryDefinitionInternal): Promise; + loadDictionarySync(def: DictionaryDefinitionInternal): SpellingDictionary; + /** + * Check to see if any of the cached dictionaries have changed. If one has changed, reload it. + * @param maxAge - Only check the dictionary if it has been at least `maxAge` ms since the last check. + * @param now - optional timestamp representing now. (Mostly used in testing) + */ + refreshCacheEntries(maxAge?: number, now?: number): Promise; + private getCacheEntry; + private setCacheEntry; + private refreshEntry; + private loadEntry; + private loadEntrySync; + private getStat; + private getStatSync; + private isEqual; + private normalizeOptions; + private loadInlineDict; +} +//# sourceMappingURL=DictionaryLoader.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.mjs b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.mjs new file mode 100644 index 000000000..96f37d459 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/DictionaryLoader.mjs @@ -0,0 +1,280 @@ +import { opConcatMap, opFilter, opMap, pipe } from '@cspell/cspell-pipe/sync'; +import { StrongWeakMap } from '@cspell/strong-weak-map'; +import { createFailedToLoadDictionary, createInlineSpellingDictionary, createSpellingDictionary, createSpellingDictionaryFromTrieFile, } from 'cspell-dictionary'; +import { isDictionaryDefinitionInlineInternal } from '../../Models/CSpellSettingsInternalDef.mjs'; +import { AutoResolveWeakCache } from '../../util/AutoResolve.mjs'; +import { toError } from '../../util/errors.mjs'; +import { SpellingDictionaryLoadError } from '../SpellingDictionaryError.mjs'; +const MAX_AGE = 10000; +const loaders = { + S: loadSimpleWordList, + C: legacyWordList, + W: wordsPerLineWordList, + T: loadTrie, + default: loadSimpleWordList, +}; +const loadersSync = { + S: loadSimpleWordListSync, + C: legacyWordListSync, + W: wordsPerLineWordListSync, + T: loadTrieSync, + default: loadSimpleWordListSync, +}; +var LoadingState; +(function (LoadingState) { + LoadingState[LoadingState["Loaded"] = 0] = "Loaded"; + LoadingState[LoadingState["Loading"] = 1] = "Loading"; +})(LoadingState || (LoadingState = {})); +export class DictionaryLoader { + constructor(cspellIO) { + this.cspellIO = cspellIO; + this.dictionaryCache = new StrongWeakMap(); + this.inlineDictionaryCache = new AutoResolveWeakCache(); + this.dictionaryCacheByDef = new StrongWeakMap(); + this.reader = toReader(cspellIO); + this.readerSync = toReaderSync(cspellIO); + } + loadDictionary(def) { + if (isDictionaryDefinitionInlineInternal(def)) { + return Promise.resolve(this.loadInlineDict(def)); + } + const { key, entry } = this.getCacheEntry(def); + if (entry) { + return entry.pending.then(([dictionary]) => dictionary); + } + const loadedEntry = this.loadEntry(def.path, def); + this.setCacheEntry(key, loadedEntry, def); + return loadedEntry.pending.then(([dictionary]) => dictionary); + } + loadDictionarySync(def) { + if (isDictionaryDefinitionInlineInternal(def)) { + return this.loadInlineDict(def); + } + const { key, entry } = this.getCacheEntry(def); + if (entry?.dictionary && entry.loadingState === LoadingState.Loaded) { + return entry.dictionary; + } + const loadedEntry = this.loadEntrySync(def.path, def); + this.setCacheEntry(key, loadedEntry, def); + return loadedEntry.dictionary; + } + /** + * Check to see if any of the cached dictionaries have changed. If one has changed, reload it. + * @param maxAge - Only check the dictionary if it has been at least `maxAge` ms since the last check. + * @param now - optional timestamp representing now. (Mostly used in testing) + */ + async refreshCacheEntries(maxAge = MAX_AGE, now = Date.now()) { + await Promise.all([...this.dictionaryCache.values()].map((entry) => this.refreshEntry(entry, maxAge, now))); + } + getCacheEntry(def) { + const defEntry = this.dictionaryCacheByDef.get(def); + if (defEntry) { + return defEntry; + } + const key = calcKey(def); + const entry = this.dictionaryCache.get(key); + if (entry) { + // replace old entry so it can be released. + entry.options = def; + } + return { key, entry }; + } + setCacheEntry(key, entry, def) { + this.dictionaryCache.set(key, entry); + this.dictionaryCacheByDef.set(def, { key, entry }); + } + async refreshEntry(entry, maxAge, now) { + if (now - entry.ts >= maxAge) { + const sig = now + Math.random(); + // Write to the ts, so the next one will not do it. + entry.sig = sig; + entry.ts = now; + const pStat = this.getStat(entry.uri); + const [newStat] = await Promise.all([pStat, entry.pending]); + const hasChanged = !this.isEqual(newStat, entry.stat); + const sigMatches = entry.sig === sig; + if (sigMatches && hasChanged) { + entry.loadingState = LoadingState.Loading; + const key = calcKey(entry.options); + const newEntry = this.loadEntry(entry.uri, entry.options); + this.dictionaryCache.set(key, newEntry); + this.dictionaryCacheByDef.set(entry.options, { key, entry: newEntry }); + } + } + } + loadEntry(uri, options, now = Date.now()) { + options = this.normalizeOptions(uri, options); + const pDictionary = load(this.reader, uri, options).catch((e) => createFailedToLoadDictionary(options.name, uri, new SpellingDictionaryLoadError(uri, options, e, 'failed to load'), options)); + const pStat = this.getStat(uri); + const pending = Promise.all([pDictionary, pStat]); + const sig = now + Math.random(); + const entry = { + uri, + options, + ts: now, + stat: undefined, + dictionary: undefined, + pending, + loadingState: LoadingState.Loading, + sig, + }; + // eslint-disable-next-line promise/catch-or-return + pending.then(([dictionary, stat]) => { + entry.stat = stat; + entry.dictionary = dictionary; + entry.loadingState = LoadingState.Loaded; + return; + }); + return entry; + } + loadEntrySync(uri, options, now = Date.now()) { + options = this.normalizeOptions(uri, options); + const stat = this.getStatSync(uri); + const sig = now + Math.random(); + try { + const dictionary = loadSync(this.readerSync, uri, options); + const pending = Promise.resolve([dictionary, stat]); + return { + uri, + options, + ts: now, + stat, + dictionary, + pending, + loadingState: LoadingState.Loaded, + sig, + }; + } + catch (e) { + const error = toError(e); + const dictionary = createFailedToLoadDictionary(options.name, uri, new SpellingDictionaryLoadError(uri, options, error, 'failed to load'), options); + const pending = Promise.resolve([dictionary, stat]); + return { + uri, + options, + ts: now, + stat, + dictionary, + pending, + loadingState: LoadingState.Loaded, + sig, + }; + } + } + getStat(uri) { + return this.cspellIO.getStat(uri).catch(toError); + } + getStatSync(uri) { + try { + return this.cspellIO.getStatSync(uri); + } + catch (e) { + return toError(e); + } + } + isEqual(a, b) { + if (!b) + return false; + if (isError(a)) { + return isError(b) && a.message === b.message && a.name === b.name; + } + return !isError(b) && !this.cspellIO.compareStats(a, b); + } + normalizeOptions(uri, options) { + if (options.name) + return options; + return { ...options, name: this.cspellIO.uriBasename(uri) }; + } + loadInlineDict(def) { + return this.inlineDictionaryCache.get(def, (def) => createInlineSpellingDictionary(def, def.__source || 'memory')); + } +} +function toReader(cspellIO) { + return async function (filename) { + const res = await cspellIO.readFile(filename); + return res.content.split(/\n|\r\n|\r/); + }; +} +function toReaderSync(cspellIO) { + return function (filename) { + const res = cspellIO.readFileSync(filename); + return res.content.split(/\n|\r\n|\r/); + }; +} +const importantOptionKeys = ['name', 'noSuggest', 'useCompounds', 'type']; +function calcKey(def) { + const path = def.path; + const loaderType = determineType(path, def); + const optValues = importantOptionKeys.map((k) => def[k]?.toString() || ''); + const parts = [path, loaderType].concat(optValues); + return parts.join('|'); +} +function isError(e) { + const err = e; + return !!err.message; +} +function determineType(uri, opts) { + const t = (opts.type && opts.type in loaders && opts.type) || 'S'; + const defLoaderType = t; + const defType = uri.endsWith('.trie.gz') ? 'T' : defLoaderType; + const regTrieTest = /\.trie\b/i; + return regTrieTest.test(uri) ? 'T' : defType; +} +function load(reader, uri, options) { + const type = determineType(uri, options); + const loader = loaders[type] || loaders.default; + return loader(reader, uri, options); +} +function loadSync(reader, uri, options) { + const type = determineType(uri, options); + const loader = loadersSync[type] || loaders.default; + return loader(reader, uri, options); +} +async function legacyWordList(readLines, filename, options) { + const lines = await readLines(filename); + return _legacyWordListSync(lines, filename, options); +} +function legacyWordListSync(readLinesSync, filename, options) { + const lines = readLinesSync(filename); + return _legacyWordListSync(lines, filename, options); +} +function _legacyWordListSync(lines, filename, options) { + const words = pipe(lines, + // Remove comments + opMap((line) => line.replace(/#.*/g, '')), + // Split on everything else + opConcatMap((line) => line.split(/[^\w\p{L}\p{M}'’]+/gu)), opFilter((word) => !!word)); + return createSpellingDictionary(words, options.name, filename, options); +} +async function wordsPerLineWordList(readLines, filename, options) { + const lines = await readLines(filename); + return _wordsPerLineWordList(lines, filename, options); +} +function wordsPerLineWordListSync(readLinesSync, filename, options) { + const lines = readLinesSync(filename); + return _wordsPerLineWordList(lines, filename, options); +} +function _wordsPerLineWordList(lines, filename, options) { + const words = pipe(lines, + // Remove comments + opMap((line) => line.replace(/#.*/g, '')), + // Split on everything else + opConcatMap((line) => line.split(/\s+/gu)), opFilter((word) => !!word)); + return createSpellingDictionary(words, options.name, filename, options); +} +async function loadSimpleWordList(reader, filename, options) { + const lines = await reader(filename); + return createSpellingDictionary(lines, options.name, filename, options); +} +function loadSimpleWordListSync(readLinesSync, filename, options) { + const lines = readLinesSync(filename); + return createSpellingDictionary(lines, options.name, filename, options); +} +async function loadTrie(readLines, filename, options) { + const lines = await readLines(filename); + return createSpellingDictionaryFromTrieFile(lines, options.name, filename, options); +} +function loadTrieSync(readLinesSync, filename, options) { + const lines = readLinesSync(filename); + return createSpellingDictionaryFromTrieFile(lines, options.name, filename, options); +} diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/index.d.mts b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/index.d.mts new file mode 100644 index 000000000..baf306acc --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/index.d.mts @@ -0,0 +1,2 @@ +export { DictionaryLoader, type LoadOptions } from './DictionaryLoader.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/index.mjs b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/index.mjs new file mode 100644 index 000000000..1fa928964 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryController/index.mjs @@ -0,0 +1 @@ +export { DictionaryLoader } from './DictionaryLoader.mjs'; diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryLoader.d.mts b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryLoader.d.mts new file mode 100644 index 000000000..d6a24e505 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryLoader.d.mts @@ -0,0 +1,15 @@ +import type { SpellingDictionary } from 'cspell-dictionary'; +import type { CSpellIO } from 'cspell-io'; +import type { DictionaryDefinitionInternal } from '../Models/CSpellSettingsInternalDef.mjs'; +import { DictionaryLoader } from './DictionaryController/index.mjs'; +export type { LoadOptions } from './DictionaryController/index.mjs'; +export declare function getDictionaryLoader(cspellIO?: CSpellIO): DictionaryLoader; +export declare function loadDictionary(def: DictionaryDefinitionInternal): Promise; +export declare function loadDictionarySync(def: DictionaryDefinitionInternal): SpellingDictionary; +/** + * Check to see if any of the cached dictionaries have changed. If one has changed, reload it. + * @param maxAge - Only check the dictionary if it has been at least `maxAge` ms since the last check. + * @param now - optional timestamp representing now. (Mostly used in testing) + */ +export declare function refreshCacheEntries(maxAge?: number, now?: number): Promise; +//# sourceMappingURL=DictionaryLoader.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryLoader.mjs b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryLoader.mjs new file mode 100644 index 000000000..cd643c99e --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/DictionaryLoader.mjs @@ -0,0 +1,22 @@ +import { getCSpellIO } from '../static.mjs'; +import { DictionaryLoader } from './DictionaryController/index.mjs'; +let loader; +export function getDictionaryLoader(cspellIO) { + if (loader) + return loader; + return (loader = new DictionaryLoader(cspellIO || getCSpellIO())); +} +export function loadDictionary(def) { + return getDictionaryLoader().loadDictionary(def); +} +export function loadDictionarySync(def) { + return getDictionaryLoader().loadDictionarySync(def); +} +/** + * Check to see if any of the cached dictionaries have changed. If one has changed, reload it. + * @param maxAge - Only check the dictionary if it has been at least `maxAge` ms since the last check. + * @param now - optional timestamp representing now. (Mostly used in testing) + */ +export async function refreshCacheEntries(maxAge, now) { + return getDictionaryLoader().refreshCacheEntries(maxAge, now); +} diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionary.d.mts b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionary.d.mts new file mode 100644 index 000000000..67e92ae99 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionary.d.mts @@ -0,0 +1,4 @@ +export type { FindOptions, FindResult, HasOptions, SearchOptions, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryOptions, SuggestionCollector, SuggestionResult, SuggestOptions, } from 'cspell-dictionary'; +export { createCollection, createInlineSpellingDictionary, createSpellingDictionary } from 'cspell-dictionary'; +export { CompoundWordsMethod } from 'cspell-trie-lib'; +//# sourceMappingURL=SpellingDictionary.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionary.mjs b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionary.mjs new file mode 100644 index 000000000..f4936b444 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionary.mjs @@ -0,0 +1,2 @@ +export { createCollection, createInlineSpellingDictionary, createSpellingDictionary } from 'cspell-dictionary'; +export { CompoundWordsMethod } from 'cspell-trie-lib'; diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionaryError.d.mts b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionaryError.d.mts new file mode 100644 index 000000000..b0cb47c7c --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionaryError.d.mts @@ -0,0 +1,10 @@ +import type { LoadOptions } from './DictionaryLoader.mjs'; +export declare class SpellingDictionaryLoadError extends Error { + readonly uri: string; + readonly options: LoadOptions; + readonly cause: Error; + readonly name: string; + constructor(uri: string, options: LoadOptions, cause: Error, message: string); +} +export declare function isSpellingDictionaryLoadError(e: Error): e is SpellingDictionaryLoadError; +//# sourceMappingURL=SpellingDictionaryError.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionaryError.mjs b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionaryError.mjs new file mode 100644 index 000000000..aca2f323a --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SpellingDictionaryError.mjs @@ -0,0 +1,12 @@ +export class SpellingDictionaryLoadError extends Error { + constructor(uri, options, cause, message) { + super(message); + this.uri = uri; + this.options = options; + this.cause = cause; + this.name = options.name; + } +} +export function isSpellingDictionaryLoadError(e) { + return e instanceof SpellingDictionaryLoadError; +} diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/SuggestionCollector.d.mts b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/SuggestionCollector.d.mts new file mode 100644 index 000000000..8d1e805c2 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/SuggestionCollector.d.mts @@ -0,0 +1,10 @@ +import type { SuggestionResult } from './entities.mjs'; +export declare class SuggestionCollector { + readonly size: number; + minScore: number; + private results; + constructor(size: number, minScore: number); + get collection(): SuggestionResult[]; + get sortedCollection(): SuggestionResult[]; +} +//# sourceMappingURL=SuggestionCollector.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/SuggestionCollector.mjs b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/SuggestionCollector.mjs new file mode 100644 index 000000000..8cd422076 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/SuggestionCollector.mjs @@ -0,0 +1,14 @@ +import { compareResults } from './helpers.mjs'; +export class SuggestionCollector { + constructor(size, minScore) { + this.size = size; + this.minScore = minScore; + this.results = []; + } + get collection() { + return this.results.concat(); + } + get sortedCollection() { + return this.collection.sort(compareResults); + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/entities.d.mts b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/entities.d.mts new file mode 100644 index 000000000..5b6f4832a --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/entities.d.mts @@ -0,0 +1,6 @@ +export type Feature = readonly [string, number]; +export interface SuggestionResult { + word: string; + score: number; +} +//# sourceMappingURL=entities.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/entities.mjs b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/entities.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/entities.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/helpers.d.mts b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/helpers.d.mts new file mode 100644 index 000000000..2fe2ad9e5 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/helpers.d.mts @@ -0,0 +1,21 @@ +import type { Feature, SuggestionResult } from './entities.mjs'; +/** + * Comparison function to return the best (highest score) results first. + * @param a Result A + * @param b Result B + */ +export declare function compareResults(a: SuggestionResult, b: SuggestionResult): number; +export declare function wordToFeatures(word: string): FeatureMap; +export declare function mergeFeatures(map: FeatureMap, features: Feature[]): void; +export declare function wordToSingleLetterFeatures(word: string): Feature[]; +export declare function wordToTwoLetterFeatures(word: string): Feature[]; +export declare function segmentString(s: string, segLen: number): string[]; +export declare class FeatureMap extends Map { + private _count; + constructor(); + get count(): number; + append(features: Feature[]): this; + correlationScore(m: FeatureMap): number; + intersectionScore(m: FeatureMap): number; +} +//# sourceMappingURL=helpers.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/helpers.mjs b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/helpers.mjs new file mode 100644 index 000000000..ba3ce48b7 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/helpers.mjs @@ -0,0 +1,58 @@ +/** + * Comparison function to return the best (highest score) results first. + * @param a Result A + * @param b Result B + */ +export function compareResults(a, b) { + return b.score - a.score || a.word.localeCompare(b.word); +} +export function wordToFeatures(word) { + const map = new FeatureMap(); + mergeFeatures(map, wordToSingleLetterFeatures(word)); + mergeFeatures(map, wordToTwoLetterFeatures(word)); + return map; +} +export function mergeFeatures(map, features) { + map.append(features); +} +export function wordToSingleLetterFeatures(word) { + return word.split('').map((a) => [a, 1]); +} +export function wordToTwoLetterFeatures(word) { + return segmentString(word, 2).map((s) => [s, 1]); +} +export function segmentString(s, segLen) { + const count = Math.max(0, s.length - segLen + 1); + const result = new Array(count); + for (let i = 0; i < count; ++i) { + result[i] = s.substr(i, segLen); + } + return result; +} +export class FeatureMap extends Map { + constructor() { + super(); + this._count = 0; + } + get count() { + return this._count; + } + append(features) { + features.forEach(([k, v]) => { + this.set(k, (this.get(k) || 0) + v); + this._count += v; + }); + return this; + } + correlationScore(m) { + const score = this.intersectionScore(m); + return score / (this._count + m._count - score); + } + intersectionScore(m) { + let score = 0; + for (const [k, v] of this) { + score += Math.min(v, m.get(k) || 0); + } + return score; + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/suggest.d.mts b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/suggest.d.mts new file mode 100644 index 000000000..c22022d53 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/suggest.d.mts @@ -0,0 +1,6 @@ +import type { Trie, WalkerIterator } from 'cspell-trie-lib'; +import type { SuggestionResult } from './entities.mjs'; +export type SuggestionIterator = Generator; +export declare function suggest(trie: Trie, word: string, minScore?: number): SuggestionIterator; +export declare function suggestIteration(i: WalkerIterator, word: string, minScore?: number): SuggestionIterator; +//# sourceMappingURL=suggest.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/suggest.mjs b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/suggest.mjs new file mode 100644 index 000000000..ccfe264ff --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/SuggestExperimental/suggest.mjs @@ -0,0 +1,27 @@ +import { wordToFeatures } from './helpers.mjs'; +const defaultMinScore = 0.35; +const wPrefix = '^'; +const wSuffix = '$'; +export function* suggest(trie, word, minScore = defaultMinScore) { + yield* suggestIteration(trie.iterate(), word, minScore); +} +export function* suggestIteration(i, word, minScore = defaultMinScore) { + let goDeeper = true; + const fA = wordToFeatures(wPrefix + word + wSuffix); + for (let r = i.next(goDeeper); !r.done; r = i.next(goDeeper)) { + const { text, node } = r.value; + const fB = wordToFeatures(wPrefix + text); + const rawScore = fA.intersectionScore(fB); + const bestPossibleScore = fA.count / (fA.count + fB.count - rawScore); + goDeeper = bestPossibleScore > minScore; + if (goDeeper && node.f) { + const fB = wordToFeatures(wPrefix + text + wSuffix); + const rawScore = fA.intersectionScore(fB); + const score = rawScore / (fA.count + fB.count - rawScore); + if (score >= minScore) { + const r = { word: text, score }; + minScore = (yield r) || minScore; + } + } + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/index.d.mts b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/index.d.mts new file mode 100644 index 000000000..45a4347fd --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/index.d.mts @@ -0,0 +1,4 @@ +export * from './Dictionaries.mjs'; +export * from './SpellingDictionary.mjs'; +export * from './SpellingDictionaryError.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/index.mjs b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/index.mjs new file mode 100644 index 000000000..d1ed0edf8 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/SpellingDictionary/index.mjs @@ -0,0 +1,3 @@ +export * from './Dictionaries.mjs'; +export * from './SpellingDictionary.mjs'; +export * from './SpellingDictionaryError.mjs'; diff --git a/action/node_modules/cspell-lib/dist/esm/clearCachedFiles.d.mts b/action/node_modules/cspell-lib/dist/esm/clearCachedFiles.d.mts new file mode 100644 index 000000000..9c2d470cb --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/clearCachedFiles.d.mts @@ -0,0 +1,2 @@ +export declare function clearCachedFiles(): Promise; +//# sourceMappingURL=clearCachedFiles.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/clearCachedFiles.mjs b/action/node_modules/cspell-lib/dist/esm/clearCachedFiles.mjs new file mode 100644 index 000000000..4c0427f21 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/clearCachedFiles.mjs @@ -0,0 +1,5 @@ +import { clearCachedSettingsFiles } from './Settings/index.mjs'; +import { refreshDictionaryCache } from './SpellingDictionary/index.mjs'; +export async function clearCachedFiles() { + await Promise.all([clearCachedSettingsFiles(), refreshDictionaryCache(0)]); +} diff --git a/action/node_modules/cspell-lib/dist/esm/exclusionHelper.d.mts b/action/node_modules/cspell-lib/dist/esm/exclusionHelper.d.mts new file mode 100644 index 000000000..caca6f553 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/exclusionHelper.d.mts @@ -0,0 +1,23 @@ +import type { Glob } from '@cspell/cspell-types'; +export type ExclusionFunction = (fileUri: string) => boolean; +export type FileExclusionFunction = (file: string) => boolean; +/** The structure of the VS Code search.exclude settings */ +export interface ExcludeFilesGlobMap { + [glob: string]: boolean; +} +export declare function extractGlobsFromExcludeFilesGlobMap(globMap: ExcludeFilesGlobMap): string[]; +/** + * @todo Support multi root globs. + * @param globs - glob patterns + * @param root - root directory + * @param allowedSchemes - allowed schemas + */ +export declare function generateExclusionFunctionForUri(globs: Glob[], root: string, allowedSchemes?: Set): ExclusionFunction; +/** + * @todo Support multi root globs. + * @param globs - glob patterns + * @param root - root directory + * @param allowedSchemes - allowed schemas + */ +export declare function generateExclusionFunctionForFiles(globs: Glob[], root: string): FileExclusionFunction; +//# sourceMappingURL=exclusionHelper.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/exclusionHelper.mjs b/action/node_modules/cspell-lib/dist/esm/exclusionHelper.mjs new file mode 100644 index 000000000..0997c0c38 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/exclusionHelper.mjs @@ -0,0 +1,50 @@ +import { GlobMatcher } from 'cspell-glob'; +import { toUri, uriToFilePath } from './util/Uri.mjs'; +const defaultAllowedSchemes = new Set(['file', 'untitled']); +export function extractGlobsFromExcludeFilesGlobMap(globMap) { + const globs = Object.getOwnPropertyNames(globMap).filter((glob) => globMap[glob]); + return globs; +} +const leadingGlobPattern = /^\*\*\/([^/*{}]+)$/; +function adjustGlobPatternForBackwardsCompatibility(g) { + return g.replace(leadingGlobPattern, '**/{$1,$1/**}'); +} +function adjustGlobPatternsForBackwardsCompatibility(globs) { + return globs.map((g) => { + if (typeof g === 'string') { + return adjustGlobPatternForBackwardsCompatibility(g); + } + return { ...g, glob: adjustGlobPatternForBackwardsCompatibility(g.glob) }; + }); +} +/** + * @todo Support multi root globs. + * @param globs - glob patterns + * @param root - root directory + * @param allowedSchemes - allowed schemas + */ +export function generateExclusionFunctionForUri(globs, root, allowedSchemes = defaultAllowedSchemes) { + const adjustedGlobs = adjustGlobPatternsForBackwardsCompatibility(globs); + const matchFn = generateExclusionFunctionForFiles(adjustedGlobs, root); + function testUri(uri) { + if (!allowedSchemes.has(uri.scheme)) { + return true; + } + return matchFn(uri.scheme === 'file' || uri.scheme === 'stdin' ? uriToFilePath(uri) : uri.path); + } + function testUriPath(uriPath) { + const uri = toUri(uriPath); + return testUri(uri); + } + return testUriPath; +} +/** + * @todo Support multi root globs. + * @param globs - glob patterns + * @param root - root directory + * @param allowedSchemes - allowed schemas + */ +export function generateExclusionFunctionForFiles(globs, root) { + const matcher = new GlobMatcher(globs, { root, dot: true }); + return (file) => matcher.match(file); +} diff --git a/action/node_modules/cspell-lib/dist/esm/getDictionary.d.mts b/action/node_modules/cspell-lib/dist/esm/getDictionary.d.mts new file mode 100644 index 000000000..deda17061 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/getDictionary.d.mts @@ -0,0 +1,9 @@ +import type { CSpellUserSettings } from '@cspell/cspell-types'; +import type { SpellingDictionaryCollection } from './SpellingDictionary/index.mjs'; +/** + * Load a dictionary collection defined by the settings. + * @param settings - that defines the dictionaries and the ones to load. + * @returns a dictionary collection that represents all the enabled dictionaries. + */ +export declare function getDictionary(settings: CSpellUserSettings): Promise; +//# sourceMappingURL=getDictionary.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/getDictionary.mjs b/action/node_modules/cspell-lib/dist/esm/getDictionary.mjs new file mode 100644 index 000000000..07b81b4e6 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/getDictionary.mjs @@ -0,0 +1,10 @@ +import { toInternalSettings } from './Settings/CSpellSettingsServer.mjs'; +import { getDictionaryInternal } from './SpellingDictionary/index.mjs'; +/** + * Load a dictionary collection defined by the settings. + * @param settings - that defines the dictionaries and the ones to load. + * @returns a dictionary collection that represents all the enabled dictionaries. + */ +export function getDictionary(settings) { + return getDictionaryInternal(toInternalSettings(settings)); +} diff --git a/action/node_modules/cspell-lib/dist/esm/index.d.mts b/action/node_modules/cspell-lib/dist/esm/index.d.mts new file mode 100644 index 000000000..7e22e0534 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/index.d.mts @@ -0,0 +1,30 @@ +import * as ExclusionHelper from './exclusionHelper.mjs'; +import * as Link from './Settings/index.link.mjs'; +import * as Text from './util/text.mjs'; +export type { Document } from './Document/index.mjs'; +export { fileToDocument, fileToTextDocument, isBinaryFile } from './Document/index.mjs'; +export { ExcludeFilesGlobMap, ExclusionFunction } from './exclusionHelper.mjs'; +export { FeatureFlag, FeatureFlags, getSystemFeatureFlags, UnknownFeatureFlagError } from './FeatureFlags/index.mjs'; +export { getLanguagesForBasename as getLanguageIdsForBaseFilename, getLanguagesForExt } from './LanguageIds.mjs'; +export type { CreateTextDocumentParams, TextDocument, TextDocumentLine, TextDocumentRef, } from './Models/TextDocument.mjs'; +export { createTextDocument, updateTextDocument } from './Models/TextDocument.mjs'; +export { calcOverrideSettings, checkFilenameMatchesGlob, clearCachedSettingsFiles, type ConfigurationDependencies, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, finalizeSettings, getCachedFileSize, getDefaultBundledSettings, getDefaultSettings, getGlobalSettings, getSources, ImportError, type ImportFileRefWithError, loadConfig, loadPnP, loadPnPSync, mergeInDocSettings, mergeSettings, readRawSettings, readSettings, readSettingsFiles, searchForConfig, sectionCSpell, } from './Settings/index.mjs'; +export { defaultFileName as defaultSettingsFilename } from './Settings/index.mjs'; +export { combineTextAndLanguageSettings, combineTextAndLanguageSettings as constructSettingsForText, } from './Settings/TextDocumentSettings.mjs'; +export { determineFinalDocumentSettings, DetermineFinalDocumentSettingsResult, spellCheckDocument, spellCheckFile, SpellCheckFileOptions, SpellCheckFileResult, } from './spellCheckFile.mjs'; +export { CompoundWordsMethod, createSpellingDictionary, createCollection as createSpellingDictionaryCollection, isSpellingDictionaryLoadError, refreshDictionaryCache, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryLoadError, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary/index.mjs'; +export type { SuggestedWord, SuggestionOptions, SuggestionsForWordResult } from './suggestions.mjs'; +export { SuggestionError, suggestionsForWord, suggestionsForWords } from './suggestions.mjs'; +export { DocumentValidator, DocumentValidatorOptions, shouldCheckDocument } from './textValidation/index.mjs'; +export type { TraceOptions, TraceResult } from './trace.mjs'; +export { traceWords, traceWordsAsync } from './trace.mjs'; +export { getLogger, Logger, setLogger } from './util/logger.mjs'; +export { resolveFile } from './util/resolveFile.mjs'; +export { checkText, checkTextDocument, CheckTextInfo, IncludeExcludeFlag, IncludeExcludeOptions, TextInfoItem, validateText, ValidationIssue, } from './validator.mjs'; +export * from '@cspell/cspell-types'; +export { asyncIterableToArray, readFile, readFileSync, writeToFile, writeToFileIterable, writeToFileIterableP, } from 'cspell-io'; +export { Link, Text }; +export { ExclusionHelper }; +export { clearCachedFiles } from './clearCachedFiles.mjs'; +export { getDictionary } from './getDictionary.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/index.mjs b/action/node_modules/cspell-lib/dist/esm/index.mjs new file mode 100644 index 000000000..6d2f24ed1 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/index.mjs @@ -0,0 +1,24 @@ +import * as ExclusionHelper from './exclusionHelper.mjs'; +import * as Link from './Settings/index.link.mjs'; +import * as Text from './util/text.mjs'; +export { fileToDocument, fileToTextDocument, isBinaryFile } from './Document/index.mjs'; +export { FeatureFlags, getSystemFeatureFlags, UnknownFeatureFlagError } from './FeatureFlags/index.mjs'; +export { getLanguagesForBasename as getLanguageIdsForBaseFilename, getLanguagesForExt } from './LanguageIds.mjs'; +export { createTextDocument, updateTextDocument } from './Models/TextDocument.mjs'; +export { calcOverrideSettings, checkFilenameMatchesGlob, clearCachedSettingsFiles, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, ENV_CSPELL_GLOB_ROOT, extractDependencies, extractImportErrors, finalizeSettings, getCachedFileSize, getDefaultBundledSettings, getDefaultSettings, getGlobalSettings, getSources, ImportError, loadConfig, loadPnP, loadPnPSync, mergeInDocSettings, mergeSettings, readRawSettings, readSettings, readSettingsFiles, searchForConfig, sectionCSpell, } from './Settings/index.mjs'; +export { defaultFileName as defaultSettingsFilename } from './Settings/index.mjs'; +export { combineTextAndLanguageSettings, combineTextAndLanguageSettings as constructSettingsForText, } from './Settings/TextDocumentSettings.mjs'; +export { determineFinalDocumentSettings, spellCheckDocument, spellCheckFile, } from './spellCheckFile.mjs'; +export { CompoundWordsMethod, createSpellingDictionary, createCollection as createSpellingDictionaryCollection, isSpellingDictionaryLoadError, refreshDictionaryCache, SpellingDictionaryLoadError, } from './SpellingDictionary/index.mjs'; +export { SuggestionError, suggestionsForWord, suggestionsForWords } from './suggestions.mjs'; +export { DocumentValidator, shouldCheckDocument } from './textValidation/index.mjs'; +export { traceWords, traceWordsAsync } from './trace.mjs'; +export { getLogger, setLogger } from './util/logger.mjs'; +export { resolveFile } from './util/resolveFile.mjs'; +export { checkText, checkTextDocument, IncludeExcludeFlag, validateText, } from './validator.mjs'; +export * from '@cspell/cspell-types'; +export { asyncIterableToArray, readFile, readFileSync, writeToFile, writeToFileIterable, writeToFileIterableP, } from 'cspell-io'; +export { Link, Text }; +export { ExclusionHelper }; +export { clearCachedFiles } from './clearCachedFiles.mjs'; +export { getDictionary } from './getDictionary.mjs'; diff --git a/action/node_modules/cspell-lib/dist/esm/spellCheckFile.d.mts b/action/node_modules/cspell-lib/dist/esm/spellCheckFile.d.mts new file mode 100644 index 000000000..89b9711e1 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/spellCheckFile.d.mts @@ -0,0 +1,67 @@ +/// +import type { CSpellSettingsWithSourceTrace, CSpellUserSettings } from '@cspell/cspell-types'; +import type { Document, DocumentWithText } from './Document/index.mjs'; +import type { Uri } from './util/Uri.mjs'; +import type { ValidateTextOptions, ValidationIssue } from './validator.mjs'; +export interface SpellCheckFileOptions extends ValidateTextOptions { + /** + * Optional path to a configuration file. + * If given, it will be used instead of searching for a configuration file. + */ + configFile?: string; + /** + * File encoding + * @defaultValue 'utf-8' + */ + encoding?: BufferEncoding; + /** + * Prevents searching for local configuration files + * By default the spell checker looks for configuration files + * starting at the location of given filename. + * If `configFile` is defined it will still be loaded instead of searching. + * `false` will override the value in `settings.noConfigSearch`. + * @defaultValue undefined + */ + noConfigSearch?: boolean; +} +export interface SpellCheckFileResult { + document: Document | DocumentWithText; + settingsUsed: CSpellSettingsWithSourceTrace; + localConfigFilepath: string | undefined; + options: SpellCheckFileOptions; + issues: ValidationIssue[]; + checked: boolean; + errors: Error[] | undefined; +} +/** + * Spell Check a file + * @param file - absolute path to file to read and check. + * @param options - options to control checking + * @param settings - default settings to use. + */ +export declare function spellCheckFile(file: string | Uri | URL, options: SpellCheckFileOptions, settings: CSpellUserSettings): Promise; +/** + * Spell Check a Document. + * @param document - document to be checked. If `document.text` is `undefined` the file will be loaded + * @param options - options to control checking + * @param settings - default settings to use. + */ +export declare function spellCheckDocument(document: Document | DocumentWithText, options: SpellCheckFileOptions, settings: CSpellUserSettings): Promise; +export interface DetermineFinalDocumentSettingsResult { + document: DocumentWithText; + settings: CSpellSettingsWithSourceTrace; +} +/** + * Combines all relevant setting values into a final configuration to be used for spell checking. + * It applies any overrides and appropriate language settings by taking into account the document type (languageId) + * the locale (natural language) and any in document settings. + * + * Note: this method will not search for configuration files. Configuration files should already be merged into `settings`. + * It is NOT necessary to include the cspell defaultSettings or globalSettings. They will be applied within this function. + * @param document - The document to be spell checked. Note: if the URI doesn't have a path, overrides cannot be applied. + * `locale` - if defined will be used unless it is overridden by an in-document setting. + * `languageId` - if defined will be used to select appropriate file type dictionaries. + * @param settings - The near final settings. Should already be the combination of all configuration files. + */ +export declare function determineFinalDocumentSettings(document: DocumentWithText, settings: CSpellUserSettings): DetermineFinalDocumentSettingsResult; +//# sourceMappingURL=spellCheckFile.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/spellCheckFile.mjs b/action/node_modules/cspell-lib/dist/esm/spellCheckFile.mjs new file mode 100644 index 000000000..96504a53b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/spellCheckFile.mjs @@ -0,0 +1,106 @@ +import { isBinaryDoc } from './Document/isBinaryDoc.mjs'; +import { documentToTextDocument, resolveDocument } from './Document/resolveDocument.mjs'; +import { createTextDocument } from './Models/TextDocument.mjs'; +import { determineTextDocumentSettings } from './textValidation/determineTextDocumentSettings.mjs'; +import { DocumentValidator } from './textValidation/index.mjs'; +import { isError } from './util/errors.mjs'; +import { toUri } from './util/Uri.mjs'; +/** + * Spell Check a file + * @param file - absolute path to file to read and check. + * @param options - options to control checking + * @param settings - default settings to use. + */ +export function spellCheckFile(file, options, settings) { + const doc = { + uri: toUri(file).toString(), + }; + return spellCheckDocument(doc, options, settings); +} +/** + * Spell Check a Document. + * @param document - document to be checked. If `document.text` is `undefined` the file will be loaded + * @param options - options to control checking + * @param settings - default settings to use. + */ +export async function spellCheckDocument(document, options, settings) { + if (isBinaryDoc(document)) { + return { + document, + options, + settingsUsed: settings, + localConfigFilepath: undefined, + issues: [], + checked: false, + errors: undefined, + }; + } + try { + return spellCheckFullDocument(await resolveDocument(document), options, settings); + } + catch (e) { + const errors = isError(e) ? [e] : []; + return { + document, + options, + settingsUsed: settings, + localConfigFilepath: undefined, + issues: [], + checked: false, + errors, + }; + } +} +async function spellCheckFullDocument(document, options, settings) { + const doc = documentToTextDocument(document); + const docValOptions = options; + const docValidator = new DocumentValidator(doc, docValOptions, settings); + await docValidator.prepare(); + const prep = docValidator._getPreparations(); + if (docValidator.errors.length) { + return { + document, + options, + settingsUsed: prep?.localConfig || settings, + localConfigFilepath: prep?.localConfigFilepath, + issues: [], + checked: false, + errors: docValidator.errors, + }; + } + const issues = docValidator.checkDocument(); + const result = { + document, + options, + settingsUsed: docValidator.getFinalizedDocSettings(), + localConfigFilepath: prep?.localConfigFilepath, + issues, + checked: docValidator.shouldCheckDocument(), + errors: undefined, + }; + return result; +} +/** + * Combines all relevant setting values into a final configuration to be used for spell checking. + * It applies any overrides and appropriate language settings by taking into account the document type (languageId) + * the locale (natural language) and any in document settings. + * + * Note: this method will not search for configuration files. Configuration files should already be merged into `settings`. + * It is NOT necessary to include the cspell defaultSettings or globalSettings. They will be applied within this function. + * @param document - The document to be spell checked. Note: if the URI doesn't have a path, overrides cannot be applied. + * `locale` - if defined will be used unless it is overridden by an in-document setting. + * `languageId` - if defined will be used to select appropriate file type dictionaries. + * @param settings - The near final settings. Should already be the combination of all configuration files. + */ +export function determineFinalDocumentSettings(document, settings) { + const doc = createTextDocument({ + uri: document.uri, + content: document.text, + languageId: document.languageId, + locale: document.locale, + }); + return { + document, + settings: determineTextDocumentSettings(doc, settings), + }; +} diff --git a/action/node_modules/cspell-lib/dist/esm/static.d.mts b/action/node_modules/cspell-lib/dist/esm/static.d.mts new file mode 100644 index 000000000..850805aa9 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/static.d.mts @@ -0,0 +1,3 @@ +import type { CSpellIO } from 'cspell-io'; +export declare function getCSpellIO(): CSpellIO; +//# sourceMappingURL=static.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/static.mjs b/action/node_modules/cspell-lib/dist/esm/static.mjs new file mode 100644 index 000000000..568e19472 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/static.mjs @@ -0,0 +1,5 @@ +import { CSpellIONode } from 'cspell-io'; +const cspellIO = new CSpellIONode(); +export function getCSpellIO() { + return cspellIO; +} diff --git a/action/node_modules/cspell-lib/dist/esm/suggestions.d.mts b/action/node_modules/cspell-lib/dist/esm/suggestions.d.mts new file mode 100644 index 000000000..fcae09043 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/suggestions.d.mts @@ -0,0 +1,74 @@ +import type { CSpellSettings, LocaleId } from '@cspell/cspell-types'; +import type { LanguageId } from './LanguageIds.mjs'; +import type { SpellingDictionaryCollection, SuggestionResult, SuggestOptions } from './SpellingDictionary/index.mjs'; +export interface WordSuggestion extends SuggestionResult { + /** + * The suggested word adjusted to match the original case. + */ + wordAdjustedToMatchCase?: string; +} +interface SuggestedWordBase extends WordSuggestion { + /** + * dictionary names + */ + dictionaries: string[]; +} +export interface SuggestedWord extends SuggestedWordBase { + noSuggest: boolean; + forbidden: boolean; +} +export interface SuggestionsForWordResult { + word: string; + suggestions: SuggestedWord[]; +} +type FromSuggestOptions = Pick; +export interface SuggestionOptions extends FromSuggestOptions { + /** + * languageId to use when determining file type. + */ + languageId?: LanguageId | LanguageId[]; + /** + * Locale to use. + */ + locale?: LocaleId; + /** + * Strict case and accent checking + * @default true + */ + strict?: boolean; + /** + * List of dictionaries to use. If specified, only that list of dictionaries will be used. + */ + dictionaries?: string[]; + /** + * The number of suggestions to make. + * @default 8 + */ + numSuggestions?: number | undefined; + /** + * Max number of changes / edits to the word to get to a suggestion matching suggestion. + * @default 4 + */ + numChanges?: number | undefined; + /** + * If multiple suggestions have the same edit / change "cost", then included them even if + * it causes more than `numSuggestions` to be returned. + * @default true + */ + includeTies?: boolean | undefined; + /** + * By default we want to use the default configuration, but there are cases + * where someone might not want that. + * @default true + */ + includeDefaultConfig?: boolean; +} +export declare function suggestionsForWords(words: Iterable | AsyncIterable, options?: SuggestionOptions, settings?: CSpellSettings): AsyncIterable; +export declare function suggestionsForWord(word: string, options?: SuggestionOptions, settings?: CSpellSettings): Promise; +export declare function calcSuggestionAdjustedToToMatchCase(originalWord: string, sugs: T[], locale: string | string[] | undefined, ignoreCase: boolean, dict: SpellingDictionaryCollection): (T & WordSuggestion)[]; +export declare class SuggestionError extends Error { + readonly code: string; + constructor(message: string, code: string); +} +export {}; +//# sourceMappingURL=suggestions.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/suggestions.mjs b/action/node_modules/cspell-lib/dist/esm/suggestions.mjs new file mode 100644 index 000000000..4f7e6480e --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/suggestions.mjs @@ -0,0 +1,183 @@ +import assert from 'assert'; +import { finalizeSettings, getDefaultSettings, getGlobalSettings, mergeSettings } from './Settings/index.mjs'; +import { calcSettingsForLanguageId, isValidLocaleIntlFormat, normalizeLocaleIntl, } from './Settings/LanguageSettings.mjs'; +import { getDictionaryInternal, refreshDictionaryCache } from './SpellingDictionary/index.mjs'; +import { createAutoResolveCache } from './util/AutoResolve.mjs'; +import { memorizeLastCall } from './util/memorizeLastCall.mjs'; +import * as util from './util/util.mjs'; +const emptySuggestionOptions = Object.freeze({}); +const emptyCSpellSettings = Object.freeze({}); +export async function* suggestionsForWords(words, options, settings) { + for await (const word of words) { + yield await suggestionsForWord(word, options, settings); + } +} +const memorizeSuggestions = memorizeLastCall(cacheSuggestionsForWord); +function cacheSuggestionsForWord(options, settings) { + const cache = createAutoResolveCache(); + return (word) => cache.get(word, (word) => _suggestionsForWord(word, options, settings)); +} +export function suggestionsForWord(word, options = emptySuggestionOptions, settings = emptyCSpellSettings) { + return memorizeSuggestions(options, settings)(word); +} +async function _suggestionsForWord(word, options, settings) { + const { languageId, locale: language, includeDefaultConfig = true, dictionaries } = options; + async function determineDictionaries(config) { + const withLocale = mergeSettings(config, util.clean({ + language: language || config.language, + // dictionaries: dictionaries?.length ? dictionaries : config.dictionaries, + })); + const withLanguageId = calcSettingsForLanguageId(withLocale, languageId ?? withLocale.languageId ?? 'plaintext'); + const settings = finalizeSettings(withLanguageId); + settings.dictionaries = dictionaries?.length ? dictionaries : settings.dictionaries || []; + validateDictionaries(settings, dictionaries); + const dictionaryCollection = await getDictionaryInternal(settings); + settings.dictionaries = settings.dictionaryDefinitions?.map((def) => def.name) || []; + const allDictionaryCollection = await getDictionaryInternal(settings); + return { + dictionaryCollection, + allDictionaryCollection, + }; + } + await refreshDictionaryCache(); + const config = includeDefaultConfig + ? mergeSettings(getDefaultSettings(settings.loadDefaultConfiguration ?? true), getGlobalSettings(), settings) + : settings; + const { dictionaryCollection, allDictionaryCollection } = await determineDictionaries(config); + return _suggestionsForWordSync(word, options, settings, dictionaryCollection, allDictionaryCollection); +} +function _suggestionsForWordSync(word, options, settings, dictionaryCollection, allDictionaryCollection) { + const extendsDictionaryCollection = allDictionaryCollection || dictionaryCollection; + const { locale: language, strict = true, numChanges = 4, numSuggestions = 8, includeTies = true, includeDefaultConfig = true, } = options; + const ignoreCase = !strict; + const config = includeDefaultConfig + ? mergeSettings(getDefaultSettings(settings.loadDefaultConfiguration ?? true), getGlobalSettings(), settings) + : settings; + const opts = { ignoreCase, numChanges, numSuggestions, includeTies }; + const suggestionsByDictionary = dictionaryCollection.dictionaries.flatMap((dict) => dict.suggest(word, opts).map((r) => ({ ...r, dictName: dict.name }))); + const locale = adjustLocale(language || config.language || undefined); + const collator = Intl.Collator(locale); + const combined = limitResults(combine(suggestionsByDictionary.sort((a, b) => a.cost - b.cost || collator.compare(a.word, b.word))), numSuggestions, includeTies); + const sugsAdjusted = calcSuggestionAdjustedToToMatchCase(word, combined, locale, ignoreCase, extendsDictionaryCollection); + const allSugs = sugsAdjusted.map((sug) => { + const found = extendsDictionaryCollection.find(sug.word); + return { + ...sug, + forbidden: found?.forbidden || false, + noSuggest: found?.noSuggest || false, + }; + }); + return { + word, + suggestions: limitResults(allSugs, numSuggestions, includeTies), + }; +} +function combine(suggestions) { + const words = new Map(); + for (const sug of suggestions) { + const { word, cost, dictName, ...rest } = sug; + const f = words.get(word) || { word, cost, ...rest, dictionaries: [] }; + f.cost = Math.min(f.cost, cost); + f.dictionaries.push(dictName); + f.dictionaries.sort(); + words.set(word, f); + } + return [...words.values()]; +} +function adjustLocale(locale) { + if (!locale) + return undefined; + const locales = [...normalizeLocaleIntl(locale)].filter((locale) => isValidLocaleIntlFormat(locale)); + if (!locales.length) + return undefined; + if (locales.length === 1) + return locales[0]; + return locales; +} +export function calcSuggestionAdjustedToToMatchCase(originalWord, sugs, locale, ignoreCase, dict) { + locale = adjustLocale(locale); + const knownSugs = new Set(sugs.map((sug) => sug.word)); + const matchStyle = { ...analyzeCase(originalWord), locale, ignoreCase }; + /* Add adjusted words */ + return sugs.map((sug) => { + const alt = matchCase(sug.word, !!sug.isPreferred, matchStyle); + if (alt === sug.word || knownSugs.has(alt)) + return sug; + const found = dict.find(alt); + if (!found || !found.forbidden || !found.noSuggest) { + knownSugs.add(alt); + return { ...sug, wordAdjustedToMatchCase: alt }; + } + return sug; + }); +} +function limitResults(suggestions, numSuggestions, includeTies) { + let cost = suggestions[0]?.cost; + let i = 0; + for (; i < suggestions.length; ++i) { + if (i >= numSuggestions && (!includeTies || suggestions[i].cost > cost)) { + break; + } + cost = suggestions[i].cost; + } + return suggestions.slice(0, i); +} +function validateDictionaries(settings, dictionaries) { + if (!dictionaries?.length) + return; + const knownDicts = new Set(settings.dictionaryDefinitions?.map((def) => def.name) || []); + for (const dict of dictionaries) { + if (!knownDicts.has(dict)) { + throw new SuggestionError(`Unknown dictionary: "${dict}"`, 'E_dictionary_unknown'); + } + } +} +function matchCase(word, isPreferred, style) { + const locale = style.locale; + if (style.isMixedCaps) { + /** + * Do not try matching mixed caps. + */ + return word; + } + if (hasCaps(word)) { + if (style.isAllCaps) + return word.toLocaleUpperCase(locale); + if (!style.ignoreCase || style.hasCaps || isPreferred) + return word; + if (isTitleCase(word) || isAllCaps(word)) + return word.toLocaleLowerCase(locale); + return word; + } + if (!style.hasCaps) + return word; + if (style.isAllCaps) + return word.toLocaleUpperCase(locale); + assert(style.isTitleCase); + return word.replace(/^\p{L}/u, (firstLetter) => firstLetter.toLocaleUpperCase(locale)); +} +const regExpHasCaps = /\p{Lu}/u; +const regExpIsAllCaps = /^[\P{L}\p{Lu}]+$/u; +const regExpIsTitleCase = /^\p{Lu}[\P{L}\p{Ll}]+$/u; +function analyzeCase(word) { + const hasCaps = regExpHasCaps.test(word); + const isAllCaps = hasCaps && regExpIsAllCaps.test(word); + const isTitleCase = hasCaps && !isAllCaps && regExpIsTitleCase.test(word); + const isMixedCaps = hasCaps && !isAllCaps && !isTitleCase; + return { hasCaps, isAllCaps, isMixedCaps, isTitleCase }; +} +function hasCaps(word) { + return regExpHasCaps.test(word); +} +function isTitleCase(word) { + return regExpIsTitleCase.test(word); +} +function isAllCaps(word) { + return regExpIsAllCaps.test(word); +} +export class SuggestionError extends Error { + constructor(message, code) { + super(message); + this.code = code; + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/ValidateTextOptions.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/ValidateTextOptions.d.mts new file mode 100644 index 000000000..98be541f9 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/ValidateTextOptions.d.mts @@ -0,0 +1,15 @@ +export interface ValidateTextOptions { + /** + * Generate suggestions where there are spelling issues. + */ + generateSuggestions?: boolean; + /** + * The number of suggestions to generate. The higher the number the longer it takes. + */ + numSuggestions?: number; + /** + * Verify that the in-document directives are correct. + */ + validateDirectives?: boolean; +} +//# sourceMappingURL=ValidateTextOptions.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/ValidateTextOptions.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/ValidateTextOptions.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/ValidateTextOptions.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/ValidationTypes.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/ValidationTypes.d.mts new file mode 100644 index 000000000..994a17615 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/ValidationTypes.d.mts @@ -0,0 +1,37 @@ +import type { MappedText, TextOffset as TextOffsetRW } from '@cspell/cspell-types'; +import type { ValidationResult } from '../Models/ValidationResult.mjs'; +export type TextOffsetRO = Readonly; +export interface ValidationOptions extends IncludeExcludeOptions { + maxNumberOfProblems?: number; + maxDuplicateProblems?: number; + minWordLength?: number; + flagWords?: string[]; + allowCompoundWords?: boolean; + /** ignore case when checking words against dictionary or ignore words list */ + ignoreCase: boolean; +} +export interface CheckOptions extends ValidationOptions { + allowCompoundWords: boolean; + ignoreCase: boolean; +} +export interface IncludeExcludeOptions { + ignoreRegExpList?: RegExp[]; + includeRegExpList?: RegExp[]; +} +export interface WordRangeAcc { + textOffset: TextOffsetRO; + isIncluded: boolean; + rangePos: number; +} +export type ValidationResultRO = Readonly; +export type LineValidatorFn = (line: LineSegment) => Iterable; +export interface LineSegment { + line: TextOffsetRO; + segment: TextOffsetRO; +} +export interface MappedTextValidationResult extends MappedText { + isFlagged?: boolean | undefined; + isFound?: boolean | undefined; +} +export type TextValidatorFn = (text: MappedText) => Iterable; +//# sourceMappingURL=ValidationTypes.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/ValidationTypes.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/ValidationTypes.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/ValidationTypes.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/checkText.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/checkText.d.mts new file mode 100644 index 000000000..35f1f441b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/checkText.d.mts @@ -0,0 +1,48 @@ +import type { CSpellUserSettings } from '@cspell/cspell-types'; +import type { Document } from '../Document/index.mjs'; +import type { TextDocument } from '../Models/TextDocument.mjs'; +import type { DocumentValidatorOptions } from './docValidator.mjs'; +import { DocumentValidator } from './docValidator.mjs'; +/** + * Annotate text with issues and include / exclude zones. + * @param text - the text to annotate. + * @param settings - the settings to use. + * @returns the Check Text result + * @deprecated + */ +export declare function checkText(text: string, settings: CSpellUserSettings): Promise; +/** + * Annotate text with issues and include / exclude zones. + * @param text - the text to annotate. + * @param settings - the settings to use. + * @returns the Check Text result + * @deprecated + */ +export declare function checkTextOld(text: string, settings: CSpellUserSettings): Promise; +export interface CheckTextInfo { + text: string; + items: TextInfoItem[]; +} +export interface TextInfoItem { + text: string; + startPos: number; + endPos: number; + flagIE: IncludeExcludeFlag; + isError?: boolean; +} +export declare enum IncludeExcludeFlag { + INCLUDE = "I", + EXCLUDE = "E" +} +export interface CheckTextOptions extends DocumentValidatorOptions { +} +/** + * Calculate document issues and include / exclude zones. + * @param doc - document to check + * @param options - check options + * @param settings - optional settings + * @returns + */ +export declare function checkTextDocument(doc: TextDocument | Document, options: CheckTextOptions, settings?: CSpellUserSettings): Promise; +export declare function genCheckText(docValidator: DocumentValidator): Promise; +//# sourceMappingURL=checkText.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/checkText.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/checkText.mjs new file mode 100644 index 000000000..066038397 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/checkText.mjs @@ -0,0 +1,118 @@ +import assert from 'assert'; +import { resolveDocumentToTextDocument } from '../Document/resolveDocument.mjs'; +import { isTextDocument } from '../Models/TextDocument.mjs'; +import * as Settings from '../Settings/index.mjs'; +import { clean } from '../util/util.mjs'; +import { DocumentValidator } from './docValidator.mjs'; +import { calcTextInclusionRanges } from './textValidator.mjs'; +import { validateText } from './validator.mjs'; +/** + * Annotate text with issues and include / exclude zones. + * @param text - the text to annotate. + * @param settings - the settings to use. + * @returns the Check Text result + * @deprecated + */ +export async function checkText(text, settings) { + const doc = clean({ + uri: '', + text, + languageId: settings.languageId || 'plaintext', + locale: settings.language, + }); + return checkTextDocument(doc, { noConfigSearch: true }, { loadDefaultConfiguration: false, ...settings }); +} +/** + * Annotate text with issues and include / exclude zones. + * @param text - the text to annotate. + * @param settings - the settings to use. + * @returns the Check Text result + * @deprecated + */ +export async function checkTextOld(text, settings) { + const validationResult = validateText(text, settings); + const finalSettings = Settings.finalizeSettings(settings); + const includeRanges = calcTextInclusionRanges(text, finalSettings); + const issues = await validationResult; + return genResult(text, issues, includeRanges); +} +export var IncludeExcludeFlag; +(function (IncludeExcludeFlag) { + IncludeExcludeFlag["INCLUDE"] = "I"; + IncludeExcludeFlag["EXCLUDE"] = "E"; +})(IncludeExcludeFlag || (IncludeExcludeFlag = {})); +/** + * Calculate document issues and include / exclude zones. + * @param doc - document to check + * @param options - check options + * @param settings - optional settings + * @returns + */ +export async function checkTextDocument(doc, options, settings = {}) { + doc = isTextDocument(doc) ? doc : await resolveDocumentToTextDocument(doc); + return genCheckText(new DocumentValidator(doc, options, settings)); +} +export async function genCheckText(docValidator) { + await docValidator.prepare(); + const issues = docValidator.checkDocument(true); + const preparations = docValidator._getPreparations(); + assert(preparations); + return genResult(docValidator.document.text, issues, preparations.includeRanges); +} +function genResult(text, issues, includeRanges) { + const result = []; + let lastPos = 0; + for (const { startPos, endPos } of includeRanges) { + result.push({ + text: text.slice(lastPos, startPos), + startPos: lastPos, + endPos: startPos, + flagIE: IncludeExcludeFlag.EXCLUDE, + }); + result.push({ + text: text.slice(startPos, endPos), + startPos, + endPos, + flagIE: IncludeExcludeFlag.INCLUDE, + }); + lastPos = endPos; + } + result.push({ + text: text.slice(lastPos), + startPos: lastPos, + endPos: text.length, + flagIE: IncludeExcludeFlag.EXCLUDE, + }); + function* merge() { + let i = 0; + for (const r of result) { + if (i >= issues.length || issues[i].offset >= r.endPos) { + yield r; + continue; + } + const span = { ...r }; + while (i < issues.length && issues[i].offset < span.endPos) { + const issue = issues[i]; + const endPos = issue.offset; + const text = span.text.slice(0, endPos - span.startPos); + const endPosError = issue.offset + issue.text.length; + yield { ...span, text, endPos }; + yield { + ...span, + isError: true, + startPos: issue.offset, + endPos: endPosError, + text: issue.text, + }; + span.text = span.text.slice(endPosError - span.startPos); + span.startPos = endPosError; + i += 1; + } + yield span; + } + } + return { + text, + items: [...merge()].filter((i) => i.startPos < i.endPos), + }; +} diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/defaultConstants.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/defaultConstants.d.mts new file mode 100644 index 000000000..baffd57ef --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/defaultConstants.d.mts @@ -0,0 +1,5 @@ +export declare const defaultMaxNumberOfProblems = 200; +export declare const defaultMaxDuplicateProblems = 5; +export declare const defaultMinWordLength = 4; +export declare const minWordSplitLen = 3; +//# sourceMappingURL=defaultConstants.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/defaultConstants.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/defaultConstants.mjs new file mode 100644 index 000000000..a5fd3f229 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/defaultConstants.mjs @@ -0,0 +1,4 @@ +export const defaultMaxNumberOfProblems = 200; +export const defaultMaxDuplicateProblems = 5; +export const defaultMinWordLength = 4; +export const minWordSplitLen = 3; diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/determineTextDocumentSettings.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/determineTextDocumentSettings.d.mts new file mode 100644 index 000000000..4d4bfec3d --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/determineTextDocumentSettings.d.mts @@ -0,0 +1,17 @@ +import type { CSpellUserSettings } from '@cspell/cspell-types'; +import type { CSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.mjs'; +import type { TextDocument, TextDocumentRef } from '../Models/TextDocument.mjs'; +/** + * Combines all relevant setting values into a final configuration to be used for spell checking. + * It applies any overrides and appropriate language settings by taking into account the document type (languageId) + * the locale (natural language) and any in document settings. + * + * Note: this method will not search for configuration files. Configuration files should already be merged into `settings`. + * It is NOT necessary to include the cspell defaultSettings or globalSettings. They will be applied within this function. + * @param document - The document to be spell checked. Note: if the URI doesn't have a path, overrides cannot be applied. + * `locale` - if defined will be used unless it is overridden by an in-document setting. + * `languageId` - if defined will be used to select appropriate file type dictionaries. + * @param settings - The near final settings. Should already be the combination of all configuration files. + */ +export declare function determineTextDocumentSettings(doc: TextDocument | TextDocumentRef, settings: CSpellUserSettings): CSpellSettingsInternal; +//# sourceMappingURL=determineTextDocumentSettings.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/determineTextDocumentSettings.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/determineTextDocumentSettings.mjs new file mode 100644 index 000000000..bcaeac64e --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/determineTextDocumentSettings.mjs @@ -0,0 +1,35 @@ +import * as path from 'path'; +import { getLanguagesForBasename } from '../LanguageIds.mjs'; +import { calcOverrideSettings, getDefaultSettings, getGlobalSettings, mergeSettings } from '../Settings/index.mjs'; +import { combineTextAndLanguageSettings } from '../Settings/TextDocumentSettings.mjs'; +import { uriToFilePath } from '../util/Uri.mjs'; +/** + * Combines all relevant setting values into a final configuration to be used for spell checking. + * It applies any overrides and appropriate language settings by taking into account the document type (languageId) + * the locale (natural language) and any in document settings. + * + * Note: this method will not search for configuration files. Configuration files should already be merged into `settings`. + * It is NOT necessary to include the cspell defaultSettings or globalSettings. They will be applied within this function. + * @param document - The document to be spell checked. Note: if the URI doesn't have a path, overrides cannot be applied. + * `locale` - if defined will be used unless it is overridden by an in-document setting. + * `languageId` - if defined will be used to select appropriate file type dictionaries. + * @param settings - The near final settings. Should already be the combination of all configuration files. + */ +export function determineTextDocumentSettings(doc, settings) { + const filename = uriToFilePath(doc.uri); + const settingsWithDefaults = mergeSettings(getDefaultSettings(settings.loadDefaultConfiguration ?? true), getGlobalSettings(), settings); + const fileSettings = calcOverrideSettings(settingsWithDefaults, filename); + const languageIds = fileSettings?.languageId?.length + ? fileSettings.languageId + : doc.languageId + ? doc.languageId + : getLanguageForFilename(filename); + if (doc.locale) { + fileSettings.language = doc.locale; + } + return combineTextAndLanguageSettings(fileSettings, doc.text, languageIds); +} +function getLanguageForFilename(filename) { + const basename = path.basename(filename); + return getLanguagesForBasename(basename); +} diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/docValidator.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/docValidator.d.mts new file mode 100644 index 000000000..4e854e7ec --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/docValidator.d.mts @@ -0,0 +1,125 @@ +import type { CSpellUserSettings, MappedText, ParsedText } from '@cspell/cspell-types'; +import type { CSpellSettingsInternal, CSpellSettingsInternalFinalized } from '../Models/CSpellSettingsInternalDef.mjs'; +import type { ExtendedSuggestion } from '../Models/Suggestion.mjs'; +import type { TextDocument, TextDocumentRef } from '../Models/TextDocument.mjs'; +import type { ValidationIssue } from '../Models/ValidationIssue.mjs'; +import type { SpellingDictionaryCollection } from '../SpellingDictionary/index.mjs'; +import type { WordSuggestion } from '../suggestions.mjs'; +import type { MatchRange } from '../util/TextRange.mjs'; +import type { TextValidator } from './lineValidatorFactory.mjs'; +import type { SimpleRange } from './parsedText.mjs'; +import type { ValidateTextOptions } from './ValidateTextOptions.mjs'; +import type { ValidationOptions } from './ValidationTypes.mjs'; +export interface DocumentValidatorOptions extends ValidateTextOptions { + /** + * Optional path to a configuration file. + * If given, it will be used instead of searching for a configuration file. + */ + configFile?: string; + /** + * Prevents searching for local configuration files + * By default the spell checker looks for configuration files + * starting at the location of given filename. + * If `configFile` is defined it will still be loaded instead of searching. + * `false` will override the value in `settings.noConfigSearch`. + * @defaultValue undefined + */ + noConfigSearch?: boolean; +} +export declare class DocumentValidator { + readonly settings: CSpellUserSettings; + private _document; + private _ready; + readonly errors: Error[]; + private _prepared; + private _preparations; + private _preparationTime; + private _suggestions; + readonly options: DocumentValidatorOptions; + /** + * @param doc - Document to validate + * @param config - configuration to use (not finalized). + */ + constructor(doc: TextDocument, options: DocumentValidatorOptions, settings: CSpellUserSettings); + get ready(): boolean; + /** + * Prepare to validate a document. + * This will load all the necessary configuration and dictionaries. + * + * @deprecated + * @deprecationMessage Use the async `prepare` method. + */ + prepareSync(): void; + prepare(): Promise; + private _prepareAsync; + private _updatePrep; + /** + * The amount of time in ms to prepare for validation. + */ + get prepTime(): number; + get validateDirectives(): boolean; + checkText(range: SimpleRange, _text: string, scope: string[]): ValidationIssue[]; + check(parsedText: ParsedText): ValidationIssue[]; + /** + * Check a Document for Validation Issues. + * @param forceCheck - force a check even if the document would normally be excluded. + * @returns the validation issues. + */ + checkDocumentAsync(forceCheck?: boolean): Promise; + /** + * Check a Document for Validation Issues. + * + * Note: The validator must be prepared before calling this method. + * @param forceCheck - force a check even if the document would normally be excluded. + * @returns the validation issues. + */ + checkDocument(forceCheck?: boolean): ValidationIssue[]; + checkDocumentDirectives(forceCheck?: boolean): ValidationIssue[]; + get document(): TextDocument; + updateDocumentText(text: string): void; + private defaultParser; + private _checkParsedText; + private addPossibleError; + private _parse; + private getSuggestions; + private genSuggestions; + getFinalizedDocSettings(): CSpellSettingsInternal; + /** + * Returns true if the final result of the configuration calculation results + * in the document being enabled. Note: in some cases, checking the document + * might still make sense, for example, the `@cspell/eslint-plugin` relies on + * `eslint` configuration to make that determination. + * @returns true if the document settings have resolved to be `enabled` + */ + shouldCheckDocument(): boolean; + /** + * Internal `cspell-lib` use. + */ + _getPreparations(): Preparations | undefined; +} +declare function sanitizeSuggestion(sug: WordSuggestion): ExtendedSuggestion; +interface Preparations { + /** loaded config */ + config: CSpellSettingsInternal; + dictionary: SpellingDictionaryCollection; + /** configuration after applying in-doc settings */ + docSettings: CSpellSettingsInternal; + finalSettings: CSpellSettingsInternalFinalized; + includeRanges: MatchRange[]; + textValidator: TextValidator; + segmenter: (texts: MappedText) => Iterable; + shouldCheck: boolean; + validateOptions: ValidationOptions; + localConfig: CSpellUserSettings | undefined; + localConfigFilepath: string | undefined; +} +interface ShouldCheckDocumentResult { + errors: Error[]; + shouldCheck: boolean; +} +export declare function shouldCheckDocument(doc: TextDocumentRef, options: DocumentValidatorOptions, settings: CSpellUserSettings): Promise; +export declare const __testing__: { + sanitizeSuggestion: typeof sanitizeSuggestion; +}; +export {}; +//# sourceMappingURL=docValidator.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/docValidator.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/docValidator.mjs new file mode 100644 index 000000000..d0b8c0161 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/docValidator.mjs @@ -0,0 +1,397 @@ +import { opConcatMap, opMap, pipeSync } from '@cspell/cspell-pipe/sync'; +import { IssueType } from '@cspell/cspell-types'; +import assert from 'assert'; +import { GlobMatcher } from 'cspell-glob'; +import path from 'path'; +import { updateTextDocument } from '../Models/TextDocument.mjs'; +import { loadConfigSync, searchForConfigSync } from '../Settings/Controller/configLoader/index.mjs'; +import { finalizeSettings, loadConfig, mergeSettings, searchForConfig } from '../Settings/index.mjs'; +import { validateInDocumentSettings } from '../Settings/InDocSettings.mjs'; +import { getDictionaryInternal, getDictionaryInternalSync } from '../SpellingDictionary/index.mjs'; +import { calcSuggestionAdjustedToToMatchCase } from '../suggestions.mjs'; +import { catchPromiseError, toError, wrapCall } from '../util/errors.mjs'; +import { AutoCache } from '../util/simpleCache.mjs'; +import { createTimer } from '../util/timer.mjs'; +import { uriToFilePath } from '../util/Uri.mjs'; +import { defaultMaxDuplicateProblems, defaultMaxNumberOfProblems } from './defaultConstants.mjs'; +import { determineTextDocumentSettings } from './determineTextDocumentSettings.mjs'; +import { textValidatorFactory } from './lineValidatorFactory.mjs'; +import { createMappedTextSegmenter } from './parsedText.mjs'; +import { settingsToValidateOptions } from './settingsToValidateOptions.mjs'; +import { calcTextInclusionRanges } from './textValidator.mjs'; +const ERROR_NOT_PREPARED = 'Validator Must be prepared before calling this function.'; +const skipValidation = false; +export class DocumentValidator { + /** + * @param doc - Document to validate + * @param config - configuration to use (not finalized). + */ + constructor(doc, options, settings) { + this.settings = settings; + this._ready = false; + this.errors = []; + this._preparationTime = -1; + this._suggestions = new AutoCache((text) => this.genSuggestions(text), 1000); + this._document = doc; + this.options = { ...options }; + const numSuggestions = this.options.numSuggestions ?? settings.numSuggestions; + if (numSuggestions !== undefined) { + this.options.numSuggestions = numSuggestions; + } + // console.error(`DocumentValidator: ${doc.uri}`); + } + get ready() { + return this._ready; + } + /** + * Prepare to validate a document. + * This will load all the necessary configuration and dictionaries. + * + * @deprecated + * @deprecationMessage Use the async `prepare` method. + */ + prepareSync() { + // @todo + // Determine doc settings. + // Calc include ranges + // Load dictionaries + if (this._ready) + return; + const timer = createTimer(); + const { options, settings } = this; + const useSearchForConfig = (!options.noConfigSearch && !settings.noConfigSearch) || options.noConfigSearch === false; + const optionsConfigFile = options.configFile; + const localConfigFn = optionsConfigFile + ? () => loadConfigSync(optionsConfigFile, settings) + : useSearchForConfig + ? () => searchForDocumentConfigSync(this._document, settings, settings) + : undefined; + const localConfig = localConfigFn && wrapCall(localConfigFn, (e) => this.addPossibleError(e))(); + this.addPossibleError(localConfig?.__importRef?.error); + const config = mergeSettings(settings, localConfig); + const docSettings = determineTextDocumentSettings(this._document, config); + const dict = getDictionaryInternalSync(docSettings); + const matcher = new GlobMatcher(localConfig?.ignorePaths || [], { root: process.cwd(), dot: true }); + const uri = this._document.uri; + const shouldCheck = !matcher.match(uriToFilePath(uri)) && (docSettings.enabled ?? true); + const finalSettings = finalizeSettings(docSettings); + const validateOptions = settingsToValidateOptions(finalSettings); + const includeRanges = calcTextInclusionRanges(this._document.text, validateOptions); + const segmenter = createMappedTextSegmenter(includeRanges); + const textValidator = textValidatorFactory(dict, validateOptions); + this._preparations = { + config, + dictionary: dict, + docSettings, + finalSettings, + shouldCheck, + validateOptions, + includeRanges, + segmenter, + textValidator, + localConfig, + localConfigFilepath: localConfig?.__importRef?.filename, + }; + this._ready = true; + this._preparationTime = timer.elapsed(); + // console.error(`prepareSync ${this._preparationTime.toFixed(2)}ms`); + } + async prepare() { + if (this._ready) + return; + if (this._prepared) + return this._prepared; + this._prepared = this._prepareAsync(); + return this._prepared; + } + async _prepareAsync() { + assert(!this._ready); + const timer = createTimer(); + const { options, settings } = this; + const useSearchForConfig = (!options.noConfigSearch && !settings.noConfigSearch) || options.noConfigSearch === false; + const pLocalConfig = options.configFile + ? loadConfig(options.configFile, settings) + : useSearchForConfig + ? searchForDocumentConfig(this._document, settings, settings) + : undefined; + const localConfig = (await catchPromiseError(pLocalConfig, (e) => this.addPossibleError(e))) || {}; + this.addPossibleError(localConfig?.__importRef?.error); + const config = mergeSettings(settings, localConfig); + const docSettings = determineTextDocumentSettings(this._document, config); + const dict = await getDictionaryInternal(docSettings); + const matcher = new GlobMatcher(localConfig?.ignorePaths || [], { root: process.cwd(), dot: true }); + const uri = this._document.uri; + const shouldCheck = !matcher.match(uriToFilePath(uri)) && (docSettings.enabled ?? true); + const finalSettings = finalizeSettings(docSettings); + const validateOptions = settingsToValidateOptions(finalSettings); + const includeRanges = calcTextInclusionRanges(this._document.text, validateOptions); + const segmenter = createMappedTextSegmenter(includeRanges); + const textValidator = textValidatorFactory(dict, validateOptions); + this._preparations = { + config, + dictionary: dict, + docSettings, + finalSettings, + shouldCheck, + validateOptions, + includeRanges, + segmenter, + textValidator, + localConfig, + localConfigFilepath: localConfig?.__importRef?.filename, + }; + this._ready = true; + this._preparationTime = timer.elapsed(); + } + _updatePrep() { + assert(this._preparations, ERROR_NOT_PREPARED); + const timer = createTimer(); + const prep = this._preparations; + const docSettings = determineTextDocumentSettings(this._document, prep.config); + const dict = getDictionaryInternalSync(docSettings); + const shouldCheck = docSettings.enabled ?? true; + const finalSettings = finalizeSettings(docSettings); + const validateOptions = settingsToValidateOptions(finalSettings); + const includeRanges = calcTextInclusionRanges(this._document.text, validateOptions); + const segmenter = createMappedTextSegmenter(includeRanges); + const textValidator = textValidatorFactory(dict, validateOptions); + this._preparations = { + ...prep, + dictionary: dict, + docSettings, + shouldCheck, + validateOptions, + includeRanges, + segmenter, + textValidator, + }; + this._preparationTime = timer.elapsed(); + } + /** + * The amount of time in ms to prepare for validation. + */ + get prepTime() { + return this._preparationTime; + } + get validateDirectives() { + return this.options.validateDirectives ?? this._preparations?.config.validateDirectives ?? false; + } + checkText(range, _text, scope) { + const text = this._document.text.slice(range[0], range[1]); + return this.check({ text, range, scope: scope.join(' ') }); + } + check(parsedText) { + assert(this._ready); + assert(this._preparations, ERROR_NOT_PREPARED); + const { segmenter, textValidator } = this._preparations; + // Determine settings for text range + // Slice text based upon include ranges + // Check text against dictionaries. + const document = this._document; + let line = undefined; + function mapToIssue(issue) { + const { range, text, isFlagged, isFound } = issue; + const offset = range[0]; + const length = range[1] - range[0]; + assert(!line || line.offset <= offset); + if (!line || line.offset + line.text.length <= offset) { + line = document.lineAt(offset); + } + return { text, offset, line, length, isFlagged, isFound }; + } + const issues = [...pipeSync(segmenter(parsedText), opConcatMap(textValidator.validate), opMap(mapToIssue))]; + if (!this.options.generateSuggestions) { + return issues; + } + const withSugs = issues.map((t) => { + // lazy suggestion calculation. + const text = t.text; + const suggestionsEx = this.getSuggestions(text); + t.suggestionsEx = suggestionsEx; + t.suggestions = suggestionsEx.map((s) => s.word); + return t; + }); + return withSugs; + } + /** + * Check a Document for Validation Issues. + * @param forceCheck - force a check even if the document would normally be excluded. + * @returns the validation issues. + */ + async checkDocumentAsync(forceCheck) { + await this.prepare(); + return this.checkDocument(forceCheck); + } + /** + * Check a Document for Validation Issues. + * + * Note: The validator must be prepared before calling this method. + * @param forceCheck - force a check even if the document would normally be excluded. + * @returns the validation issues. + */ + checkDocument(forceCheck = false) { + if (skipValidation) + return []; + assert(this._ready); + assert(this._preparations, ERROR_NOT_PREPARED); + const spellingIssues = forceCheck || this.shouldCheckDocument() ? [...this._checkParsedText(this._parse())] : []; + const directiveIssues = this.checkDocumentDirectives(); + // console.log('Stats: %o', this._preparations.textValidator.lineValidator.dict.stats()); + const allIssues = spellingIssues.concat(directiveIssues).sort((a, b) => a.offset - b.offset); + return allIssues; + } + checkDocumentDirectives(forceCheck = false) { + assert(this._ready); + assert(this._preparations, ERROR_NOT_PREPARED); + const validateDirectives = forceCheck || this.validateDirectives; + if (!validateDirectives) + return []; + const document = this.document; + const issueType = IssueType.directive; + function toValidationIssue(dirIssue) { + const { text, range, suggestions, suggestionsEx, message } = dirIssue; + const offset = range[0]; + const pos = document.positionAt(offset); + const line = document.getLine(pos.line); + const issue = { text, offset, line, suggestions, suggestionsEx, message, issueType }; + return issue; + } + return [...validateInDocumentSettings(this.document.text, this._preparations.config)].map(toValidationIssue); + } + get document() { + return this._document; + } + updateDocumentText(text) { + updateTextDocument(this._document, [{ text }]); + this._updatePrep(); + } + defaultParser() { + return pipeSync(this.document.getLines(), opMap((line) => { + const { text, offset } = line; + const range = [offset, offset + text.length]; + return { text, range }; + })); + } + *_checkParsedText(parsedTexts) { + assert(this._preparations, ERROR_NOT_PREPARED); + const { maxNumberOfProblems = defaultMaxNumberOfProblems, maxDuplicateProblems = defaultMaxDuplicateProblems } = this._preparations.validateOptions; + let numProblems = 0; + const mapOfProblems = new Map(); + for (const pText of parsedTexts) { + for (const issue of this.check(pText)) { + const { text } = issue; + const n = (mapOfProblems.get(text) || 0) + 1; + mapOfProblems.set(text, n); + if (n > maxDuplicateProblems) + continue; + yield issue; + if (++numProblems >= maxNumberOfProblems) + return; + } + } + } + addPossibleError(error) { + if (!error) + return; + error = this.errors.push(toError(error)); + } + _parse() { + assert(this._preparations, ERROR_NOT_PREPARED); + const parser = this._preparations.finalSettings.parserFn; + if (typeof parser !== 'object') + return this.defaultParser(); + return parser.parse(this.document.text, this.document.uri.path).parsedTexts; + } + getSuggestions(text) { + return this._suggestions.get(text); + } + genSuggestions(text) { + assert(this._preparations, ERROR_NOT_PREPARED); + const settings = this._preparations.docSettings; + const dict = this._preparations.dictionary; + const sugOptions = { + compoundMethod: 0, + numSuggestions: this.options.numSuggestions, + includeTies: false, + ignoreCase: !(settings.caseSensitive ?? false), + timeout: settings.suggestionsTimeout, + numChanges: settings.suggestionNumChanges, + }; + const locale = this._preparations.config.language; + const rawSuggestions = dict.suggest(text, sugOptions); + const sugsWithAlt = calcSuggestionAdjustedToToMatchCase(text, rawSuggestions, locale, sugOptions.ignoreCase, dict); + return sugsWithAlt.map(sanitizeSuggestion); + } + getFinalizedDocSettings() { + assert(this._ready); + assert(this._preparations, ERROR_NOT_PREPARED); + return this._preparations.docSettings; + } + /** + * Returns true if the final result of the configuration calculation results + * in the document being enabled. Note: in some cases, checking the document + * might still make sense, for example, the `@cspell/eslint-plugin` relies on + * `eslint` configuration to make that determination. + * @returns true if the document settings have resolved to be `enabled` + */ + shouldCheckDocument() { + assert(this._preparations, ERROR_NOT_PREPARED); + return this._preparations.shouldCheck; + } + /** + * Internal `cspell-lib` use. + */ + _getPreparations() { + return this._preparations; + } +} +function sanitizeSuggestion(sug) { + const { word, isPreferred, wordAdjustedToMatchCase } = sug; + if (isPreferred && wordAdjustedToMatchCase) + return { word, wordAdjustedToMatchCase, isPreferred }; + if (isPreferred) + return { word, isPreferred }; + if (wordAdjustedToMatchCase) + return { word, wordAdjustedToMatchCase }; + return { word }; +} +async function searchForDocumentConfig(document, defaultConfig, pnpSettings) { + const { uri } = document; + if (uri.scheme !== 'file') + return Promise.resolve(defaultConfig); + return searchForConfig(path.dirname(uriToFilePath(uri)), pnpSettings).then((s) => s || defaultConfig); +} +function searchForDocumentConfigSync(document, defaultConfig, pnpSettings) { + const { uri } = document; + if (uri.scheme !== 'file') + defaultConfig; + return searchForConfigSync(uriToFilePath(uri), pnpSettings) || defaultConfig; +} +export async function shouldCheckDocument(doc, options, settings) { + const errors = []; + function addPossibleError(error) { + if (!error) + return undefined; + error = errors.push(toError(error)); + return undefined; + } + async function shouldCheck() { + const useSearchForConfig = (!options.noConfigSearch && !settings.noConfigSearch) || options.noConfigSearch === false; + const pLocalConfig = options.configFile + ? loadConfig(options.configFile, settings) + : useSearchForConfig + ? searchForDocumentConfig(doc, settings, settings) + : undefined; + const localConfig = (await catchPromiseError(pLocalConfig, addPossibleError)) || {}; + addPossibleError(localConfig?.__importRef?.error); + const config = mergeSettings(settings, localConfig); + const matcher = new GlobMatcher(localConfig?.ignorePaths || [], { root: process.cwd(), dot: true }); + const docSettings = determineTextDocumentSettings(doc, config); + const uri = doc.uri; + return !matcher.match(uriToFilePath(uri)) && (docSettings.enabled ?? true); + } + return { errors, shouldCheck: await shouldCheck() }; +} +export const __testing__ = { + sanitizeSuggestion, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/index.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/index.d.mts new file mode 100644 index 000000000..f06f43f0a --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/index.d.mts @@ -0,0 +1,12 @@ +export type { ValidationIssue } from '../Models/ValidationIssue.mjs'; +export type { ValidationResult } from '../Models/ValidationResult.mjs'; +export type { CheckTextInfo, TextInfoItem } from './checkText.mjs'; +export { checkText, checkTextDocument, IncludeExcludeFlag } from './checkText.mjs'; +export type { DocumentValidatorOptions } from './docValidator.mjs'; +export { DocumentValidator, shouldCheckDocument } from './docValidator.mjs'; +export type { Offset, SimpleRange } from './parsedText.mjs'; +export { calcTextInclusionRanges } from './textValidator.mjs'; +export type { ValidateTextOptions } from './ValidateTextOptions.mjs'; +export type { CheckOptions, IncludeExcludeOptions, ValidationOptions } from './ValidationTypes.mjs'; +export { validateText } from './validator.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/index.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/index.mjs new file mode 100644 index 000000000..572ea8fca --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/index.mjs @@ -0,0 +1,4 @@ +export { checkText, checkTextDocument, IncludeExcludeFlag } from './checkText.mjs'; +export { DocumentValidator, shouldCheckDocument } from './docValidator.mjs'; +export { calcTextInclusionRanges } from './textValidator.mjs'; +export { validateText } from './validator.mjs'; diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/isWordValid.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/isWordValid.d.mts new file mode 100644 index 000000000..6b57e84be --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/isWordValid.d.mts @@ -0,0 +1,8 @@ +import type { CachingDictionary } from 'cspell-dictionary'; +import type { TextOffsetRO } from './ValidationTypes.mjs'; +export declare function hasWordCheck(dict: CachingDictionary, word: string): boolean; +export declare function isWordValidWithEscapeRetry(dict: CachingDictionary, wo: TextOffsetRO, line: TextOffsetRO): boolean; +export declare const __testing__: { + hasWordCheck: typeof hasWordCheck; +}; +//# sourceMappingURL=isWordValid.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/isWordValid.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/isWordValid.mjs new file mode 100644 index 000000000..0c8aa3f5b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/isWordValid.mjs @@ -0,0 +1,13 @@ +export function hasWordCheck(dict, word) { + word = word.replace(/\\/g, ''); + return dict.has(word); +} +export function isWordValidWithEscapeRetry(dict, wo, line) { + const firstTry = hasWordCheck(dict, wo.text); + return (firstTry || + // Drop the first letter if it is preceded by a '\'. + (line.text[wo.offset - line.offset - 1] === '\\' && hasWordCheck(dict, wo.text.slice(1)))); +} +export const __testing__ = { + hasWordCheck, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/lineValidatorFactory.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/lineValidatorFactory.d.mts new file mode 100644 index 000000000..f946aa168 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/lineValidatorFactory.d.mts @@ -0,0 +1,14 @@ +import type { CachingDictionary, SpellingDictionary } from 'cspell-dictionary'; +import type { LineValidatorFn, TextValidatorFn, ValidationOptions } from './ValidationTypes.mjs'; +interface LineValidator { + fn: LineValidatorFn; + dict: CachingDictionary; +} +export declare function lineValidatorFactory(sDict: SpellingDictionary, options: ValidationOptions): LineValidator; +export interface TextValidator { + validate: TextValidatorFn; + lineValidator: LineValidator; +} +export declare function textValidatorFactory(dict: SpellingDictionary, options: ValidationOptions): TextValidator; +export {}; +//# sourceMappingURL=lineValidatorFactory.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/lineValidatorFactory.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/lineValidatorFactory.mjs new file mode 100644 index 000000000..69c8199eb --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/lineValidatorFactory.mjs @@ -0,0 +1,118 @@ +import { opConcatMap, opFilter, opMap, pipe, toArray } from '@cspell/cspell-pipe/sync'; +import { createCachingDictionary } from 'cspell-dictionary'; +import { genSequence } from 'gensequence'; +import * as RxPat from '../Settings/RegExpPatterns.mjs'; +import * as Text from '../util/text.mjs'; +import { clean } from '../util/util.mjs'; +import { split } from '../util/wordSplitter.mjs'; +import { defaultMinWordLength } from './defaultConstants.mjs'; +import { isWordValidWithEscapeRetry } from './isWordValid.mjs'; +import { mapRangeBackToOriginalPos } from './parsedText.mjs'; +export function lineValidatorFactory(sDict, options) { + const { minWordLength = defaultMinWordLength, flagWords = [], allowCompoundWords = false, ignoreCase = true, } = options; + const hasWordOptions = { + ignoreCase, + useCompounds: allowCompoundWords || undefined, // let the dictionaries decide on useCompounds if allow is false + }; + const dictCol = createCachingDictionary(sDict, hasWordOptions); + const setOfFlagWords = new Set(flagWords); + const setOfKnownSuccessfulWords = new Set(); + const rememberFilter = (fn) => (v) => { + const keep = fn(v); + if (!keep) { + setOfKnownSuccessfulWords.add(v.text); + } + return keep; + }; + const filterAlreadyChecked = (wo) => { + return !setOfKnownSuccessfulWords.has(wo.text); + }; + function testForFlaggedWord(wo) { + const text = wo.text; + return setOfFlagWords.has(text) || setOfFlagWords.has(text.toLowerCase()) || dictCol.isForbidden(text); + } + function isWordIgnored(word) { + return dictCol.isNoSuggestWord(word); + } + function isWordFlagged(word) { + const isIgnored = isWordIgnored(word.text); + const isFlagged = !isIgnored && testForFlaggedWord(word); + return isFlagged; + } + function checkFlagWords(word) { + word.isFlagged = isWordFlagged(word); + return word; + } + function checkWord(word) { + const isIgnored = isWordIgnored(word.text); + const { isFlagged = !isIgnored && testForFlaggedWord(word) } = word; + const isFound = isFlagged ? undefined : isIgnored || isWordValidWithEscapeRetry(dictCol, word, word.line); + return clean({ ...word, isFlagged, isFound }); + } + const fn = (lineSegment) => { + function splitterIsValid(word) { + return (setOfKnownSuccessfulWords.has(word.text) || + (!testForFlaggedWord(word) && isWordValidWithEscapeRetry(dictCol, word, lineSegment.line))); + } + function checkFullWord(vr) { + if (vr.isFlagged) { + return [vr]; + } + const codeWordResults = toArray(pipe(Text.extractWordsFromCodeTextOffset(vr), opFilter(filterAlreadyChecked), opMap((t) => ({ ...t, line: vr.line })), opMap(checkFlagWords), opFilter(rememberFilter((wo) => wo.text.length >= minWordLength || !!wo.isFlagged)), opMap((wo) => (wo.isFlagged ? wo : checkWord(wo))), opFilter(rememberFilter((wo) => wo.isFlagged || !wo.isFound)), opFilter(rememberFilter((wo) => !RxPat.regExRepeatedChar.test(wo.text))), + // get back the original text. + opMap((wo) => ({ + ...wo, + text: Text.extractText(lineSegment.segment, wo.offset, wo.offset + wo.text.length), + })))); + if (!codeWordResults.length || isWordIgnored(vr.text) || checkWord(vr).isFound) { + rememberFilter((_) => false)(vr); + return []; + } + return codeWordResults; + } + function checkPossibleWords(possibleWord) { + if (isWordFlagged(possibleWord)) { + const vr = { + ...possibleWord, + line: lineSegment.line, + isFlagged: true, + }; + return [vr]; + } + const mismatches = toArray(pipe(Text.extractWordsFromTextOffset(possibleWord), opFilter(filterAlreadyChecked), opMap((wo) => ({ ...wo, line: lineSegment.line })), opMap(checkFlagWords), opFilter(rememberFilter((wo) => wo.text.length >= minWordLength || !!wo.isFlagged)), opConcatMap(checkFullWord))); + if (mismatches.length) { + // Try the more expensive word splitter + const splitResult = split(lineSegment.segment, possibleWord.offset, splitterIsValid); + const nonMatching = splitResult.words.filter((w) => !w.isFound); + if (nonMatching.length < mismatches.length) { + return nonMatching.map((w) => ({ ...w, line: lineSegment.line })).map(checkFlagWords); + } + } + return mismatches; + } + const checkedPossibleWords = genSequence(pipe(Text.extractPossibleWordsFromTextOffset(lineSegment.segment), opFilter(filterAlreadyChecked), opConcatMap(checkPossibleWords))); + return checkedPossibleWords; + }; + return { fn, dict: dictCol }; +} +export function textValidatorFactory(dict, options) { + const lineValidator = lineValidatorFactory(dict, options); + const lineValidatorFn = lineValidator.fn; + function validate(pText) { + const { text, range: srcRange, map } = pText; + const srcOffset = srcRange[0]; + const segment = { text, offset: 0 }; + const lineSegment = { line: segment, segment }; + function mapBackToOriginSimple(vr) { + const { text, offset, isFlagged, isFound } = vr; + const r = mapRangeBackToOriginalPos([offset, offset + text.length], map); + const range = [r[0] + srcOffset, r[1] + srcOffset]; + return { text, range, isFlagged, isFound }; + } + return [...lineValidatorFn(lineSegment)].map(mapBackToOriginSimple); + } + return { + validate, + lineValidator, + }; +} diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/parsedText.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/parsedText.d.mts new file mode 100644 index 000000000..7689506c6 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/parsedText.d.mts @@ -0,0 +1,15 @@ +import type { MappedText } from '@cspell/cspell-types'; +import type { ValidationIssue } from '../Models/ValidationIssue.mjs'; +import type * as TextRange from '../util/TextRange.mjs'; +export type Offset = number; +export type SimpleRange = readonly [Offset, Offset]; +export declare function mapIssueBackToOriginalPos(mappedText: MappedText, issue: ValidationIssue): ValidationIssue; +export declare function mapRangeBackToOriginalPos(offRange: SimpleRange, map: number[] | undefined): SimpleRange; +export declare function mapRangeToLocal(rangeOrig: SimpleRange, map: number[] | undefined): SimpleRange; +/** + * Factory to create a segmentation function that will segment MappedText against a set of includeRanges. + * The function produced is optimized for forward scanning. It will perform poorly for randomly ordered offsets. + * @param includeRanges Allowed ranges for words. + */ +export declare function createMappedTextSegmenter(includeRanges: TextRange.MatchRange[]): (text: MappedText) => Iterable; +//# sourceMappingURL=parsedText.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/parsedText.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/parsedText.mjs new file mode 100644 index 000000000..614b951bc --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/parsedText.mjs @@ -0,0 +1,102 @@ +import { extractTextMapRangeOrigin } from '../util/TextMap.mjs'; +export function mapIssueBackToOriginalPos(mappedText, issue) { + if (!mappedText.map || mappedText.map.length === 0) + return issue; + const textOff = mapTextOffsetBackToOriginalPos(mappedText, issue); + return { + ...issue, + ...textOff, + }; +} +function mapTextOffsetBackToOriginalPos(mappedText, textOff) { + if (!mappedText.map || !mappedText.map.length) + return textOff; + const off = textOff.offset - mappedText.range[0]; + const range = mapRangeBackToOriginalPos([off, off + (textOff.length ?? textOff.text.length)], mappedText.map); + return { + text: textOff.text, + offset: mappedText.range[0] + range[0], + length: range[1] - range[0], + }; +} +export function mapRangeBackToOriginalPos(offRange, map) { + if (!map || !map.length) + return offRange; + const [start, end] = offRange; + let i = 0, j = 0, p = 1; + while (p < map.length && map[p] < start) { + i = map[p - 1]; + j = map[p]; + p += 2; + } + const iA = start - j + i; + while (p < map.length && map[p] < end) { + i = map[p - 1]; + j = map[p]; + p += 2; + } + const iB = end - j + i; + return [iA, iB]; +} +export function mapRangeToLocal(rangeOrig, map) { + if (!map || !map.length) + return rangeOrig; + const [start, end] = rangeOrig; + let i = 0, j = 0, p = 0; + while (p < map.length && map[p] < start) { + i = map[p]; + j = map[p + 1]; + p += 2; + } + const jA = start - i + j; + while (p < map.length && map[p] < end) { + i = map[p]; + j = map[p + 1]; + p += 2; + } + const jB = end - i + j; + return [jA, jB]; +} +/** + * Factory to create a segmentation function that will segment MappedText against a set of includeRanges. + * The function produced is optimized for forward scanning. It will perform poorly for randomly ordered offsets. + * @param includeRanges Allowed ranges for words. + */ +export function createMappedTextSegmenter(includeRanges) { + let rangePos = 0; + function* segmenter(pText) { + if (!includeRanges.length) { + return; + } + const range = pText.range; + const textEndPos = range[1]; + let textStartPos = range[0]; + while (rangePos && (rangePos >= includeRanges.length || includeRanges[rangePos].startPos > textStartPos)) { + rangePos -= 1; + } + const cur = includeRanges[rangePos]; + if (textEndPos <= cur.endPos && textStartPos >= cur.startPos) { + yield pText; + return; + } + while (textStartPos < textEndPos) { + while (includeRanges[rangePos] && includeRanges[rangePos].endPos <= textStartPos) { + rangePos += 1; + } + if (!includeRanges[rangePos]) { + break; + } + const { startPos, endPos } = includeRanges[rangePos]; + if (textEndPos < startPos) { + break; + } + const a = Math.max(textStartPos, startPos); + const b = Math.min(textEndPos, endPos); + if (a !== b) { + yield extractTextMapRangeOrigin(pText, [a, b]); + } + textStartPos = b; + } + } + return segmenter; +} diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/settingsToValidateOptions.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/settingsToValidateOptions.d.mts new file mode 100644 index 000000000..de2fe7437 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/settingsToValidateOptions.d.mts @@ -0,0 +1,4 @@ +import type { CSpellSettingsInternalFinalized } from '../Models/CSpellSettingsInternalDef.mjs'; +import type { ValidationOptions } from './ValidationTypes.mjs'; +export declare function settingsToValidateOptions(settings: CSpellSettingsInternalFinalized): ValidationOptions; +//# sourceMappingURL=settingsToValidateOptions.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/settingsToValidateOptions.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/settingsToValidateOptions.mjs new file mode 100644 index 000000000..8301e6649 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/settingsToValidateOptions.mjs @@ -0,0 +1,7 @@ +export function settingsToValidateOptions(settings) { + const opt = { + ...settings, + ignoreCase: !(settings.caseSensitive ?? false), + }; + return opt; +} diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/textValidator.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/textValidator.d.mts new file mode 100644 index 000000000..dda5c06b1 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/textValidator.d.mts @@ -0,0 +1,21 @@ +import type { SpellingDictionary } from 'cspell-dictionary'; +import type { Sequence } from 'gensequence'; +import type { ValidationResult } from '../Models/ValidationResult.mjs'; +import * as TextRange from '../util/TextRange.mjs'; +import type { IncludeExcludeOptions, LineSegment, ValidationOptions } from './ValidationTypes.mjs'; +/** + * @deprecated + * @deprecation Use spellCheckDocument + */ +export declare function validateText(text: string, dict: SpellingDictionary, options: ValidationOptions): Sequence; +export declare function calcTextInclusionRanges(text: string, options: IncludeExcludeOptions): TextRange.MatchRange[]; +/** + * Returns a mapper function that will segment a TextOffset based upon the includeRanges. + * This function is optimized for forward scanning. It will perform poorly for randomly ordered offsets. + * @param includeRanges Allowed ranges for words. + */ +export declare function mapLineSegmentAgainstRangesFactory(includeRanges: TextRange.MatchRange[]): (lineSeg: LineSegment) => LineSegment[]; +export declare const _testMethods: { + mapWordsAgainstRanges: typeof mapLineSegmentAgainstRangesFactory; +}; +//# sourceMappingURL=textValidator.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/textValidator.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/textValidator.mjs new file mode 100644 index 000000000..60e823714 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/textValidator.mjs @@ -0,0 +1,88 @@ +import { opConcatMap, opFilter, opTake, pipe } from '@cspell/cspell-pipe/sync'; +import { genSequence } from 'gensequence'; +import * as Text from '../util/text.mjs'; +import * as TextRange from '../util/TextRange.mjs'; +import { defaultMaxDuplicateProblems, defaultMaxNumberOfProblems } from './defaultConstants.mjs'; +import { lineValidatorFactory } from './lineValidatorFactory.mjs'; +/** + * @deprecated + * @deprecation Use spellCheckDocument + */ +export function validateText(text, dict, options) { + const { maxNumberOfProblems = defaultMaxNumberOfProblems, maxDuplicateProblems = defaultMaxDuplicateProblems } = options; + const mapOfProblems = new Map(); + const includeRanges = calcTextInclusionRanges(text, options); + const lineValidator = lineValidatorFactory(dict, options); + const validator = lineValidator.fn; + const iter = pipe(Text.extractLinesOfText(text), opConcatMap(mapLineToLineSegments(includeRanges)), opConcatMap(validator), opFilter((wo) => { + const word = wo.text; + // Keep track of the number of times we have seen the same problem + const n = (mapOfProblems.get(word) || 0) + 1; + mapOfProblems.set(word, n); + // Filter out if there is too many + return n <= maxDuplicateProblems; + }), opTake(maxNumberOfProblems)); + return genSequence(iter); +} +export function calcTextInclusionRanges(text, options) { + const { ignoreRegExpList = [], includeRegExpList = [] } = options; + const filteredIncludeList = includeRegExpList.filter((a) => !!a); + const finalIncludeList = filteredIncludeList.length ? filteredIncludeList : [/.*/gim]; + const includeRanges = TextRange.excludeRanges(TextRange.findMatchingRangesForPatterns(finalIncludeList, text), TextRange.findMatchingRangesForPatterns(ignoreRegExpList, text)); + return includeRanges; +} +function mapLineToLineSegments(includeRanges) { + const mapAgainstRanges = mapLineSegmentAgainstRangesFactory(includeRanges); + return (line) => { + const segment = { line, segment: line }; + return mapAgainstRanges(segment); + }; +} +/** + * Returns a mapper function that will segment a TextOffset based upon the includeRanges. + * This function is optimized for forward scanning. It will perform poorly for randomly ordered offsets. + * @param includeRanges Allowed ranges for words. + */ +export function mapLineSegmentAgainstRangesFactory(includeRanges) { + let rangePos = 0; + const mapper = (lineSeg) => { + if (!includeRanges.length) { + return []; + } + const parts = []; + const { segment, line } = lineSeg; + const { text, offset, length } = segment; + const textEndPos = offset + (length ?? text.length); + let textStartPos = offset; + while (rangePos && (rangePos >= includeRanges.length || includeRanges[rangePos].startPos > textStartPos)) { + rangePos -= 1; + } + const cur = includeRanges[rangePos]; + if (textEndPos <= cur.endPos && textStartPos >= cur.startPos) { + return [lineSeg]; + } + while (textStartPos < textEndPos) { + while (includeRanges[rangePos] && includeRanges[rangePos].endPos <= textStartPos) { + rangePos += 1; + } + if (!includeRanges[rangePos]) { + break; + } + const { startPos, endPos } = includeRanges[rangePos]; + if (textEndPos < startPos) { + break; + } + const a = Math.max(textStartPos, startPos); + const b = Math.min(textEndPos, endPos); + if (a !== b) { + parts.push({ line, segment: { offset: a, text: text.slice(a - offset, b - offset) } }); + } + textStartPos = b; + } + return parts; + }; + return mapper; +} +export const _testMethods = { + mapWordsAgainstRanges: mapLineSegmentAgainstRangesFactory, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/validator.d.mts b/action/node_modules/cspell-lib/dist/esm/textValidation/validator.d.mts new file mode 100644 index 000000000..771ff4efa --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/validator.d.mts @@ -0,0 +1,10 @@ +import type { CSpellUserSettings } from '@cspell/cspell-types'; +import type { ValidationIssue } from '../Models/ValidationIssue.mjs'; +import type { ValidateTextOptions } from './ValidateTextOptions.mjs'; +export declare const diagSource = "cSpell Checker"; +/** + * @deprecated + * @deprecationMessage Use spellCheckDocument + */ +export declare function validateText(text: string, settings: CSpellUserSettings, options?: ValidateTextOptions): Promise; +//# sourceMappingURL=validator.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/textValidation/validator.mjs b/action/node_modules/cspell-lib/dist/esm/textValidation/validator.mjs new file mode 100644 index 000000000..052b4b310 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/textValidation/validator.mjs @@ -0,0 +1,58 @@ +import { IssueType } from '@cspell/cspell-types'; +import { createTextDocument } from '../Models/TextDocument.mjs'; +import * as Settings from '../Settings/index.mjs'; +import { validateInDocumentSettings } from '../Settings/InDocSettings.mjs'; +import { CompoundWordsMethod, getDictionaryInternal } from '../SpellingDictionary/index.mjs'; +import { settingsToValidateOptions } from './settingsToValidateOptions.mjs'; +import { validateText as validateFullText } from './textValidator.mjs'; +export const diagSource = 'cSpell Checker'; +/** + * @deprecated + * @deprecationMessage Use spellCheckDocument + */ +export async function validateText(text, settings, options = {}) { + const finalSettings = Settings.finalizeSettings(settings); + const dict = await getDictionaryInternal(finalSettings); + const spellingIssues = [...validateFullText(text, dict, settingsToValidateOptions(finalSettings))]; + const validationIssues = options.validateDirectives || finalSettings.validateDirectives + ? validateInDocumentSettings(text, settings) + : []; + const issues = spellingIssues.concat(mapValidationIssues(text, validationIssues)); + if (!options.generateSuggestions) { + return issues; + } + const sugOptions = { + numSuggestions: options.numSuggestions, + compoundMethod: CompoundWordsMethod.NONE, + includeTies: false, + ignoreCase: !(settings.caseSensitive ?? false), + timeout: settings.suggestionsTimeout, + numChanges: settings.suggestionNumChanges, + }; + const withSugs = issues.map((t) => { + const text = t.text; + const suggestionsEx = dict + .suggest(text, sugOptions) + .map(({ word, isPreferred }) => (isPreferred ? { word, isPreferred } : { word })); + t.suggestions = suggestionsEx.map((s) => s.word); + t.suggestionsEx = suggestionsEx; + return t; + }); + return withSugs; +} +function mapValidationIssues(text, valIssues) { + const issues = [...valIssues]; + if (!issues.length) + return []; + const document = createTextDocument({ uri: '', content: text }); + const issueType = IssueType.directive; + function toValidationIssue(dirIssue) { + const { text, range, suggestions, suggestionsEx, message } = dirIssue; + const offset = range[0]; + const pos = document.positionAt(offset); + const line = document.getLine(pos.line); + const issue = { text, offset, line, suggestions, suggestionsEx, message, issueType }; + return issue; + } + return issues.map(toValidationIssue); +} diff --git a/action/node_modules/cspell-lib/dist/esm/trace.d.mts b/action/node_modules/cspell-lib/dist/esm/trace.d.mts new file mode 100644 index 000000000..84a8c24c8 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/trace.d.mts @@ -0,0 +1,23 @@ +import type { CSpellSettings, LocaleId } from '@cspell/cspell-types'; +import type { LanguageId } from './LanguageIds.mjs'; +export interface TraceResult { + word: string; + found: boolean; + foundWord: string | undefined; + forbidden: boolean; + noSuggest: boolean; + dictName: string; + dictSource: string; + dictActive: boolean; + configSource: string; + errors: Error[] | undefined; +} +export interface TraceOptions { + languageId?: LanguageId | LanguageId[]; + locale?: LocaleId; + ignoreCase?: boolean; + allowCompoundWords?: boolean; +} +export declare function traceWords(words: string[], settings: CSpellSettings, options: TraceOptions | undefined): Promise; +export declare function traceWordsAsync(words: Iterable | AsyncIterable, settings: CSpellSettings, options: TraceOptions | undefined): AsyncIterableIterator; +//# sourceMappingURL=trace.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/trace.mjs b/action/node_modules/cspell-lib/dist/esm/trace.mjs new file mode 100644 index 000000000..ce265ad5d --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/trace.mjs @@ -0,0 +1,64 @@ +import { genSequence } from 'gensequence'; +import { toInternalSettings } from './Settings/CSpellSettingsServer.mjs'; +import { finalizeSettings, mergeSettings } from './Settings/index.mjs'; +import { calcSettingsForLanguageId } from './Settings/LanguageSettings.mjs'; +import { getDictionaryInternal, refreshDictionaryCache } from './SpellingDictionary/index.mjs'; +import * as util from './util/util.mjs'; +export async function traceWords(words, settings, options) { + const results = await util.asyncIterableToArray(traceWordsAsync(words, settings, options)); + const s = genSequence(results) + .concatMap((p) => p) + .toArray(); + return s; +} +export async function* traceWordsAsync(words, settings, options) { + const { languageId, locale: language, ignoreCase = true, allowCompoundWords } = options || {}; + async function finalize(config) { + const withLocale = mergeSettings(config, util.clean({ + language: language || config.language, + allowCompoundWords: allowCompoundWords ?? config.allowCompoundWords, + })); + const withLanguageId = calcSettingsForLanguageId(withLocale, languageId ?? withLocale.languageId ?? 'plaintext'); + const settings = finalizeSettings(withLanguageId); + const dictionaries = (settings.dictionaries || []) + .concat((settings.dictionaryDefinitions || []).map((d) => d.name)) + .filter(util.uniqueFn); + const dictSettings = toInternalSettings({ ...settings, dictionaries }); + const dictBase = await getDictionaryInternal(settings); + const dicts = await getDictionaryInternal(dictSettings); + const activeDictionaries = dictBase.dictionaries.map((d) => d.name); + return { + activeDictionaries, + config: settings, + dicts, + }; + } + await refreshDictionaryCache(); + const { config, dicts, activeDictionaries } = await finalize(settings); + const setOfActiveDicts = new Set(activeDictionaries); + const opts = util.clean({ ignoreCase, useCompounds: config.allowCompoundWords }); + function normalizeErrors(errors) { + if (!errors?.length) + return undefined; + return errors; + } + function processWord(word) { + return dicts.dictionaries + .map((dict) => ({ dict, findResult: dict.find(word, opts) })) + .map(({ dict, findResult }) => ({ + word, + found: !!findResult?.found, + foundWord: findResult?.found || undefined, + forbidden: findResult?.forbidden || false, + noSuggest: findResult?.noSuggest || false, + dictName: dict.name, + dictSource: dict.source, + dictActive: setOfActiveDicts.has(dict.name), + configSource: config.name || '', + errors: normalizeErrors(dict.getErrors?.()), + })); + } + for await (const word of words) { + yield processWord(word); + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/AutoResolve.d.mts b/action/node_modules/cspell-lib/dist/esm/util/AutoResolve.d.mts new file mode 100644 index 000000000..0381846c7 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/AutoResolve.d.mts @@ -0,0 +1,21 @@ +export declare function autoResolve(map: Map, key: K, resolve: (k: K) => V): V; +export declare class AutoResolveCache { + readonly map: Map; + get(k: K): V | undefined; + get(k: K, resolve: (k: K) => V): V; + get(k: K, resolve?: (k: K) => V): V | undefined; + has(k: K): boolean; + set(k: K, v: V): this; +} +export declare function createAutoResolveCache(): AutoResolveCache; +export declare function autoResolveWeak(map: WeakMap, key: K, resolve: (k: K) => V): V; +export declare class AutoResolveWeakCache { + readonly map: WeakMap; + get(k: K): V | undefined; + get(k: K, resolve: (k: K) => V): V; + get(k: K, resolve?: (k: K) => V): V | undefined; + has(k: K): boolean; + set(k: K, v: V): this; +} +export declare function createAutoResolveWeakCache(): AutoResolveWeakCache; +//# sourceMappingURL=AutoResolve.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/AutoResolve.mjs b/action/node_modules/cspell-lib/dist/esm/util/AutoResolve.mjs new file mode 100644 index 000000000..971480732 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/AutoResolve.mjs @@ -0,0 +1,52 @@ +export function autoResolve(map, key, resolve) { + const found = map.get(key); + if (found !== undefined || map.has(key)) + return found; + const value = resolve(key); + map.set(key, value); + return value; +} +export class AutoResolveCache { + constructor() { + this.map = new Map(); + } + get(k, resolve) { + return resolve ? autoResolve(this.map, k, resolve) : this.map.get(k); + } + has(k) { + return this.map.has(k); + } + set(k, v) { + this.map.set(k, v); + return this; + } +} +export function createAutoResolveCache() { + return new AutoResolveCache(); +} +export function autoResolveWeak(map, key, resolve) { + const found = map.get(key); + if (found !== undefined || map.has(key)) + return found; + const value = resolve(key); + map.set(key, value); + return value; +} +export class AutoResolveWeakCache { + constructor() { + this.map = new WeakMap(); + } + get(k, resolve) { + return resolve ? autoResolveWeak(this.map, k, resolve) : this.map.get(k); + } + has(k) { + return this.map.has(k); + } + set(k, v) { + this.map.set(k, v); + return this; + } +} +export function createAutoResolveWeakCache() { + return new AutoResolveWeakCache(); +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/AutoResolveLRUCache.d.mts b/action/node_modules/cspell-lib/dist/esm/util/AutoResolveLRUCache.d.mts new file mode 100644 index 000000000..8ac09074a --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/AutoResolveLRUCache.d.mts @@ -0,0 +1,54 @@ +interface LLNode { + value: T; + n?: LLNode | undefined; + p?: LLNode | undefined; +} +interface LL { + n?: LLNode | undefined; + p?: LLNode | undefined; +} +export declare class AutoResolveLRUCache { + readonly maxSize: number; + readonly isEqual: (a: T, b: T) => boolean; + protected list: LL<{ + p: T; + r: V; + }>; + private count; + private _misses; + private _hits; + private _added; + private _removed; + constructor(maxSize: number, isEqual: (a: T, b: T) => boolean); + get(params: T): V | undefined; + get(params: T, fn: (p: T) => V): V; + get(params: T, fn?: (p: T) => V): V | undefined; + get size(): number; + get hits(): number; + get misses(): number; + get added(): number; + get removed(): number; + clear(): void; + private addToHead; + stats(): { + size: number; + hits: number; + misses: number; + added: number; + removed: number; + }; + toJSON(): { + size: number; + hits: number; + misses: number; + added: number; + removed: number; + }; + static assertValid(cache: AutoResolveLRUCache): void; +} +export declare function assertValidateLL(list: LL): void; +export declare class AutoResolveLastNCalls extends AutoResolveLRUCache { + constructor(maxSize: number); +} +export {}; +//# sourceMappingURL=AutoResolveLRUCache.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/AutoResolveLRUCache.mjs b/action/node_modules/cspell-lib/dist/esm/util/AutoResolveLRUCache.mjs new file mode 100644 index 000000000..cb10feb12 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/AutoResolveLRUCache.mjs @@ -0,0 +1,128 @@ +import assert from 'assert'; +import { isArrayEqual } from './util.mjs'; +export class AutoResolveLRUCache { + constructor(maxSize, isEqual) { + this.maxSize = maxSize; + this.isEqual = isEqual; + this.list = {}; + this.count = 0; + this._misses = 0; + this._hits = 0; + this._added = 0; + this._removed = 0; + assert(maxSize > 0); + } + get(params, fn) { + const isEqual = this.isEqual; + for (let n = this.list.n; n; n = n.n) { + if (isEqual(n.value.p, params)) { + this.addToHead(n); + ++this._hits; + return n.value.r; + } + } + ++this._misses; + if (!fn) + return undefined; + const value = { + p: params, + r: fn(params), + }; + this.addToHead({ value, n: undefined, p: undefined }); + return value.r; + } + get size() { + return this.count; + } + get hits() { + return this._hits; + } + get misses() { + return this._misses; + } + get added() { + return this._added; + } + get removed() { + return this._removed; + } + clear() { + this._added = 0; + this._hits = 0; + this._misses = 0; + this._removed = 0; + this.list.n = undefined; + this.list.p = undefined; + this.count = 0; + } + addToHead(n) { + if (!this.list.n) { + this.list.n = n; + this.list.p = n; + n.n = undefined; + n.p = undefined; + this.count = 1; + this._added = 1; + return; + } + if (this.list.n === n) + return; + if (this.list.p === n) { + this.list.p = n.p; + } + const isNew = !n.n && !n.p; + n.p && (n.p.n = n.n); + n.n && (n.n.p = n.p); + n.p = undefined; + n.n = this.list.n; + n.n && (n.n.p = n); + this.list.n = n; + const add = (isNew && 1) || 0; + this._added += add; + this.count += add; + if (this.count > this.maxSize) { + const prev = this.list.p?.p; + assert(prev); + prev.n = undefined; + this.list.p = prev; + ++this._removed; + --this.count; + } + } + stats() { + return { size: this.count, hits: this.hits, misses: this.misses, added: this.added, removed: this.removed }; + } + toJSON() { + return this.stats(); + } + static assertValid(cache) { + assertValidateLL(cache.list); + } +} +export function assertValidateLL(list) { + if (!list.n && !list.p) + return; + assert(list.n, 'Bad Next'); + assert(list.p, 'Bad Prev'); + const visited = new Set(); + // validate forwards + let n = list; + for (; n.n; n = n.n) { + assert(!visited.has(n.n), 'Circular'); + visited.add(n.n); + } + assert(list.p === n, 'Tail matches'); + visited.clear(); + // validate backwards + n = list; + for (; n.p; n = n.p) { + assert(!visited.has(n.p), 'Circular'); + visited.add(n.p); + } + assert(list.n === n, 'Head matches'); +} +export class AutoResolveLastNCalls extends AutoResolveLRUCache { + constructor(maxSize) { + super(maxSize, isArrayEqual); + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/Comparable.d.mts b/action/node_modules/cspell-lib/dist/esm/util/Comparable.d.mts new file mode 100644 index 000000000..24da3aefa --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/Comparable.d.mts @@ -0,0 +1,20 @@ +export type Comparable = number | string | boolean | undefined | null | Date; +export type ComparableFilter = T extends Comparable ? T : never; +export type ComparablePropertyNames = { + [K in keyof T]: T[K] extends Comparable ? K : never; +}[keyof T]; +export type ComparableProperties = Pick>; +export type CompareArg = ComparablePropertyNames | ((t: T) => Comparable); +export type CompareFn = (a: T, b: T) => number; +export declare function compareBy(extract: CompareArg, ...extractors: CompareArg[]): CompareFn; +export declare function compareBy(extract: CompareArg): CompareFn; +export declare function compareBy(extract1: CompareArg, extract2: CompareArg): CompareFn; +export declare function compareBy(extract1: CompareArg, extract2: CompareArg, extract3: CompareArg): CompareFn; +export declare function compareByRev(extract: CompareArg, ...extractors: CompareArg[]): CompareFn; +export declare function compareByRev(extract: CompareArg): CompareFn; +export declare function compareByRev(extract1: CompareArg, extract2: CompareArg): CompareFn; +export declare function compareByRev(extract1: CompareArg, extract2: CompareArg, extract3: CompareArg): CompareFn; +export declare function compareEach(...compareFn: CompareFn[]): CompareFn; +export declare function compare(a: T, b: T): number; +export declare function reverse(fn: CompareFn): CompareFn; +//# sourceMappingURL=Comparable.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/Comparable.mjs b/action/node_modules/cspell-lib/dist/esm/util/Comparable.mjs new file mode 100644 index 000000000..de3da47ef --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/Comparable.mjs @@ -0,0 +1,46 @@ +export function compareBy(extract, ...extractors) { + const compareFns = [extract, ...extractors] + .map((ex) => (typeof ex === 'function' ? ex : (t) => t[ex])) + .map((ex) => (a, b) => _compare(ex(a), ex(b))); + return compareEach(...compareFns); +} +export function compareByRev(extract, ...extractors) { + return reverse(compareBy(extract, ...extractors)); +} +export function compareEach(...compareFn) { + return (a, b) => { + for (const fn of compareFn) { + const r = fn(a, b); + if (r) { + return r; + } + } + return 0; + }; +} +function _compare(a, b) { + if (a === b) + return 0; + if (a === undefined) + return 1; + if (b === undefined) + return -1; + if (a === null) + return 1; + if (b === null) + return -1; + if (a < b) + return -1; + if (a > b) + return 1; + return 0; +} +export function compare(a, b) { + return _compare(a, b); +} +export function reverse(fn) { + return (a, b) => { + const r = fn(a, b); + return r ? -r : 0; + }; +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/FreqCounter.d.mts b/action/node_modules/cspell-lib/dist/esm/util/FreqCounter.d.mts new file mode 100644 index 000000000..3f17ffc8d --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/FreqCounter.d.mts @@ -0,0 +1,16 @@ +import type { IterableLike } from './IterableLike.mjs'; +export declare class FreqCounter { + private _total; + readonly _counters: Map; + get total(): number; + get counters(): Map; + getCount(key: T): number | undefined; + getFreq(key: T): number; + addKeyCount(key: T, count: number): this; + addKey(key: T): this; + addKeys(keys: IterableLike): void; + addKeyCounts(values: IterableLike<[T, number]>): void; + merge(...freqCounters: FreqCounter[]): FreqCounter; + static create(values?: IterableLike): FreqCounter; +} +//# sourceMappingURL=FreqCounter.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/FreqCounter.mjs b/action/node_modules/cspell-lib/dist/esm/util/FreqCounter.mjs new file mode 100644 index 000000000..c3bdf46ae --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/FreqCounter.mjs @@ -0,0 +1,47 @@ +export class FreqCounter { + constructor() { + this._total = 0; + this._counters = new Map(); + } + get total() { + return this._total; + } + get counters() { + return this._counters; + } + getCount(key) { + return this._counters.get(key); + } + getFreq(key) { + return (this.getCount(key) || 0) / (this._total || 1); + } + addKeyCount(key, count) { + this._total += count; + this._counters.set(key, (this._counters.get(key) || 0) + count); + return this; + } + addKey(key) { + return this.addKeyCount(key, 1); + } + addKeys(keys) { + for (const key of keys) { + this.addKey(key); + } + } + addKeyCounts(values) { + for (const pair of values) { + this.addKeyCount(pair[0], pair[1]); + } + } + merge(...freqCounters) { + for (const fc of freqCounters) { + this.addKeyCounts(fc._counters); + } + return this; + } + static create(values) { + const fc = new FreqCounter(); + fc.addKeys(values || []); + return fc; + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/IterableLike.d.mts b/action/node_modules/cspell-lib/dist/esm/util/IterableLike.d.mts new file mode 100644 index 000000000..eaaa91b93 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/IterableLike.d.mts @@ -0,0 +1,4 @@ +export interface IterableLike { + [Symbol.iterator]: () => Iterator | IterableIterator; +} +//# sourceMappingURL=IterableLike.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/IterableLike.mjs b/action/node_modules/cspell-lib/dist/esm/util/IterableLike.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/IterableLike.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell-lib/dist/esm/util/MinHeapQueue.d.mts b/action/node_modules/cspell-lib/dist/esm/util/MinHeapQueue.d.mts new file mode 100644 index 000000000..9f1f3d65c --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/MinHeapQueue.d.mts @@ -0,0 +1,23 @@ +declare function addToHeap(t: T[], c: T, compare: (a: T, b: T) => number): void; +declare function takeFromHeap(t: T[], compare: (a: T, b: T) => number): T | undefined; +/** + * MinHeapQueue - based upon a minHeap array. + */ +export declare class MinHeapQueue implements IterableIterator { + readonly compare: (a: T, b: T) => number; + private values; + constructor(compare: (a: T, b: T) => number); + add(t: T): MinHeapQueue; + get length(): number; + dequeue(): T | undefined; + concat(i: Iterable): MinHeapQueue; + next(): IteratorResult; + [Symbol.iterator](): IterableIterator; + clone(): MinHeapQueue; +} +export declare const __testing__: { + addToHeap: typeof addToHeap; + takeFromHeap: typeof takeFromHeap; +}; +export {}; +//# sourceMappingURL=MinHeapQueue.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/MinHeapQueue.mjs b/action/node_modules/cspell-lib/dist/esm/util/MinHeapQueue.mjs new file mode 100644 index 000000000..567725c62 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/MinHeapQueue.mjs @@ -0,0 +1,92 @@ +function swap(t, i, j) { + const a = t[i]; + t[i] = t[j]; + t[j] = a; +} +function addToHeap(t, c, compare) { + t.push(c); + let b = t.length - 1; + let a = (b - 1) >> 1; + while (b > 0 && compare(t[a], t[b]) >= 0) { + swap(t, a, b); + b = a; + a = (b - 1) >> 1; + } +} +function takeFromHeap(t, compare) { + const result = t[0]; + if (t.length <= 1) { + t.length = 0; + return result; + } + t[0] = t[t.length - 1]; + t.length -= 1; + const m = t.length - 1; + let i = 0; + let j = i * 2 + 1; + while (j < m) { + const a = j; + const b = j + 1; + const k = compare(t[a], t[b]) < 0 ? a : b; + if (compare(t[i], t[k]) <= 0) { + break; + } + swap(t, i, k); + i = k; + j = i * 2 + 1; + } + if (j === m) { + if (compare(t[i], t[j]) > 0) { + swap(t, i, j); + } + } + return result; +} +/** + * MinHeapQueue - based upon a minHeap array. + */ +export class MinHeapQueue { + constructor(compare) { + this.compare = compare; + this.values = []; + } + add(t) { + addToHeap(this.values, t, this.compare); + return this; + } + get length() { + return this.values.length; + } + dequeue() { + return takeFromHeap(this.values, this.compare); + } + concat(i) { + for (const v of i) { + this.add(v); + } + return this; + } + next() { + const value = this.dequeue(); + return value !== undefined + ? { + value, + } + : { + value, + done: true, + }; + } + [Symbol.iterator]() { + return this; + } + clone() { + const clone = new MinHeapQueue(this.compare); + clone.values = this.values.concat(); + return clone; + } +} +export const __testing__ = { + addToHeap, + takeFromHeap, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/util/PairingHeap.d.mts b/action/node_modules/cspell-lib/dist/esm/util/PairingHeap.d.mts new file mode 100644 index 000000000..63cbcbcda --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/PairingHeap.d.mts @@ -0,0 +1,32 @@ +export interface PairHeapNode { + /** Value */ + v: T; + /** Siblings */ + s: PairHeapNode | undefined; + /** Children */ + c: PairHeapNode | undefined; +} +export type CompareFn = (a: T, b: T) => number; +export declare class PairingHeap implements IterableIterator { + readonly compare: CompareFn; + private _heap; + private _size; + constructor(compare: CompareFn); + add(v: T): this; + dequeue(): T | undefined; + concat(i: Iterable): this; + next(): IteratorResult; + peek(): T | undefined; + [Symbol.iterator](): IterableIterator; + get length(): number; +} +declare function insert(compare: CompareFn, heap: PairHeapNode | undefined, v: T): PairHeapNode; +declare function merge(compare: CompareFn, a: PairHeapNode, b: PairHeapNode): PairHeapNode; +declare function mergeSiblings(compare: CompareFn, n: PairHeapNode): PairHeapNode; +export declare const heapMethods: { + insert: typeof insert; + merge: typeof merge; + mergeSiblings: typeof mergeSiblings; +}; +export {}; +//# sourceMappingURL=PairingHeap.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/PairingHeap.js b/action/node_modules/cspell-lib/dist/esm/util/PairingHeap.mjs similarity index 100% rename from action/node_modules/cspell-trie-lib/dist/esm/lib/utils/PairingHeap.js rename to action/node_modules/cspell-lib/dist/esm/util/PairingHeap.mjs diff --git a/action/node_modules/cspell-lib/dist/esm/util/TextMap.d.mts b/action/node_modules/cspell-lib/dist/esm/util/TextMap.d.mts new file mode 100644 index 000000000..1cbc04797 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/TextMap.d.mts @@ -0,0 +1,15 @@ +import type { MappedText } from '@cspell/cspell-types'; +import type { Range } from '@cspell/cspell-types/Parser'; +/** + * Extract a substring from a TextMap. + * @param textMap - A text range with an optional map + * @param extractRange - The range in the original document to extract + * @returns The TextMap covering extractRange + */ +export declare function extractTextMapRangeOrigin(textMap: MappedText, extractRange: Range): MappedText; +interface WithRange { + readonly range: Range; +} +export declare function doesIntersect(textMap: WithRange, rangeOrigin: Range): boolean; +export {}; +//# sourceMappingURL=TextMap.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/TextMap.mjs b/action/node_modules/cspell-lib/dist/esm/util/TextMap.mjs new file mode 100644 index 000000000..cb6c047c8 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/TextMap.mjs @@ -0,0 +1,53 @@ +import assert from 'assert'; +/** + * Extract a substring from a TextMap. + * @param textMap - A text range with an optional map + * @param extractRange - The range in the original document to extract + * @returns The TextMap covering extractRange + */ +export function extractTextMapRangeOrigin(textMap, extractRange) { + const { text: srcTxt, range: srcRange, map: srcMap } = textMap; + const [r0, r1] = srcRange; + const startOrig = Math.min(Math.max(extractRange[0], r0), r1); + const endOrig = Math.min(Math.max(extractRange[1], r0), r1); + const a = startOrig - r0; + const b = endOrig - r0; + const range = [startOrig, endOrig]; + if (!srcMap || !srcMap.length || a === b) { + const text = srcTxt.slice(a, b); + return { text, range }; + } + assert((srcMap.length & 1) === 0, 'Map must be pairs of values.'); + const mapLen = srcMap.length; + const mapEndSrc = srcMap[mapLen - 2]; + const mapEndDst = srcMap[mapLen - 1]; + const endDiff = srcTxt.length - mapEndDst; + const head = !srcMap[0] && !srcMap[1] ? [] : [0, 0]; + const tail = [mapEndSrc + endDiff, mapEndDst + endDiff]; + const sMap = head.concat(srcMap).concat(tail); + let idx = 0; + for (; idx < sMap.length && a >= sMap[idx]; idx += 2) { + // empty + } + const aIdx = idx; + idx -= 2; + const a0 = a - sMap[idx]; + const a1 = a0 + sMap[idx + 1]; + for (; idx < sMap.length && b > sMap[idx]; idx += 2) { + // empty + } + const bIdx = idx; + const b0 = b - sMap[idx]; + const b1 = b0 + sMap[idx + 1]; + const text = srcTxt.slice(a1, b1); + if (bIdx === aIdx) { + return { text, range }; + } + const ab = [a0, a1]; + const map = sMap.slice(aIdx, bIdx + 2).map((v, i) => v - ab[i & 1]); + return { text, range, map }; +} +export function doesIntersect(textMap, rangeOrigin) { + const r = textMap.range; + return r[0] < rangeOrigin[1] && r[1] > rangeOrigin[0]; +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/TextRange.d.mts b/action/node_modules/cspell-lib/dist/esm/util/TextRange.d.mts new file mode 100644 index 000000000..4fc6efb31 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/TextRange.d.mts @@ -0,0 +1,28 @@ +export interface MatchRange { + startPos: number; + endPos: number; +} +export interface MatchRangeWithText extends MatchRange { + text: string; +} +export interface MatchRangeOptionalText extends MatchRange { + text?: string; +} +export declare function findMatchingRanges(pattern: RegExp, text: string): MatchRangeOptionalText[]; +export declare function unionRanges(ranges: MatchRange[]): MatchRange[]; +export declare function findMatchingRangesForPatterns(patterns: RegExp[], text: string): MatchRange[]; +/** + * Create a new set of positions that have the excluded position ranges removed. + */ +export declare function excludeRanges(includeRanges: MatchRange[], excludeRanges: MatchRange[]): MatchRange[]; +export declare function extractRangeText(text: string, ranges: MatchRange[]): MatchRangeWithText[]; +declare const SymSortedMatchRangeArray: unique symbol; +interface SortedMatchRangeArray extends Array { + [SymSortedMatchRangeArray]: true; +} +declare function makeSortedMatchRangeArray(sortedValues: MatchRange[]): SortedMatchRangeArray; +export declare const __testing__: { + makeSortedMatchRangeArray: typeof makeSortedMatchRangeArray; +}; +export {}; +//# sourceMappingURL=TextRange.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/TextRange.mjs b/action/node_modules/cspell-lib/dist/esm/util/TextRange.mjs new file mode 100644 index 000000000..905ede007 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/TextRange.mjs @@ -0,0 +1,112 @@ +import * as GS from 'gensequence'; +function toMatchRangeWithText(m) { + const index = m.index || 0; + const _text = m[0]; + return { + startPos: index, + endPos: index + _text.length, + text: _text, + }; +} +export function findMatchingRanges(pattern, text) { + if (pattern.source === '.*') { + return [{ startPos: 0, endPos: text.length }]; + } + const regex = new RegExp(pattern); + if (!regex.global) { + const m = text.match(regex); + if (!m) + return []; + return [toMatchRangeWithText(m)]; + } + return [...text.matchAll(regex)].map(toMatchRangeWithText); +} +function compareRanges(a, b) { + return a.startPos - b.startPos || a.endPos - b.endPos; +} +export function unionRanges(ranges) { + return makeSortedMatchRangeArray([..._unionRanges(ranges)]); +} +function* _unionRanges(ranges) { + const sortedRanges = sortMatchRangeArray(ranges); + if (!sortedRanges.length) + return; + let { startPos, endPos } = sortedRanges[0]; + for (const r of ranges) { + if (r.startPos > endPos) { + yield { startPos, endPos }; + startPos = r.startPos; + endPos = r.endPos; + continue; + } + endPos = Math.max(endPos, r.endPos); + } + if (startPos < endPos) { + yield { startPos, endPos }; + } +} +export function findMatchingRangesForPatterns(patterns, text) { + const matchedPatterns = GS.genSequence(patterns).concatMap((pattern) => findMatchingRanges(pattern, text)); + return unionRanges(matchedPatterns.toArray()); +} +/** + * Create a new set of positions that have the excluded position ranges removed. + */ +export function excludeRanges(includeRanges, excludeRanges) { + return [..._excludeRanges(sortMatchRangeArray(includeRanges), sortMatchRangeArray(excludeRanges))]; +} +function* _excludeRanges(includeRanges, excludeRanges) { + if (!includeRanges.length) + return; + if (!excludeRanges.length) { + yield* includeRanges; + return; + } + let exIndex = 0; + const limit = excludeRanges.length; + for (const incRange of includeRanges) { + const endPos = incRange.endPos; + let startPos = incRange.startPos; + for (; exIndex < limit; ++exIndex) { + const ex = excludeRanges[exIndex]; + if (ex.startPos >= endPos) + break; + if (ex.endPos <= startPos) + continue; + if (ex.startPos > startPos) { + yield { startPos, endPos: ex.startPos }; + } + startPos = ex.endPos; + if (startPos >= endPos) + break; + } + if (startPos < endPos) { + yield { startPos, endPos }; + } + } +} +export function extractRangeText(text, ranges) { + return ranges.map(({ startPos, endPos }) => ({ + startPos, + endPos, + text: text.slice(startPos, endPos), + })); +} +const SymSortedMatchRangeArray = Symbol('SortedMatchRangeArray'); +function sortMatchRangeArray(values) { + if (isSortedMatchRangeArray(values)) + return values; + return makeSortedMatchRangeArray(values.sort(compareRanges)); +} +function isSortedMatchRangeArray(a) { + return a[SymSortedMatchRangeArray] === true; +} +function makeSortedMatchRangeArray(sortedValues) { + const sorted = sortedValues; + sorted[SymSortedMatchRangeArray] = true; + Object.freeze(sorted); + return sorted; +} +export const __testing__ = { + makeSortedMatchRangeArray, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/util/Uri.d.mts b/action/node_modules/cspell-lib/dist/esm/util/Uri.d.mts new file mode 100644 index 000000000..4fe760373 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/Uri.d.mts @@ -0,0 +1,50 @@ +export interface Uri { + readonly scheme: string; + readonly path: string; + readonly authority?: string; + readonly fragment?: string; + readonly query?: string; +} +export interface UriInstance extends Uri { + toString(): string; +} +export declare function toUri(uriOrFile: string | Uri | URL): UriInstance; +export declare function uriToFilePath(uri: Uri): string; +export declare function fromFilePath(file: string): UriInstance; +export declare function fromStdinFilePath(path?: string): UriInstance; +export declare const file: typeof fromFilePath; +export declare function parse(uri: string): UriInstance; +export declare function normalizeDriveLetter(path: string): string; +export declare function isUri(uri: unknown): uri is UriInstance; +export declare function basename(uri: Uri): string; +export declare function dirname(uri: Uri): UriInstance; +export declare function extname(uri: Uri): string; +export declare function joinPath(uri: Uri, ...paths: string[]): UriInstance; +export declare function resolvePath(uri: Uri, ...paths: string[]): UriInstance; +export declare function from(uri: Uri, ...parts: Partial[]): UriInstance; +declare class UriImpl implements UriInstance { + readonly scheme: string; + readonly authority?: string; + readonly path: string; + readonly query?: string; + readonly fragment?: string; + constructor(uri: PartialWithUndefined); + toString(): string; + toJson(): PartialWithUndefined; + with(change: Partial): UriImpl; + static isUri(uri: unknown): uri is UriImpl; + static from(uri: Uri, ...parts: Partial[]): UriImpl; + static parse(uri: string): UriImpl; + static file(filename: string): UriImpl; + static stdin(filePath?: string): UriImpl; +} +declare function normalizeFilePath(path: string): string; +type PartialWithUndefined = { + [P in keyof T]?: T[P] | undefined; +}; +export declare const __testing__: { + UriImpl: typeof UriImpl; + normalizeFilePath: typeof normalizeFilePath; +}; +export {}; +//# sourceMappingURL=Uri.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/Uri.mjs b/action/node_modules/cspell-lib/dist/esm/util/Uri.mjs new file mode 100644 index 000000000..41329b16d --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/Uri.mjs @@ -0,0 +1,158 @@ +import assert from 'assert'; +import { URI, Utils } from 'vscode-uri'; +const isFile = /^(?:[a-zA-Z]:|[/\\])/; +const isPossibleUri = /\w:\/\//; +const isUrl = /^(file:|stdin:|https?:|s?ftp:)/; +const STDIN_PROTOCOL = 'stdin:'; +export function toUri(uriOrFile) { + if (UriImpl.isUri(uriOrFile)) + return uriOrFile; + if (URI.isUri(uriOrFile)) + return UriImpl.from(uriOrFile); + if (uriOrFile instanceof URL) + return UriImpl.parse(uriOrFile.toString()); + if (isUrlLike(uriOrFile)) + return UriImpl.parse(uriOrFile.href); + if (isUri(uriOrFile)) + return UriImpl.from(uriOrFile); + if (isUrl.test(uriOrFile)) + return UriImpl.parse(uriOrFile); + return isFile.test(uriOrFile) && !isPossibleUri.test(uriOrFile) + ? UriImpl.file(normalizeDriveLetter(uriOrFile)) + : UriImpl.parse(uriOrFile); +} +const hasDriveLetter = /^[A-Z]:/i; +export function uriToFilePath(uri) { + const adj = uri.scheme === 'stdin' ? { scheme: 'file' } : {}; + return normalizeDriveLetter(URI.from(UriImpl.from(uri, adj)).fsPath); +} +export function fromFilePath(file) { + return UriImpl.file(file); +} +export function fromStdinFilePath(path) { + return UriImpl.stdin(path); +} +export const file = fromFilePath; +export function parse(uri) { + return UriImpl.parse(uri); +} +export function normalizeDriveLetter(path) { + return hasDriveLetter.test(path) ? path[0].toLowerCase() + path.slice(1) : path; +} +function isUrlLike(url) { + return (!!url && typeof url === 'object' && typeof url.href === 'string') || false; +} +export function isUri(uri) { + if (!uri || typeof uri !== 'object') + return false; + if (UriImpl.isUri(uri)) + return true; + if (URI.isUri(uri)) + return true; + const u = uri; + return typeof u.path === 'string' && typeof u.scheme === 'string'; +} +export function basename(uri) { + return Utils.basename(URI.from(uri)); +} +export function dirname(uri) { + return UriImpl.from(Utils.dirname(URI.from(uri))); +} +export function extname(uri) { + return Utils.extname(URI.from(uri)); +} +export function joinPath(uri, ...paths) { + return UriImpl.from(Utils.joinPath(URI.from(uri), ...paths)); +} +export function resolvePath(uri, ...paths) { + return UriImpl.from(Utils.resolvePath(URI.from(uri), ...paths)); +} +export function from(uri, ...parts) { + return UriImpl.from(uri, ...parts); +} +const keys = ['scheme', 'authority', 'path', 'query', 'fragment']; +class UriImpl { + constructor(uri) { + this.scheme = uri.scheme || ''; + uri.authority && (this.authority = uri.authority); + this.path = uri.path || ''; + uri.query && (this.query = uri.query); + uri.fragment && (this.fragment = uri.fragment); + } + toString() { + const path = this.path; + const base = `${this.scheme}://${this.authority || ''}${path}`; + const query = (this.query && `?${this.query}`) || ''; + const fragment = (this.fragment && `#${this.fragment}`) || ''; + const url = base + query + fragment; + return encodeURI(url); + } + toJson() { + const { scheme, authority, path, query, fragment } = this; + return { scheme, authority, path, query, fragment }; + } + with(change) { + const { scheme, authority, path, query, fragment } = this; + const u = { scheme, authority, path, query, fragment }; + for (const key of keys) { + if (change[key] && typeof change[key] === 'string') { + u[key] = change[key]; + } + } + return new UriImpl(u); + } + static isUri(uri) { + return uri instanceof UriImpl; + } + static from(uri, ...parts) { + let u = new UriImpl(uri); + for (const part of parts) { + u = u.with(part); + } + return u; + } + static parse(uri) { + if (uri.startsWith(STDIN_PROTOCOL)) { + return UriImpl.from(parseStdinUri(uri)); + } + const u = URI.parse(uri); + return UriImpl.from(u); + } + static file(filename) { + return UriImpl.from(URI.file(normalizeFilePath(filename))); + } + static stdin(filePath = '') { + return UriImpl.from(UriImpl.file(filePath), { scheme: 'stdin' }); + } +} +function normalizeFilePath(path) { + return normalizeDriveLetter(path.replace(/\\/g, '/')); +} +function parseStdinUri(uri) { + assert(uri.startsWith(STDIN_PROTOCOL)); + const idxSlash = STDIN_PROTOCOL.length; + let idxSlashEnd = idxSlash; + for (; uri[idxSlashEnd] === '/'; ++idxSlashEnd) { + // empty + } + const pathStart = idxSlashEnd; + const iH = uri.indexOf('#', pathStart); + const idxHash = iH > 0 ? iH : uri.length; + const iQ = uri.indexOf('?', pathStart); + const idxQ = iQ > 0 && iQ < idxHash ? iQ : idxHash; + const pathEnd = idxQ; + const path = uri.slice(pathStart, pathEnd); + const query = idxQ < idxHash ? uri.slice(idxQ + 1, idxHash) : ''; + const hash = uri.slice(idxHash + 1); + const pathPrefix = idxSlashEnd - idxSlash > 2 ? '/' : ''; + return { + scheme: 'stdin', + path: pathPrefix + normalizeFilePath(decodeURI(path)), + query: decodeURI(query), + fragment: decodeURI(hash), + }; +} +export const __testing__ = { + UriImpl, + normalizeFilePath, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/util/debugPerf.d.mts b/action/node_modules/cspell-lib/dist/esm/util/debugPerf.d.mts new file mode 100644 index 000000000..52c7d9ef0 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/debugPerf.d.mts @@ -0,0 +1,9 @@ +/** + * Measure and log result. + * @param fn - function to measure. + * @param message - message to log + * @param callback - called when the function has finished. + * @returns a function + */ +export declare function perfFn

(fn: (...args: P) => R, message: string, callback?: (m: string, elapsedMs: number) => void): (...args: P) => R; +//# sourceMappingURL=debugPerf.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/debugPerf.mjs b/action/node_modules/cspell-lib/dist/esm/util/debugPerf.mjs new file mode 100644 index 000000000..fc73afa67 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/debugPerf.mjs @@ -0,0 +1,17 @@ +import { createTimer } from './timer.mjs'; +/** + * Measure and log result. + * @param fn - function to measure. + * @param message - message to log + * @param callback - called when the function has finished. + * @returns a function + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function perfFn(fn, message, callback = (message, time) => console.error(`${message}: ${time.toFixed(2)}ms`)) { + return (...args) => { + const timer = createTimer(); + const r = fn(...args); + callback(message, timer.elapsed()); + return r; + }; +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/errors.d.mts b/action/node_modules/cspell-lib/dist/esm/util/errors.d.mts new file mode 100644 index 000000000..3981c9f56 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/errors.d.mts @@ -0,0 +1,26 @@ +/// +declare function getTypeOf(t: unknown): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"; +export declare function isErrnoException(e: unknown): e is NodeJS.ErrnoException; +export declare function isError(e: unknown): e is Error; +export declare function toError(e: unknown, errorFactory?: UnknownErrorConstructor): Error; +interface UnknownErrorConstructor { + new (cause: unknown): Error; +} +export declare class UnknownError extends Error { + readonly cause: unknown; + constructor(cause: unknown); +} +type ErrorHandler = (err: unknown) => T | undefined; +type ErrorHandlerP = (err: unknown) => T | Promise | undefined; +export declare function catchPromiseError(p: undefined, handler: ErrorHandlerP): undefined; +export declare function catchPromiseError(p: Promise, handler: ErrorHandlerP): Promise; +export declare function catchPromiseError(p: Promise | undefined, handler: ErrorHandler): Promise | undefined; +export declare function wrapCall(fn: (...p: []) => U, handler: ErrorHandler): (...p: []) => U | undefined; +export declare function wrapCall(fn: (...p: [P0]) => U, handler: ErrorHandler): (...p: [P0]) => U | undefined; +export declare function wrapCall(fn: (...p: [P0, P1]) => U, handler: ErrorHandler): (...p: [P0, P1]) => U | undefined; +export declare function wrapCall

(fn: (...p: P) => U, handler: ErrorHandler): (...p: P[]) => U | undefined; +export declare const __testing__: { + getTypeOf: typeof getTypeOf; +}; +export {}; +//# sourceMappingURL=errors.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/errors.mjs b/action/node_modules/cspell-lib/dist/esm/util/errors.mjs new file mode 100644 index 000000000..a565f1866 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/errors.mjs @@ -0,0 +1,67 @@ +import { format } from 'util'; +function getTypeOf(t) { + return typeof t; +} +const allowStringOrUndefined = { + string: true, + undefined: true, +}; +const allowNumberOrUndefined = { + number: true, + undefined: true, +}; +export function isErrnoException(e) { + if (!e || typeof e !== 'object') + return false; + if (!isError(e)) + return false; + const ex = e; + return (typeof ex.errno in allowNumberOrUndefined && + typeof ex.code in allowStringOrUndefined && + typeof ex.path in allowStringOrUndefined); +} +export function isError(e) { + if (e instanceof Error) + return true; + if (!e || typeof e !== 'object') + return false; + const ex = e; + return typeof ex.name == 'string' && typeof ex.message == 'string' && typeof ex.stack in allowStringOrUndefined; +} +export function toError(e, errorFactory = UnknownError) { + if (isError(e)) + return e; + return new errorFactory(e); +} +export class UnknownError extends Error { + constructor(cause) { + super(format(cause)); + this.cause = cause; + } +} +export function catchPromiseError(p, handler) { + if (p === undefined) + return undefined; + return _catchPromiseError(p, handler); +} +export function wrapCall(fn, handler) { + return (...p) => { + try { + return fn(...p); + } + catch (e) { + return handler(e); + } + }; +} +async function _catchPromiseError(p, handler) { + try { + return await p; + } + catch (e) { + return handler(e); + } +} +export const __testing__ = { + getTypeOf, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/util/fileReader.d.mts b/action/node_modules/cspell-lib/dist/esm/util/fileReader.d.mts new file mode 100644 index 000000000..507de9adc --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/fileReader.d.mts @@ -0,0 +1,4 @@ +/// +export declare function readLines(filename: string, encoding?: BufferEncoding): Promise>; +export declare function readLinesSync(filename: string, encoding?: BufferEncoding): string[]; +//# sourceMappingURL=fileReader.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/fileReader.mjs b/action/node_modules/cspell-lib/dist/esm/util/fileReader.mjs new file mode 100644 index 000000000..5c0c75735 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/fileReader.mjs @@ -0,0 +1,15 @@ +import { readFile, readFileSync } from 'cspell-io'; +import { toIterableIterator } from './iterableIteratorLib.mjs'; +export async function readLines(filename, encoding = 'utf8') { + try { + const content = await readFile(filename, encoding); + return toIterableIterator(content.split(/\r?\n/g)); + } + catch (e) { + return Promise.reject(e); + } +} +export function readLinesSync(filename, encoding = 'utf8') { + const content = readFileSync(filename, encoding); + return content.split(/\r?\n/g); +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/iterableIteratorLib.d.mts b/action/node_modules/cspell-lib/dist/esm/util/iterableIteratorLib.d.mts new file mode 100644 index 000000000..a4cec1bc0 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/iterableIteratorLib.d.mts @@ -0,0 +1,4 @@ +import type { IterableLike } from './IterableLike.mjs'; +export declare function toIterableIterator(i: IterableLike): IterableIterator; +export declare function concatIterables(...iterables: IterableLike[]): IterableIterator; +//# sourceMappingURL=iterableIteratorLib.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/iterableIteratorLib.mjs b/action/node_modules/cspell-lib/dist/esm/util/iterableIteratorLib.mjs new file mode 100644 index 000000000..c88dcb02b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/iterableIteratorLib.mjs @@ -0,0 +1,8 @@ +export function* toIterableIterator(i) { + yield* i; +} +export function* concatIterables(...iterables) { + for (const i of iterables) { + yield* i; + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/logger.d.mts b/action/node_modules/cspell-lib/dist/esm/util/logger.d.mts new file mode 100644 index 000000000..033fa5b0b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/logger.d.mts @@ -0,0 +1,31 @@ +type Console = typeof console; +export interface Logger { + log: Console['log']; + warn: Console['warn']; + error: Console['error']; +} +/** + * See `Console.error` + */ +export declare function logError(...args: any[]): void; +/** + * See `Console.warn` + */ +export declare function logWarning(...args: any[]): void; +/** + * See `Console.log` + */ +export declare function log(...args: any[]): void; +/** + * Set the global cspell-lib logger + * @param logger - a logger like `console` + * @returns the old logger. + */ +export declare function setLogger(logger: Logger): Logger; +/** + * Get the current cspell-lib logger. + * @returns the current logger. + */ +export declare function getLogger(): Logger; +export {}; +//# sourceMappingURL=logger.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/logger.mjs b/action/node_modules/cspell-lib/dist/esm/util/logger.mjs new file mode 100644 index 000000000..4aecd442c --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/logger.mjs @@ -0,0 +1,37 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +let _logger = console; +/** + * See `Console.error` + */ +export function logError(...args) { + _logger.error(...args); +} +/** + * See `Console.warn` + */ +export function logWarning(...args) { + _logger.warn(...args); +} +/** + * See `Console.log` + */ +export function log(...args) { + _logger.log(...args); +} +/** + * Set the global cspell-lib logger + * @param logger - a logger like `console` + * @returns the old logger. + */ +export function setLogger(logger) { + const oldLogger = _logger; + _logger = logger; + return oldLogger; +} +/** + * Get the current cspell-lib logger. + * @returns the current logger. + */ +export function getLogger() { + return _logger; +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/memorizeLastCall.d.mts b/action/node_modules/cspell-lib/dist/esm/util/memorizeLastCall.d.mts new file mode 100644 index 000000000..47762dee3 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/memorizeLastCall.d.mts @@ -0,0 +1,13 @@ +/** + * Create a function that memorizes the last call. If the next call is called with the same arguments, the + * the last value is returned. + * @param fn - function to memorize + * @returns a new function. + */ +export declare function memorizeLastCall(fn: (...p: []) => T): (...p: []) => T; +export declare function memorizeLastCall(fn: (...p: [K0]) => T): (...p: [K0]) => T; +export declare function memorizeLastCall(fn: (...p: [K0, K1]) => T): (...p: [K0, K1]) => T; +export declare function memorizeLastCall(fn: (...p: [K0, K1, K2]) => T): (...p: [K0, K1, K2]) => T; +export declare function memorizeLastCall(fn: (...p: [K0, K1, K2, K3]) => T): (...p: [K0, K1, K2, K3]) => T; +export declare function memorizeLastCall(fn: (...p: [...K[]]) => T): (...p: [...K[]]) => T; +//# sourceMappingURL=memorizeLastCall.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/memorizeLastCall.mjs b/action/node_modules/cspell-lib/dist/esm/util/memorizeLastCall.mjs new file mode 100644 index 000000000..2d33500ce --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/memorizeLastCall.mjs @@ -0,0 +1,13 @@ +import { isArrayEqual } from './util.mjs'; +export function memorizeLastCall(fn) { + let last; + return (...p) => { + if (last && isArrayEqual(last.args, p)) { + return last.value; + } + const args = p; + const value = fn(...args); + last = { args, value }; + return value; + }; +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/memorizerWeak.d.mts b/action/node_modules/cspell-lib/dist/esm/util/memorizerWeak.d.mts new file mode 100644 index 000000000..32bbf913f --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/memorizerWeak.d.mts @@ -0,0 +1,6 @@ +export declare function memorizerWeak(fn: (...p: [...K[]]) => T): (...p: [...K[]]) => T; +export declare function memorizerWeak(fn: (...p: [K0, K1]) => T): (...p: [K0, K1]) => T; +export declare function memorizerWeak(fn: (...p: [K0, K1, K2]) => T): (...p: [K0, K1, K2]) => T; +export declare function memorizerWeak(fn: (...p: [K0, K1, K2, K3]) => T): (...p: [K0, K1, K2, K3]) => T; +export declare function memorizerWeak(fn: (...p: [K0]) => T): (...p: [K0]) => T; +//# sourceMappingURL=memorizerWeak.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/memorizer.js b/action/node_modules/cspell-lib/dist/esm/util/memorizerWeak.mjs similarity index 83% rename from action/node_modules/cspell-trie-lib/dist/esm/lib/utils/memorizer.js rename to action/node_modules/cspell-lib/dist/esm/util/memorizerWeak.mjs index 789817fe7..dea648c76 100644 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/memorizer.js +++ b/action/node_modules/cspell-lib/dist/esm/util/memorizerWeak.mjs @@ -1,5 +1,5 @@ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export function memorizer(fn) { +// prettier-ignore +export function memorizerWeak(fn) { const r = {}; function find(p) { let n = r; @@ -19,7 +19,7 @@ export function memorizer(fn) { continue; } const r = {}; - n.c = n.c || new Map(); + n.c = n.c || new WeakMap(); n.c.set(k, r); n = r; } diff --git a/action/node_modules/cspell-lib/dist/esm/util/regexHelper.d.mts b/action/node_modules/cspell-lib/dist/esm/util/regexHelper.d.mts new file mode 100644 index 000000000..9961db057 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/regexHelper.d.mts @@ -0,0 +1,7 @@ +/** + * Escape a string so it can be used as an exact match within a RegExp. + * @param s - string to escape + * @returns - the escaped string. + */ +export declare function escapeRegEx(s: string): string; +//# sourceMappingURL=regexHelper.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/regexHelper.mjs b/action/node_modules/cspell-lib/dist/esm/util/regexHelper.mjs new file mode 100644 index 000000000..a13c7c38e --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/regexHelper.mjs @@ -0,0 +1,8 @@ +/** + * Escape a string so it can be used as an exact match within a RegExp. + * @param s - string to escape + * @returns - the escaped string. + */ +export function escapeRegEx(s) { + return s.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d'); +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/repMap.d.mts b/action/node_modules/cspell-lib/dist/esm/util/repMap.d.mts new file mode 100644 index 000000000..760571970 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/repMap.d.mts @@ -0,0 +1,4 @@ +import type { ReplaceMap } from '@cspell/cspell-types'; +export type ReplaceMapper = (src: string) => string; +export declare function createMapper(repMap: ReplaceMap): ReplaceMapper; +//# sourceMappingURL=repMap.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/repMap.mjs b/action/node_modules/cspell-lib/dist/esm/util/repMap.mjs new file mode 100644 index 000000000..1da86ca3a --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/repMap.mjs @@ -0,0 +1,33 @@ +import { escapeRegEx } from './regexHelper.mjs'; +export function createMapper(repMap) { + const filteredMap = repMap.filter(([match, _]) => !!match); + if (!filteredMap.length) { + return (a) => a; + } + const regExStr = filteredMap + .map(([from, _]) => from) + // make sure it compiles into a regex + .map((s) => { + try { + // fix up any nested () + const r = s.match(/\(/) ? s.replace(/\((?=.*\))/g, '(?:').replace(/\(\?:\?/g, '(?') : s; + new RegExp(r); + s = r; + } + catch (err) { + return escapeRegEx(s); + } + return s; + }) + .map((s) => `(${s})`) + .join('|'); + const regEx = new RegExp(regExStr, 'g'); + const values = repMap.filter(([match, _]) => !!match).map(([_, into]) => into); + function resolve(m, ...matches) { + const index = matches.findIndex((a) => !!a); + return 0 <= index && index < values.length ? values[index] : m; + } + return function (s) { + return s.replace(regEx, resolve); + }; +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/resolveFile.d.mts b/action/node_modules/cspell-lib/dist/esm/util/resolveFile.d.mts new file mode 100644 index 000000000..834a07c45 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/resolveFile.d.mts @@ -0,0 +1,13 @@ +export interface ResolveFileResult { + filename: string; + relativeTo: string | undefined; + found: boolean; +} +/** + * Resolve filename to absolute paths. + * It tries to look for local files as well as node_modules + * @param filename an absolute path, relative path, `~` path, or a node_module. + * @param relativeTo absolute path + */ +export declare function resolveFile(filename: string, relativeTo: string): ResolveFileResult; +//# sourceMappingURL=resolveFile.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/resolveFile.mjs b/action/node_modules/cspell-lib/dist/esm/util/resolveFile.mjs new file mode 100644 index 000000000..01ec6bd87 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/resolveFile.mjs @@ -0,0 +1,96 @@ +import * as fs from 'fs'; +import * as os from 'os'; +import * as path from 'path'; +import resolveFrom from 'resolve-from'; +import resolveGlobal from 'resolve-global'; +const testNodeModules = /^node_modules\//; +/** + * Resolve filename to absolute paths. + * It tries to look for local files as well as node_modules + * @param filename an absolute path, relative path, `~` path, or a node_module. + * @param relativeTo absolute path + */ +export function resolveFile(filename, relativeTo) { + filename = filename.replace(/^~/, os.homedir()); + const steps = [ + { filename, fn: tryUrl }, + { filename, fn: tryNodeResolve }, + { filename: path.resolve(relativeTo, filename), fn: tryResolveExists }, + { filename: path.resolve(filename), fn: tryResolveExists }, + { filename, fn: tryNodeResolveDefaultPaths }, + { filename, fn: tryResolveFrom }, + { filename: filename.replace(testNodeModules, ''), fn: tryResolveFrom }, + { filename, fn: tryResolveGlobal }, + ]; + for (const step of steps) { + const r = step.fn(step.filename, relativeTo); + if (r.found) + return r; + } + return { filename: path.resolve(relativeTo, filename), relativeTo, found: false }; +} +const isUrlRegExp = /^\w+:\/\//i; +/** + * Check to see if it is a URL. + * Note: URLs are absolute! + * @param filename - url string + * @returns ResolveFileResult + */ +function tryUrl(filename, relativeTo) { + if (isUrlRegExp.test(filename)) { + return { filename, relativeTo: undefined, found: true }; + } + if (isUrlRegExp.test(relativeTo)) { + const url = new URL(filename, relativeTo); + return { filename: url.href, relativeTo, found: true }; + } + return { filename, relativeTo: undefined, found: false }; +} +function tryNodeResolveDefaultPaths(filename) { + try { + const r = require.resolve(filename); + return { filename: r, relativeTo: undefined, found: true }; + } + catch (_) { + return { filename, relativeTo: undefined, found: false }; + } +} +function tryNodeResolve(filename, relativeTo) { + const home = os.homedir(); + function calcPaths(p) { + const paths = [p]; + // Do not progress towards the root if it is a relative filename. + if (filename.startsWith('.') && + (filename.startsWith('./') || filename.startsWith('.' + path.sep) || filename.startsWith('..'))) { + return paths; + } + for (; p && path.dirname(p) !== p && p !== home; p = path.dirname(p)) { + paths.push(p); + } + return paths; + } + const paths = calcPaths(path.resolve(relativeTo)); + try { + const r = require.resolve(filename, { paths }); + return { filename: r, relativeTo, found: true }; + } + catch (_) { + return { filename, relativeTo, found: false }; + } +} +function tryResolveGlobal(filename) { + const r = resolveGlobal.silent(filename); + return { filename: r || filename, relativeTo: undefined, found: !!r }; +} +function tryResolveExists(filename) { + return { filename, relativeTo: undefined, found: fs.existsSync(filename) }; +} +function tryResolveFrom(filename, relativeTo) { + try { + return { filename: resolveFrom(relativeTo, filename), relativeTo, found: true }; + } + catch (error) { + // Failed to resolve a relative module request + return { filename: filename, relativeTo, found: false }; + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/search.d.mts b/action/node_modules/cspell-lib/dist/esm/util/search.d.mts new file mode 100644 index 000000000..d1f80576a --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/search.d.mts @@ -0,0 +1,6 @@ +/** + * Search for an item in a sorted array. + * The value returned is either the position of the item or where it should be inserted. + */ +export declare function binarySearch(arr: Array, item: T, leftOffset?: number, rightOffset?: number): number; +//# sourceMappingURL=search.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/search.mjs b/action/node_modules/cspell-lib/dist/esm/util/search.mjs new file mode 100644 index 000000000..ad37ffb2f --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/search.mjs @@ -0,0 +1,18 @@ +/** + * Search for an item in a sorted array. + * The value returned is either the position of the item or where it should be inserted. + */ +export function binarySearch(arr, item, leftOffset, rightOffset) { + let left = Math.max(leftOffset ?? 0, 0); + let right = Math.min(rightOffset ?? arr.length, arr.length); + while (left < right) { + const pos = (left + right) >> 1; + if (arr[pos] < item) { + left = pos + 1; + } + else { + right = pos; + } + } + return left; +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/simpleCache.d.mts b/action/node_modules/cspell-lib/dist/esm/util/simpleCache.d.mts new file mode 100644 index 000000000..d00f7179b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/simpleCache.d.mts @@ -0,0 +1,46 @@ +export declare class SimpleWeakCache { + readonly size: number; + private L0; + private L1; + private L2; + private sizeL0; + constructor(size: number); + has(key: K): boolean; + get(key: K): T | undefined; + set(key: K, value: T): void; + private _set; + private caches; + private rotate; +} +export declare class AutoWeakCache extends SimpleWeakCache { + readonly factory: (key: K) => T; + constructor(factory: (key: K) => T, size: number); + get(key: K): T; +} +/** + * This will cache between `size` and 3 x `size` items. + * It has three stashes, L0, L1, and L2. Each can contain `size` items. + * When L0 is full, its items are given to L1 and L1's are given to L2, and L2 is empties. + * + * The stashes are searched in order, L0...L2. If an item is found in L1, or L2, it is + * promoted to L0. + */ +export declare class SimpleCache { + readonly size: number; + private L0; + private L1; + private L2; + constructor(size: number); + has(key: K): boolean; + get(key: K): T | undefined; + set(key: K, value: T): void; + private _set; + private caches; + private rotate; +} +export declare class AutoCache extends SimpleCache { + readonly factory: (key: K) => T; + constructor(factory: (key: K) => T, size: number); + get(key: K): T; +} +//# sourceMappingURL=simpleCache.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/simpleCache.mjs b/action/node_modules/cspell-lib/dist/esm/util/simpleCache.mjs new file mode 100644 index 000000000..3b61a5a22 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/simpleCache.mjs @@ -0,0 +1,135 @@ +export class SimpleWeakCache { + constructor(size) { + this.size = size; + this.L0 = new WeakMap(); + this.L1 = new WeakMap(); + this.L2 = new WeakMap(); + this.sizeL0 = 0; + } + has(key) { + for (const c of this.caches()) { + if (c.has(key)) + return true; + } + return false; + } + get(key) { + for (const c of this.caches()) { + const entry = c.get(key); + if (entry) { + if (c !== this.L0) { + this._set(key, entry); + } + return entry.v; + } + } + return undefined; + } + set(key, value) { + this._set(key, { v: value }); + } + _set(key, entry) { + if (this.L0.has(key)) { + this.L0.set(key, entry); + return this; + } + if (this.sizeL0 >= this.size) { + this.rotate(); + } + this.sizeL0 += 1; + this.L0.set(key, entry); + } + caches() { + return [this.L0, this.L1, this.L2]; + } + rotate() { + this.L2 = this.L1; + this.L1 = this.L0; + this.L0 = new WeakMap(); + this.sizeL0 = 0; + } +} +export class AutoWeakCache extends SimpleWeakCache { + constructor(factory, size) { + super(size); + this.factory = factory; + } + get(key) { + const v = super.get(key); + if (v !== undefined) + return v; + const val = this.factory(key); + this.set(key, val); + return val; + } +} +/** + * This will cache between `size` and 3 x `size` items. + * It has three stashes, L0, L1, and L2. Each can contain `size` items. + * When L0 is full, its items are given to L1 and L1's are given to L2, and L2 is empties. + * + * The stashes are searched in order, L0...L2. If an item is found in L1, or L2, it is + * promoted to L0. + */ +export class SimpleCache { + constructor(size) { + this.size = size; + this.L0 = new Map(); + this.L1 = new Map(); + this.L2 = new Map(); + } + has(key) { + for (const c of this.caches()) { + if (c.has(key)) + return true; + } + return false; + } + get(key) { + for (const c of this.caches()) { + const entry = c.get(key); + if (entry) { + if (c !== this.L0) { + this._set(key, entry); + } + return entry.v; + } + } + return undefined; + } + set(key, value) { + this._set(key, { v: value }); + } + _set(key, entry) { + if (this.L0.has(key)) { + this.L0.set(key, entry); + return this; + } + if (this.L0.size >= this.size) { + this.rotate(); + } + this.L0.set(key, entry); + } + caches() { + return [this.L0, this.L1, this.L2]; + } + rotate() { + this.L2 = this.L1; + this.L1 = this.L0; + this.L0 = new Map(); + } +} +export class AutoCache extends SimpleCache { + constructor(factory, size) { + super(size); + this.factory = factory; + } + get(key) { + const v = super.get(key); + if (v !== undefined) + return v; + const val = this.factory(key); + this.set(key, val); + return val; + } +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/text.d.mts b/action/node_modules/cspell-lib/dist/esm/util/text.d.mts new file mode 100644 index 000000000..bf1080609 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/text.d.mts @@ -0,0 +1,49 @@ +import type { TextDocumentOffset, TextOffset } from '@cspell/cspell-types'; +import type { Uri } from './Uri.mjs'; +export { stringToRegExp } from './textRegex.mjs'; +export declare function splitCamelCaseWordWithOffset(wo: TextOffset): Array; +/** + * Split camelCase words into an array of strings. + */ +export declare function splitCamelCaseWord(word: string): string[]; +/** + * This function lets you iterate over regular expression matches. + */ +export declare function match(reg: RegExp, text: string): Iterable; +export declare function matchStringToTextOffset(reg: RegExp, text: string): Iterable; +export declare function matchToTextOffset(reg: RegExp, text: TextOffset): Iterable; +export declare function extractLinesOfText(text: string): Iterable; +/** + * Extract out whole words from a string of text. + */ +export declare function extractWordsFromText(text: string): Iterable; +/** + * Extract out whole words from a string of text. + */ +export declare function extractWordsFromTextOffset(text: TextOffset): Iterable; +export declare function cleanText(text: string): string; +export declare function cleanTextOffset(text: TextOffset): TextOffset; +/** + * Extract out whole words and words containing numbers from a string of text. + */ +export declare function extractPossibleWordsFromTextOffset(text: TextOffset): Iterable; +export declare function extractWordsFromCode(text: string): Iterable; +export declare function extractWordsFromCodeTextOffset(textOffset: TextOffset): Iterable; +export declare function isUpperCase(word: string): boolean; +export declare function isLowerCase(word: string): boolean; +export declare function isFirstCharacterUpper(word: string): boolean; +export declare function isFirstCharacterLower(word: string): boolean; +export declare function ucFirst(word: string): string; +export declare function lcFirst(word: string): string; +export declare function snakeToCamel(word: string): string; +export declare function camelToSnake(word: string): string; +export declare function matchCase(example: string, word: string): string; +export declare function textOffset(text: string, offset?: number): TextOffset; +export declare function extractText(textOffset: TextOffset, startPos: number, endPos: number): string; +export declare function calculateTextDocumentOffsets(uri: string | Uri | URL, doc: string, wordOffsets: T[]): (TextDocumentOffset & T)[]; +export declare function removeAccents(text: string): string; +export declare const __testing__: { + regExWords: RegExp; + regExWordsAndDigits: RegExp; +}; +//# sourceMappingURL=text.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/text.mjs b/action/node_modules/cspell-lib/dist/esm/util/text.mjs new file mode 100644 index 000000000..b3732db71 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/text.mjs @@ -0,0 +1,180 @@ +import { opConcatMap, opMap, pipe } from '@cspell/cspell-pipe/sync'; +import { sequenceFromRegExpMatch } from 'gensequence'; +import { binarySearch } from './search.mjs'; +import { regExAccents, regExAllLower, regExAllUpper, regExFirstUpper, regExIgnoreCharacters, regExSplitWords, regExSplitWords2, regExUpperSOrIng, regExWords, regExWordsAndDigits, } from './textRegex.mjs'; +import { toUri } from './Uri.mjs'; +import { scanMap } from './util.mjs'; +export { stringToRegExp } from './textRegex.mjs'; +// CSpell:ignore ings ning gimuy tsmerge +export function splitCamelCaseWordWithOffset(wo) { + return splitCamelCaseWord(wo.text).map(scanMap((last, text) => ({ text, offset: last.offset + last.text.length }), { + text: '', + offset: wo.offset, + })); +} +/** + * Split camelCase words into an array of strings. + */ +export function splitCamelCaseWord(word) { + const wPrime = word.replace(regExUpperSOrIng, (s) => s[0] + s.slice(1).toLowerCase()); + const separator = '_<^*_*^>_'; + const pass1 = wPrime.replace(regExSplitWords, '$1' + separator + '$2'); + const pass2 = pass1.replace(regExSplitWords2, '$1' + separator + '$2'); + return pass2.split(separator); +} +/** + * This function lets you iterate over regular expression matches. + */ +export function match(reg, text) { + return sequenceFromRegExpMatch(reg, text); +} +export function matchStringToTextOffset(reg, text) { + return matchToTextOffset(reg, { text, offset: 0 }); +} +export function matchToTextOffset(reg, text) { + const textOffset = text; + const fnOffsetMap = offsetMap(textOffset.offset); + textOffset.text.matchAll(reg); + return pipe(match(reg, textOffset.text), opMap((m) => fnOffsetMap({ text: m[0], offset: m.index || 0 }))); +} +export function* extractLinesOfText(text) { + let i = 0; + for (let j = text.indexOf('\n', i); j >= 0; j = text.indexOf('\n', i)) { + const end = j + 1; + yield { text: text.slice(i, end), offset: i }; + i = end; + } + yield { text: text.slice(i, text.length), offset: i }; +} +/** + * Extract out whole words from a string of text. + */ +export function extractWordsFromText(text) { + return extractWordsFromTextOffset(textOffset(text)); +} +/** + * Extract out whole words from a string of text. + */ +export function extractWordsFromTextOffset(text) { + const reg = new RegExp(regExWords); + return matchToTextOffset(reg, cleanTextOffset(text)); +} +export function cleanText(text) { + text = text.replace(regExIgnoreCharacters, (match) => ' '.repeat(match.length)); + return text; +} +export function cleanTextOffset(text) { + return { + text: cleanText(text.text), + offset: text.offset, + }; +} +/** + * Extract out whole words and words containing numbers from a string of text. + */ +export function extractPossibleWordsFromTextOffset(text) { + const reg = new RegExp(regExWordsAndDigits); + return matchToTextOffset(reg, text); +} +export function extractWordsFromCode(text) { + return extractWordsFromCodeTextOffset(textOffset(text)); +} +export function extractWordsFromCodeTextOffset(textOffset) { + return pipe(extractWordsFromTextOffset(textOffset), opConcatMap(splitCamelCaseWordWithOffset)); +} +export function isUpperCase(word) { + return !!word.match(regExAllUpper); +} +export function isLowerCase(word) { + return !!word.match(regExAllLower); +} +export function isFirstCharacterUpper(word) { + return isUpperCase(word.slice(0, 1)); +} +export function isFirstCharacterLower(word) { + return isLowerCase(word.slice(0, 1)); +} +export function ucFirst(word) { + return word.slice(0, 1).toUpperCase() + word.slice(1); +} +export function lcFirst(word) { + return word.slice(0, 1).toLowerCase() + word.slice(1); +} +export function snakeToCamel(word) { + return word.split('_').map(ucFirst).join(''); +} +export function camelToSnake(word) { + return splitCamelCaseWord(word).join('_').toLowerCase(); +} +export function matchCase(example, word) { + if (example.match(regExFirstUpper)) { + return word.slice(0, 1).toUpperCase() + word.slice(1).toLowerCase(); + } + if (example.match(regExAllLower)) { + return word.toLowerCase(); + } + if (example.match(regExAllUpper)) { + return word.toUpperCase(); + } + if (isFirstCharacterUpper(example)) { + return ucFirst(word); + } + if (isFirstCharacterLower(example)) { + return lcFirst(word); + } + return word; +} +export function textOffset(text, offset = 0) { + return { text, offset }; +} +export function extractText(textOffset, startPos, endPos) { + const { text, offset: orig } = textOffset; + const a = Math.max(startPos - orig, 0); + const b = Math.max(endPos - orig, 0); + return text.slice(a, b); +} +function offsetMap(offset) { + return (xo) => ({ ...xo, offset: xo.offset + offset }); +} +export function calculateTextDocumentOffsets(uri, doc, wordOffsets) { + const lines = [ + -1, + ...pipe(match(/\n/g, doc), opMap((a) => a.index)), + doc.length, + ]; + let lastRow = -1; + let lastOffset = doc.length + 1; + let lastLineRow = -1; + let lastLine; + function findRowCol(offset) { + const row = binarySearch(lines, offset, offset >= lastOffset ? lastRow : undefined); + const col = offset - lines[Math.max(0, row - 1)]; + lastOffset = offset; + lastRow = row; + return [row, col]; + } + function extractLine(row) { + const offset = lines[row - 1] + 1; + const text = doc.slice(offset, lines[row] + 1); + return { text, offset }; + } + function calcLine(row) { + const last = lastLineRow === row ? lastLine : undefined; + lastLineRow = row; + const r = last ?? extractLine(row); + lastLine = r; + return r; + } + const _uri = toUri(uri).toString(); + return wordOffsets.map((wo) => { + const [row, col] = findRowCol(wo.offset); + return { ...wo, row, col, doc, uri: _uri, line: calcLine(row) }; + }); +} +export function removeAccents(text) { + return text.normalize('NFD').replace(regExAccents, ''); +} +export const __testing__ = { + regExWords, + regExWordsAndDigits, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/util/textRegex.d.mts b/action/node_modules/cspell-lib/dist/esm/util/textRegex.d.mts new file mode 100644 index 000000000..35fbfd49f --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/textRegex.d.mts @@ -0,0 +1,19 @@ +export declare const regExUpperSOrIng: RegExp; +export declare const regExSplitWords: RegExp; +export declare const regExSplitWords2: RegExp; +export declare const regExWords: RegExp; +export declare const regExWordsAndDigits: RegExp; +export declare const regExIgnoreCharacters: RegExp; +export declare const regExFirstUpper: RegExp; +export declare const regExAllUpper: RegExp; +export declare const regExAllLower: RegExp; +export declare const regExPossibleWordBreaks: RegExp; +export declare const regExMatchRegExParts: RegExp; +export declare const regExAccents: RegExp; +export declare const regExEscapeCharacters: RegExp; +/** Matches against leading `'` or `{single letter}'` */ +export declare const regExDanglingQuote: RegExp; +/** Match tailing endings after CAPS words */ +export declare const regExTrailingEndings: RegExp; +export declare function stringToRegExp(pattern: string | RegExp, defaultFlags?: string, forceFlags?: string): RegExp | undefined; +//# sourceMappingURL=textRegex.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/textRegex.mjs b/action/node_modules/cspell-lib/dist/esm/util/textRegex.mjs new file mode 100644 index 000000000..a8aae436b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/textRegex.mjs @@ -0,0 +1,124 @@ +// cspell:ignore ings ning gimuy anrvtbf gimuxy +export const regExUpperSOrIng = /([\p{Lu}\p{M}]+\\?['’]?(?:s|ing|ies|es|ings|ed|ning))(?!\p{Ll})/gu; +export const regExSplitWords = /(\p{Ll}\p{M}?)(\p{Lu})/gu; +export const regExSplitWords2 = /(\p{Lu}\p{M}?)(\p{Lu}\p{M}?\p{Ll})/gu; +export const regExWords = /\p{L}\p{M}?(?:(?:\\?['’])?\p{L}\p{M}?)*/gu; +export const regExWordsAndDigits = /(?:\d+)?[\p{L}\p{M}_'’-](?:(?:\\?['’])?[\p{L}\p{M}\w'’-])*/gu; +export const regExIgnoreCharacters = /[\p{sc=Hiragana}\p{sc=Han}\p{sc=Katakana}\u30A0-\u30FF\p{sc=Hangul}]/gu; +export const regExFirstUpper = /^\p{Lu}\p{M}?\p{Ll}+$/u; +export const regExAllUpper = /^(?:\p{Lu}\p{M}?)+$/u; +export const regExAllLower = /^(?:\p{Ll}\p{M}?)+$/u; +export const regExPossibleWordBreaks = /[-_’']/g; +export const regExMatchRegExParts = /^\s*\/([\s\S]*?)\/([gimuxy]*)\s*$/; +export const regExAccents = /\p{M}/gu; +export const regExEscapeCharacters = /(?<=\\)[anrvtbf]/gi; +/** Matches against leading `'` or `{single letter}'` */ +export const regExDanglingQuote = /(?<=(?:^|(?!\p{M})\P{L})(?:\p{L}\p{M}?)?)[']/gu; +/** Match tailing endings after CAPS words */ +export const regExTrailingEndings = /(?<=(?:\p{Lu}\p{M}?){2})['’]?(?:s|d|ings?|ies|e[ds]?|ning|th|nth)(?!\p{Ll})/gu; +export function stringToRegExp(pattern, defaultFlags = 'gimu', forceFlags = 'g') { + if (pattern instanceof RegExp) { + return pattern; + } + try { + const [, pat, flag] = [ + ...(pattern.match(regExMatchRegExParts) || ['', pattern.trim(), defaultFlags]), + forceFlags, + ]; + if (pat) { + const regPattern = flag.includes('x') ? removeVerboseFromRegExp(pat) : pat; + // Make sure the flags are unique. + const flags = [...new Set(forceFlags + flag)].join('').replace(/[^gimuy]/g, ''); + const regex = new RegExp(regPattern, flags); + return regex; + } + } + catch (e) { + /* empty */ + } + return undefined; +} +const SPACES = { + ' ': true, + '\n': true, + '\r': true, + '\t': true, +}; +/** + * Remove all whitespace and comments from a regexp string. The format follows Pythons Verbose. + * Note: this is a best attempt. Special cases for comments: `#` and spaces should be proceeded with a `\` + * + * All space must be proceeded by a `\` or in a character class `[]` + * + * @param pattern - the pattern to clean + */ +function removeVerboseFromRegExp(pattern) { + function escape(acc) { + const char = pattern[acc.idx]; + if (char !== '\\') + return undefined; + const next = pattern[++acc.idx]; + acc.idx++; + if (next === '#') { + acc.result += '#'; + return acc; + } + if (!(next in SPACES)) { + acc.result += '\\' + next; + return acc; + } + acc.result += next; + if (next === '\r' && pattern[acc.idx] === '\n') { + acc.result += '\n'; + acc.idx++; + } + return acc; + } + function braces(acc) { + const char = pattern[acc.idx]; + if (char !== '[') + return undefined; + acc.result += char; + acc.idx++; + let escCount = 0; + while (acc.idx < pattern.length) { + const char = pattern[acc.idx]; + acc.result += char; + acc.idx++; + if (char === ']' && !(escCount & 1)) + break; + escCount = char === '\\' ? escCount + 1 : 0; + } + return acc; + } + function spaces(acc) { + const char = pattern[acc.idx]; + if (!(char in SPACES)) + return undefined; + acc.idx++; + return acc; + } + function comments(acc) { + const char = pattern[acc.idx]; + if (char !== '#') + return undefined; + while (acc.idx < pattern.length && pattern[acc.idx] !== '\n') { + acc.idx++; + } + return acc; + } + function copy(acc) { + const char = pattern[acc.idx++]; + acc.result += char; + return acc; + } + const reducers = [escape, braces, spaces, comments, copy]; + const result = { idx: 0, result: '' }; + while (result.idx < pattern.length) { + for (const r of reducers) { + if (r(result)) + break; + } + } + return result.result; +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/timer.d.mts b/action/node_modules/cspell-lib/dist/esm/util/timer.d.mts new file mode 100644 index 000000000..84355b0d9 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/timer.d.mts @@ -0,0 +1,26 @@ +export interface Timer { + /** Start / restart the timer. */ + start(): void; + /** + * Calculate the amount of time in ms since the + * timer was created / started. + */ + elapsed(): number; + /** + * Calculate the amount of time in ms since the + * end of the last lap. + */ + lap(): number; +} +export declare function createTimer(hrTimeFn?: HRTimeFn): Timer; +export type HRTimeFn = (time?: HRTime) => HRTime; +export type HRTime = [number, number]; +export declare function toMilliseconds(t: HRTime): number; +export declare function polyHrTime(time?: HRTime): HRTime; +export interface LapRecorder { + times: [name: string, lapTime: number, totalTime: number][]; + lap(name: string): void; + report(): string[]; +} +export declare function createLapRecorder(): LapRecorder; +//# sourceMappingURL=timer.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/timer.mjs b/action/node_modules/cspell-lib/dist/esm/util/timer.mjs new file mode 100644 index 000000000..4bed61f73 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/timer.mjs @@ -0,0 +1,50 @@ +const _hrTime = process?.hrtime || polyHrTime; +export function createTimer(hrTimeFn = _hrTime) { + let start = hrTimeFn(); + let lastLap = 0; + function elapsed() { + return toMilliseconds(hrTimeFn(start)); + } + return { + start() { + start = hrTimeFn(); + lastLap = 0; + }, + elapsed, + lap() { + const now = elapsed(); + const diff = now - lastLap; + lastLap = now; + return diff; + }, + }; +} +export function toMilliseconds(t) { + return (t[0] + t[1] * 1e-9) * 1000; +} +export function polyHrTime(time) { + const now = Date.now() - (time ? toMilliseconds(time) : 0); + const inSeconds = now * 1.0e-3; + const s = Math.floor(inSeconds); + const n = (inSeconds - s) * 1.0e9; + return [s, n]; +} +export function createLapRecorder() { + const timer = createTimer(); + const times = []; + let lapTime = 0; + function lap(name) { + const now = timer.elapsed(); + const diff = now - lapTime; + times.push([name, diff, now]); + lapTime = diff; + } + function report() { + return times.map(([name, time]) => `${name}: ${time.toFixed(2)}`); + } + return { + times, + lap, + report, + }; +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/types.d.mts b/action/node_modules/cspell-lib/dist/esm/util/types.d.mts new file mode 100644 index 000000000..2aaf6f2eb --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/types.d.mts @@ -0,0 +1,62 @@ +/** + * Make all optional fields required. + */ +export type RequireOptional = { + [K in keyof Required]: T[K]; +}; +/** + * Make all properties in T optional and Possibly undefined + */ +export type PartialWithUndefined = { + [P in keyof T]?: T[P] | undefined; +}; +/** + * Make all fields mandatory + */ +export type Mandatory = { + [P in keyof T]-?: Exclude; +}; +/** + * Union the fields + */ +export type UnionFields = { + [K in keyof T | keyof U]: (K extends keyof T ? T[K] : undefined) | (K extends keyof U ? U[K] : undefined); +}; +/** + * The keys of an object where the values cannot be undefined. + */ +export type RequiredKeys = Exclude<{ + [P in keyof T]: T[P] extends Exclude ? P : never; +}[keyof T], undefined>; +/** + * The keys of an object where the values cannot be undefined. + */ +export type OptionalKeys = Exclude<{ + [P in keyof T]: T[P] extends Exclude ? never : P; +}[keyof T], undefined>; +/** + * Extract the fields that cannot be `undefined` + */ +export type OnlyRequired = { + [P in RequiredKeys]: T[P]; +}; +/** + * Extract the fields that can be `undefined` + */ +export type OnlyOptional = { + [P in keyof T as P extends OptionalKeys ? P : never]: T[P]; +}; +export type MakeOptional = OnlyRequired & Partial>; +/** + * Like Required, but keeps the Optional. + */ +export type RemoveUndefined = { + [P in keyof T]: Exclude; +}; +/** + * Allow undefined in optional fields + */ +export type OptionalOrUndefined = { + [P in keyof T]: P extends OptionalKeys ? T[P] | undefined : T[P]; +}; +//# sourceMappingURL=types.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/types.mjs b/action/node_modules/cspell-lib/dist/esm/util/types.mjs new file mode 100644 index 000000000..b196885de --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/types.mjs @@ -0,0 +1,7 @@ +/* + * Verified + */ +export {}; +/* + * Experimental + */ diff --git a/action/node_modules/cspell-lib/dist/esm/util/util.d.mts b/action/node_modules/cspell-lib/dist/esm/util/util.d.mts new file mode 100644 index 000000000..2372556f1 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/util.d.mts @@ -0,0 +1,33 @@ +import type { RemoveUndefined } from './types.mjs'; +export declare const uniqueFn: typeof uniqueFilterFnGenerator; +export declare function uniqueFilterFnGenerator(): (v: T) => boolean; +export declare function uniqueFilterFnGenerator(extractFn: (v: T) => U): (v: T) => boolean; +export declare function unique(src: T[]): T[]; +/** + * Delete all `undefined` fields from an object. + * @param src - object to be cleaned + */ +export declare function clean(src: T): RemoveUndefined; +/** + * Creates a scan function that can be used in a map function. + */ +export declare function scanMap(accFn: (acc: T, value: T) => T, init?: T): (value: T) => T; +export declare function scanMap(accFn: (acc: U, value: T) => U, init: U): (value: T) => U; +export declare function isDefined(v: T | undefined): v is T; +export declare function asyncIterableToArray(iter: Iterable | AsyncIterable): Promise[]>; +/** + * Shallow is Equal test. + * @param a - array of values + * @param b - array of values + * @returns true if the values of `a` are exactly equal to the values of `b` + */ +export declare function isArrayEqual(a: K[], b: K[]): boolean; +/** + * Determine if two sets intersect + * @param a - first Set + * @param b - second Set + * @returns true iff any element of `a` is in `b` + */ +export declare function doSetsIntersect(a: Set, b: Set): boolean; +export declare function isRecordEqual>(a: T | undefined, b: T | undefined): boolean; +//# sourceMappingURL=util.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/util.mjs b/action/node_modules/cspell-lib/dist/esm/util/util.mjs new file mode 100644 index 000000000..e7965d90d --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/util.mjs @@ -0,0 +1,97 @@ +// alias for uniqueFilterFnGenerator +export const uniqueFn = uniqueFilterFnGenerator; +export function uniqueFilterFnGenerator(extractFn) { + const values = new Set(); + const extractor = extractFn || ((a) => a); + return (v) => { + const vv = extractor(v); + const ret = !values.has(vv); + values.add(vv); + return ret; + }; +} +export function unique(src) { + return [...new Set(src)]; +} +/** + * Delete all `undefined` fields from an object. + * @param src - object to be cleaned + */ +export function clean(src) { + const r = src; + for (const key of Object.keys(r)) { + if (r[key] === undefined) { + delete r[key]; + } + } + return r; +} +export function scanMap(accFn, init) { + let acc = init; + let first = true; + return function (value) { + if (first && acc === undefined) { + first = false; + acc = value; + return acc; + } + acc = accFn(acc, value); + return acc; + }; +} +export function isDefined(v) { + return v !== undefined; +} +export async function asyncIterableToArray(iter) { + const acc = []; + for await (const t of iter) { + acc.push(t); + } + return acc; +} +/** + * Shallow is Equal test. + * @param a - array of values + * @param b - array of values + * @returns true if the values of `a` are exactly equal to the values of `b` + */ +export function isArrayEqual(a, b) { + if (a === b) + return true; + let isMatch = a.length === b.length; + for (let i = 0; i < a.length && isMatch; ++i) { + isMatch = a[i] === b[i]; + } + return isMatch; +} +/** + * Determine if two sets intersect + * @param a - first Set + * @param b - second Set + * @returns true iff any element of `a` is in `b` + */ +export function doSetsIntersect(a, b) { + function compare(a, b) { + for (const item of a) { + if (b.has(item)) + return true; + } + return false; + } + return a.size <= b.size ? compare(a, b) : compare(b, a); +} +export function isRecordEqual(a, b) { + if (a === b) + return true; + if (a === undefined || b === undefined) + return false; + for (const key of Object.keys(a)) { + if (a[key] !== b[key]) + return false; + } + for (const key of Object.keys(b)) { + if (a[key] !== b[key]) + return false; + } + return true; +} diff --git a/action/node_modules/cspell-lib/dist/esm/util/wordSplitter.d.mts b/action/node_modules/cspell-lib/dist/esm/util/wordSplitter.d.mts new file mode 100644 index 000000000..2c8a72b06 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/wordSplitter.d.mts @@ -0,0 +1,46 @@ +import type { TextOffset } from '@cspell/cspell-types'; +export type IsValidWordFn = (word: TextOffset) => boolean; +export interface SplitResult { + /** Original line passed to the split function */ + line: TextOffset; + /** Starting point of processing - Original offset passed to the split function */ + offset: number; + /** The span of text that was split */ + text: TextOffset; + /** The collection of words that `text` was split into */ + words: TextOffsetWithValid[]; + /** the offset at which the split stopped */ + endOffset: number; +} +export interface LineSegment { + line: TextOffset; + relStart: number; + relEnd: number; +} +export interface TextOffsetWithValid extends TextOffset { + isFound: boolean; +} +export interface SplitOptions extends WordBreakOptions { +} +export declare function split(line: TextOffset, offset: number, isValidWord: IsValidWordFn, options?: SplitOptions): SplitResult; +type BreakPairs = readonly number[]; +interface PossibleWordBreak { + /** offset from the start of the string */ + offset: number; + /** + * break pairs (start, end) + * (the characters between the start and end are removed) + * With a pure break, start === end. + */ + breaks: BreakPairs[]; +} +export type SortedBreaks = PossibleWordBreak[]; +interface WordBreakOptions { + optionalWordBreakCharacters?: string; +} +declare function generateWordBreaks(line: LineSegment, options: WordBreakOptions): SortedBreaks; +export declare const __testing__: { + generateWordBreaks: typeof generateWordBreaks; +}; +export {}; +//# sourceMappingURL=wordSplitter.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/util/wordSplitter.mjs b/action/node_modules/cspell-lib/dist/esm/util/wordSplitter.mjs new file mode 100644 index 000000000..eeb20bac0 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/util/wordSplitter.mjs @@ -0,0 +1,321 @@ +import { PairingHeap } from './PairingHeap.mjs'; +import { escapeRegEx } from './regexHelper.mjs'; +import { regExDanglingQuote, regExEscapeCharacters, regExPossibleWordBreaks, regExSplitWords, regExSplitWords2, regExTrailingEndings, regExWordsAndDigits, } from './textRegex.mjs'; +const ignoreBreak = Object.freeze([]); +export function split(line, offset, isValidWord, options = {}) { + const relWordToSplit = findNextWordText({ text: line.text, offset: offset - line.offset }); + const lineOffset = line.offset; + const requested = new Map(); + if (!relWordToSplit.text) { + const text = rebaseTextOffset(relWordToSplit); + return { + line, + offset, + text: text, + words: [], + endOffset: text.offset + text.text.length, + }; + } + const lineSegment = { + line, + relStart: relWordToSplit.offset, + relEnd: relWordToSplit.offset + relWordToSplit.text.length, + }; + const possibleBreaks = generateWordBreaks(lineSegment, options); + if (!possibleBreaks.length) { + const text = rebaseTextOffset(relWordToSplit); + return { + line, + offset, + text: text, + words: [{ ...text, isFound: isValidWord(text) }], + endOffset: text.offset + text.text.length, + }; + } + function rebaseTextOffset(relText) { + return { + ...relText, + offset: relText.offset + lineOffset, + }; + } + function has(word) { + const i = word.offset; + const j = word.text.length; + let v = i + (j << 20); + if (i < 1 << 20 && j < 1 << 11) { + const b = requested.get(v); + if (b !== undefined) + return b; + } + else { + v = -1; + } + const r = isValidWord(rebaseTextOffset(word)); + if (v >= 0) { + requested.set(v, r); + } + return r; + } + // Add a dummy break at the end to avoid needing to check for last break. + possibleBreaks.push({ + offset: lineSegment.relEnd, + breaks: [ignoreBreak], + }); + const result = { + line, + offset, + text: rebaseTextOffset(relWordToSplit), + words: splitIntoWords(lineSegment, possibleBreaks, has).map(rebaseTextOffset), + endOffset: lineOffset + lineSegment.relEnd, + }; + return result; +} +function findNextWordText({ text, offset }) { + const reg = new RegExp(regExWordsAndDigits); + reg.lastIndex = offset; + const m = reg.exec(text); + if (!m) { + return { + text: '', + offset: offset + text.length, + }; + } + return { + text: m[0], + offset: m.index, + }; +} +function generateWordBreaks(line, options) { + const camelBreaks = genWordBreakCamel(line); + const symbolBreaks = genSymbolBreaks(line); + const optionalBreaks = genOptionalWordBreaks(line, options.optionalWordBreakCharacters); + return mergeSortedBreaks(...camelBreaks, ...symbolBreaks, ...optionalBreaks); +} +function offsetRegEx(reg, offset) { + const r = new RegExp(reg); + r.lastIndex = offset; + return r; +} +function genWordBreakCamel(line) { + const breaksCamel1 = []; + const text = line.line.text.slice(0, line.relEnd); + // lower,Upper: camelCase -> camel|Case + for (const m of text.matchAll(offsetRegEx(regExSplitWords, line.relStart))) { + if (m.index === undefined) + break; + const i = m.index + 1; + breaksCamel1.push({ + offset: m.index, + breaks: [[i, i], ignoreBreak], + }); + } + const breaksCamel2 = []; + // cspell:ignore ERRORC + // Upper,Upper,lower: ERRORCodes -> ERROR|Codes, ERRORC|odes + for (const m of text.matchAll(offsetRegEx(regExSplitWords2, line.relStart))) { + if (m.index === undefined) + break; + const i = m.index + m[1].length; + const j = i + 1; + breaksCamel2.push({ + offset: m.index, + breaks: [[i, i], [j, j], ignoreBreak], + }); + } + return [breaksCamel1, breaksCamel2]; +} +function calcBreaksForRegEx(line, reg, calcBreak) { + const sb = []; + const text = line.line.text.slice(0, line.relEnd); + for (const m of text.matchAll(offsetRegEx(reg, line.relStart))) { + const b = calcBreak(m); + if (b) { + sb.push(b); + } + } + return sb; +} +function genOptionalWordBreaks(line, optionalBreakCharacters) { + function calcBreaks(m) { + const i = m.index; + if (i === undefined) + return; + const j = i + m[0].length; + return { + offset: i, + breaks: [ + [i, j], + ignoreBreak, + ], + }; + } + const breaks = [ + calcBreaksForRegEx(line, regExDanglingQuote, calcBreaks), + calcBreaksForRegEx(line, regExTrailingEndings, calcBreaks), + ]; + if (optionalBreakCharacters) { + const regex = new RegExp(`[${escapeRegEx(optionalBreakCharacters)}]`, 'gu'); + breaks.push(calcBreaksForRegEx(line, regex, calcBreaks)); + } + return breaks; +} +function genSymbolBreaks(line) { + function calcBreaks(m) { + const i = m.index; + if (i === undefined) + return; + const j = i + m[0].length; + return { + offset: i, + breaks: [ + [i, j], + [i, i], + [j, j], + ignoreBreak, + ], + }; + } + return [ + calcBreaksForRegEx(line, regExPossibleWordBreaks, calcBreaks), + calcBreaksForRegEx(line, /\d+/g, calcBreaks), + calcBreaksForRegEx(line, regExEscapeCharacters, calcBreaks), + ]; +} +function splitIntoWords(lineSeg, breaks, has) { + const maxIndex = lineSeg.relEnd; + const maxAttempts = 1000; + const knownPathsByIndex = new Map(); + /** + * Create a set of possible candidate to consider + * @param p - prev candidate that lead to this one + * @param i - offset within the string + * @param bi - current index into the set of breaks + * @param currentCost - current cost accrued + */ + function makeCandidates(p, i, bi, currentCost) { + const len = maxIndex; + while (bi < breaks.length && breaks[bi].offset < i) { + bi += 1; + } + if (bi >= breaks.length) { + return []; + } + const br = breaks[bi]; + function c(bp) { + const d = bp.length < 2 ? len - i : (bp[0] - i) * 0.5 + len - bp[1]; + const ec = currentCost + d; + return { + p, + i, + bi, + bp, + c: currentCost, + ec, + text: undefined, + }; + } + return br.breaks.map(c); + } + function toTextOffset(text, offset) { + const valid = has({ text, offset }); + return { + text, + offset, + isFound: valid, + }; + } + function compare(a, b) { + return a.ec - b.ec || b.i - a.i; + } + function pathToWords(node) { + const results = []; + for (let p = node; p; p = p.n) { + if (p.text) { + results.push(p.text); + } + } + return results; + } + function addToKnownPaths(candidate, path) { + for (let can = candidate; can !== undefined; can = can.p) { + const t = can.text; + const i = can.i; + const cost = (!t || t.isFound ? 0 : t.text.length) + (path?.c ?? 0); + const exitingPath = knownPathsByIndex.get(i); + // Keep going only if this is a better candidate than the existing path + if (exitingPath && exitingPath.c <= cost) { + return undefined; + } + const node = { + n: path, + i, + c: cost, + text: t, + }; + knownPathsByIndex.set(i, node); + path = node; + } + return path; + } + let maxCost = lineSeg.relEnd - lineSeg.relStart; + const candidates = new PairingHeap(compare); + const text = lineSeg.line.text; + candidates.concat(makeCandidates(undefined, lineSeg.relStart, 0, 0)); + let attempts = 0; + let bestPath; + while (maxCost && candidates.length && attempts++ < maxAttempts) { + /** Best Candidate Index */ + const best = candidates.dequeue(); + if (!best || best.c >= maxCost) { + continue; + } + // Does it have a split? + if (best.bp.length) { + // yes + const i = best.bp[0]; + const j = best.bp[1]; + const t = i > best.i ? toTextOffset(text.slice(best.i, i), best.i) : undefined; + const cost = !t || t.isFound ? 0 : t.text.length; + const mc = maxIndex - j; + best.c += cost; + best.ec = best.c + mc; + best.text = t; + const possiblePath = knownPathsByIndex.get(j); + if (possiblePath) { + // We found a known apply to candidate + const f = addToKnownPaths(best, possiblePath); + bestPath = !bestPath || (f && f.c < bestPath.c) ? f : bestPath; + } + else if (best.c < maxCost) { + const c = makeCandidates(t ? best : best.p, j, best.bi + 1, best.c); + candidates.concat(c); + } + } + else { + // It is a pass through + const c = makeCandidates(best.p, best.i, best.bi + 1, best.c); + candidates.concat(c); + if (!c.length) { + const t = maxIndex > best.i ? toTextOffset(text.slice(best.i, maxIndex), best.i) : undefined; + const cost = !t || t.isFound ? 0 : t.text.length; + best.c += cost; + best.ec = best.c; + best.text = t; + const segText = t || best.p?.text || toTextOffset('', best.i); + const can = t ? { ...best, text: segText } : { ...best, ...best.p, text: segText }; + const f = addToKnownPaths(can, undefined); + bestPath = !bestPath || (f && f.c < bestPath.c) ? f : bestPath; + } + } + if (bestPath && bestPath.c < maxCost) { + maxCost = bestPath.c; + } + } + return pathToWords(bestPath); +} +function mergeSortedBreaks(...maps) { + return [].concat(...maps).sort((a, b) => a.offset - b.offset); +} +export const __testing__ = { + generateWordBreaks, +}; diff --git a/action/node_modules/cspell-lib/dist/esm/validator.d.mts b/action/node_modules/cspell-lib/dist/esm/validator.d.mts new file mode 100644 index 000000000..2f45137b3 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/validator.d.mts @@ -0,0 +1,3 @@ +export type { CheckTextInfo, IncludeExcludeOptions, TextInfoItem, ValidateTextOptions, ValidationIssue, } from './textValidation/index.mjs'; +export { checkText, checkTextDocument, IncludeExcludeFlag, validateText } from './textValidation/index.mjs'; +//# sourceMappingURL=validator.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/validator.mjs b/action/node_modules/cspell-lib/dist/esm/validator.mjs new file mode 100644 index 000000000..570f00e7b --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/validator.mjs @@ -0,0 +1 @@ +export { checkText, checkTextDocument, IncludeExcludeFlag, validateText } from './textValidation/index.mjs'; diff --git a/action/node_modules/cspell-lib/dist/esm/wordListHelper.d.mts b/action/node_modules/cspell-lib/dist/esm/wordListHelper.d.mts new file mode 100644 index 000000000..283d5c8a0 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/wordListHelper.d.mts @@ -0,0 +1,14 @@ +export interface WordDictionary { + [index: string]: boolean; +} +export type WordSet = Set; +/** + * Reads words from a file. It will not throw and error. + * @param filename the file to read + */ +export declare function loadWordsNoError(filename: string): Promise>; +export declare function splitLine(line: string): string[]; +export declare function splitCodeWords(words: string[]): string[]; +export declare function splitLineIntoCodeWords(line: string): IterableIterator; +export declare function splitLineIntoWords(line: string): IterableIterator; +//# sourceMappingURL=wordListHelper.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/esm/wordListHelper.mjs b/action/node_modules/cspell-lib/dist/esm/wordListHelper.mjs new file mode 100644 index 000000000..21719bbb9 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/esm/wordListHelper.mjs @@ -0,0 +1,30 @@ +// cSpell:enableCompoundWords +import { readLines } from './util/fileReader.mjs'; +import { concatIterables, toIterableIterator } from './util/iterableIteratorLib.mjs'; +import { logError } from './util/logger.mjs'; +import * as Text from './util/text.mjs'; +const regExpWordsWithSpaces = /^\s*\p{L}+(?:\s+\p{L}+){0,3}$/u; +/** + * Reads words from a file. It will not throw and error. + * @param filename the file to read + */ +export function loadWordsNoError(filename) { + return readLines(filename).catch((e) => (logError(e), toIterableIterator([]))); +} +export function splitLine(line) { + return [...Text.extractWordsFromText(line)].map(({ text }) => text); +} +export function splitCodeWords(words) { + return words.map(Text.splitCamelCaseWord).reduce((a, b) => a.concat(b), []); +} +export function splitLineIntoCodeWords(line) { + const asMultiWord = regExpWordsWithSpaces.test(line) ? [line] : []; + const asWords = splitLine(line); + const splitWords = splitCodeWords(asWords); + const wordsToAdd = new Set(concatIterables(asMultiWord, asWords, splitWords)); + return toIterableIterator(wordsToAdd); +} +export function splitLineIntoWords(line) { + const asWords = splitLine(line); + return concatIterables([line], asWords); +} diff --git a/action/node_modules/cspell-lib/dist/lib-cjs/index.cjs b/action/node_modules/cspell-lib/dist/lib-cjs/index.cjs new file mode 100644 index 000000000..18051710d --- /dev/null +++ b/action/node_modules/cspell-lib/dist/lib-cjs/index.cjs @@ -0,0 +1,10 @@ +"use strict"; +/** + * This module contains CJS only files. + * It includes files that use 3rd part libs that can only be CJS due to their exports. + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.srcDirectory = void 0; +var pkg_info_cjs_1 = require("./pkg-info.cjs"); +Object.defineProperty(exports, "srcDirectory", { enumerable: true, get: function () { return pkg_info_cjs_1.srcDirectory; } }); +//# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/lib-cjs/index.d.cts b/action/node_modules/cspell-lib/dist/lib-cjs/index.d.cts new file mode 100644 index 000000000..e74826e70 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/lib-cjs/index.d.cts @@ -0,0 +1,6 @@ +/** + * This module contains CJS only files. + * It includes files that use 3rd part libs that can only be CJS due to their exports. + */ +export { srcDirectory } from './pkg-info.cjs'; +//# sourceMappingURL=index.d.cts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/lib-cjs/pkg-info.cjs b/action/node_modules/cspell-lib/dist/lib-cjs/pkg-info.cjs new file mode 100644 index 000000000..ceb6d7dbc --- /dev/null +++ b/action/node_modules/cspell-lib/dist/lib-cjs/pkg-info.cjs @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.srcDirectory = void 0; +exports.srcDirectory = __dirname; +//# sourceMappingURL=pkg-info.cjs.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/lib-cjs/pkg-info.d.cts b/action/node_modules/cspell-lib/dist/lib-cjs/pkg-info.d.cts new file mode 100644 index 000000000..deecc6dc8 --- /dev/null +++ b/action/node_modules/cspell-lib/dist/lib-cjs/pkg-info.d.cts @@ -0,0 +1,2 @@ +export declare const srcDirectory: string; +//# sourceMappingURL=pkg-info.d.cts.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/test/test.matchers.js b/action/node_modules/cspell-lib/dist/test/test.matchers.js deleted file mode 100644 index 0e1f118bf..000000000 --- a/action/node_modules/cspell-lib/dist/test/test.matchers.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.extendExpect = exports.toEqualCaseInsensitive = void 0; -const toEqualCaseInsensitive = -// `floor` and `ceiling` get types from the line above -// it is recommended to type them as `unknown` and to validate the values -function (actual, expected) { - if (typeof actual !== 'string' || typeof expected !== 'string') { - throw new Error('These must be of type number!'); - } - const pass = actual.toLowerCase() === expected.toLowerCase(); - return { - message: () => - // `this` context will have correct typings - `expected ${this.utils.printReceived(actual)} to equal ${this.utils.printExpected(expected)} case insensitive`, - pass, - }; -}; -exports.toEqualCaseInsensitive = toEqualCaseInsensitive; -function extendExpect(e) { - e.extend({ - toEqualCaseInsensitive: exports.toEqualCaseInsensitive, - }); - return e; -} -exports.extendExpect = extendExpect; -//# sourceMappingURL=test.matchers.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/dist/util/Memorizer.js b/action/node_modules/cspell-lib/dist/util/Memorizer.js deleted file mode 100644 index 6a300160d..000000000 --- a/action/node_modules/cspell-lib/dist/util/Memorizer.js +++ /dev/null @@ -1,124 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.memorizerAll = exports.callOnce = exports.memorizerKeyBy = exports.memorizer = void 0; -/* eslint-disable @typescript-eslint/no-explicit-any */ -const defaultSize = 50000; -/** - * Memorize the result of a function call to be returned on later calls with the same parameters. - * - * Note: The parameters are converted into a string: `key = args.join('>!@[')` - * - * For speed, it keeps two caches, L0 and L1. Each cache can contain up to `size` values. But that actual number - * of cached values is between `size + 1` and `size * 2`. - * - * Caches are NOT sorted. Items are added to L0 until it is full. Once it is full, L1 takes over L0's values and L0 is cleared. - * - * If an item is not found in L0, L1 is checked before calling the `fn` and the resulting value store in L0. - * - * @param fn - function to be called. - * @param size - size of cache - */ -function memorizer(fn, size) { - return memorizerKeyBy(fn, (...args) => args.join('>!@['), size); -} -exports.memorizer = memorizer; -/** - * Memorize the result of a function call to be returned on later calls with the same parameters. - * - * Note: `keyFn` is use to convert the function parameters into a string to look up in the cache. - * - * For speed, it keeps two caches, L0 and L1. Each cache can contain up to `size` values. But that actual number - * of cached values is between `size + 1` and `size * 2`. - * - * Caches are NOT sorted. Items are added to L0 until it is full. Once it is full, L1 takes over L0's values and L0 is cleared. - * - * If an item is not found in L0, L1 is checked before calling the `fn` and the resulting value store in L0. - * - * @param fn - function to be memorized - * @param keyFn - extracts a `key` value from the arguments to `fn` to be used as the key to the cache - * @param size - size of the cache. - * @returns A function - */ -function memorizerKeyBy(fn, keyFn, size = defaultSize) { - let count = 0; - let cacheL0 = Object.create(null); - let cacheL1 = Object.create(null); - return (...args) => { - const key = keyFn(...args); - if (key in cacheL0) - return cacheL0[key]; - const v = key in cacheL1 ? cacheL1[key] : fn(...args); - if (count >= size) { - cacheL1 = cacheL0; - cacheL0 = Object.create(null); - count = 0; - } - cacheL0[key] = v; - ++count; - return v; - }; -} -exports.memorizerKeyBy = memorizerKeyBy; -/** - * Creates a function that will call `fn` exactly once when invoked and remember the value returned. - * All subsequent calls will return exactly same value. - * @param fn - function to call - * @returns a new function - */ -function callOnce(fn) { - let last; - return () => { - if (last) { - return last.value; - } - last = { - value: fn(), - }; - return last.value; - }; -} -exports.callOnce = callOnce; -/** - * Create a function that will memorize all calls to `fn` to ensure that `fn` is - * called exactly once for each unique set of arguments. - * @param fn - function to memorize - * @returns a function - */ -function memorizerAll(fn) { - const r = {}; - function find(p) { - let n = r; - for (const k of p) { - if (!n) - break; - n = n.c?.get(k); - } - return n; - } - function set(p, v) { - let n = r; - for (const k of p) { - const c = n.c?.get(k); - if (c) { - n = c; - continue; - } - const r = {}; - n.c = n.c || new Map(); - n.c.set(k, r); - n = r; - } - n.v = v; - } - return (...p) => { - const f = find(p); - if (f && 'v' in f) { - return f.v; - } - const v = fn(...p); - set(p, v); - return v; - }; -} -exports.memorizerAll = memorizerAll; -//# sourceMappingURL=Memorizer.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-lib/node_modules/.bin/cspell-grammar b/action/node_modules/cspell-lib/node_modules/.bin/cspell-grammar index e1b5b22b2..71fb6cc71 120000 --- a/action/node_modules/cspell-lib/node_modules/.bin/cspell-grammar +++ b/action/node_modules/cspell-lib/node_modules/.bin/cspell-grammar @@ -1 +1 @@ -../../../cspell-grammar/bin.js \ No newline at end of file +../../../cspell-grammar/bin.mjs \ No newline at end of file diff --git a/action/node_modules/cspell-lib/package.json b/action/node_modules/cspell-lib/package.json index c699efc6d..8f217f055 100644 --- a/action/node_modules/cspell-lib/package.json +++ b/action/node_modules/cspell-lib/package.json @@ -1,30 +1,39 @@ { "name": "cspell-lib", - "version": "6.28.0", + "version": "6.29.1", "description": "A library of useful functions used across various cspell tools.", - "main": "dist/index.js", - "typings": "dist/index.d.ts", - "files:comment": "Due to a lerna bug, patterns like `!**/*.map` are not getting recursively honored", + "type": "commonjs", + "main": "dist/cjs/index.js", + "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.mjs", "files": [ "dist", + "!dist/esm/**/*.js", + "!dist/esm/**/*.ts", "!**/*.tsbuildInfo", "!**/__mocks__", + "!**/test*/**", + "!**/test.*", "!**/*.test.*", "!**/*.spec.*", "!**/*.map" ], "scripts": { - "clean": "shx rm -rf dist temp coverage .tsbuildinfo", - "build": "pnpm run compile && pnpm run build-api", - "build-api": "rollup -c api/rollup.config.mjs", - "clean-build": "pnpm run clean && pnpm run build", - "compile": "tsc -p .", - "watch": "tsc --watch -p .", - "coverage": "jest --coverage", - "test-watch": "jest --watch", + "clean": "shx rm -rf dist coverage temp .tsbuildinfo", + "clean-build": "pnpm clean && pnpm build", + "build": "tsc -b . && ts2mjs dist/esm && pnpm run build:api", + "build:api": "rollup -c api/rollup.config.mjs", + "build:cjs": "tsc -b tsconfig.cjs.json", + "build:esm": "tsc -b tsconfig.esm.json", + "build:esm:ts2mjs": "tsc -b tsconfig.esm.json && ts2mjs dist/esm", + "build:lib": "tsc -b src/lib/tsconfig.json", + "coverage": "pnpm coverage:vitest && pnpm coverage:fix", + "coverage:vitest": "vitest run --coverage", + "coverage:fix": "nyc report --temp-dir \"$(pwd)/coverage\" --reporter lcov --report-dir \"$(pwd)/coverage\" --cwd ../..", + "test-watch": "vitest", "prepublishOnly": "pnpm run clean-build", - "test": "jest --maxWorkers=1", - "test:update-snapshot": "jest --updateSnapshot" + "test": "vitest run", + "test:update-snapshot": "vitest run -u" }, "repository": { "type": "git", @@ -48,19 +57,19 @@ }, "homepage": "https://github.com/streetsidesoftware/cspell#readme", "dependencies": { - "@cspell/cspell-bundled-dicts": "6.28.0", - "@cspell/cspell-pipe": "6.28.0", - "@cspell/cspell-types": "6.28.0", - "@cspell/strong-weak-map": "6.28.0", + "@cspell/cspell-bundled-dicts": "6.29.1", + "@cspell/cspell-pipe": "6.29.1", + "@cspell/cspell-types": "6.29.1", + "@cspell/strong-weak-map": "6.29.1", "clear-module": "^4.1.2", "comment-json": "^4.2.3", "configstore": "^5.0.1", "cosmiconfig": "^8.1.0", - "cspell-dictionary": "6.28.0", - "cspell-glob": "6.28.0", - "cspell-grammar": "6.28.0", - "cspell-io": "6.28.0", - "cspell-trie-lib": "6.28.0", + "cspell-dictionary": "6.29.1", + "cspell-glob": "6.29.1", + "cspell-grammar": "6.29.1", + "cspell-io": "6.29.1", + "cspell-trie-lib": "6.29.1", "fast-equals": "^4.0.3", "find-up": "^5.0.0", "gensequence": "^5.0.2", @@ -78,17 +87,17 @@ "@cspell/dict-csharp": "^4.0.2", "@cspell/dict-css": "^3.0.0", "@cspell/dict-fa-ir": "^2.0.0", - "@cspell/dict-fr-fr": "^2.2.0", + "@cspell/dict-fr-fr": "^2.2.1", "@cspell/dict-html": "^4.0.3", "@cspell/dict-nl-nl": "^2.2.8", - "@cspell/dict-python": "^4.0.1", + "@cspell/dict-python": "^4.0.2", "@types/configstore": "^5.0.1", "@types/jest": "^29.4.0", "cspell-dict-nl-nl": "^1.1.2", - "expect": "^29.4.3", - "jest": "^29.4.3", + "expect": "^29.5.0", + "jest": "^29.5.0", "lorem-ipsum": "^2.0.8", "ts-jest": "^29.0.5" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/cspell-trie-lib/dist/esm/index.js b/action/node_modules/cspell-trie-lib/dist/esm/index.js deleted file mode 100644 index 09c185e22..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/index.js +++ /dev/null @@ -1 +0,0 @@ -export * from './lib/index.js'; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/SimpleDictionaryParser.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/SimpleDictionaryParser.js deleted file mode 100644 index 16efe027a..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/SimpleDictionaryParser.js +++ /dev/null @@ -1,191 +0,0 @@ -import { opCombine as opPipe, opConcatMap, opFilter, opMap } from '@cspell/cspell-pipe/sync'; -import { CASE_INSENSITIVE_PREFIX, COMPOUND_FIX, FORBID_PREFIX, IDENTITY_PREFIX, LINE_COMMENT, OPTIONAL_COMPOUND_FIX, } from './constants.js'; -import { buildTrieFast } from './TrieBuilder.js'; -import { normalizeWord, normalizeWordForCaseInsensitive } from './utils/normalizeWord.js'; -const RegExpSplit = /[\s,;]/g; -const _defaultOptions = { - commentCharacter: LINE_COMMENT, - optionalCompoundCharacter: OPTIONAL_COMPOUND_FIX, - compoundCharacter: COMPOUND_FIX, - forbiddenPrefix: FORBID_PREFIX, - caseInsensitivePrefix: CASE_INSENSITIVE_PREFIX, - keepExactPrefix: IDENTITY_PREFIX, - stripCaseAndAccents: true, - stripCaseAndAccentsKeepDuplicate: false, - stripCaseAndAccentsOnForbidden: false, - split: false, - splitKeepBoth: false, - splitSeparator: RegExpSplit, -}; -export const defaultParseDictionaryOptions = Object.freeze(_defaultOptions); -export const cSpellToolDirective = 'cspell-dictionary:'; -export const setOfCSpellDirectiveFlags = ['no-split', 'split', 'generate-alternatives', 'no-generate-alternatives']; -/** - * Normalizes a dictionary words based upon prefix / suffixes. - * Case insensitive versions are also generated. - * @param options - defines prefixes used when parsing lines. - * @returns words that have been normalized. - */ -export function createDictionaryLineParserMapper(options) { - const _options = options || _defaultOptions; - const { commentCharacter = _defaultOptions.commentCharacter, optionalCompoundCharacter: optionalCompound = _defaultOptions.optionalCompoundCharacter, compoundCharacter: compound = _defaultOptions.compoundCharacter, caseInsensitivePrefix: ignoreCase = _defaultOptions.caseInsensitivePrefix, forbiddenPrefix: forbidden = _defaultOptions.forbiddenPrefix, keepExactPrefix: keepCase = _defaultOptions.keepExactPrefix, splitSeparator = _defaultOptions.splitSeparator, splitKeepBoth = _defaultOptions.splitKeepBoth, stripCaseAndAccentsKeepDuplicate = _defaultOptions.stripCaseAndAccentsKeepDuplicate, stripCaseAndAccentsOnForbidden = _defaultOptions.stripCaseAndAccentsOnForbidden, } = _options; - let { stripCaseAndAccents = _defaultOptions.stripCaseAndAccents, split = _defaultOptions.split } = _options; - // console.log('options: %o', options); - // eslint-disable-next-line @typescript-eslint/no-explicit-any - function isString(line) { - return typeof line === 'string'; - } - function trim(line) { - return line.trim(); - } - function removeComments(line) { - const idx = line.indexOf(commentCharacter); - if (idx < 0) - return line; - const idxDirective = line.indexOf(cSpellToolDirective, idx); - if (idxDirective >= 0) { - const flags = line - .slice(idxDirective) - .split(/[\s,;]/g) - .map((s) => s.trim()) - .filter((a) => !!a); - for (const flag of flags) { - switch (flag) { - case 'split': - split = true; - break; - case 'no-split': - split = false; - break; - case 'no-generate-alternatives': - stripCaseAndAccents = false; - break; - case 'generate-alternatives': - stripCaseAndAccents = true; - break; - } - } - } - return line.slice(0, idx).trim(); - } - function filterEmptyLines(line) { - return !!line; - } - function* mapOptionalPrefix(line) { - if (line[0] === optionalCompound) { - const t = line.slice(1); - yield t; - yield compound + t; - } - else { - yield line; - } - } - function* mapOptionalSuffix(line) { - if (line.slice(-1) === optionalCompound) { - const t = line.slice(0, -1); - yield t; - yield t + compound; - } - else { - yield line; - } - } - const doNotNormalizePrefix = Object.create(null); - [ignoreCase, keepCase, '"'].forEach((prefix) => (doNotNormalizePrefix[prefix] = true)); - if (!stripCaseAndAccentsOnForbidden) { - doNotNormalizePrefix[forbidden] = true; - } - function removeDoublePrefix(w) { - return w.startsWith(ignoreCase + ignoreCase) ? w.slice(1) : w; - } - function stripKeepCasePrefixAndQuotes(word) { - word = word.replace(/"(.*?)"/g, '$1'); - return word[0] === keepCase ? word.slice(1) : word; - } - function _normalize(word) { - return normalizeWord(stripKeepCasePrefixAndQuotes(word)); - } - function* mapNormalize(word) { - const nWord = _normalize(word); - const forms = new Set(); - forms.add(nWord); - if (stripCaseAndAccents && !(word[0] in doNotNormalizePrefix)) { - for (const n of normalizeWordForCaseInsensitive(nWord)) { - (stripCaseAndAccentsKeepDuplicate || n !== nWord) && forms.add(ignoreCase + n); - } - } - yield* forms; - } - function* splitWords(lines) { - for (const line of lines) { - if (split) { - const lineEscaped = line.indexOf('"') >= 0 - ? line.replace(/".*?"/g, (quoted) => ' ' + quoted.replace(/(\s)/g, '\\$1') + ' ') - : line; - const words = splitLine(lineEscaped, splitSeparator); - yield* words.map((escaped) => escaped.replace(/\\/g, '')); - if (!splitKeepBoth) - continue; - } - yield line; - } - } - function* splitLines(paragraphs) { - for (const paragraph of paragraphs) { - yield* paragraph.split('\n'); - } - } - const processLines = opPipe(opFilter(isString), splitLines, opMap(removeComments), splitWords, opMap(trim), opFilter(filterEmptyLines), opConcatMap(mapOptionalPrefix), opConcatMap(mapOptionalSuffix), opConcatMap(mapNormalize), opMap(removeDoublePrefix)); - return processLines; -} -/** - * Normalizes a dictionary words based upon prefix / suffixes. - * Case insensitive versions are also generated. - * @param lines - one word per line - * @param _options - defines prefixes used when parsing lines. - * @returns words that have been normalized. - */ -export function parseDictionaryLines(lines, options) { - return createDictionaryLineParserMapper(options)(typeof lines === 'string' ? [lines] : lines); -} -export function parseLinesToDictionary(lines, options) { - const _options = mergeOptions(_defaultOptions, options); - const dictLines = parseDictionaryLines(lines, _options); - return buildTrieFast([...new Set(dictLines)].sort(), { - compoundCharacter: _options.compoundCharacter, - forbiddenWordPrefix: _options.forbiddenPrefix, - stripCaseAndAccentsPrefix: _options.caseInsensitivePrefix, - }); -} -export function parseDictionary(text, options) { - return parseLinesToDictionary(text.split('\n'), options); -} -// function escapeRegEx(s: string) { -// return s.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d'); -// } -function mergeOptions(base, ...partials) { - const opt = { ...base }; - for (const p of partials) { - if (!p) - continue; - Object.assign(opt, p); - } - return opt; -} -const RegExpToEncode = /\\([\s,;])/g; -const RegExpDecode = /<<(%[\da-f]{2})>>/gi; -function encodeLine(line) { - return line.replace(RegExpToEncode, (_, v) => '<<' + encodeURIComponent(v) + '>>'); -} -function decodeLine(line) { - return line.replace(RegExpDecode, (_, v) => '\\' + decodeURIComponent(v)); -} -function splitLine(line, regExp) { - return encodeLine(line) - .split(regExp) - .map((line) => decodeLine(line)); -} -export const __testing__ = { - splitLine, -}; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/TrieBuilder.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/TrieBuilder.js deleted file mode 100644 index c29e81edf..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/TrieBuilder.js +++ /dev/null @@ -1,214 +0,0 @@ -import { consolidate } from './consolidate.js'; -import { Trie } from './trie.js'; -import { createTrieRoot, createTriFromList, trieNodeToRoot } from './trie-util.js'; -import { mergeOptionalWithDefaults } from './utils/mergeOptionalWithDefaults.js'; -import { SecondChanceCache } from './utils/secondChanceCache.js'; -/** - * Builds an optimized Trie from a Iterable. It attempts to reduce the size of the trie - * by finding common endings. - * @param words Iterable set of words -- no processing is done on the words, they are inserted as is. - * @param trieOptions options for the Trie - */ -export function buildTrie(words, trieOptions) { - return new TrieBuilder(words, trieOptions).build(); -} -/** - * Builds a Trie from a Iterable. NO attempt a reducing the size of the Trie is done. - * @param words Iterable set of words -- no processing is done on the words, they are inserted as is. - * @param trieOptions options for the Trie - */ -export function buildTrieFast(words, trieOptions) { - const root = createTriFromList(words, trieOptions); - return new Trie(root, undefined); -} -// cspell:words sigs -const MAX_NUM_SIGS = 100000; -const MAX_TRANSFORMS = 1000000; -const MAX_CACHE_SIZE = 1000000; -export class TrieBuilder { - constructor(words, trieOptions) { - this.count = 0; - this.signatures = new SecondChanceCache(MAX_NUM_SIGS); - this.cached = new SecondChanceCache(MAX_CACHE_SIZE); - this.transforms = new SecondChanceCache(MAX_TRANSFORMS); - this._eow = Object.freeze({ f: 1 }); - /** position 0 of lastPath is always the root */ - this.lastPath = [{ s: '', n: { f: undefined, c: undefined } }]; - this.tails = new Map([['', this._eow]]); - this._canBeCached(this._eow); // this line is just for coverage reasons - this.signatures.set(this.signature(this._eow), this._eow); - this.cached.set(this._eow, this.count++); - this.trieOptions = Object.freeze(mergeOptionalWithDefaults(trieOptions)); - if (words) { - this.insert(words); - } - } - set _root(n) { - this.lastPath[0].n = n; - } - get _root() { - return trieNodeToRoot(this.lastPath[0].n, this.trieOptions); - } - signature(n) { - const isWord = n.f ? '*' : ''; - const ref = n.c ? JSON.stringify([...n.c.entries()].map(([k, n]) => [k, this.cached.get(n)])) : ''; - return isWord + ref; - } - _canBeCached(n) { - if (!n.c) - return true; - for (const v of n.c) { - if (!this.cached.has(v[1])) - return false; - } - return true; - } - tryCacheFrozen(n) { - if (this.cached.has(n)) { - return n; - } - this.cached.set(n, this.count++); - return n; - } - freeze(n) { - if (Object.isFrozen(n)) - return n; - // istanbul ignore else - if (n.c) { - const c = [...n.c] - .sort((a, b) => (a[0] < b[0] ? -1 : 1)) - .map(([k, n]) => [k, this.freeze(n)]); - n.c = new Map(c); - Object.freeze(n.c); - } - return Object.freeze(n); - } - tryToCache(n) { - if (!this._canBeCached(n)) { - return n; - } - const sig = this.signature(n); - const ref = this.signatures.get(sig); - if (ref !== undefined) { - return this.tryCacheFrozen(ref); - } - this.signatures.set(sig, this.freeze(n)); - return n; - } - storeTransform(src, s, result) { - if (!Object.isFrozen(result) || !Object.isFrozen(src)) - return; - const t = this.transforms.get(src) ?? new Map(); - t.set(s, result); - this.transforms.set(src, t); - } - addChild(node, head, child) { - if (node.c?.get(head) !== child) { - if (!node.c || Object.isFrozen(node)) { - node = { ...node, c: new Map(node.c ?? []) }; - } - node.c?.set(head, child); - } - return Object.isFrozen(child) ? this.tryToCache(node) : node; - } - buildTail(s) { - const v = this.tails.get(s); - if (v) - return v; - const head = s[0]; - const tail = s.slice(1); - const t = this.tails.get(tail); - const c = t || this.buildTail(tail); - const n = this.addChild({ f: undefined, c: undefined }, head, c); - if (!t) { - return n; - } - const cachedNode = this.tryCacheFrozen(Object.freeze(n)); - this.tails.set(s, cachedNode); - return cachedNode; - } - _insert(node, s, d) { - const orig = node; - if (Object.isFrozen(node)) { - const n = this.transforms.get(node)?.get(s); - if (n) { - return this.tryCacheFrozen(n); - } - } - if (!s) { - if (!node.c) { - return this._eow; - } - else { - node = copyIfFrozen(node); - node.f = this._eow.f; - return node; - } - } - const head = s[0]; - const tail = s.slice(1); - const cNode = node.c?.get(head); - const child = cNode ? this._insert(cNode, tail, d + 1) : this.buildTail(tail); - node = this.addChild(node, head, child); - this.storeTransform(orig, s, node); - this.lastPath[d] = { s: head, n: child }; - return node; - } - insertWord(word) { - let d = 1; - for (const s of word.split('')) { - const p = this.lastPath[d]; - if (p?.s !== s) - break; - d++; - } - // remove the remaining part of the path because it doesn't match this word. - if (word.length < d) { - d = word.length; - } - this.lastPath.length = d; - d -= 1; - const { n } = this.lastPath[d]; - const tail = word.slice(d); - this.lastPath[d].n = this._insert(n, tail, d + 1); - while (d > 0) { - const { s, n } = this.lastPath[d]; - d -= 1; - const parent = this.lastPath[d]; - const pn = parent.n; - parent.n = this.addChild(pn, s, n); - if (pn === parent.n) - break; - const tail = word.slice(d); - this.storeTransform(pn, tail, parent.n); - } - } - insert(words) { - for (const w of words) { - w && this.insertWord(w); - } - } - /** - * Resets the builder - */ - reset() { - this._root = createTrieRoot(this.trieOptions); - this.cached.clear(); - this.signatures.clear(); - this.signatures.set(this.signature(this._eow), this._eow); - this.count = 0; - this.cached.set(this._eow, this.count++); - } - build(consolidateSuffixes = false) { - const root = this._root; - // Reset the builder to prevent updating the trie in the background. - this.reset(); - return new Trie(consolidateSuffixes ? consolidate(root) : root); - } -} -function copyIfFrozen(n) { - if (!Object.isFrozen(n)) - return n; - const c = n.c ? new Map(n.c) : undefined; - return { f: n.f, c }; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/TrieNode.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/TrieNode.js deleted file mode 100644 index 47a9828ca..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/TrieNode.js +++ /dev/null @@ -1,3 +0,0 @@ -export const FLAG_WORD = 1; -export class ChildMap extends Map { -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/compoundWalker.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/compoundWalker.js deleted file mode 100644 index 3a90f9c31..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/compoundWalker.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * - * Depth first walk of a compound trie. - * If there are compounds, this becomes an infinite iterator. - * Use i.next(false) to prevent the walker from going deeper into the trie. - * - * @param trie the compound Trie to walk - */ -export function* compoundWalker(trie, caseSensitive = true) { - const { compoundCharacter: cc, forbiddenWordPrefix: forbidden, stripCaseAndAccentsPrefix } = trie.options; - const blockNode = new Set([cc, forbidden, stripCaseAndAccentsPrefix]); - const root = (!caseSensitive && trie.root.c?.get(stripCaseAndAccentsPrefix)) || trie.root; - function* walk(n, s, c, d) { - const deeper = yield { n, s, c, d }; - if (deeper !== false && n.c) { - for (const [k, cn] of n.c) { - if (blockNode.has(k)) - continue; - yield* walk(cn, s + k, false, d); - } - if (n.c.has(cc)) { - const compoundNodes = root.c?.get(cc); - if (compoundNodes) { - yield* walk(compoundNodes, s, true, d + 1); - } - } - } - } - // Make sure we do not walk forbidden and compound only words from the root. - for (const n of root.c || []) { - if (!blockNode.has(n[0])) { - yield* walk(n[1], n[0], false, 0); - } - } -} -/** - * - * @param trie Trie to walk - * @param maxDepth Max compound depth - * @param caseSensitive case sensitive search. - */ -export function* compoundWords(trie, maxDepth, caseSensitive = true) { - const stream = compoundWalker(trie, caseSensitive); - let item = stream.next(); - while (!item.done) { - const { n, s, d } = item.value; - if (d >= maxDepth) { - item = stream.next(false); - continue; - } - if (n.f) { - yield s; - } - item = stream.next(); - } -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/consolidate.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/consolidate.js deleted file mode 100644 index a6d8268be..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/consolidate.js +++ /dev/null @@ -1,90 +0,0 @@ -import { trieNodeToRoot } from './trie-util.js'; -import { FLAG_WORD } from './TrieNode.js'; -/** - * Consolidate to DAWG - * @param root the root of the Trie tree - */ -export function consolidate(root) { - let count = 0; - const signatures = new Map(); - const cached = new Map(); - const knownMap = new Map(); - function signature(n) { - const isWord = n.f ? '*' : ''; - const ref = n.c ? JSON.stringify([...n.c.entries()].map(([k, n]) => [k, cached.get(n)])) : ''; - return isWord + ref; - } - function findEow(n) { - if (n.f && !n.c) - return n; - let r; - // istanbul ignore else - if (n.c) { - for (const c of n.c.values()) { - r = findEow(c); - // istanbul ignore else - if (r) - break; - } - } - return r; - } - function compareMaps(a, b) { - for (const e of a) { - if (b.get(e[0]) !== e[1]) - return false; - } - return a.length === b.size; - } - function deepCopy(n) { - const k = knownMap.get(n); - if (k) { - return k; - } - const orig = n; - if (n.c) { - const children = [...n.c].map((c) => [c[0], deepCopy(c[1])]); - if (!compareMaps(children, n.c)) { - n = { f: n.f, c: new Map(children) }; - } - } - const sig = signature(n); - const ref = signatures.get(sig); - if (ref) { - knownMap.set(orig, ref); - return ref; - } - Object.freeze(n); - signatures.set(sig, n); - cached.set(n, count++); - knownMap.set(orig, n); - return n; - } - function process(n) { - if (cached.has(n)) { - return n; - } - if (Object.isFrozen(n)) { - return knownMap.get(n) || deepCopy(n); - } - if (n.c) { - const children = [...n.c] - .sort((a, b) => (a[0] < b[0] ? -1 : 1)) - .map((c) => [c[0], process(c[1])]); - n.c = new Map(children); - } - const sig = signature(n); - const ref = signatures.get(sig); - if (ref) { - return ref; - } - signatures.set(sig, n); - cached.set(n, count++); - return n; - } - // Add end of word to the set of signatures and cache it. - const eow = findEow(root) || { f: FLAG_WORD, c: undefined }; - signatures.set(signature(eow), eow); - cached.set(eow, count++); - return trieNodeToRoot(process(root), root); -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/constants.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/constants.js deleted file mode 100644 index 924e942a8..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/constants.js +++ /dev/null @@ -1,11 +0,0 @@ -export const COMPOUND_FIX = '+'; -export const OPTIONAL_COMPOUND_FIX = '*'; -export const CASE_INSENSITIVE_PREFIX = '~'; -export const FORBID_PREFIX = '!'; -export const LINE_COMMENT = '#'; -export const IDENTITY_PREFIX = '='; -export const defaultTrieOptions = Object.freeze({ - compoundCharacter: COMPOUND_FIX, - forbiddenWordPrefix: FORBID_PREFIX, - stripCaseAndAccentsPrefix: CASE_INSENSITIVE_PREFIX, -}); diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/convertToTrieRefNodes.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/convertToTrieRefNodes.js deleted file mode 100644 index badb483ea..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/convertToTrieRefNodes.js +++ /dev/null @@ -1,83 +0,0 @@ -import { genSequence } from 'gensequence'; -import { FLAG_WORD } from './TrieNode.js'; -const MinReferenceCount = 3; -/** - * An iterator that will emit TrieRefNodes mostly in descending frequency - * @param root Root of the Trie -- a DAWG is preferred to keep the number of duplicates down. - */ -export function convertToTrieRefNodes(root) { - const eow = { f: FLAG_WORD, c: undefined }; - const tallies = new Map([[eow, 0]]); - let count = 0; - const cached = new Map(); - const rollupTally = new Map(); - function tally(n) { - if (n.f && !n.c) { - tallies.set(eow, (tallies.get(eow) || 0) + 1); - return; - } - const t = tallies.get(n); - if (t) { - tallies.set(n, t + 1); - return; - } - tallies.set(n, 1); - for (const c of n.c?.values() || []) { - tally(c); - } - } - function rollup(n) { - const c = rollupTally.get(n); - if (c) { - return c; - } - if (!n.c) { - const sum = tallies.get(eow) || 0; - rollupTally.set(n, sum); - return sum; - } - const sum = [...n.c.values()].reduce((acc, v) => acc + rollup(v), tallies.get(n) || 0); - rollupTally.set(n, sum); - return sum; - } - function* walkByTallies(tallies) { - const nodes = [...genSequence(tallies).filter((a) => a[1] >= MinReferenceCount)].sort((a, b) => b[1] - a[1]); - for (const [n] of nodes) { - yield* walkByRollup(n); - } - } - function* walkByRollup(n) { - if (cached.has(n)) - return; - if (n.f && !n.c) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - cached.set(n, cached.get(eow)); - return; - } - const children = [...(n.c?.values() || [])].sort((a, b) => (rollupTally.get(b) || 0) - (rollupTally.get(a) || 0)); - for (const c of children) { - yield* walkByRollup(c); - } - cached.set(n, count++); - yield convert(n); - } - function convert(n) { - const { f, c } = n; - const r = c - ? [...c].sort((a, b) => (a[0] < b[0] ? -1 : 1)).map(([s, n]) => [s, cached.get(n)]) - : undefined; - const rn = r ? (f ? { f, r } : { r }) : { f }; - return rn; - } - function* walk(root) { - cached.set(eow, count++); - yield convert(eow); - // Emit the highest referenced nodes first. - yield* walkByTallies(tallies); - // Emit the rest. - yield* walkByRollup(root); - } - tally(root); - rollup(root); - return walk(root); -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distance.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distance.js deleted file mode 100644 index be3f2685a..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distance.js +++ /dev/null @@ -1,42 +0,0 @@ -import { distanceAStarWeighted } from './distanceAStarWeighted.js'; -import { levenshteinDistance } from './levenshtein.js'; -import { addDefToWeightMap, createWeightMap } from './weightedMaps.js'; -const defaultCost = 100; -/** - * Calculate the edit distance between any two words. - * Use the Damerau–Levenshtein distance algorithm. - * @param wordA - * @param wordB - * @param editCost - the cost of each edit (defaults to 100) - * @returns the edit distance. - */ -export function editDistance(wordA, wordB, editCost = defaultCost) { - return levenshteinDistance(wordA, wordB) * editCost; -} -/** - * Calculate the weighted edit distance between any two words. - * @param wordA - * @param wordB - * @param weights - the weights to use - * @param editCost - the cost of each edit (defaults to 100) - * @returns the edit distance - */ -export function editDistanceWeighted(wordA, wordB, weights, editCost = defaultCost) { - return distanceAStarWeighted(wordA, wordB, weights, editCost); -} -/** - * Collect Map definitions into a single weighted map. - * @param defs - list of definitions - * @returns A Weighted Map to be used with distance calculations. - */ -export function createWeightedMap(defs) { - return createWeightMap(...defs); -} -/** - * Update a WeightedMap with a WeightedMapDef - * @param weightedMap - map to update - * @param def - the definition to use - */ -export function updatedWeightedMap(weightedMap, def) { - addDefToWeightMap(weightedMap, def); -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distanceAStar.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distanceAStar.js deleted file mode 100644 index c97347beb..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distanceAStar.js +++ /dev/null @@ -1,53 +0,0 @@ -import { PairingHeap } from '../utils/PairingHeap.js'; -/** - * Calculate the edit distance between two words using an A* algorithm. - * - * Using basic weights, this algorithm has the same results as the Damerau-Levenshtein algorithm. - */ -export function distanceAStar(a, b) { - const aN = a.length; - const bN = b.length; - const cost = 100; - const candidates = new PairingHeap(compare); - candidates.add({ ai: 0, bi: 0, c: 0 }); - function opSub(n) { - const { ai, bi, c } = n; - if (ai < aN && bi < bN) { - const cc = a[ai] === b[bi] ? c : c + cost; - candidates.add({ ai: ai + 1, bi: bi + 1, c: cc }); - } - } - function opIns(n) { - const { ai, bi, c } = n; - if (bi < bN) { - candidates.add({ ai: ai, bi: bi + 1, c: c + cost }); - } - } - function opDel(n) { - const { ai, bi, c } = n; - if (ai < aN) { - candidates.add({ ai: ai + 1, bi: bi, c: c + cost }); - } - } - function opSwap(n) { - const { ai, bi, c } = n; - if (a[ai] === b[bi + 1] && a[ai + 1] === b[bi]) { - candidates.add({ ai: ai + 2, bi: bi + 2, c: c + cost }); - } - } - let best; - // const bc2 = 2 * bc; - while ((best = candidates.dequeue())) { - if (best.ai === aN && best.bi === bN) - break; - opSwap(best); - opIns(best); - opDel(best); - opSub(best); - } - return best?.c ?? -1; -} -function compare(a, b) { - // Choose lowest cost or farthest Manhattan distance. - return a.c - b.c || b.ai + b.bi - a.ai - a.bi; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distanceAStarWeighted.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distanceAStarWeighted.js deleted file mode 100644 index 753087a81..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/distanceAStarWeighted.js +++ /dev/null @@ -1,136 +0,0 @@ -import assert from 'assert'; -import { PairingHeap } from '../utils/PairingHeap.js'; -/** - * Calculate the edit distance between two words using an A* algorithm. - * - * Using basic weights, this algorithm has the same results as the Damerau-Levenshtein algorithm. - */ -export function distanceAStarWeighted(wordA, wordB, map, cost = 100) { - const best = _distanceAStarWeightedEx(wordA, wordB, map, cost); - const penalty = map.calcAdjustment(wordB); - return best.c + best.p + penalty; -} -export function distanceAStarWeightedEx(wordA, wordB, map, cost = 100) { - const best = _distanceAStarWeightedEx(wordA, wordB, map, cost); - const aa = '^' + wordA + '$'; - const bb = '^' + wordB + '$'; - const penalty = map.calcAdjustment(wordB); - const result = { - a: aa, - b: bb, - cost: best.c + best.p + penalty, - penalty, - segments: [], - }; - const segments = result.segments; - for (let n = best; n.f; n = n.f) { - const f = n.f; - const a = aa.slice(f.ai, n.ai); - const b = bb.slice(f.bi, n.bi); - const c = n.c - f.c; - const p = n.p - f.p; - segments.push({ a, b, c, p }); - } - segments.reverse(); - return result; -} -function _distanceAStarWeightedEx(wordA, wordB, map, cost = 100) { - // Add ^ and $ for begin/end detection. - const a = '^' + wordA + '$'; - const b = '^' + wordB + '$'; - const aN = a.length; - const bN = b.length; - const candidates = new CandidatePool(aN, bN); - candidates.add({ ai: 0, bi: 0, c: 0, p: 0, f: undefined }); - /** Substitute / Replace */ - function opSub(n) { - const { ai, bi, c, p } = n; - if (ai < aN && bi < bN) { - const cc = a[ai] === b[bi] ? c : c + cost; - candidates.add({ ai: ai + 1, bi: bi + 1, c: cc, p, f: n }); - } - } - /** Insert */ - function opIns(n) { - const { ai, bi, c, p } = n; - if (bi < bN) { - candidates.add({ ai: ai, bi: bi + 1, c: c + cost, p, f: n }); - } - } - /** Delete */ - function opDel(n) { - const { ai, bi, c, p } = n; - if (ai < aN) { - candidates.add({ ai: ai + 1, bi: bi, c: c + cost, p, f: n }); - } - } - /** Swap adjacent letters */ - function opSwap(n) { - const { ai, bi, c, p } = n; - if (a[ai] === b[bi + 1] && a[ai + 1] === b[bi]) { - candidates.add({ ai: ai + 2, bi: bi + 2, c: c + cost, p, f: n }); - } - } - function opMap(n) { - const { ai, bi, c, p } = n; - const pos = { a, b, ai, bi, c, p }; - const costCalculations = [map.calcInsDelCosts(pos), map.calcSwapCosts(pos), map.calcReplaceCosts(pos)]; - costCalculations.forEach((iter) => { - for (const nn of iter) { - candidates.add({ ...nn, f: n }); - } - }); - } - let best; - // const bc2 = 2 * bc; - while ((best = candidates.next())) { - if (best.ai === aN && best.bi === bN) - break; - opSwap(best); - opIns(best); - opDel(best); - opMap(best); - opSub(best); - } - assert(best); - return best; -} -class CandidatePool { - constructor(aN, bN) { - this.aN = aN; - this.bN = bN; - this.pool = new PairingHeap(compare); - this.grid = []; - } - next() { - let n; - while ((n = this.pool.dequeue())) { - if (!n.d) - return n; - } - return undefined; - } - add(n) { - const i = idx(n.ai, n.bi, this.bN); - const g = this.grid[i]; - if (!g) { - this.grid[i] = n; - this.pool.add(n); - return; - } - // Do not add if the existing node is better. - if (g.c <= n.c) - return; - // New node is better. - g.d = true; - this.grid[i] = n; - this.pool.add(n); - } -} -function idx(r, c, cols) { - return r * cols + c; -} -function compare(a, b) { - // lowest cost then progress - return a.c - b.c || b.ai + b.bi - a.ai - a.bi; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/formatResultEx.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/formatResultEx.js deleted file mode 100644 index 0882ba66f..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/formatResultEx.js +++ /dev/null @@ -1,53 +0,0 @@ -import { distanceAStarWeightedEx } from './distanceAStarWeighted.js'; -function pL(s, w) { - const strWidth = vizWidth(s); - const w0 = Math.max(0, w - strWidth); - return ' '.repeat(w0) + s; -} -function pR(s, w) { - const strWidth = vizWidth(s); - const w0 = Math.max(0, w - strWidth); - return s + ' '.repeat(w0); -} -function vizWidth(s) { - const r = s.replace(/[\u0300-\u036F\u007f-\u009f]/gu, ''); - let i = 0; - for (const c of r) { - i += c.length; - } - return i; -} -export function formatExResult(ex) { - if (!ex) - return ''; - const { cost, segments, penalty } = ex; - const asString = segments.map(({ a, b, c, p }) => ({ - a: `<${a}>`, - b: `<${b}>`, - c: c.toString(10), - p: p.toString(10), - })); - asString.push({ - a: '', - b: '', - c: ' = ' + segments.reduce((sum, { c }) => sum + c, 0).toString(10), - p: ' = ' + segments.reduce((sum, { p }) => sum + p, 0).toString(10), - }); - const parts = asString.map(({ a, b, c, p }) => ({ - a, - b, - c, - p, - w: Math.max(vizWidth(a), vizWidth(b), vizWidth(c), vizWidth(p)), - })); - const a = 'a: |' + parts.map(({ a, w }) => pR(a, w)).join('|') + '|'; - const b = 'b: |' + parts.map(({ b, w }) => pR(b, w)).join('|') + '|'; - const c = 'c: |' + parts.map(({ c, w }) => pL(c, w)).join('|') + '|'; - const p = 'p: |' + parts.map(({ p, w }) => pL(p, w)).join('|') + '|'; - const penaltyMsg = penalty ? `[+${penalty}]` : ''; - return `<${ex.a.slice(1, -1)}> -> <${ex.b.slice(1, -1)}> (${cost - penalty}${penaltyMsg})\n${[a, b, c, p].join('\n')}\n`; -} -export function formattedDistance(wordA, wordB, weightMap, cost) { - const x = distanceAStarWeightedEx(wordA, wordB, weightMap, cost); - return formatExResult(x); -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/index.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/index.js deleted file mode 100644 index 78fc4b983..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/index.js +++ /dev/null @@ -1 +0,0 @@ -export { createWeightedMap, editDistance, editDistanceWeighted } from './distance.js'; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/levenshtein.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/levenshtein.js deleted file mode 100644 index 01c874605..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/levenshtein.js +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Damerau–Levenshtein distance - * [Damerau–Levenshtein distance - Wikipedia](https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance) - * @param a - first word - * @param b - second word - * @returns Distance value - */ -export function levenshteinDistance(a, b) { - // By prefixing with spaces, no out of bounds checks are necessary. - const aa = ' ' + a; - const bb = ' ' + b; - const nA = a.length + 1; - const nB = b.length + 1; - const firstRow = []; - for (let i = 0; i <= nA; ++i) { - firstRow[i] = i; - } - const matrix = [firstRow, [1].concat(firstRow), [2, 1].concat(firstRow)]; - let ppRow = matrix[0]; - let pRow = matrix[1]; - for (let j = 2; j <= nB; ++j) { - const row = matrix[j % 3]; - row[0] = pRow[0] + 1; - row[1] = pRow[1] + 1; - const bp = bb[j - 1]; - const bc = bb[j]; - let ap = aa[0]; - for (let i = 2, i1 = 1; i <= nA; i1 = i, ++i) { - const ac = aa[i]; - const c = pRow[i1] + (ac == bc ? 0 : 1); - const ct = ac == bp && ap == bc ? ppRow[i1 - 1] + 1 : c; - row[i] = Math.min(c, // substitute - ct, // transpose - pRow[i] + 1, // insert - row[i1] + 1 // delete - ); - ap = ac; - } - ppRow = pRow; - pRow = row; - } - return pRow[nA]; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/weightedMaps.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/weightedMaps.js deleted file mode 100644 index 377caa475..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/distance/weightedMaps.js +++ /dev/null @@ -1,289 +0,0 @@ -import { DEFAULT_COMPOUNDED_WORD_SEPARATOR } from '../suggestions/constants.js'; -const matchPossibleWordSeparators = /[+∙•・●]/g; -export function createWeightMap(...defs) { - const map = _createWeightMap(); - addDefsToWeightMap(map, defs); - return map; -} -export function addDefToWeightMap(map, ...defs) { - return addDefsToWeightMap(map, defs); -} -export function addAdjustment(map, ...adjustments) { - for (const adj of adjustments) { - map.adjustments.set(adj.id, adj); - } - return map; -} -export function addDefsToWeightMap(map, defs) { - function addSet(set, def) { - addSetToTrieCost(map.insDel, set, def.insDel, def.penalty); - addSetToTrieTrieCost(map.replace, set, def.replace, def.penalty); - addSetToTrieTrieCost(map.swap, set, def.swap, def.penalty); - } - for (const _def of defs) { - const def = normalizeDef(_def); - const mapSets = splitMap(def); - mapSets.forEach((s) => addSet(s, def)); - } - return map; -} -function _createWeightMap() { - return new _WeightedMap(); -} -function lowest(a, b) { - if (a === undefined) - return b; - if (b === undefined) - return a; - return a <= b ? a : b; -} -function highest(a, b) { - if (a === undefined) - return b; - if (b === undefined) - return a; - return a >= b ? a : b; -} -function normalize(s) { - const f = new Set([s]); - f.add(s.normalize('NFC')); - f.add(s.normalize('NFD')); - return f; -} -export function* splitMapSubstringsIterable(map) { - let seq = ''; - let mode = 0; - for (const char of map) { - if (mode && char === ')') { - yield* normalize(seq); - mode = 0; - continue; - } - if (mode) { - seq += char; - continue; - } - if (char === '(') { - mode = 1; - seq = ''; - continue; - } - yield* normalize(char); - } -} -export function splitMapSubstrings(map) { - return [...splitMapSubstringsIterable(map)]; -} -/** - * Splits a WeightedMapDef.map - * @param map - */ -function splitMap(def) { - const { map } = def; - const sets = map.split('|'); - return sets.map(splitMapSubstrings).filter((s) => s.length > 0); -} -function addToTrieCost(trie, str, cost, penalties) { - if (!str) - return; - let t = trie; - for (const c of str) { - const n = (t.n = t.n || Object.create(null)); - t = n[c] = n[c] || Object.create(null); - } - t.c = lowest(t.c, cost); - t.p = highest(t.p, penalties); -} -function addToTrieTrieCost(trie, left, right, cost, penalties) { - let t = trie; - for (const c of left) { - const n = (t.n = t.n || Object.create(null)); - t = n[c] = n[c] || Object.create(null); - } - const trieCost = (t.t = t.t || Object.create(null)); - addToTrieCost(trieCost, right, cost, penalties); -} -function addSetToTrieCost(trie, set, cost, penalties) { - if (cost === undefined) - return; - for (const str of set) { - addToTrieCost(trie, str, cost, penalties); - } -} -function addSetToTrieTrieCost(trie, set, cost, penalties) { - if (cost === undefined) - return; - for (const left of set) { - for (const right of set) { - if (left === right) - continue; - addToTrieTrieCost(trie, left, right, cost, penalties); - } - } -} -function* searchTrieNodes(trie, str, i) { - const len = str.length; - for (let n = trie.n; i < len && n;) { - const t = n[str[i]]; - if (!t) - return; - ++i; - yield { i, t }; - n = t.n; - } -} -function* walkTrieNodes(t, s) { - if (!t) - return; - yield { s, t }; - if (!t.n) - return; - for (const [k, v] of Object.entries(t.n)) { - yield* walkTrieNodes(v, s + k); - } -} -function* walkTrieCost(trie) { - for (const { s, t } of walkTrieNodes(trie, '')) { - if (t.c) { - yield { s, c: t.c, p: t.p }; - } - } -} -function* walkTrieTrieCost(trie) { - for (const { s: a, t } of walkTrieNodes(trie, '')) { - if (t.t) { - for (const { s: b, c, p } of walkTrieCost(t.t)) { - yield { a, b, c, p }; - } - } - } -} -function* findTrieCostPrefixes(trie, str, i) { - for (const n of searchTrieNodes(trie, str, i)) { - const { c, p } = n.t; - if (c !== undefined) { - yield { i: n.i, c, p: p || 0 }; - } - } -} -function* findTrieTrieCostPrefixes(trie, str, i) { - for (const n of searchTrieNodes(trie, str, i)) { - const t = n.t.t; - if (t !== undefined) { - yield { i: n.i, t }; - } - } -} -class _WeightedMap { - constructor() { - this.insDel = {}; - this.replace = {}; - this.swap = {}; - this.adjustments = new Map(); - } - *calcInsDelCosts(pos) { - const { a, ai, b, bi, c, p } = pos; - for (const del of findTrieCostPrefixes(this.insDel, a, ai)) { - yield { a, b, ai: del.i, bi, c: c + del.c, p: p + del.p }; - } - for (const ins of findTrieCostPrefixes(this.insDel, b, bi)) { - yield { a, b, ai, bi: ins.i, c: c + ins.c, p: p + ins.p }; - } - } - *calcReplaceCosts(pos) { - // Search for matching substrings in `a` to be replaced by - // matching substrings from `b`. All substrings start at their - // respective `ai`/`bi` positions. - const { a, ai, b, bi, c, p } = pos; - for (const del of findTrieTrieCostPrefixes(this.replace, a, ai)) { - for (const ins of findTrieCostPrefixes(del.t, b, bi)) { - yield { a, b, ai: del.i, bi: ins.i, c: c + ins.c, p: p + ins.p }; - } - } - } - *calcSwapCosts(pos) { - const { a, ai, b, bi, c, p } = pos; - const swap = this.swap; - for (const left of findTrieTrieCostPrefixes(swap, a, ai)) { - for (const right of findTrieCostPrefixes(left.t, a, left.i)) { - const sw = a.slice(left.i, right.i) + a.slice(ai, left.i); - if (b.slice(bi).startsWith(sw)) { - const len = sw.length; - yield { a, b, ai: ai + len, bi: bi + len, c: c + right.c, p: p + right.p }; - } - } - } - } - calcAdjustment(word) { - let penalty = 0; - for (const adj of this.adjustments.values()) { - if (adj.regexp.global) { - for (const _m of word.matchAll(adj.regexp)) { - penalty += adj.penalty; - } - } - else if (adj.regexp.test(word)) { - penalty += adj.penalty; - } - } - return penalty; - } -} -function prettyPrintInsDel(trie, pfx = '', indent = ' ') { - function* walk() { - for (const { s, c, p } of walkTrieCost(trie)) { - const pm = p ? ` + ${p}` : ''; - yield indent + `(${s}) = ${c}${pm}`; - } - } - return ['InsDel:', ...[...walk()].sort()].map((line) => pfx + line + '\n').join(''); -} -export function prettyPrintReplace(trie, pfx = '', indent = ' ') { - function* walk() { - for (const { a, b, c, p } of walkTrieTrieCost(trie)) { - const pm = p ? ` + ${p}` : ''; - yield indent + `(${a}) -> (${b}) = ${c}${pm}`; - } - } - return ['Replace:', ...[...walk()].sort()].map((line) => pfx + line + '\n').join(''); -} -export function prettyPrintSwap(trie, pfx = '', indent = ' ') { - function* walk() { - for (const { a, b, c, p } of walkTrieTrieCost(trie)) { - const pm = p ? ` + ${p}` : ''; - yield indent + `(${a}) <-> (${b}) = ${c}${pm}`; - } - } - return ['Swap:', ...[...walk()].sort()].map((line) => pfx + line + '\n').join(''); -} -export function prettyPrintWeightMap(map) { - return [prettyPrintInsDel(map.insDel), prettyPrintReplace(map.replace), prettyPrintSwap(map.swap)].join('\n'); -} -export function lookupReplaceCost(map, a, b) { - const trie = map.replace; - let tt = trie; - for (let ai = 0; ai < a.length && tt; ++ai) { - tt = tt.n?.[a[ai]]; - } - if (!tt) - return undefined; - let t = tt.t; - for (let bi = 0; bi < b.length && t; ++bi) { - t = t.n?.[b[bi]]; - } - return t?.c; -} -function normalizeDef(def) { - const { map, ...rest } = def; - return { ...rest, map: normalizeMap(map) }; -} -function normalizeMap(map) { - return map.replace(matchPossibleWordSeparators, DEFAULT_COMPOUNDED_WORD_SEPARATOR); -} -export const __testing__ = { - findTrieCostPrefixes, - findTrieTrieCostPrefixes, - normalizeDef, - splitMap, - splitMapSubstrings, -}; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/find.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/find.js deleted file mode 100644 index 0e60e831b..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/find.js +++ /dev/null @@ -1,282 +0,0 @@ -import { CASE_INSENSITIVE_PREFIX, COMPOUND_FIX, FORBID_PREFIX } from './constants.js'; -import { FLAG_WORD } from './TrieNode.js'; -import { memorizeLastCall } from './utils/memorizeLastCall.js'; -import { mergeDefaults } from './utils/mergeDefaults.js'; -const defaultLegacyMinCompoundLength = 3; -const _defaultFindOptions = { - matchCase: false, - compoundMode: 'compound', - forbidPrefix: FORBID_PREFIX, - compoundFix: COMPOUND_FIX, - caseInsensitivePrefix: CASE_INSENSITIVE_PREFIX, - legacyMinCompoundLength: defaultLegacyMinCompoundLength, -}; -const arrayCompoundModes = ['none', 'compound', 'legacy']; -const knownCompoundModes = new Map(arrayCompoundModes.map((a) => [a, a])); -/** - * - * @param root Trie root node. root.c contains the compound root and forbidden root. - * @param word A pre normalized word use `normalizeWord` or `normalizeWordToLowercase` - * @param options - */ -export function findWord(root, word, options) { - return _findWord(root, word, createFindOptions(options)); -} -/** - * - * @param root Trie root node. root.c contains the compound root and forbidden root. - * @param word A pre normalized word use `normalizeWord` or `normalizeWordToLowercase` - * @param options - */ -export function findWordNode(root, word, options) { - return _findWordNode(root, word, createFindOptions(options)); -} -/** - * - * @param root Trie root node. root.c contains the compound root and forbidden root. - * @param word A pre normalized word use `normalizeWord` or `normalizeWordToLowercase` - * @param options - */ -function _findWord(root, word, options) { - const { node: _, ...result } = _findWordNode(root, word, options); - return result; -} -/** - * - * @param root Trie root node. root.c contains the compound root and forbidden root. - * @param word A pre normalized word use `normalizeWord` or `normalizeWordToLowercase` - * @param options - */ -function _findWordNode(root, word, options) { - const compoundMode = knownCompoundModes.get(options.compoundMode) || _defaultFindOptions.compoundMode; - const compoundPrefix = options.compoundMode === 'compound' ? root.compoundCharacter ?? options.compoundFix : ''; - const ignoreCasePrefix = options.matchCase ? '' : root.stripCaseAndAccentsPrefix ?? options.caseInsensitivePrefix; - function __findCompound() { - const f = findCompoundWord(root, word, compoundPrefix, ignoreCasePrefix); - const result = { ...f }; - if (f.found !== false && f.compoundUsed) { - // If case was ignored when searching for the word, then check the forbidden - // in the ignore case forbidden list. - const r = !f.caseMatched ? walk(root, options.caseInsensitivePrefix) : root; - result.forbidden = isForbiddenWord(r, word, options.forbidPrefix); - } - return result; - } - function __findExact() { - const n = walk(root, word); - const isFound = isEndOfWordNode(n); - const result = { - found: isFound && word, - compoundUsed: false, - forbidden: isForbiddenWord(root, word, options.forbidPrefix), - node: n, - caseMatched: true, - }; - return result; - } - switch (compoundMode) { - case 'none': - return options.matchCase ? __findExact() : __findCompound(); - case 'compound': - return __findCompound(); - case 'legacy': - return findLegacyCompound(root, word, options); - } -} -export function findLegacyCompound(root, word, options) { - const roots = [root]; - if (!options.matchCase) { - roots.push(walk(root, options.caseInsensitivePrefix)); - } - return findLegacyCompoundNode(roots, word, options.legacyMinCompoundLength); -} -export function findCompoundNode(root, word, compoundCharacter, ignoreCasePrefix) { - // Approach - do a depth first search for the matching word. - const stack = [ - // { n: root, compoundPrefix: '', cr: undefined, caseMatched: true }, - { n: root, compoundPrefix: ignoreCasePrefix, cr: undefined, caseMatched: true }, - ]; - const compoundPrefix = compoundCharacter || ignoreCasePrefix; - const possibleCompoundPrefix = ignoreCasePrefix && compoundCharacter ? ignoreCasePrefix + compoundCharacter : ''; - const w = word.normalize(); - function determineRoot(s) { - const prefix = s.compoundPrefix; - let r = root; - let i; - for (i = 0; i < prefix.length && r; ++i) { - r = r.c?.get(prefix[i]); - } - const caseMatched = s.caseMatched && prefix[0] !== ignoreCasePrefix; - return { - n: s.n, - compoundPrefix: prefix === compoundPrefix ? possibleCompoundPrefix : '', - cr: r, - caseMatched, - }; - } - let compoundUsed = false; - let caseMatched = true; - let i = 0; - let node; - // eslint-disable-next-line no-constant-condition - while (true) { - const s = stack[i]; - const h = w[i++]; - const n = s.cr || s.n; - const c = n?.c?.get(h); - if (c && i < word.length) { - // Go deeper. - caseMatched = s.caseMatched; - stack[i] = { n: c, compoundPrefix, cr: undefined, caseMatched }; - } - else if (!c || !c.f) { - // Remember the first matching node for possible auto completion. - node = node || c; - // We did not find the word backup and take the first unused compound branch - while (--i > 0 && (!stack[i].compoundPrefix || !stack[i].n?.c?.has(compoundCharacter))) { - /* empty */ - } - if (i >= 0 && stack[i].compoundPrefix) { - compoundUsed = i > 0; - const r = determineRoot(stack[i]); - stack[i] = r; - if (!r.cr) { - break; - } - if (!i && !r.caseMatched) { - if (w !== w.toLowerCase()) { - // It is not going to be found. - break; - } - } - } - else { - break; - } - } - else { - node = c; - caseMatched = s.caseMatched; - break; - } - } - const found = (i && i === word.length && word) || false; - const result = { found, compoundUsed, node, forbidden: undefined, caseMatched }; - return result; -} -function findCompoundWord(root, word, compoundCharacter, ignoreCasePrefix) { - const { found, compoundUsed, node, caseMatched } = findCompoundNode(root, word, compoundCharacter, ignoreCasePrefix); - // Was it a word? - if (!node || !node.f) { - return { found: false, compoundUsed, node, forbidden: undefined, caseMatched }; - } - return { found, compoundUsed, node, forbidden: undefined, caseMatched }; -} -export function findWordExact(root, word) { - return isEndOfWordNode(walk(root, word)); -} -export function isEndOfWordNode(n) { - return n?.f === FLAG_WORD; -} -function walk(root, word) { - const w = word; - let n = root; - let i = 0; - while (n && i < word.length) { - const h = w[i++]; - n = n.c?.get(h); - } - return n; -} -function findLegacyCompoundNode(roots, word, minCompoundLength) { - const root = roots[0]; - const numRoots = roots.length; - // Approach - do a depth first search for the matching word. - const stack = [ - { n: root, usedRoots: 1, subLength: 0, isCompound: false, cr: undefined, caseMatched: true }, - ]; - const w = word; - const wLen = w.length; - let compoundUsed = false; - let caseMatched = true; - let i = 0; - let node; - // eslint-disable-next-line no-constant-condition - while (true) { - const s = stack[i]; - const h = w[i++]; - const n = s.cr || s.n; - const c = n?.c?.get(h); - if (c && i < wLen) { - // Go deeper. - stack[i] = { - n: c, - usedRoots: 0, - subLength: s.subLength + 1, - isCompound: s.isCompound, - cr: undefined, - caseMatched: s.caseMatched, - }; - } - else if (!c || !c.f || (c.f && s.subLength < minCompoundLength - 1)) { - // We did not find the word backup and take the first unused compound branch - while (--i > 0) { - const s = stack[i]; - if (s.usedRoots < numRoots && - s.n?.f && - (s.subLength >= minCompoundLength || !s.subLength) && - wLen - i >= minCompoundLength) { - break; - } - } - if (i > 0 || stack[i].usedRoots < numRoots) { - compoundUsed = i > 0; - const s = stack[i]; - s.cr = roots[s.usedRoots++]; - s.subLength = 0; - s.isCompound = compoundUsed; - s.caseMatched = s.caseMatched && s.usedRoots <= 1; - } - else { - break; - } - } - else { - node = c; - caseMatched = s.caseMatched; - break; - } - } - function extractWord() { - if (!word || i < word.length) - return false; - const letters = []; - let subLen = 0; - for (let j = 0; j < i; ++j) { - const { subLength } = stack[j]; - if (subLength < subLen) { - letters.push('+'); - } - letters.push(word[j]); - subLen = subLength; - } - return letters.join(''); - } - const found = extractWord(); - const result = { found, compoundUsed, node, forbidden: undefined, caseMatched }; - return result; -} -function findLegacyCompoundWord(roots, word, minCompoundLength) { - const { found, compoundUsed, caseMatched } = findLegacyCompoundNode(roots, word, minCompoundLength); - return { found, compoundUsed, caseMatched }; -} -export function isForbiddenWord(root, word, forbiddenPrefix) { - return findWordExact(root?.c?.get(forbiddenPrefix), word); -} -export const createFindOptions = memorizeLastCall(_createFindOptions); -function _createFindOptions(options) { - return mergeDefaults(options, _defaultFindOptions); -} -export const __testing__ = { - findLegacyCompoundWord, -}; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/flatten.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/flatten.js deleted file mode 100644 index a35c35a3b..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/flatten.js +++ /dev/null @@ -1,108 +0,0 @@ -export function flattenToTrieRefNode(root, nodes) { - const signatures = new Map(); - const cached = new Set([0]); // The end of word is always a 0 and is always cached. - function canCache(n) { - if (!n.r) - return true; - for (const v of n.r) { - if (!cached.has(v[1])) - return false; - } - return true; - } - function convert(n) { - const r = copy(n); - if (n.c) { - const children = [...n.c].sort((a, b) => (a[0] < b[0] ? -1 : 1)); - r.r = children.map((c) => [c[0], convert(c[1])]); - } - if (!canCache(r)) { - return nodes.push(r) - 1; - } - const sig = signature(r); - const ref = signatures.get(sig); - if (ref !== undefined) { - cached.add(ref); - return ref; - } - const idx = nodes.push(r) - 1; - signatures.set(sig, idx); - return idx; - } - return convert(root); -} -export function flattenToTrieRefNodeIterable(root) { - const signatures = new Map(); - const cached = new Set([0]); // The end of word is always a 0 and is always cached. - function canCache(n) { - if (!n.r) - return true; - for (const v of n.r) { - if (!cached.has(v[1])) - return false; - } - return true; - } - function* convert(root) { - const stack = []; - function addToStack(c, p) { - if (!c) - return; - const children = [...c.entries()].map(([k, n]) => ({ k, n, p })).sort((a, b) => (a.k < b.k ? 1 : -1)); - stack.push(...children); - } - const r = copy(root); - addToStack(root.c, r); - let t; - let count = 0; - function calcRef(r) { - if (!canCache(r)) { - return { ref: count++, emit: true }; - } - const sig = signature(r); - const ref = signatures.get(sig); - if (ref !== undefined) { - cached.add(ref); - return { ref, emit: false }; - } - const idx = count++; - signatures.set(sig, idx); - return { ref: idx, emit: true }; - } - while ((t = stack.pop())) { - if (t.r) { - // We are on the way out. - const ref = calcRef(t.r); - t.p.r = t.p.r || []; - t.p.r.push([t.k, ref.ref]); - if (ref.emit) { - yield t.r; - } - } - else { - // Going deeper - t.r = copy(t.n); - stack.push(t); - addToStack(t.n.c, t.r); - } - } - const ref = calcRef(r); - if (ref.emit) { - yield r; - } - } - return convert(root); -} -export function flattenToTrieRefNodeArray(root) { - const nodes = []; - flattenToTrieRefNode(root, nodes); - return nodes; -} -function signature(n) { - const refs = n.r ? JSON.stringify(n.r) : ''; - const isWord = n.f ? '*' : ''; - return isWord + refs; -} -function copy(n) { - return n.f ? { f: n.f, r: undefined } : { f: undefined, r: undefined }; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/index.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/index.js deleted file mode 100644 index 6941eacae..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/index.js +++ /dev/null @@ -1,16 +0,0 @@ -export { consolidate } from './consolidate.js'; -export { createWeightedMap, editDistance, editDistanceWeighted } from './distance/index.js'; -export { importTrie, serializeTrie } from './io/importExport.js'; -export { mapDictionaryInformationToWeightMap } from './mappers/mapDictionaryInfoToWeightMap.js'; -export { createDictionaryLineParserMapper as createDictionaryLineParser, parseDictionary, parseDictionaryLines, } from './SimpleDictionaryParser.js'; -export { impersonateCollector, suggestionCollector } from './suggestCollector.js'; -export { CASE_INSENSITIVE_PREFIX, COMPOUND, COMPOUND_FIX, defaultTrieOptions, FORBID, FORBID_PREFIX, NORMALIZED, OPTIONAL_COMPOUND, OPTIONAL_COMPOUND_FIX, Trie, } from './trie.js'; -export { countNodes, countWords, createTrieRoot, createTriFromList, findNode, has, insert, isCircular, isWordTerminationNode, iterateTrie, iteratorTrieWords, orderTrie, trieNodeToRoot, walk, } from './trie-util.js'; -export { buildTrie, buildTrieFast, TrieBuilder } from './TrieBuilder.js'; -export { ChildMap, FLAG_WORD } from './TrieNode.js'; -export { isDefined } from './utils/isDefined.js'; -export { mergeDefaults } from './utils/mergeDefaults.js'; -export { mergeOptionalWithDefaults } from './utils/mergeOptionalWithDefaults.js'; -export { normalizeWord, normalizeWordForCaseInsensitive, normalizeWordToLowercase } from './utils/normalizeWord.js'; -export { expandCharacterSet } from './utils/text.js'; -export { CompoundWordsMethod, hintedWalker, JOIN_SEPARATOR, walker, WORD_SEPARATOR } from './walker/index.js'; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExport.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExport.js deleted file mode 100644 index 201342b63..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExport.js +++ /dev/null @@ -1,59 +0,0 @@ -import { toDistributableIterable } from '@cspell/cspell-pipe'; -import { genSequence } from 'gensequence'; -import * as iv1 from './importExportV1.js'; -import * as iv2 from './importExportV2.js'; -import * as iv3 from './importExportV3.js'; -import * as iv4 from './importExportV4.js'; -const serializers = [ - iv1.serializeTrie, - iv1.serializeTrie, - iv2.serializeTrie, - iv3.serializeTrie, - iv4.serializeTrie, -]; -const deserializers = [iv1.importTrie, iv1.importTrie, iv2.importTrie, iv3.importTrie, iv4.importTrie]; -const DEFAULT_VERSION = 3; -/** - * Serialize a TrieNode. - * Note: This is destructive. The node will no longer be usable. - * Even though it is possible to preserve the trie, dealing with very large tries can consume a lot of memory. - * Considering this is the last step before exporting, it was decided to let this be destructive. - */ -export function serializeTrie(root, options = 16) { - const version = typeof options !== 'number' && options.version ? options.version : DEFAULT_VERSION; - const method = serializers[version]; - if (!method) { - throw new Error(`Unknown version: ${version}`); - } - return method(root, options); -} -export function importTrie(lines) { - function parseHeaderRows(headerRows) { - const header = headerRows.join('\n'); - const headerReg = /^\s*TrieXv(\d+)/m; - const match = header.match(headerReg); - if (!match) - throw new Error('Unknown file format'); - return parseInt(match[1], 10); - } - function readHeader(iter) { - const headerRows = []; - for (const entry of iter) { - const line = entry.trim(); - headerRows.push(line); - if (line === iv1.DATA || line === iv2.DATA) { - break; - } - } - return headerRows; - } - const input = toDistributableIterable(lines); - const headerLines = readHeader(input); - const version = parseHeaderRows(headerLines); - const stream = genSequence(headerLines).concat(input); - const method = deserializers[version]; - if (!method) { - throw new Error(`Unsupported version: ${version}`); - } - return method(stream); -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV1.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV1.js deleted file mode 100644 index 5cd54fee5..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV1.js +++ /dev/null @@ -1,121 +0,0 @@ -import { genSequence } from 'gensequence'; -import { convertToTrieRefNodes } from '../convertToTrieRefNodes.js'; -import { trieNodeToRoot } from '../trie-util.js'; -import { ChildMap, FLAG_WORD } from '../TrieNode.js'; -const EOW = '*'; -export const DATA = EOW; -function toReferences(node) { - return genSequence(convertToTrieRefNodes(node)); -} -const regExpEscapeChars = /([[\]\\,:{}*])/g; -const regExTrailingComma = /,(\}|\n)/g; -function escapeChar(char) { - return char.replace(regExpEscapeChars, '\\$1'); // lgtm[js/incomplete-sanitization] -} -function trieToExportString(node, base) { - function* walk(node) { - if (node.f) { - yield EOW; - } - if (node.r) { - const refs = [...node.r].sort((a, b) => (a[0] < b[0] ? -1 : 1)); - for (const n of refs) { - const [c, r] = n; - const ref = r ? r.toString(base) : ''; - yield escapeChar(c) + ref + ','; - } - } - } - return genSequence(walk(node)); -} -function generateHeader(base, comment) { - const header = ['#!/usr/bin/env cspell-trie reader', 'TrieXv1', 'base=' + base] - .concat(comment ? comment.split('\n').map((a) => '# ' + a) : []) - .concat(['# Data:']); - return genSequence(header).map((a) => a + '\n'); -} -/** - * Serialize a TrieNode. - * Note: This is destructive. The node will no longer be usable. - * Even though it is possible to preserve the trie, dealing with very large tries can consume a lot of memory. - * Considering this is the last step before exporting, it was decided to let this be destructive. - */ -export function serializeTrie(root, options = 16) { - options = typeof options === 'number' ? { base: options } : options; - const { base = 16, comment = '' } = options; - const radix = base > 36 ? 36 : base < 10 ? 10 : base; - const rows = toReferences(root).map((node) => { - const row = [...trieToExportString(node, radix), '\n'].join('').replace(regExTrailingComma, '$1'); - return row; - }); - return generateHeader(radix, comment).concat(rows); -} -function* toIterableIterator(iter) { - yield* iter; -} -export function importTrie(linesX) { - let radix = 16; - const comment = /^\s*#/; - const iter = toIterableIterator(linesX); - function parseHeaderRows(headerRows) { - const header = headerRows.slice(0, 2).join('\n'); - const headerReg = /^TrieXv1\nbase=(\d+)$/; - /* istanbul ignore if */ - if (!headerReg.test(header)) - throw new Error('Unknown file format'); - radix = Number.parseInt(header.replace(headerReg, '$1'), 10); - } - function readHeader(iter) { - const headerRows = []; - // eslint-disable-next-line no-constant-condition - while (true) { - const next = iter.next(); - if (next.done) { - break; - } - const line = next.value.trim(); - if (!line || comment.test(line)) { - continue; - } - if (line === DATA) { - break; - } - headerRows.push(line); - } - parseHeaderRows(headerRows); - } - const regNotEscapedCommas = /(^|[^\\]),/g; - const regUnescapeCommas = /__COMMA__/g; - const regUnescape = /[\\](.)/g; - const flagsWord = { f: FLAG_WORD }; - function splitLine(line) { - const pattern = '$1__COMMA__'; - return line - .replace(regNotEscapedCommas, pattern) - .split(regUnescapeCommas) - .map((a) => a.replace(regUnescape, '$1')); - } - function decodeLine(line, nodes) { - const isWord = line[0] === EOW; - line = isWord ? line.slice(1) : line; - const flags = isWord ? flagsWord : {}; - const children = splitLine(line) - .filter((a) => !!a) - .map((a) => [a[0], Number.parseInt(a.slice(1) || '0', radix)]) - .map(([k, i]) => [k, nodes[i]]); - const cNode = children.length ? { c: new ChildMap(children) } : {}; - return { ...cNode, ...flags }; - } - readHeader(iter); - const n = genSequence([DATA]) - .concat(iter) - .map((a) => a.replace(/\r?\n/, '')) - .filter((a) => !!a) - .reduce((acc, line) => { - const { lines, nodes } = acc; - const root = decodeLine(line, nodes); - nodes[lines] = root; - return { lines: lines + 1, root, nodes }; - }, { lines: 0, nodes: [], root: {} }); - return trieNodeToRoot(n.root, {}); -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV2.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV2.js deleted file mode 100644 index ca7e4a93c..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV2.js +++ /dev/null @@ -1,168 +0,0 @@ -import { genSequence } from 'gensequence'; -import { trieNodeToRoot } from '../trie-util.js'; -import { ChildMap, FLAG_WORD } from '../TrieNode.js'; -const EOW = '*'; -export const DATA = '__DATA__'; -function leaves(node) { - function toRefNode(node, k) { - const refNode = node; - refNode.s = refNode.s ?? k; - return refNode; - } - function* walk(node, k, p) { - const ref = toRefNode(node, k); - if (!ref.c) { - yield { n: ref, p }; - } - else { - for (const n of ref.c) { - yield* walk(n[1], n[0], ref); - } - } - } - return genSequence(walk(node, '')); -} -function flattenToReferences(node) { - function* walk() { - let iterations = 100; - let processed = 0; - let index = 0; - do { - processed = 0; - const signatureMap = new Map(); - for (const leaf of leaves(node)) { - const h = signature(leaf.n); - let m = signatureMap.get(h); - if (m === undefined) { - // first time, add it to hash - yield leaf.n; - m = index; - signatureMap.set(h, m); - index += 1; - } - // Fix up the parent - /* istanbul ignore else */ - if (leaf.p && leaf.p.c) { - leaf.p.r = leaf.p.r || []; - leaf.p.r.push(m); - leaf.p.c.delete(leaf.n.s); - if (!leaf.p.c.size) { - delete leaf.p.c; - } - } - processed += 1; - } - iterations -= 1; - } while (processed && iterations && node.c); - yield node; - } - return genSequence(walk()); -} -function signature(node) { - const flags = node.f ? EOW : ''; - const refs = node.r ? node.r.sort((a, b) => a - b).join(',') : ''; - return node.s + flags + refs; -} -function toLine(node, base) { - const flags = node.f ? EOW : ''; - const refs = node.r - ? node.r - .sort((a, b) => a - b) - .map((r) => r.toString(base)) - .join(',') - : ''; - return node.s + flags + refs; -} -function generateHeader(base, comment) { - const header = ['#!/usr/bin/env cspell-trie reader', 'TrieXv2', 'base=' + base] - .concat(comment ? comment.split('\n').map((a) => '# ' + a) : []) - .concat(['# Data:', DATA]); - return genSequence(header); -} -/** - * Serialize a TrieNode. - * Note: This is destructive. The node will no longer be usable. - * Even though it is possible to preserve the trie, dealing with very large tries can consume a lot of memory. - * Considering this is the last step before exporting, it was decided to let this be destructive. - */ -export function serializeTrie(root, options = 16) { - options = typeof options === 'number' ? { base: options } : options; - const { base = 16, comment = '' } = options; - const radix = base > 36 ? 36 : base < 10 ? 10 : base; - const rootRef = { ...root, s: '^' }; - const rows = flattenToReferences(rootRef).map((n) => toLine(n, base)); - return generateHeader(radix, comment) - .concat(rows) - .map((a) => a + '\n'); -} -function* toIterableIterator(iter) { - yield* iter; -} -export function importTrie(linesX) { - let radix = 16; - const comment = /^\s*#/; - const iter = toIterableIterator(linesX); - function parseHeaderRows(headerRows) { - const header = headerRows.slice(0, 2).join('\n'); - const headerReg = /^TrieXv2\nbase=(\d+)$/; - /* istanbul ignore if */ - if (!headerReg.test(header)) - throw new Error('Unknown file format'); - radix = Number.parseInt(header.replace(headerReg, '$1'), 10); - } - function readHeader(iter) { - const headerRows = []; - // eslint-disable-next-line no-constant-condition - while (true) { - const next = iter.next(); - if (next.done) { - break; - } - const line = next.value.trim(); - if (!line || comment.test(line)) { - continue; - } - if (line === DATA) { - break; - } - headerRows.push(line); - } - parseHeaderRows(headerRows); - } - function parseLine(line, base) { - const isWord = line[1] === EOW; - const refOffset = isWord ? 2 : 1; - const refs = line - .slice(refOffset) - .split(',') - .filter((a) => !!a) - .map((r) => parseInt(r, base)); - return { - letter: line[0], - isWord, - refs, - }; - } - const flagsWord = { f: FLAG_WORD }; - function decodeLine(line, nodes) { - const { letter, isWord, refs } = parseLine(line, radix); - const flags = isWord ? flagsWord : {}; - const children = refs - .map((r) => nodes[r]) - .sort((a, b) => (a.s < b.s ? -1 : 1)) - .map((n) => [n.s, n]); - const cNode = children.length ? { c: new ChildMap(children) } : {}; - return { s: letter, ...cNode, ...flags }; - } - readHeader(iter); - const n = genSequence(iter) - .map((a) => a.replace(/\r?\n/, '')) - .filter((a) => !!a) - .reduce((acc, line) => { - const { nodes } = acc; - const root = decodeLine(line, nodes); - nodes.push(root); - return { root, nodes }; - }, { nodes: [], root: { s: '', c: new Map() } }); - return trieNodeToRoot(n.root, {}); -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV3.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV3.js deleted file mode 100644 index d386ef7e8..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV3.js +++ /dev/null @@ -1,281 +0,0 @@ -import { genSequence } from 'gensequence'; -import { trieNodeToRoot } from '../trie-util.js'; -import { FLAG_WORD } from '../TrieNode.js'; -import { bufferLines } from '../utils/bufferLines.js'; -const EOW = '$'; // End of word -const BACK = '<'; // Move up the tree -const EOL = '\n'; // End of Line (ignored) -const LF = '\r'; // Line Feed (ignored) -const REF = '#'; // Start of Reference -const EOR = ';'; // End of Reference -const ESCAPE = '\\'; -const specialCharacters = new Set([EOW, BACK, EOL, REF, EOR, ESCAPE, LF] - .concat('0123456789'.split('')) - .concat('`~!@#$%^&*()_-+=[]{};:\'"<>,./?\\|'.split(''))); -const specialCharacterMap = new Map([ - ['\n', '\\n'], - ['\r', '\\r'], - ['\\', '\\\\'], -]); -const characterMap = new Map([...specialCharacterMap].map((a) => [a[1], a[0]])); -const specialPrefix = stringToCharSet('~!'); -const WORDS_PER_LINE = 20; -export const DATA = '__DATA__'; -function generateHeader(base, comment) { - const header = ['#!/usr/bin/env cspell-trie reader', 'TrieXv3', 'base=' + base] - .concat(comment ? comment.split('\n').map((a) => '# ' + a) : []) - .concat(['# Data:', DATA]); - return genSequence(header).map((a) => a + '\n'); -} -/** - * Serialize a TrieRoot. - */ -export function serializeTrie(root, options = 16) { - options = typeof options === 'number' ? { base: options, addLineBreaksToImproveDiffs: false } : options; - const { base = 16, comment = '', addLineBreaksToImproveDiffs: addBreaks = true } = options; - const radix = base > 36 ? 36 : base < 10 ? 10 : base; - const cache = new Map(); - const cacheShouldRef = new Map(); - let count = 0; - const backBuffer = { last: '', count: 0, words: 0, eol: false }; - const optimizeSimpleReferences = options.optimizeSimpleReferences ?? false; - const wordChars = []; - function ref(n) { - return '#' + n.toString(radix) + ';'; - } - function escape(s) { - return specialCharacters.has(s) ? ESCAPE + (specialCharacterMap.get(s) || s) : s; - } - function* flush() { - while (backBuffer.count) { - const n = Math.min(9, backBuffer.count); - yield n > 1 ? backBuffer.last + n : backBuffer.last; - backBuffer.last = BACK; - backBuffer.count -= n; - } - if (backBuffer.eol) { - yield EOL; - backBuffer.eol = false; - backBuffer.words = 0; - } - } - function* emit(s) { - switch (s) { - case EOW: - yield* flush(); - backBuffer.last = EOW; - backBuffer.count = 0; - backBuffer.words++; - break; - case BACK: - backBuffer.count++; - break; - case EOL: - backBuffer.eol = true; - break; - default: - if (backBuffer.words >= WORDS_PER_LINE) { - backBuffer.eol = true; - } - yield* flush(); - if (s.startsWith(REF)) { - backBuffer.words++; - } - yield s; - } - } - function* walk(node, depth) { - const r = cache.get(node); - if (r !== undefined && (!optimizeSimpleReferences || !shouldSimpleRef(node))) { - yield* emit(ref(r)); - return; - } - if (node.c) { - if (addBreaks && depth > 0 && depth <= 2) { - yield* emit(EOL); - } - cache.set(node, count++); - const c = [...node.c].sort((a, b) => (a[0] < b[0] ? -1 : 1)); - for (const [s, n] of c) { - wordChars[depth] = s; - yield* emit(escape(s)); - yield* walk(n, depth + 1); - yield* emit(BACK); - if (depth === 0) - yield* emit(EOL); - } - } - // Output EOW after children so it can be optimized on read - if (node.f) { - yield* emit(EOW); - } - if (addBreaks && (depth === 2 || (depth === 3 && wordChars[0] in specialPrefix))) { - yield* emit(EOL); - } - } - function* serialize(node) { - yield* walk(node, 0); - yield* flush(); - } - function _calcShouldSimpleRef(node) { - if (node.c?.size !== 1) - return false; - const [n] = [...node.c.values()]; - return !!n.f && (n.c === undefined || n.c.size === 0); - } - function shouldSimpleRef(node) { - const r = cacheShouldRef.get(node); - if (r !== undefined) - return r; - const rr = _calcShouldSimpleRef(node); - cacheShouldRef.set(node, rr); - return rr; - } - return generateHeader(radix, comment).concat(bufferLines(serialize(root), 1200, '')); -} -function* toIterableIterator(iter) { - yield* iter; -} -export function importTrie(linesX) { - linesX = typeof linesX === 'string' ? linesX.split(/^/m) : linesX; - const root = trieNodeToRoot({}, {}); - let radix = 16; - const comment = /^\s*#/; - const iter = toIterableIterator(linesX); - function parseHeaderRows(headerRows) { - const header = headerRows.slice(0, 2).join('\n'); - const headerReg = /^TrieXv3\nbase=(\d+)$/; - /* istanbul ignore if */ - if (!headerReg.test(header)) - throw new Error('Unknown file format'); - radix = Number.parseInt(header.replace(headerReg, '$1'), 10); - } - function readHeader(iter) { - const headerRows = []; - // eslint-disable-next-line no-constant-condition - while (true) { - const next = iter.next(); - if (next.done) { - break; - } - const line = next.value.trim().replace(/\r|\n/g, ''); - if (!line || comment.test(line)) { - continue; - } - if (line === DATA) { - break; - } - headerRows.push(line); - } - parseHeaderRows(headerRows); - } - readHeader(iter); - const n = genSequence(iter) - .concatMap((a) => a.split('')) - .reduce(parseStream(radix), { - nodes: [root], - root, - stack: [{ node: root, s: '' }], - parser: undefined, - }); - return n.root; -} -function parseStream(radix) { - const eow = Object.freeze({ f: 1 }); - function parseReference(acc, _) { - let ref = ''; - function parser(acc, s) { - if (s === EOR) { - const { root, nodes, stack } = acc; - const r = parseInt(ref, radix); - const top = stack[stack.length - 1]; - const p = stack[stack.length - 2].node; - p.c?.set(top.s, nodes[r]); - return { root, nodes, stack, parser: undefined }; - } - ref = ref + s; - return acc; - } - const { nodes } = acc; - nodes.pop(); - return { ...acc, nodes, parser }; - } - function parseEscapeCharacter(acc, _) { - let prev = ''; - const parser = function (acc, s) { - if (prev) { - s = characterMap.get(prev + s) || s; - return parseCharacter({ ...acc, parser: undefined }, s); - } - if (s === ESCAPE) { - prev = s; - return acc; - } - return parseCharacter({ ...acc, parser: undefined }, s); - }; - return { ...acc, parser }; - } - function parseCharacter(acc, s) { - const parser = undefined; - const { root, nodes, stack } = acc; - const top = stack[stack.length - 1]; - const node = top.node; - node.c = node.c ?? new Map(); - const n = { f: undefined, c: undefined, n: nodes.length }; - node.c.set(s, n); - stack.push({ node: n, s }); - nodes.push(n); - return { root, nodes, stack, parser }; - } - function parseEOW(acc, _) { - const parser = parseBack; - const { root, nodes, stack } = acc; - const top = stack[stack.length - 1]; - const node = top.node; - node.f = FLAG_WORD; - if (!node.c) { - top.node = eow; - const p = stack[stack.length - 2].node; - p.c?.set(top.s, eow); - nodes.pop(); - } - stack.pop(); - return { root, nodes, stack, parser }; - } - const charactersBack = new Set((BACK + '23456789').split('')); - function parseBack(acc, s) { - if (!charactersBack.has(s)) { - return parserMain({ ...acc, parser: undefined }, s); - } - let n = s === BACK ? 1 : parseInt(s, 10) - 1; - const { stack } = acc; - while (n-- > 0) { - stack.pop(); - } - return { ...acc, parser: parseBack }; - } - function parseIgnore(acc, _) { - return acc; - } - const parsers = new Map([ - [EOW, parseEOW], - [BACK, parseBack], - [REF, parseReference], - [ESCAPE, parseEscapeCharacter], - [EOL, parseIgnore], - [LF, parseIgnore], - ]); - function parserMain(acc, s) { - const parser = acc.parser ?? parsers.get(s) ?? parseCharacter; - return parser(acc, s); - } - return parserMain; -} -function stringToCharSet(values) { - const set = Object.create(null); - const len = values.length; - for (let i = 0; i < len; ++i) { - set[values[i]] = true; - } - return set; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV4.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV4.js deleted file mode 100644 index 5ec5d60b5..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/io/importExportV4.js +++ /dev/null @@ -1,439 +0,0 @@ -/* eslint-disable no-irregular-whitespace */ -/** - * Trie file format v4 - * - * Trie format v4 is very similar to v3. The v4 reader can even read v3 files. - * The motivation behind v4 is to reduce the cost of storing `.trie` files in git. - * When a word is added in v3, nearly the entire file is changed due to the absolute - * references. V4 adds an index sorted by the most frequently used reference to the least. - * Because git diff is line based, it is important to add line breaks at logical points. - * V3 added line breaks just to make sure the lines were not too long, V4 takes a different - * approach. Line breaks are added at two distinct points. First, at the start of each two - * letter prefix and second after approximately 50 words have been emitted. - * - * To improve readability and git diff, at the beginning of each two letter prefix, - * a comment is emitted. - * - * Example: - * - * ``` - * /* ab *​/ - * ``` - */ -import { opConcatMap, opFilter, pipe } from '@cspell/cspell-pipe/sync'; -import { genSequence } from 'gensequence'; -import { trieNodeToRoot } from '../trie-util.js'; -import { FLAG_WORD } from '../TrieNode.js'; -import { bufferLines } from '../utils/bufferLines.js'; -const EOW = '$'; // End of word -const BACK = '<'; // Move up the tree -const EOL = '\n'; // End of Line (ignored) -const LF = '\r'; // Line Feed (ignored) -const REF = '#'; // Start absolute of Reference -const REF_REL = '@'; // Start indexed of Reference -const EOR = ';'; // End of Reference -const ESCAPE = '\\'; -const REF_INDEX_BEGIN = '['; -const REF_INDEX_END = ']'; -const INLINE_DATA_COMMENT_LINE = '/'; -const specialCharacters = stringToCharSet([EOW, BACK, EOL, REF, REF_REL, EOR, ESCAPE, LF, REF_INDEX_BEGIN, REF_INDEX_END, INLINE_DATA_COMMENT_LINE] - .concat('0123456789'.split('')) - .concat('`~!@#$%^&*()_-+=[]{};:\'"<>,./?\\|'.split('')) - .join('')); -const SPECIAL_CHARACTERS_MAP = [ - ['\n', '\\n'], - ['\r', '\\r'], - ['\\', '\\\\'], -]; -const specialCharacterMap = stringToCharMap(SPECIAL_CHARACTERS_MAP); -const characterMap = stringToCharMap(SPECIAL_CHARACTERS_MAP.map((a) => [a[1], a[0]])); -const specialPrefix = stringToCharSet('~!'); -const WORDS_PER_LINE = 20; -export const DATA = '__DATA__'; -function generateHeader(base, comment) { - const comments = comment - .split('\n') - .map((a) => '# ' + a.trimEnd()) - .join('\n'); - return `\ -#!/usr/bin/env cspell-trie reader -TrieXv4 -base=${base} -${comments} -# Data: -${DATA} -`; -} -/** - * Serialize a TrieRoot. - */ -export function serializeTrie(root, options = 16) { - options = typeof options === 'number' ? { base: options } : options; - const { base = 10, comment = '' } = options; - const radix = base > 36 ? 36 : base < 10 ? 10 : base; - const cache = new Map(); - const refMap = buildReferenceMap(root, base); - const nodeToIndexMap = new Map(refMap.refCounts.map(([node], index) => [node, index])); - let count = 0; - const backBuffer = { last: '', count: 0, words: 0, eol: false }; - const wordChars = []; - function ref(n, idx) { - const r = idx === undefined || n < idx ? REF + n.toString(radix) : REF_REL + idx.toString(radix); - return radix === 10 ? r : r + ';'; - } - function escape(s) { - return s in specialCharacters ? ESCAPE + (specialCharacterMap[s] || s) : s; - } - function* flush() { - while (backBuffer.count) { - const n = Math.min(9, backBuffer.count); - yield n > 1 ? backBuffer.last + n : backBuffer.last; - backBuffer.last = BACK; - backBuffer.count -= n; - } - if (backBuffer.eol) { - yield EOL; - backBuffer.eol = false; - backBuffer.words = 0; - } - } - function* emit(s) { - switch (s) { - case EOW: - yield* flush(); - backBuffer.last = EOW; - backBuffer.count = 0; - backBuffer.words++; - break; - case BACK: - backBuffer.count++; - break; - case EOL: - backBuffer.eol = true; - break; - default: - if (backBuffer.words >= WORDS_PER_LINE) { - backBuffer.eol = true; - } - yield* flush(); - if (s.startsWith(REF) || s.startsWith(REF_REL)) { - backBuffer.words++; - } - yield s; - } - } - const comment_begin = `${EOL}${INLINE_DATA_COMMENT_LINE}* `; - const comment_end = ` *${INLINE_DATA_COMMENT_LINE}${EOL}`; - function* walk(node, depth) { - const nodeNumber = cache.get(node); - const refIndex = nodeToIndexMap.get(node); - if (nodeNumber !== undefined) { - yield* emit(ref(nodeNumber, refIndex)); - return; - } - if (node.c) { - if (depth > 0 && depth <= 2) { - const chars = wordChars.slice(0, depth).map(escape).join(''); - yield* emit(comment_begin + chars + comment_end); - } - cache.set(node, count++); - const c = [...node.c].sort((a, b) => (a[0] < b[0] ? -1 : 1)); - for (const [s, n] of c) { - wordChars[depth] = s; - yield* emit(escape(s)); - yield* walk(n, depth + 1); - yield* emit(BACK); - if (depth === 0) - yield* emit(EOL); - } - } - // Output EOW after children so it can be optimized on read - if (node.f) { - yield* emit(EOW); - } - if (depth === 2 || (depth === 3 && wordChars[0] in specialPrefix)) { - yield* emit(EOL); - } - } - function* serialize(node) { - yield* walk(node, 0); - yield* flush(); - } - const lines = [...bufferLines(serialize(root), 1000, '')]; - const resolvedReferences = refMap.refCounts.map(([node]) => cache.get(node) || 0); - // const r = refMap.refCounts.slice(0, 200).map(([node, c]) => ({ n: cache.get(node) || 0, c })); - // console.log('First 100: %o \n %o', r.slice(0, 100), r.slice(100, 200)); - const reference = '[\n' + - resolvedReferences - .map((n) => n.toString(radix)) - .join(',') - .replace(/.{110,130}[,]/g, '$&\n') + - '\n]\n'; - return genSequence([generateHeader(radix, comment), reference]).concat(lines); -} -function buildReferenceMap(root, base) { - const refCount = new Map(); - let nodeCount = 0; - function walk(node) { - const ref = refCount.get(node); - if (ref) { - ref.c++; - return; - } - refCount.set(node, { c: 1, n: nodeCount++ }); - if (!node.c) - return; - for (const child of node.c.values()) { - walk(child); - } - } - walk(root); - // sorted highest to lowest - const refCountAndNode = [ - ...pipe(refCount, opFilter(([_, ref]) => ref.c >= 2)), - ].sort((a, b) => b[1].c - a[1].c || a[1].n - b[1].n); - let adj = 0; - const baseLogScale = 1 / Math.log(base); - const refs = refCountAndNode - .filter(([_, ref], idx) => { - const i = idx - adj; - const charsIdx = Math.ceil(Math.log(i) * baseLogScale); - const charsNode = Math.ceil(Math.log(ref.n) * baseLogScale); - const savings = ref.c * (charsNode - charsIdx) - charsIdx; - const keep = savings > 0; - adj += keep ? 0 : 1; - return keep; - }) - .map(([n, ref]) => [n, ref.c]); - return { refCounts: refs }; -} -export function importTrie(linesX) { - linesX = typeof linesX === 'string' ? linesX.split(/^/m) : linesX; - let radix = 10; - const comment = /^\s*#/; - const iter = tapIterable(pipe(linesX, opConcatMap((a) => a.split(/^/m)))); - function parseHeaderRows(headerRows) { - const header = headerRows.slice(0, 2).join('\n'); - const headerReg = /^TrieXv[34]\nbase=(\d+)$/; - /* istanbul ignore if */ - if (!headerReg.test(header)) - throw new Error('Unknown file format'); - radix = Number.parseInt(header.replace(headerReg, '$1'), 10); - } - function readHeader(iter) { - const headerRows = []; - for (const value of iter) { - const line = value.trim(); - if (!line || comment.test(line)) - continue; - if (line === DATA) - break; - headerRows.push(line); - } - parseHeaderRows(headerRows); - } - readHeader(iter); - const root = parseStream(radix, iter); - return root; -} -const numbersSet = stringToCharSet('0123456789'); -function parseStream(radix, iter) { - const eow = Object.freeze({ f: 1 }); - let refIndex = []; - const root = trieNodeToRoot({}, {}); - function parseReference(acc, s) { - const isIndexRef = s === REF_REL; - let ref = ''; - function parser(acc, s) { - if (s === EOR || (radix === 10 && !(s in numbersSet))) { - const { root, nodes, stack } = acc; - const r = parseInt(ref, radix); - const top = stack[stack.length - 1]; - const p = stack[stack.length - 2].node; - const n = isIndexRef ? refIndex[r] : r; - p.c?.set(top.s, nodes[n]); - const rr = { root, nodes, stack, parser: undefined }; - return s === EOR ? rr : parserMain(rr, s); - } - ref = ref + s; - return acc; - } - const { nodes } = acc; - nodes.pop(); - return { ...acc, nodes, parser }; - } - function parseEscapeCharacter(acc, _) { - let prev = ''; - const parser = function (acc, s) { - if (prev) { - s = characterMap[prev + s] || s; - return parseCharacter({ ...acc, parser: undefined }, s); - } - if (s === ESCAPE) { - prev = s; - return acc; - } - return parseCharacter({ ...acc, parser: undefined }, s); - }; - return { ...acc, parser }; - } - function parseComment(acc, s) { - const endOfComment = s; - let isEscaped = false; - function parser(acc, s) { - if (isEscaped) { - isEscaped = false; - return acc; - } - if (s === ESCAPE) { - isEscaped = true; - return acc; - } - if (s === endOfComment) { - return { ...acc, parser: undefined }; - } - return acc; - } - return { ...acc, parser }; - } - function parseCharacter(acc, s) { - const parser = undefined; - const { root, nodes, stack } = acc; - const top = stack[stack.length - 1]; - const node = top.node; - node.c = node.c ?? new Map(); - const n = { f: undefined, c: undefined, n: nodes.length }; - node.c.set(s, n); - stack.push({ node: n, s }); - nodes.push(n); - return { root, nodes, stack, parser }; - } - function parseEOW(acc, _) { - const parser = parseBack; - const { root, nodes, stack } = acc; - const top = stack[stack.length - 1]; - const node = top.node; - node.f = FLAG_WORD; - if (!node.c) { - top.node = eow; - const p = stack[stack.length - 2].node; - p.c?.set(top.s, eow); - nodes.pop(); - } - stack.pop(); - return { root, nodes, stack, parser }; - } - const charactersBack = stringToCharSet(BACK + '23456789'); - function parseBack(acc, s) { - if (!(s in charactersBack)) { - return parserMain({ ...acc, parser: undefined }, s); - } - let n = s === BACK ? 1 : parseInt(s, 10) - 1; - const { stack } = acc; - while (n-- > 0) { - stack.pop(); - } - return { ...acc, parser: parseBack }; - } - function parseIgnore(acc, _) { - return acc; - } - const parsers = createStringLookupMap([ - [EOW, parseEOW], - [BACK, parseBack], - [REF, parseReference], - [REF_REL, parseReference], - [ESCAPE, parseEscapeCharacter], - [EOL, parseIgnore], - [LF, parseIgnore], - [INLINE_DATA_COMMENT_LINE, parseComment], - ]); - function parserMain(acc, s) { - const parser = acc.parser ?? parsers[s] ?? parseCharacter; - return parser(acc, s); - } - const charsetSpaces = stringToCharSet(' \r\n\t'); - function parseReferenceIndex(acc, s) { - let json = ''; - function parserStart(acc, s) { - if (s === REF_INDEX_BEGIN) { - json = json + s; - return { ...acc, parser }; - } - if (s in charsetSpaces) { - return acc; - } - // A Reference Index was not found. - return parserMain({ ...acc, parser: undefined }, s); - } - function parser(acc, s) { - json = json + s; - if (s === REF_INDEX_END) { - refIndex = json - .replace(/[\s[\]]/g, '') - .split(',') - .map((n) => parseInt(n, radix)); - return { ...acc, parser: undefined }; - } - return acc; - } - return parserStart({ ...acc, parser: parserStart }, s); - } - genSequence(iter) - .concatMap((a) => a.split('')) - .reduce(parserMain, { - nodes: [root], - root, - stack: [{ node: root, s: '' }], - parser: parseReferenceIndex, - }); - return root; -} -function stringToCharSet(values) { - const set = Object.create(null); - const len = values.length; - for (let i = 0; i < len; ++i) { - set[values[i]] = true; - } - return set; -} -function stringToCharMap(values) { - return createStringLookupMap(values); -} -function createStringLookupMap(values) { - const map = Object.create(null); - const len = values.length; - for (let i = 0; i < len; ++i) { - map[values[i][0]] = values[i][1]; - } - return map; -} -/** - * Allows an iterable to be shared by multiple consumers. - * Each consumer takes from the iterable. - * @param iterable - the iterable to share - */ -function tapIterable(iterable) { - let lastValue; - let iter; - function getNext() { - if (lastValue && lastValue.done) { - return { ...lastValue }; - } - iter = iter || iterable[Symbol.iterator](); - lastValue = iter.next(); - return lastValue; - } - function* iterableFn() { - let next; - while (!(next = getNext()).done) { - yield next.value; - } - } - return { - [Symbol.iterator]: iterableFn, - }; -} -export const __testing__ = { - buildReferenceMap, -}; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/joinLetters.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/joinLetters.js deleted file mode 100644 index a0fb24338..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/joinLetters.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Bring letters / strings together. - * - `['a', 'b'] => 'ab'` - * - `['a', 'bc'] => 'a(bc)'` - * @param letters - letters to join - */ -export function joinLetters(letters) { - const v = [...letters]; - return v.map((a) => (a.length > 1 || !a.length ? `(${a})` : a)).join(''); -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapCosts.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapCosts.js deleted file mode 100644 index b6dadd63a..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapCosts.js +++ /dev/null @@ -1,22 +0,0 @@ -import { cleanCopy } from '../utils/util.js'; -const defaultEditCosts = { - accentCosts: 1, - baseCost: 100, - capsCosts: 1, - firstLetterPenalty: 4, - nonAlphabetCosts: 110, -}; -const defaultHunspellCosts = { - ...defaultEditCosts, - ioConvertCost: 30, - keyboardCost: 99, - mapCost: 25, - replaceCosts: 75, - tryCharCost: 100, -}; -export function mapHunspellCosts(costs = {}) { - return { ...defaultHunspellCosts, ...cleanCopy(costs) }; -} -export function mapEditCosts(costs = {}) { - return { ...defaultEditCosts, ...cleanCopy(costs) }; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapDictionaryInfo.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapDictionaryInfo.js deleted file mode 100644 index acbc7fb60..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapDictionaryInfo.js +++ /dev/null @@ -1,63 +0,0 @@ -import { opFlatten, opMap, pipeSync } from '@cspell/cspell-pipe/sync'; -import { parseLocale } from '../models/locale/index.js'; -import { isDefined } from '../utils/util.js'; -import { mapEditCosts } from './mapCosts.js'; -import { hunspellInformationToSuggestionCostDef } from './mapHunspellInformation.js'; -import { calcFirstCharacterReplaceDefs, parseAccents, parseAlphabet } from './mapToSuggestionCostDef.js'; -export function mapDictionaryInformation(dictInfo) { - const _locale = dictInfo.locale; - const locale = _locale ? parseLocale(_locale).filter((loc) => loc.isValid()) : undefined; - const locales = locale?.map((loc) => loc.locale); - const costs = mapEditCosts(dictInfo.costs); - const defsEC = dictInfo.suggestionEditCosts || []; - const defsHI = dictInfo.hunspellInformation - ? hunspellInformationToSuggestionCostDef(dictInfo.hunspellInformation, locale) - : []; - return [ - ...defsEC, - ...processAlphabet(dictInfo.alphabet, locales, costs), - ...processAccents(dictInfo.accents, costs), - ...defsHI, - ]; -} -function processAlphabet(alphabet, locale, editCost) { - const csAlphabet = toCharSets(alphabet, 'a-zA-Z', editCost.baseCost); - return [ - ...pipeSync(csAlphabet, opMap((cs) => parseAlphabet(cs, locale, editCost)), opFlatten()), - ...calcFirstCharacterReplaceDefs(csAlphabet, editCost), - ]; -} -function toCharSets(cs, defaultValue, cost, penalty) { - cs = cs ?? defaultValue; - if (!cs) - return []; - if (typeof cs === 'string') { - cs = [ - { - characters: cs, - cost, - }, - ]; - } - if (penalty !== undefined) { - cs.forEach((cs) => (cs.penalty = penalty)); - } - return cs; -} -function processAccents(accents, editCost) { - const cs = toCharSets(accents, '\u0300-\u0341', editCost.accentCosts); - return cs.map((cs) => parseAccents(cs, editCost)).filter(isDefined); -} -export function mapDictionaryInformationToAdjustment(dictInfo) { - if (!dictInfo.adjustments) - return []; - return dictInfo.adjustments.map(mapAdjustment); -} -function mapAdjustment(adj) { - const { id, regexp, penalty } = adj; - return { - id: id, - regexp: new RegExp(regexp), - penalty, - }; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapDictionaryInfoToWeightMap.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapDictionaryInfoToWeightMap.js deleted file mode 100644 index f2be53fc1..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapDictionaryInfoToWeightMap.js +++ /dev/null @@ -1,34 +0,0 @@ -import { addAdjustment, createWeightMap } from '../distance/weightedMaps.js'; -import { mapDictionaryInformation, mapDictionaryInformationToAdjustment } from './mapDictionaryInfo.js'; -const defaultDefs = [ - { - map: '1234567890-.', - insDel: 1, - penalty: 200, - }, -]; -const defaultAdjustments = [ - { - id: 'compound-case-change', - regexp: /\p{Ll}∙\p{Lu}/gu, - penalty: 1000, - }, - { - id: 'short-compounds-1', - regexp: /^[^∙]{0,2}(?=∙)|∙[^∙]{0,2}(?=∙|$)/gm, - penalty: 100, - }, - { - id: 'short-compounds-3', - regexp: /^[^∙]{3}(?=∙)|∙[^∙]{3}(?=∙|$)/gm, - penalty: 50, - }, -]; -export function mapDictionaryInformationToWeightMap(dictInfo) { - const defs = mapDictionaryInformation(dictInfo).concat(defaultDefs); - const adjustments = mapDictionaryInformationToAdjustment(dictInfo); - const map = createWeightMap(...defs); - addAdjustment(map, ...defaultAdjustments, ...adjustments); - return map; -} -export const __testing__ = {}; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapHunspellInformation.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapHunspellInformation.js deleted file mode 100644 index 38a2158bf..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapHunspellInformation.js +++ /dev/null @@ -1,195 +0,0 @@ -import { opFilter, opFlatten, opMap, pipe } from '@cspell/cspell-pipe/sync'; -import { caseForms } from '../utils/text.js'; -import { isDefined, unique as uniqueU } from '../utils/util.js'; -import { joinLetters } from './joinLetters.js'; -import { mapHunspellCosts } from './mapCosts.js'; -import { calcCostsForAccentedLetters, calcFirstCharacterReplace, parseAlphabet, splitMap, } from './mapToSuggestionCostDef.js'; -export function hunspellInformationToSuggestionCostDef(hunInfo, locales) { - const costs = calcCosts(hunInfo.costs, locales); - const operations = [ - affKey, - affKeyCaps, - affMap, - affMapAccents, - affMapCaps, - affNoTry, - affRepConv, - affTry, - affTryAccents, - affTryFirstCharacterReplace, - ]; - function parseAff(aff, costs) { - // cspell:ignore OCONV - const regSupportedAff = /^(?:MAP|KEY|TRY|NO-TRY|ICONV|OCONV|REP)\s/; - const rejectAff = /^(?:MAP|KEY|TRY|ICONV|OCONV|REP)\s+\d+$/; - const lines = aff - .split('\n') - .map((a) => a.replace(/#.*/, '')) - .map((a) => a.trim()) - .filter((a) => regSupportedAff.test(a)) - .filter((a) => !rejectAff.test(a)); - const defs = pipe(lines, opMap((line) => pipe(operations, opMap((fn) => fn(line, costs)), opMap(asArrayOf), opFlatten())), opFlatten(), opFilter(isDefined)); - return [...defs]; - } - return parseAff(hunInfo.aff, costs); -} -function calcCosts(costs = {}, locale) { - const useLocale = locale?.length ? locale.map((loc) => loc.locale) : undefined; - const hunCosts = mapHunspellCosts(costs); - const c = { - ...hunCosts, - locale: useLocale, - }; - return c; -} -const regExpMap = /^(?:MAP)\s+(\S+)$/; -function affMap(line, costs) { - const m = line.match(regExpMap); - if (!m) - return undefined; - const map = m[1]; - const cost = costs.mapCost; - return { - map, - replace: cost, - swap: cost, - }; -} -const regExpTry = /^(?:TRY)\s+(\S+)$/; -function affTry(line, costs) { - const m = line.match(regExpTry); - if (!m) - return undefined; - const cost = costs.tryCharCost; - const tryChars = m[1]; - const characters = tryChars; - return parseAlphabet({ - characters, - cost, - }, costs.locale, costs); -} -function affTryFirstCharacterReplace(line, costs) { - const m = line.match(regExpTry); - if (!m) - return undefined; - const characters = m[1]; - // Make it a bit cheaper so it will match - const cost = costs.tryCharCost; - return calcFirstCharacterReplace({ - characters, - cost, - }, costs); -} -const regExpNoTry = /^NO-TRY\s+(\S+)$/; -function affNoTry(line, costs) { - const m = line.match(regExpNoTry); - if (!m) - return undefined; - const map = m[1]; - return { - map, - insDel: Math.max(costs.nonAlphabetCosts - costs.tryCharCost, 0), - penalty: costs.nonAlphabetCosts + costs.tryCharCost, - }; -} -// cspell:ignore conv -const regExpRepConv = /^(?:REP|(?:I|O)CONV)\s+(\S+)\s+(\S+)$/; -function affRepConv(line, costs) { - const m = line.match(regExpRepConv); - if (!m) - return undefined; - const cost = line.startsWith('REP') ? costs.replaceCosts : costs.ioConvertCost; - const from = m[1]; - let into = m[2]; - into = into.replace(/^0$/, ''); - if (from.startsWith('^') && !into.startsWith('^')) { - into = '^' + into; - } - if (from.endsWith('$') && !into.endsWith('$')) { - into = into + '$'; - } - return { - map: joinLetters([from, into]), - replace: cost, - }; -} -const regExpKey = /^(?:KEY)\s+(\S+)$/; -function affKey(line, costs) { - const m = line.match(regExpKey); - if (!m) - return undefined; - const kbd = m[1]; - const pairs = [...splitMap(kbd)] - .map(reducer((p, v) => ({ a: p.b, b: v }), { a: '|', b: '|' })) - .filter((ab) => ab.a !== '|' && ab.b !== '|') - .map(({ a, b }) => joinLetters([a, b])); - const pairsUpper = pairs.map((p) => p.toLocaleUpperCase(costs.locale)); - const map = uniqueU(pairs.concat(pairsUpper)).join('|'); - const cost = costs.keyboardCost; - return { - map, - replace: cost, - swap: cost, - }; -} -function affKeyCaps(line, costs) { - const m = line.match(regExpKey); - if (!m) - return undefined; - return parseCaps(m[1], costs); -} -function affMapCaps(line, costs) { - const m = line.match(regExpMap); - if (!m) - return undefined; - return parseCaps(m[1], costs); -} -function affTryAccents(line, costs) { - const m = line.match(regExpTry); - if (!m) - return undefined; - return calcCostsForAccentedLetters(m[1], costs.locale, costs); -} -function affMapAccents(line, costs) { - const m = line.match(regExpMap); - if (!m) - return undefined; - return calcCostsForAccentedLetters(m[1], costs.locale, costs); -} -function parseCaps(value, costs) { - const locale = costs.locale; - const letters = [...splitMap(value)].filter((a) => a !== '|'); - const withCases = letters - .map((s) => caseForms(s, locale)) - .filter((forms) => forms.length > 1) - .map(joinLetters); - const map = uniqueU(withCases).join('|'); - const cost = costs.capsCosts; - if (!map) - return undefined; - return { - map, - replace: cost, - }; -} -function reducer(fn, initialVal) { - let acc = initialVal; - return (val, i) => (acc = fn(acc, val, i)); -} -function asArrayOf(v) { - return Array.isArray(v) ? v : [v]; -} -export const __testing__ = { - affKey, - affKeyCaps, - affMap, - affMapAccents, - affMapCaps, - affNoTry, - affRepConv, - affTry, - affTryAccents, - affTryFirstCharacterReplace, - calcCosts, - split: splitMap, -}; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapToSuggestionCostDef.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapToSuggestionCostDef.js deleted file mode 100644 index b224e6b61..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/mappers/mapToSuggestionCostDef.js +++ /dev/null @@ -1,112 +0,0 @@ -import { opFilter, opFlatten, opMap, opUnique, pipe } from '@cspell/cspell-pipe/sync'; -import { accentForms, caseForms, expandCharacterSet, stripAccents, stripNonAccents } from '../utils/text.js'; -import { clean } from '../utils/util.js'; -import { joinLetters } from './joinLetters.js'; -export function parseAlphabet(cs, locale, editCost) { - const { cost, penalty } = cs; - const characters = expandCharacterSet(cs.characters); - const charForms = [ - ...pipe(characters, opMap((c) => caseForms(c, locale).sort())), - ]; - const alphabet = joinLetters([ - ...pipe(charForms, opFlatten(), opMap((letter) => accentForms(letter)), opFlatten(), opUnique()), - ].sort()); - const sugAlpha = clean({ - map: alphabet, - replace: cost, - insDel: cost, - swap: cost, - penalty, - }); - return [ - sugAlpha, - parseAlphabetCaps(cs.characters, locale, editCost), - ...calcCostsForAccentedLetters(alphabet, locale, editCost), - ]; -} -export function parseAlphabetCaps(alphabet, locale, editCost) { - const characters = expandCharacterSet(alphabet); - const charForms = [ - ...pipe(characters, opMap((c) => caseForms(c, locale).sort())), - ]; - const caps = charForms.map((a) => joinLetters(a)).join('|'); - const sugCaps = { - map: caps, - replace: editCost.capsCosts, - }; - return sugCaps; -} -export function calcFirstCharacterReplaceDefs(alphabets, editCost) { - return alphabets.map((cs) => calcFirstCharacterReplace(cs, editCost)); -} -export function calcFirstCharacterReplace(cs, editCost) { - const mapOfFirstLetters = [ - ...pipe(expandCharacterSet(cs.characters), opUnique(), opMap((letter) => `(^${letter})`)), - ] - .sort() - .join('') + '(^)'; - const penalty = editCost.firstLetterPenalty; - // Make it a bit cheaper so it will match - const cost = cs.cost - penalty; - return { - map: mapOfFirstLetters, - replace: cost, - penalty: penalty * 2, - }; -} -export function parseAccents(cs, _editCost) { - const { cost, penalty } = cs; - const accents = joinLetters([ - ...pipe(expandCharacterSet(cs.characters), opMap((char) => stripNonAccents(char))), - ]); - if (!accents) - return undefined; - return clean({ - map: accents, - replace: cost, - insDel: cost, - penalty, - }); -} -export function calcCostsForAccentedLetters(simpleMap, locale, costs) { - const charactersWithAccents = [ - ...pipe(splitMap(simpleMap), opMap((char) => caseForms(char, locale)), opFlatten(), opMap((char) => [...accentForms(char)]), opFilter((forms) => forms.length > 1)), - ]; - const characters = pipe(charactersWithAccents, opMap((forms) => new Set([...forms, ...forms.map((char) => stripAccents(char))])), opMap((forms) => [...forms].sort()), opFilter((forms) => forms.length > 1), opMap(joinLetters), opUnique()); - const replaceAccentMap = [...characters].join('|'); - const cost = costs.accentCosts; - const costToReplaceAccent = !replaceAccentMap ? [] : [{ map: replaceAccentMap, replace: cost }]; - const normalizeMap = charactersWithAccents - .map((a) => a.sort()) - .map(joinLetters) - .join('|'); - const costToNormalizeAccent = !normalizeMap ? [] : [{ map: normalizeMap, replace: 0 }]; - return [...costToReplaceAccent, ...costToNormalizeAccent]; -} -/** - * Splits a simple map string into its parts. - * - `abc` => `a`, `b`, `c` - * - `a(bc)` => `a`, `bc` - * @param map - string of characters - */ -export function* splitMap(map) { - let seq = ''; - let mode = 0; - for (const char of map) { - if (mode && char === ')') { - yield seq; - mode = 0; - continue; - } - if (mode) { - seq += char; - continue; - } - if (char === '(') { - mode = 1; - seq = ''; - continue; - } - yield char; - } -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/index.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/index.js deleted file mode 100644 index d01188be3..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/index.js +++ /dev/null @@ -1 +0,0 @@ -export { Locale, parseLocale } from './locale.js'; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/knownLocales.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/knownLocales.js deleted file mode 100644 index 9f1ea2be1..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/knownLocales.js +++ /dev/null @@ -1,533 +0,0 @@ -export const codes = [ - // ['code', 'language'[', ''locale']], - ['af', 'Afrikaans'], - ['af-NA', 'Afrikaans', 'Namibia'], - ['af-ZA', 'Afrikaans', 'South Africa'], - ['ak', 'Akan'], - ['ak-GH', 'Akan', 'Ghana'], - ['am', 'Amharic'], - ['am-ET', 'Amharic', 'Ethiopia'], - ['ar', 'Arabic'], - ['ar-1', 'Arabic'], - ['ar-AE', 'Arabic', 'United Arab Emirates'], - ['ar-BH', 'Arabic', 'Bahrain'], - ['ar-DJ', 'Arabic', 'Djibouti'], - ['ar-DZ', 'Arabic', 'Algeria'], - ['ar-EG', 'Arabic', 'Egypt'], - ['ar-EH', 'Arabic'], - ['ar-ER', 'Arabic', 'Eritrea'], - ['ar-IL', 'Arabic', 'Israel'], - ['ar-IQ', 'Arabic', 'Iraq'], - ['ar-JO', 'Arabic', 'Jordan'], - ['ar-KM', 'Arabic', 'Comoros'], - ['ar-KW', 'Arabic', 'Kuwait'], - ['ar-LB', 'Arabic', 'Lebanon'], - ['ar-LY', 'Arabic', 'Libya'], - ['ar-MA', 'Arabic', 'Morocco'], - ['ar-MR', 'Arabic', 'Mauritania'], - ['ar-OM', 'Arabic', 'Oman'], - ['ar-PS', 'Arabic'], - ['ar-QA', 'Arabic', 'Qatar'], - ['ar-SA', 'Arabic', 'Saudi Arabia'], - ['ar-SD', 'Arabic', 'Sudan'], - ['ar-SO', 'Arabic', 'Somalia'], - ['ar-SS', 'Arabic'], - ['ar-SY', 'Arabic', 'Syria'], - ['ar-TD', 'Arabic', 'Chad'], - ['ar-TN', 'Arabic', 'Tunisia'], - ['ar-YE', 'Arabic', 'Yemen'], - ['as', 'Assamese'], - ['as-IN', 'Assamese', 'India'], - ['az', 'Azerbaijani'], - ['az-AZ', 'Azerbaijani', 'Azerbaijan'], - ['be', 'Belarusian'], - ['be-BY', 'Belarusian', 'Belarus'], - ['bg', 'Bulgarian'], - ['bg-BG', 'Bulgarian', 'Bulgaria'], - ['bm', 'Bambara'], - ['bm-ML', 'Bambara', 'Mali'], - ['bn', 'Bengali'], - ['bn-BD', 'Bengali', 'Bangladesh'], - ['bn-IN', 'Bengali', 'India'], - ['bo', 'Tibetan'], - ['bo-CN', 'Tibetan', 'China'], - ['bo-IN', 'Tibetan', 'India'], - ['br', 'Breton'], - ['br-FR', 'Breton', 'France'], - ['bs', 'Bosnian'], - ['bs-BA', 'Bosnian', 'Bosnia and Herzegovina'], - ['ca', 'Catalan'], - ['ca-AD', 'Catalan', 'Andorra'], - ['ca-ES', 'Catalan', 'Spain'], - ['ca-FR', 'Catalan', 'France'], - ['ca-IT', 'Catalan', 'Italy'], - ['ce', 'Chechen'], - ['ce-RU', 'Chechen', 'Russia'], - ['cs', 'Czech'], - ['cs-CZ', 'Czech', 'Czech Republic'], - ['cu', 'Old Slavonic'], - ['cu-RU', 'Old Slavonic', 'Russia'], - ['cy', 'Welsh'], - ['cy-GB', 'Welsh', 'United Kingdom'], - ['da', 'Danish'], - ['da-DK', 'Danish', 'Denmark'], - ['da-GL', 'Danish', 'Greenland'], - ['de', 'German'], - ['de-AT', 'German', 'Austria'], - ['de-BE', 'German', 'Belgium'], - ['de-CH', 'German', 'Switzerland'], - ['de-DE', 'German', 'Germany'], - ['de-IT', 'German', 'Italy'], - ['de-LI', 'German', 'Liechtenstein'], - ['de-LU', 'German', 'Luxembourg'], - ['dz', 'Dzongkha'], - ['dz-BT', 'Dzongkha', 'Bhutan'], - ['ee', 'Ewe'], - ['ee-GH', 'Ewe', 'Ghana'], - ['ee-TG', 'Ewe', 'Togo'], - ['el', 'Greek', 'Modern (1453-)'], - ['el-CY', 'Greek', 'Cyprus'], - ['el-GR', 'Greek', 'Greece'], - ['en', 'English'], - ['en-AG', 'English', 'Antigua and Barbuda'], - ['en-AI', 'English', 'Anguilla'], - ['en-AS', 'English', 'American Samoa'], - ['en-AT', 'English', 'Austria'], - ['en-AU', 'English', 'Australia'], - ['en-BB', 'English', 'Barbados'], - ['en-BE', 'English', 'Belgium'], - ['en-BI', 'English', 'Burundi'], - ['en-BM', 'English', 'Bermuda'], - ['en-BS', 'English', 'Bahamas'], - ['en-BW', 'English', 'Botswana'], - ['en-BZ', 'English', 'Belize'], - ['en-CA', 'English', 'Canada'], - ['en-CC', 'English', 'Cocos (Keeling) Islands'], - ['en-CH', 'English', 'Switzerland'], - ['en-CK', 'English', 'Cook Islands'], - ['en-CM', 'English', 'Cameroon'], - ['en-CX', 'English', 'Christmas Island'], - ['en-CY', 'English', 'Cyprus'], - ['en-DE', 'English', 'Germany'], - ['en-DG', 'English'], - ['en-DK', 'English', 'Denmark'], - ['en-DM', 'English', 'Dominica'], - ['en-ER', 'English', 'Eritrea'], - ['en-FI', 'English', 'Finland'], - ['en-FJ', 'English', 'Fiji'], - ['en-FK', 'English', 'Falkland Islands (Islas Malvinas)'], - ['en-FM', 'English', 'Micronesia'], - ['en-GB', 'English', 'United Kingdom'], - ['en-GD', 'English', 'Grenada'], - ['en-GG', 'English', 'Guernsey'], - ['en-GH', 'English', 'Ghana'], - ['en-GI', 'English', 'Gibraltar'], - ['en-GM', 'English', 'Gambia'], - ['en-GU', 'English', 'Guam'], - ['en-GY', 'English', 'Guyana'], - ['en-HK', 'English', 'Hong Kong'], - ['en-IE', 'English', 'Ireland'], - ['en-IL', 'English', 'Israel'], - ['en-IM', 'English', 'Isle of Man'], - ['en-IN', 'English', 'India'], - ['en-IO', 'English', 'British Indian Ocean Territory'], - ['en-JE', 'English', 'Jersey'], - ['en-JM', 'English', 'Jamaica'], - ['en-KE', 'English', 'Kenya'], - ['en-KI', 'English', 'Kiribati'], - ['en-KN', 'English', 'Saint Kitts and Nevis'], - ['en-KY', 'English', 'Cayman Islands'], - ['en-LC', 'English', 'Saint Lucia'], - ['en-LR', 'English', 'Liberia'], - ['en-LS', 'English', 'Lesotho'], - ['en-MG', 'English', 'Madagascar'], - ['en-MH', 'English', 'Marshall Islands'], - ['en-MO', 'English', 'Macau'], - ['en-MP', 'English', 'Northern Mariana Islands'], - ['en-MS', 'English', 'Montserrat'], - ['en-MT', 'English', 'Malta'], - ['en-MU', 'English', 'Mauritius'], - ['en-MW', 'English', 'Malawi'], - ['en-MY', 'English', 'Malaysia'], - ['en-NA', 'English', 'Namibia'], - ['en-NF', 'English', 'Norfolk Island'], - ['en-NG', 'English', 'Nigeria'], - ['en-NL', 'English', 'Netherlands'], - ['en-NR', 'English', 'Nauru'], - ['en-NU', 'English', 'Niue'], - ['en-NZ', 'English', 'New Zealand'], - ['en-PG', 'English', 'Papua New Guinea'], - ['en-PH', 'English', 'Philippines'], - ['en-PK', 'English', 'Pakistan'], - ['en-PN', 'English', 'Pitcairn Islands'], - ['en-PR', 'English', 'Puerto Rico'], - ['en-PW', 'English', 'Palau'], - ['en-RW', 'English', 'Rwanda'], - ['en-SB', 'English', 'Solomon Islands'], - ['en-SC', 'English', 'Seychelles'], - ['en-SD', 'English', 'Sudan'], - ['en-SE', 'English', 'Sweden'], - ['en-SG', 'English', 'Singapore'], - ['en-SH', 'English', 'Saint Helena'], - ['en-SI', 'English', 'Slovenia'], - ['en-SL', 'English', 'Sierra Leone'], - ['en-SS', 'English'], - ['en-SX', 'English'], - ['en-SZ', 'English', 'Swaziland'], - ['en-TC', 'English', 'Turks and Caicos Islands'], - ['en-TK', 'English', 'Tokelau'], - ['en-TO', 'English', 'Tonga'], - ['en-TT', 'English', 'Trinidad and Tobago'], - ['en-TV', 'English', 'Tuvalu'], - ['en-TZ', 'English', 'Tanzania'], - ['en-UG', 'English', 'Uganda'], - ['en-UM', 'English', 'Baker Island'], - ['en-US', 'English', 'United States'], - ['en-VC', 'English', 'Saint Vincent and the Grenadines'], - ['en-VG', 'English', 'British Virgin Islands'], - ['en-VI', 'English', 'U.S. Virgin Islands'], - ['en-VU', 'English', 'Vanuatu'], - ['en-WS', 'English', 'Samoa'], - ['en-ZA', 'English', 'South Africa'], - ['en-ZM', 'English', 'Zambia'], - ['en-ZW', 'English', 'Zimbabwe'], - ['eo', 'Esperanto'], - ['es', 'Spanish'], - ['es-AR', 'Spanish', 'Argentina'], - ['es-BO', 'Spanish', 'Bolivia'], - ['es-BR', 'Spanish', 'Brazil'], - ['es-BZ', 'Spanish', 'Belize'], - ['es-CL', 'Spanish', 'Chile'], - ['es-CO', 'Spanish', 'Colombia'], - ['es-CR', 'Spanish', 'Costa Rica'], - ['es-CU', 'Spanish', 'Cuba'], - ['es-DO', 'Spanish', 'Dominican Republic'], - ['es-EA', 'Spanish'], - ['es-EC', 'Spanish', 'Ecuador'], - ['es-ES', 'Spanish', 'Spain'], - ['es-GQ', 'Spanish', 'Equatorial Guinea'], - ['es-GT', 'Spanish', 'Guatemala'], - ['es-HN', 'Spanish', 'Honduras'], - ['es-IC', 'Spanish'], - ['es-MX', 'Spanish', 'Mexico'], - ['es-NI', 'Spanish', 'Nicaragua'], - ['es-PA', 'Spanish', 'Panama'], - ['es-PE', 'Spanish', 'Peru'], - ['es-PH', 'Spanish', 'Philippines'], - ['es-PR', 'Spanish', 'Puerto Rico'], - ['es-PY', 'Spanish', 'Paraguay'], - ['es-SV', 'Spanish', 'El Salvador'], - ['es-US', 'Spanish', 'United States'], - ['es-UY', 'Spanish', 'Uruguay'], - ['es-VE', 'Spanish', 'Venezuela'], - ['et', 'Estonian'], - ['et-EE', 'Estonian', 'Estonia'], - ['eu', 'Basque'], - ['eu-ES', 'Basque', 'Spain'], - ['fa', 'Persian'], - ['fa-AF', 'Persian', 'Afghanistan'], - ['fa-IR', 'Persian', 'Iran'], - ['ff', 'Fulah'], - ['ff-CM', 'Fulah', 'Cameroon'], - ['ff-GN', 'Fulah', 'Guinea'], - ['ff-MR', 'Fulah', 'Mauritania'], - ['ff-SN', 'Fulah', 'Senegal'], - ['fi', 'Finnish'], - ['fi-FI', 'Finnish', 'Finland'], - ['fo', 'Faroese'], - ['fo-DK', 'Faroese', 'Denmark'], - ['fo-FO', 'Faroese', 'Faroe Islands'], - ['fr', 'French'], - ['fr-BE', 'French', 'Belgium'], - ['fr-BF', 'French', 'Burkina Faso'], - ['fr-BI', 'French', 'Burundi'], - ['fr-BJ', 'French', 'Benin'], - ['fr-BL', 'French'], - ['fr-CA', 'French', 'Canada'], - ['fr-CD', 'French', 'Congo'], - ['fr-CF', 'French', 'Central African Republic'], - ['fr-CG', 'French', 'Congo'], - ['fr-CH', 'French', 'Switzerland'], - ['fr-CI', "French, Cote d'Ivoire (Ivory Coast)"], - ['fr-CM', 'French', 'Cameroon'], - ['fr-DJ', 'French', 'Djibouti'], - ['fr-DZ', 'French', 'Algeria'], - ['fr-FR', 'French', 'France'], - ['fr-GA', 'French', 'Gabon'], - ['fr-GF', 'French', 'French Guiana'], - ['fr-GN', 'French', 'Guinea'], - ['fr-GP', 'French', 'Saint Barthelemy'], - ['fr-GQ', 'French', 'Equatorial Guinea'], - ['fr-HT', 'French', 'Haiti'], - ['fr-KM', 'French', 'Comoros'], - ['fr-LU', 'French', 'Luxembourg'], - ['fr-MA', 'French', 'Morocco'], - ['fr-MC', 'French', 'Monaco'], - ['fr-MF', 'French'], - ['fr-MG', 'French', 'Madagascar'], - ['fr-ML', 'French', 'Mali'], - ['fr-MQ', 'French', 'Martinique'], - ['fr-MR', 'French', 'Mauritania'], - ['fr-MU', 'French', 'Mauritius'], - ['fr-NC', 'French', 'New Caledonia'], - ['fr-NE', 'French', 'Niger'], - ['fr-PF', 'French', 'French Polynesia'], - ['fr-PM', 'French', 'Saint Pierre and Miquelon'], - ['fr-RE', 'French', 'Reunion'], - ['fr-RW', 'French', 'Rwanda'], - ['fr-SC', 'French', 'Seychelles'], - ['fr-SN', 'French', 'Senegal'], - ['fr-SY', 'French', 'Syria'], - ['fr-TD', 'French', 'Chad'], - ['fr-TG', 'French', 'Togo'], - ['fr-TN', 'French', 'Tunisia'], - ['fr-VU', 'French', 'Vanuatu'], - ['fr-WF', 'French', 'Wallis and Futuna'], - ['fr-YT', 'French', 'Mayotte'], - ['fy', 'Western Frisian'], - ['fy-NL', 'Western Frisian', 'Netherlands'], - ['ga', 'Irish'], - ['ga-IE', 'Irish', 'Ireland'], - ['gd', 'Gaelic'], - ['gd-GB', 'Gaelic', 'United Kingdom'], - ['gl', 'Galician'], - ['gl-ES', 'Galician', 'Spain'], - ['gu', 'Gujarati'], - ['gu-IN', 'Gujarati', 'India'], - ['gv', 'Manx'], - ['gv-IM', 'Manx', 'Isle of Man'], - ['ha', 'Hausa'], - ['ha-GH', 'Hausa', 'Ghana'], - ['ha-NE', 'Hausa', 'Niger'], - ['ha-NG', 'Hausa', 'Nigeria'], - ['he', 'Hebrew'], - ['he-IL', 'Hebrew', 'Israel'], - ['hi', 'Hindi'], - ['hi-IN', 'Hindi', 'India'], - ['hr', 'Croatian'], - ['hr-BA', 'Croatian', 'Bosnia and Herzegovina'], - ['hr-HR', 'Croatian', 'Croatia'], - ['hu', 'Hungarian'], - ['hu-HU', 'Hungarian', 'Hungary'], - ['hy', 'Armenian'], - ['hy-AM', 'Armenian', 'Armenia'], - ['id', 'Indonesian'], - ['id-ID', 'Indonesian', 'Indonesia'], - ['ig', 'Igbo'], - ['ig-NG', 'Igbo', 'Nigeria'], - ['ii', 'Sichuan Yi'], - ['ii-CN', 'Sichuan Yi', 'China'], - ['is', 'Icelandic'], - ['is-IS', 'Icelandic', 'Iceland'], - ['it', 'Italian'], - ['it-CH', 'Italian', 'Switzerland'], - ['it-IT', 'Italian', 'Italy'], - ['it-SM', 'Italian', 'San Marino'], - ['it-VA', 'Italian', 'Vatican City'], - ['ja', 'Japanese'], - ['ja-JP', 'Japanese', 'Japan'], - ['ka', 'Georgian'], - ['ka-GE', 'Georgian', 'Georgia'], - ['ki', 'Kikuyu'], - ['ki-KE', 'Kikuyu', 'Kenya'], - ['kk', 'Kazakh'], - ['kk-KZ', 'Kazakh', 'Kazakhstan'], - ['kl', 'Kalaallisut'], - ['kl-GL', 'Kalaallisut', 'Greenland'], - ['km', 'Central Khmer'], - ['km-KH', 'Central Khmer', 'Cambodia'], - ['kn', 'Kannada'], - ['kn-IN', 'Kannada', 'India'], - ['ko', 'Korean'], - ['ko-KP', 'Korean', 'Korea'], - ['ko-KR', 'Korean', 'Korea'], - ['ks', 'Kashmiri'], - ['ks-IN', 'Kashmiri', 'India'], - ['kw', 'Cornish'], - ['kw-GB', 'Cornish', 'United Kingdom'], - ['ky', 'Kirghiz'], - ['ky-KG', 'Kirghiz', 'Kyrgyzstan'], - ['lb', 'Luxembourgish'], - ['lb-LU', 'Luxembourgish', 'Luxembourg'], - ['lg', 'Ganda'], - ['lg-UG', 'Ganda', 'Uganda'], - ['ln', 'Lingala'], - ['ln-AO', 'Lingala', 'Angola'], - ['ln-CD', 'Lingala', 'Congo'], - ['ln-CF', 'Lingala', 'Central African Republic'], - ['ln-CG', 'Lingala', 'Congo'], - ['lo', 'Lao'], - ['lo-LA', 'Lao', 'Laos'], - ['lt', 'Lithuanian'], - ['lt-LT', 'Lithuanian', 'Lithuania'], - ['lu', 'Luba-Katanga'], - ['lu-CD', 'Luba-Katanga', 'Congo'], - ['lv', 'Latvian'], - ['lv-LV', 'Latvian', 'Latvia'], - ['mg', 'Malagasy'], - ['mg-MG', 'Malagasy', 'Madagascar'], - ['mk', 'Macedonian'], - ['mk-MK', 'Macedonian', 'Macedonia'], - ['ml', 'Malayalam'], - ['ml-IN', 'Malayalam', 'India'], - ['mn', 'Mongolian'], - ['mn-MN', 'Mongolian', 'Mongolia'], - ['mr', 'Marathi'], - ['mr-IN', 'Marathi', 'India'], - ['ms', 'Malay'], - ['ms-BN', 'Malay', 'Brunei'], - ['ms-MY', 'Malay', 'Malaysia'], - ['ms-SG', 'Malay', 'Singapore'], - ['mt', 'Maltese'], - ['mt-MT', 'Maltese', 'Malta'], - ['my', 'Burmese'], - ['my-MM', 'Burmese', 'Myanmar (Burma)'], - ['nb', 'Bokmål Norwegian'], - ['nb-NO', 'Bokmål Norwegian', 'Norway'], - ['nb-SJ', 'Bokmål Norwegian', 'Svalbard'], - ['nd', 'Ndebele, North'], - ['nd-ZW', 'Ndebele, North', 'Zimbabwe'], - ['ne', 'Nepali'], - ['ne-IN', 'Nepali', 'India'], - ['ne-NP', 'Nepali', 'Nepal'], - ['nl', 'Dutch'], - ['nl-AW', 'Dutch', 'Aruba'], - ['nl-BE', 'Dutch', 'Belgium'], - ['nl-BQ', 'Dutch'], - ['nl-CW', 'Dutch'], - ['nl-NL', 'Dutch', 'Netherlands'], - ['nl-SR', 'Dutch', 'Suriname'], - ['nl-SX', 'Dutch'], - ['nn', 'Norwegian Nynorsk'], - ['nn-NO', 'Norwegian Nynorsk', 'Norway'], - ['om', 'Oromo'], - ['om-ET', 'Oromo', 'Ethiopia'], - ['om-KE', 'Oromo', 'Kenya'], - ['or', 'Oriya'], - ['or-IN', 'Oriya', 'India'], - ['os', 'Ossetian'], - ['os-GE', 'Ossetian', 'Georgia'], - ['os-RU', 'Ossetian', 'Russia'], - ['pa', 'Panjabi'], - ['pa-IN', 'Panjabi', 'India'], - ['pa-PK', 'Panjabi', 'Pakistan'], - ['pl', 'Polish'], - ['pl-PL', 'Polish', 'Poland'], - ['ps', 'Pushto'], - ['ps-AF', 'Pushto', 'Afghanistan'], - ['pt', 'Portuguese'], - ['pt-AO', 'Portuguese', 'Angola'], - ['pt-BR', 'Portuguese', 'Brazil'], - ['pt-CH', 'Portuguese', 'Switzerland'], - ['pt-CV', 'Portuguese', 'Cape Verde'], - ['pt-GQ', 'Portuguese', 'Equatorial Guinea'], - ['pt-GW', 'Portuguese', 'Guinea-Bissau'], - ['pt-LU', 'Portuguese', 'Luxembourg'], - ['pt-MO', 'Portuguese', 'Macau'], - ['pt-MZ', 'Portuguese', 'Mozambique'], - ['pt-PT', 'Portuguese', 'Portugal'], - ['pt-ST', 'Portuguese', 'Sao Tome and Principe'], - ['pt-TL', 'Portuguese', 'Timor-Leste (East Timor)'], - ['qu', 'Quechua'], - ['qu-BO', 'Quechua', 'Bolivia'], - ['qu-EC', 'Quechua', 'Ecuador'], - ['qu-PE', 'Quechua', 'Peru'], - ['rm', 'Romansh'], - ['rm-CH', 'Romansh', 'Switzerland'], - ['rn', 'Rundi'], - ['rn-BI', 'Rundi', 'Burundi'], - ['ro', 'Romanian'], - ['ro-MD', 'Romanian', 'Moldova'], - ['ro-RO', 'Romanian', 'Romania'], - ['ru', 'Russian'], - ['ru-BY', 'Russian', 'Belarus'], - ['ru-KG', 'Russian', 'Kyrgyzstan'], - ['ru-KZ', 'Russian', 'Kazakhstan'], - ['ru-MD', 'Russian', 'Moldova'], - ['ru-RU', 'Russian', 'Russia'], - ['ru-UA', 'Russian', 'Ukraine'], - ['rw', 'Kinyarwanda'], - ['rw-RW', 'Kinyarwanda', 'Rwanda'], - ['se', 'Northern Sami'], - ['se-FI', 'Northern Sami', 'Finland'], - ['se-NO', 'Northern Sami', 'Norway'], - ['se-SE', 'Northern Sami', 'Sweden'], - ['sg', 'Sango'], - ['sg-CF', 'Sango', 'Central African Republic'], - ['si', 'Sinhala'], - ['si-LK', 'Sinhala', 'Sri Lanka'], - ['sk', 'Slovak'], - ['sk-SK', 'Slovak', 'Slovakia'], - ['sl', 'Slovenian'], - ['sl-SI', 'Slovenian', 'Slovenia'], - ['sn', 'Shona'], - ['sn-ZW', 'Shona', 'Zimbabwe'], - ['so', 'Somali'], - ['so-DJ', 'Somali', 'Djibouti'], - ['so-ET', 'Somali', 'Ethiopia'], - ['so-KE', 'Somali', 'Kenya'], - ['so-SO', 'Somali', 'Somalia'], - ['sq', 'Albanian'], - ['sq-AL', 'Albanian', 'Albania'], - ['sq-MK', 'Albanian', 'Macedonia'], - ['sq-XK', 'Albanian'], - ['sr', 'Serbian'], - ['sr-BA', 'Serbian', 'Bosnia and Herzegovina'], - ['sr-ME', 'Serbian', 'Montenegro'], - ['sr-RS', 'Serbian', 'Serbia'], - ['sr-XK', 'Serbian'], - ['sv', 'Swedish'], - ['sv-AX', 'Swedish', 'Aland'], - ['sv-FI', 'Swedish', 'Finland'], - ['sv-SE', 'Swedish', 'Sweden'], - ['sw', 'Swahili'], - ['sw-CD', 'Swahili', 'Congo'], - ['sw-KE', 'Swahili', 'Kenya'], - ['sw-TZ', 'Swahili', 'Tanzania'], - ['sw-UG', 'Swahili', 'Uganda'], - ['ta', 'Tamil'], - ['ta-IN', 'Tamil', 'India'], - ['ta-LK', 'Tamil', 'Sri Lanka'], - ['ta-MY', 'Tamil', 'Malaysia'], - ['ta-SG', 'Tamil', 'Singapore'], - ['te', 'Telugu'], - ['te-IN', 'Telugu', 'India'], - ['th', 'Thai'], - ['th-TH', 'Thai', 'Thailand'], - ['ti', 'Tigrinya'], - ['ti-ER', 'Tigrinya', 'Eritrea'], - ['ti-ET', 'Tigrinya', 'Ethiopia'], - ['tk', 'Turkmen'], - ['tk-TM', 'Turkmen', 'Turkmenistan'], - ['to', 'Tonga (Tonga Islands)'], - ['to-TO', 'Tonga (Tonga Islands)', 'Tonga'], - ['tr', 'Turkish'], - ['tr-CY', 'Turkish', 'Cyprus'], - ['tr-TR', 'Turkish', 'Turkey'], - ['ug', 'Uighur'], - ['ug-CN', 'Uighur', 'China'], - ['uk', 'Ukrainian'], - ['uk-UA', 'Ukrainian', 'Ukraine'], - ['ur', 'Urdu'], - ['ur-IN', 'Urdu', 'India'], - ['ur-PK', 'Urdu', 'Pakistan'], - ['uz', 'Uzbek'], - ['uz-AF', 'Uzbek', 'Afghanistan'], - ['uz-UZ', 'Uzbek', 'Uzbekistan'], - ['vi', 'Vietnamese'], - ['vi-VN', 'Vietnamese', 'Vietnam'], - ['vo', 'Volapük'], - ['yi', 'Yiddish'], - ['yi-1', 'Yiddish'], - ['yo', 'Yoruba'], - ['yo-BJ', 'Yoruba', 'Benin'], - ['yo-NG', 'Yoruba', 'Nigeria'], - ['zh', 'Chinese'], - ['zh-CN', 'Chinese', 'China'], - ['zh-HK', 'Chinese', 'Hong Kong'], - ['zh-MO', 'Chinese', 'Macau'], - ['zh-SG', 'Chinese', 'Singapore'], - ['zh-TW', 'Chinese', 'China'], - ['zu', 'Zulu'], - ['zu-ZA', 'Zulu', 'South Africa'], -]; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/locale.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/locale.js deleted file mode 100644 index a475849cf..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/models/locale/locale.js +++ /dev/null @@ -1,60 +0,0 @@ -import { codes } from './knownLocales.js'; -let codesByLocale; -export class Locale { - constructor(locale) { - this._raw = locale; - this._locale = normalizeLocale(locale); - } - get locale() { - return this._locale; - } - localInfo() { - return lookupLocaleInfo(this._locale); - } - isValid() { - return isStandardLocale(this._locale); - } - toJSON() { - return this.locale; - } - toString() { - return this.locale; - } -} -const regExTwoLetter = /^[a-z]{2}$/i; -const regExLocaleWithCountry = /^([a-z]{2})[_-]?([a-z]{2,3})$/i; -const regExValidLocale = /^([a-z]{2})(?:-([A-Z]{2,3}))?$/; -/** - * Attempt to normalize a locale. - * @param locale a locale string - */ -export function normalizeLocale(locale) { - locale = locale.trim(); - if (regExTwoLetter.test(locale)) - return locale.toLowerCase(); - const m = locale.match(regExLocaleWithCountry); - // give up if we cannot parse it. - if (!m) - return locale; - const lang = m[1].toLowerCase(); - const variant = m[2].toUpperCase(); - return `${lang}-${variant}`; -} -export function isStandardLocale(locale) { - return regExValidLocale.test(locale); -} -export function lookupLocaleInfo(locale) { - codesByLocale = codesByLocale || buildLocaleLookup(); - return codesByLocale.get(locale); -} -function buildLocaleLookup() { - const info = codes.map(([locale, language, country]) => ({ locale, language, country })); - return new Map(info.map((i) => [i.locale, i])); -} -function createLocale(locale) { - return new Locale(locale); -} -export function parseLocale(locales) { - locales = typeof locales === 'string' ? locales.split(',') : locales; - return locales.map(createLocale); -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggest.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/suggest.js deleted file mode 100644 index 92dfd562c..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggest.js +++ /dev/null @@ -1,4 +0,0 @@ -/** - * This file is here to support code the referenced suggest directly and limit the exports. - */ -export { genCompoundableSuggestions, genSuggestions, suggest } from './suggestions/suggest.js'; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestCollector.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestCollector.js deleted file mode 100644 index e126722df..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestCollector.js +++ /dev/null @@ -1 +0,0 @@ -export { compSuggestionResults, defaultSuggestionCollectorOptions, impersonateCollector, isSuggestionResult, suggestionCollector, } from './suggestions/suggestCollector.js'; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/constants.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/constants.js deleted file mode 100644 index 4e282cc85..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/constants.js +++ /dev/null @@ -1 +0,0 @@ -export const DEFAULT_COMPOUNDED_WORD_SEPARATOR = '∙'; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/genSuggestionsOptions.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/genSuggestionsOptions.js deleted file mode 100644 index c22fbe38b..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/genSuggestionsOptions.js +++ /dev/null @@ -1,44 +0,0 @@ -import { CompoundWordsMethod } from '../walker/index.js'; -export const defaultGenSuggestionOptions = { - compoundMethod: CompoundWordsMethod.NONE, - ignoreCase: true, - changeLimit: 5, -}; -export const defaultSuggestionOptions = { - ...defaultGenSuggestionOptions, - numSuggestions: 8, - includeTies: true, - timeout: 5000, -}; -const keyMapOfGenSuggestionOptionsStrict = { - changeLimit: 'changeLimit', - compoundMethod: 'compoundMethod', - ignoreCase: 'ignoreCase', - compoundSeparator: 'compoundSeparator', -}; -const keyMapOfSuggestionOptionsStrict = { - ...keyMapOfGenSuggestionOptionsStrict, - filter: 'filter', - includeTies: 'includeTies', - numSuggestions: 'numSuggestions', - timeout: 'timeout', - weightMap: 'weightMap', -}; -/** - * Create suggestion options using composition. - * @param opts - partial options. - * @returns Options - with defaults. - */ -export function createSuggestionOptions(...opts) { - const options = { ...defaultSuggestionOptions }; - const keys = Object.keys(keyMapOfSuggestionOptionsStrict); - for (const opt of opts) { - for (const key of keys) { - assign(options, opt, key); - } - } - return options; -} -function assign(dest, src, k) { - dest[k] = src[k] ?? dest[k]; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/orthography.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/orthography.js deleted file mode 100644 index 5d7e7a08d..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/orthography.js +++ /dev/null @@ -1,65 +0,0 @@ -const intl = new Intl.Collator('en', { sensitivity: 'base' }); -export const compare = intl.compare; -/** - * This a set of letters that look like each other. - * There can be a maximum of 30 groups. - * It is possible for a letter to appear in more than 1 group, but not encouraged. - */ -export const visualLetterGroups = [ - // cspell:disable - forms('ǎàåÄÀAãâáǟặắấĀāăąaäæɐɑαаᾳ') + 'ᾳ', - forms('Bbḃвъь'), - forms('ċČčcĉçCÇćĊСсς'), - forms('ḎḋḏḑďđḍDd'), - forms('ēëÈÊËềéèếệĕeEĒėęěêəɛёЁеʒ'), - forms('fḟF'), - forms('ġĠĞǧĝģGgɣ'), - forms('ħĦĥḥHhḤȟн'), - forms('IįïİÎÍīiÌìíîıɪɨїΊΙ'), - forms('jJĵ'), - forms('ķKkκкќ'), - forms('ḷłľļLlĺḶίι'), - forms('Mṃṁm'), - forms('nņÑNṇňŇñńŋѝий'), - forms('ÒOøȭŌōőỏoÖòȱȯóôõöơɔόδо'), - forms('PṗpрРρ'), - forms('Qq'), - forms('řRṛrŕŗѓгя'), - forms('ṣšȘṢsSŠṡŞŝśșʃΣ'), - forms('tțȚťTṭṬṫ'), - forms('ÜüûŪưůūűúÛŭÙùuųU'), - forms('Vvν'), - forms('ŵwWẃẅẁωш'), - forms('xXх'), - forms('ÿýYŷyÝỳУўу'), - forms('ZẓžŽżŻźz'), - // cspell:enable -]; -function forms(letters) { - const n = letters.normalize('NFC').replace(/\p{M}/gu, ''); - const na = n.normalize('NFD').replace(/\p{M}/gu, ''); - const s = new Set(n + n.toLowerCase() + n.toUpperCase() + na + na.toLowerCase() + na.toUpperCase()); - return [...s].join(''); -} -/** - * This is a map of letters to groups mask values. - * If two letters are part of the same group then `visualLetterMaskMap[a] & visualLetterMaskMap[b] !== 0` - */ -export const visualLetterMaskMap = calcVisualLetterMasks(visualLetterGroups); -/** - * - * @param groups - * @returns - */ -function calcVisualLetterMasks(groups) { - // map each letter in a group to the index of the group. - const map = Object.create(null); - for (let i = 0; i < groups.length; ++i) { - const m = 1 << i; - const g = groups[i]; - for (const c of g) { - map[c] = (map[c] || 0) | m; - } - } - return map; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggest.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggest.js deleted file mode 100644 index cccaa3d7d..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggest.js +++ /dev/null @@ -1,195 +0,0 @@ -import { isWordTerminationNode } from '../trie-util.js'; -import { clean } from '../utils/clean.js'; -import { CompoundWordsMethod, hintedWalker, JOIN_SEPARATOR, WORD_SEPARATOR } from '../walker/index.js'; -import { createSuggestionOptions } from './genSuggestionsOptions.js'; -import { visualLetterMaskMap } from './orthography.js'; -import { suggestionCollector } from './suggestCollector.js'; -const baseCost = 100; -const swapCost = 75; -const postSwapCost = swapCost - baseCost; -const insertSpaceCost = -1; -const mapSubCost = 1; -const maxCostScale = 0.5; -const discourageInsertCost = baseCost; -const setOfSeparators = new Set([JOIN_SEPARATOR, WORD_SEPARATOR]); -export function suggest(root, word, options = {}) { - const opts = createSuggestionOptions(options); - const collectorOpts = clean(opts); - const collector = suggestionCollector(word, collectorOpts); - collector.collect(genSuggestions(root, word, { ...opts, ...collector.genSuggestionOptions })); - return collector.suggestions; -} -export function* genSuggestions(root, word, options = {}) { - const roots = Array.isArray(root) ? root : [root]; - for (const r of roots) { - yield* genCompoundableSuggestions(r, word, options); - } - return undefined; -} -export function* genCompoundableSuggestions(root, word, options = {}) { - const { compoundMethod = CompoundWordsMethod.NONE, changeLimit, ignoreCase } = createSuggestionOptions(options); - const history = []; - const historyTags = new Map(); - const bc = baseCost; - const psc = postSwapCost; - const matrix = [[]]; - const stack = []; - const x = ' ' + word; - const mx = x.length - 1; - const specialInsCosts = Object.assign(Object.create(null), { - [WORD_SEPARATOR]: insertSpaceCost, - [JOIN_SEPARATOR]: insertSpaceCost, - }); - const specialSubCosts = Object.assign(Object.create(null), { - '-': discourageInsertCost, - }); - let stopNow = false; - let costLimit = bc * Math.min(word.length * maxCostScale, changeLimit); - function updateCostLimit(maxCost) { - switch (typeof maxCost) { - case 'number': - costLimit = maxCost; - break; - case 'symbol': - stopNow = true; - break; - } - } - const a = 0; - let b = 0; - for (let i = 0, c = 0; i <= mx && c <= costLimit; ++i) { - c = i * baseCost; - matrix[0][i] = c; - b = i; - } - stack[0] = { a, b }; - const hint = word; - const iWalk = hintedWalker(root, ignoreCase, hint, compoundMethod, options.compoundSeparator); - let goDeeper = true; - for (let r = iWalk.next({ goDeeper }); !stopNow && !r.done; r = iWalk.next({ goDeeper })) { - const { text, node, depth } = r.value; - let { a, b } = stack[depth]; - /** Current character from word */ - const w = text.slice(-1); - /** Current character visual letter group */ - const wG = visualLetterMaskMap[w] || 0; - if (setOfSeparators.has(w)) { - const mxRange = matrix[depth].slice(a, b + 1); - const mxMin = Math.min(...mxRange); - const tag = [a].concat(mxRange.map((c) => c - mxMin)).join(); - const ht = historyTags.get(tag); - if (ht && ht.m <= mxMin) { - goDeeper = false; - const { i, w, m } = ht; - if (i >= history.length) { - continue; - } - const r = history[i]; - if (r.word.slice(0, w.length) !== w) { - continue; - } - const dc = mxMin - m; - for (let p = i; p < history.length; ++p) { - const { word, cost: hCost } = history[p]; - const fix = word.slice(0, w.length); - if (fix !== w) { - break; - } - const cost = hCost + dc; - if (cost <= costLimit) { - const suffix = word.slice(w.length); - const emit = text + suffix; - updateCostLimit(yield { word: emit, cost }); - } - } - continue; - } - else { - historyTags.set(tag, { w: text, i: history.length, m: mxMin }); - } - } - /** current depth */ - const d = depth + 1; - const lastSugLetter = d > 1 ? text[d - 2] : ''; - /** standard cost */ - const c = bc - d + (specialSubCosts[w] || 0); - /** insert cost */ - const ci = c + (specialInsCosts[w] || 0); - // Setup first column - matrix[d] = matrix[d] || []; - matrix[d][a] = matrix[d - 1][a] + ci + d - a; - let lastLetter = x[a]; - let min = matrix[d][a]; - let i; - // calc the core letters - for (i = a + 1; i <= b; ++i) { - const curLetter = x[i]; - /** current group */ - const cG = visualLetterMaskMap[curLetter] || 0; - const subCost = w === curLetter - ? 0 - : wG & cG - ? mapSubCost - : curLetter === lastSugLetter - ? w === lastLetter - ? psc - : c - : c; - const e = Math.min(matrix[d - 1][i - 1] + subCost, // substitute - matrix[d - 1][i] + ci, // insert - matrix[d][i - 1] + c // delete - ); - min = Math.min(min, e); - matrix[d][i] = e; - lastLetter = curLetter; - } - // fix the last column - const { b: bb } = stack[d - 1]; - while (b < mx) { - b += 1; - i = b; - const curLetter = x[i]; - const cG = visualLetterMaskMap[curLetter] || 0; - const subCost = w === curLetter - ? 0 - : wG & cG - ? mapSubCost - : curLetter === lastSugLetter - ? w === lastLetter - ? psc - : c - : c; - // if (i - 1) is out of range, use the last value. - // no need to be exact, the value will be past maxCost. - const j = Math.min(bb, i - 1); - const e = Math.min(matrix[d - 1][j] + subCost, // substitute - matrix[d][i - 1] + c // delete - ); - min = Math.min(min, e); - matrix[d][i] = e; - lastLetter = curLetter; - if (e > costLimit) - break; - } - // Adjust the range between a and b - for (; b > a && matrix[d][b] > costLimit; b -= 1) { - /* empty */ - } - for (; a < b && matrix[d][a] > costLimit; a += 1) { - /* empty */ - } - b = Math.min(b + 1, mx); - stack[d] = { a, b }; - const cost = matrix[d][b]; - if (node.f && isWordTerminationNode(node) && cost <= costLimit) { - const r = { word: text, cost }; - history.push(r); - updateCostLimit(yield r); - } - else { - updateCostLimit(yield undefined); - } - goDeeper = min <= costLimit; - } - return undefined; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggestAStar.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggestAStar.js deleted file mode 100644 index 029e961b9..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggestAStar.js +++ /dev/null @@ -1,415 +0,0 @@ -import { PairingHeap } from '../utils/PairingHeap.js'; -import { CompoundWordsMethod, JOIN_SEPARATOR, WORD_SEPARATOR } from '../walker/index.js'; -import { createSuggestionOptions } from './genSuggestionsOptions.js'; -import { visualLetterMaskMap } from './orthography.js'; -import { suggestionCollector } from './suggestCollector.js'; -export function* genCompoundableSuggestions(root, word, options) { - const { compoundMethod, ignoreCase, changeLimit } = options; - const len = word.length; - const nodes = determineInitialNodes(root, ignoreCase); - const noFollow = determineNoFollow(root); - function compare(a, b) { - const deltaCost = a.g - b.g; - if (deltaCost) - return deltaCost; - // The costs are the some return the one with the most progress. - return b.i - a.i; - } - const opCosts = { - baseCost: 100, - swapCost: 75, - duplicateLetterCost: 25, - visuallySimilar: 1, - firstLetterBias: 25, - wordBreak: 99, - }; - const bc = opCosts.baseCost; - const maxCostScale = 1.03 / 2; - const mapSugCost = opCosts.visuallySimilar; - const wordSeparator = compoundMethod === CompoundWordsMethod.JOIN_WORDS ? JOIN_SEPARATOR : WORD_SEPARATOR; - const compoundIndicator = root.compoundCharacter; - let costLimit = bc * Math.min(len * maxCostScale, changeLimit); - let stopNow = false; - const candidates = new PairingHeap(compare); - const locationCache = new Map(); - const wordsToEmit = []; - const pathToLocation = new Map(); - const edgesToResolve = []; - const emittedWords = new Map(); - function updateCostLimit(maxCost) { - switch (typeof maxCost) { - case 'number': - costLimit = Math.min(maxCost, costLimit); - break; - case 'symbol': - stopNow = true; - break; - } - } - function getLocationNode(path) { - const index = path.i; - const node = path.n; - const foundByIndex = locationCache.get(index); - const byTrie = foundByIndex || new Map(); - if (!foundByIndex) - locationCache.set(index, byTrie); - const f = byTrie.get(node); - const n = f || { in: new Map(), er: [], bc: 0, p: path, sbc: -1, sfx: [] }; - if (!f) - byTrie.set(node, n); - return n; - } - function* emitWord(word, cost) { - if (cost <= costLimit) { - // console.log(`e: ${word} ${cost}`); - const f = emittedWords.get(word); - if (f !== undefined && f <= cost) - return undefined; - emittedWords.set(word, cost); - const lastChar = word[word.length - 1]; - if (!noFollow[lastChar]) { - updateCostLimit(yield { word: word, cost: cost }); - } - } - return undefined; - } - function* emitWords() { - for (const w of wordsToEmit) { - yield* emitWord(w.word, w.cost); - } - wordsToEmit.length = 0; - return undefined; - } - function addEdgeToBeResolved(path, edge) { - path.r = path.r || new Set(); - path.r.add(edge); - } - function addEdge(path, edge) { - const g = path.g + edge.c; - const i = edge.i; - if (g > costLimit) - return undefined; - const { n } = edge; - const w = path.w + edge.s; - const can = { e: edge, n, i, w, g, r: undefined, a: true }; - const location = getLocationNode(can); - location.er.push(edge); - // Is Location Resolved - if (location.sbc >= 0 && location.sbc <= can.g) { - // No need to go further, this node has been resolved. - // Return the edge to be resolved - addEdgeToBeResolved(path, edge); - edgesToResolve.push({ edge, suffixes: location.sfx }); - return undefined; - } - const found = location.in.get(can.w); - if (found) { - // If the existing path is cheaper or the same keep it. - // Do not add the edge. - if (found.g <= can.g) - return undefined; - // Otherwise mark it as inactive and - const e = found.e; - if (e) { - edgesToResolve.push({ edge: e, suffixes: [] }); - } - found.a = false; - } - addEdgeToBeResolved(path, edge); - location.in.set(can.w, can); - if (location.p.g > can.g) { - pathToLocation.delete(location.p); - location.sbc = -1; - location.sfx.length = 0; - location.p = can; - } - if (location.p === can) { - // Make this path the representation of this location. - pathToLocation.set(can, location); - candidates.add(can); - } - return edge; - } - function opWordFound(best) { - if (!best.n.f) - return; - const i = best.i; - const toDelete = len - i; - const edge = { p: best, n: best.n, i, s: '', c: bc * toDelete, a: Action.Delete }; - addEdgeToBeResolved(best, edge); - edgesToResolve.push({ edge, suffixes: [{ s: '', c: 0 }] }); - if (compoundMethod && best.g + opCosts.wordBreak <= costLimit) { - const s = wordSeparator; - nodes.forEach((node) => { - const e = { p: best, n: node, i, s, c: opCosts.wordBreak, a: Action.WordBreak }; - addEdge(best, e); - }); - } - } - function opCompoundWord(best) { - if (!best.n.c?.get(compoundIndicator)) - return; - const i = best.i; - const s = ''; - nodes.forEach((node) => { - const n = node.c?.get(compoundIndicator); - if (!n) - return; - const e = { p: best, n, i, s, c: opCosts.wordBreak, a: Action.CompoundWord }; - addEdge(best, e); - }); - } - function opInsert(best) { - const children = best.n.c; - if (!children) - return; - const i = best.i; - const c = bc; - for (const [s, n] of children) { - const e = { p: best, n, i, s, c, a: Action.Insert }; - addEdge(best, e); - } - } - function opDelete(best, num = 1) { - const i = best.i; - const e = { - p: best, - n: best.n, - i: i + num, - s: '', - c: bc * num, - a: Action.Delete, - // t: word.slice(i, i + num), - }; - return addEdge(best, e); - } - function opIdentity(best) { - const s = word[best.i]; - const n = best.n.c?.get(s); - if (!n) - return; - const i = best.i + 1; - const e = { p: best, n, i, s, c: 0, a: Action.Identity }; - addEdge(best, e); - } - function opReplace(best) { - const children = best.n.c; - if (!children) - return; - const wc = word[best.i]; - const wg = visualLetterMaskMap[wc] || 0; - const i = best.i + 1; - const cost = bc + (best.i ? 0 : opCosts.firstLetterBias); - for (const [s, n] of children) { - if (s == wc) - continue; - const sg = visualLetterMaskMap[s] || 0; - const c = wg & sg ? mapSugCost : cost; - const e = { p: best, n, i, s, c, a: Action.Replace /* , t: wc */ }; - addEdge(best, e); - } - } - function opSwap(best) { - const children = best.n.c; - const i = best.i; - const i2 = i + 1; - if (!children || len <= i2) - return; - const wc1 = word[i]; - const wc2 = word[i2]; - if (wc1 === wc2) - return; - const n = best.n.c?.get(wc2); - const n2 = n?.c?.get(wc1); - if (!n || !n2) - return; - const e = { - p: best, - n: n2, - i: i2 + 1, - s: wc2 + wc1, - c: opCosts.swapCost, - a: Action.Swap, - // , t: wc1 + wc2, - }; - addEdge(best, e); - } - function opDuplicate(best) { - const children = best.n.c; - const i = best.i; - const i2 = i + 1; - if (!children || len <= i2) - return; - const wc1 = word[i]; - const wc2 = word[i2]; - const n = best.n.c?.get(wc1); - if (!n) - return; - if (wc1 === wc2) { - // convert double letter to single - const e = { p: best, n, i: i + 2, s: wc1, c: opCosts.duplicateLetterCost, a: Action.Delete }; - addEdge(best, e); - return; - } - const n2 = n?.c?.get(wc1); - if (!n2) - return; - // convert single to double letter - const e = { p: best, n: n2, i: i2, s: wc1 + wc1, c: opCosts.duplicateLetterCost, a: Action.Insert }; - addEdge(best, e); - } - function resolveEdges() { - let e; - while ((e = edgesToResolve.shift())) { - resolveEdge(e); - } - } - function resolveLocationEdges(location, suffixes) { - for (const edge of location.er) { - edgesToResolve.push({ edge, suffixes }); - } - } - function resolveEdge({ edge, suffixes }) { - const { p, s: es, c: ec } = edge; - if (!p.r?.has(edge)) - return; - const edgeSuffixes = suffixes.map((sfx) => ({ s: es + sfx.s, c: ec + sfx.c })); - for (const { s, c } of edgeSuffixes) { - const cost = p.g + c; - if (cost <= costLimit) { - const word = p.w + s; - wordsToEmit.push({ word, cost }); - } - } - p.r.delete(edge); - const location = pathToLocation.get(p); - if (location?.p === p) { - location.sfx = location.sfx.concat(edgeSuffixes); - if (!p.r.size) { - location.sbc = p.g; - resolveLocationEdges(location, edgeSuffixes); - } - } - else if (!p.r.size) { - if (p.e) { - // Keep rolling up. - edgesToResolve.push({ edge: p.e, suffixes: edgeSuffixes }); - } - } - } - function cancelEdges(path) { - if (!path.r) - return; - const suffixes = []; - for (const edge of path.r) { - edgesToResolve.push({ edge, suffixes }); - } - } - /************ - * Below is the core of the A* algorithm - */ - updateCostLimit(yield undefined); - nodes.forEach((node, idx) => { - const g = idx ? 1 : 0; - candidates.add({ e: undefined, n: node, i: 0, w: '', g, r: undefined, a: true }); - }); - const iterationsBeforePolling = 100; - let i = iterationsBeforePolling; - let maxSize = 0; - let best; - // const bc2 = 2 * bc; - while (!stopNow && (best = candidates.dequeue())) { - if (--i < 0) { - i = iterationsBeforePolling; - updateCostLimit(yield undefined); - } - maxSize = Math.max(maxSize, candidates.length); - if (!best.a) { - // best's edges are already part of a location node. - continue; - } - if (best.g > costLimit) { - cancelEdges(best); - continue; - } - const bi = best.i; - opWordFound(best); - const children = best.n.c; - if (!children) - continue; - if (bi === len) { - opInsert(best); - } - else { - opIdentity(best); - opReplace(best); - opDelete(best); - opInsert(best); - opSwap(best); - opCompoundWord(best); - opDuplicate(best); - } - resolveEdges(); - yield* emitWords(); - } - resolveEdges(); - yield* emitWords(); - // console.log(` - // word: ${word} - // maxSize: ${maxSize} - // length: ${candidates.length} - // `); - return undefined; -} -var Action; -(function (Action) { - Action[Action["Identity"] = 0] = "Identity"; - Action[Action["Replace"] = 1] = "Replace"; - Action[Action["Delete"] = 2] = "Delete"; - Action[Action["Insert"] = 3] = "Insert"; - Action[Action["Swap"] = 4] = "Swap"; - Action[Action["CompoundWord"] = 5] = "CompoundWord"; - Action[Action["WordBreak"] = 6] = "WordBreak"; -})(Action || (Action = {})); -export function suggest(root, word, options) { - const opts = createSuggestionOptions(options); - const collector = suggestionCollector(word, { - numSuggestions: opts.numSuggestions, - changeLimit: opts.changeLimit, - includeTies: opts.includeTies, - ignoreCase: opts.ignoreCase, - timeout: opts.timeout, - }); - collector.collect(genSuggestions(root, word, opts)); - return collector.suggestions; -} -export function* genSuggestions(root, word, options) { - const roots = Array.isArray(root) ? root : [root]; - for (const r of roots) { - yield* genCompoundableSuggestions(r, word, options); - } - return undefined; -} -function determineNoFollow(root) { - const noFollow = Object.assign(Object.create(null), { - [root.compoundCharacter]: true, - [root.forbiddenWordPrefix]: true, - [root.stripCaseAndAccentsPrefix]: true, - }); - return noFollow; -} -function determineInitialNodes(root, ignoreCase) { - const roots = Array.isArray(root) ? root : [root]; - const rootNodes = roots; - const noCaseNodes = ignoreCase - ? roots - .filter((r) => r.stripCaseAndAccentsPrefix) - .map((n) => n.c?.get(n.stripCaseAndAccentsPrefix)) - .filter(isDefined) - : []; - const nodes = rootNodes.concat(noCaseNodes); - return nodes; -} -function isDefined(v) { - return v !== undefined; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggestCollector.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggestCollector.js deleted file mode 100644 index 2f14ebd59..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/suggestions/suggestCollector.js +++ /dev/null @@ -1,205 +0,0 @@ -import { editDistanceWeighted } from '../distance/index.js'; -import { addDefToWeightMap } from '../distance/weightedMaps.js'; -import { createTimer } from '../utils/timer.js'; -import { clean, regexQuote, replaceAllFactory } from '../utils/util.js'; -import { WORD_SEPARATOR } from '../walker/index.js'; -import { DEFAULT_COMPOUNDED_WORD_SEPARATOR } from './constants.js'; -const defaultMaxNumberSuggestions = 10; -const BASE_COST = 100; -const MAX_NUM_CHANGES = 5; -const MAX_COST_SCALE = 0.5; -// max allowed cost scale should be a bit over 50% to allow for suggestions to short words, but not too high to have too many suggestions. -const MAX_ALLOWED_COST_SCALE = 1.03 * MAX_COST_SCALE; -const collator = new Intl.Collator(); -// This is a bit broken, it was supposed to also include JOIN_SEPARATOR (`+`) -// Add it back later. -const regexSeparator = new RegExp(`[${regexQuote(WORD_SEPARATOR)}]`, 'g'); -const wordLengthCost = [0, 50, 25, 5, 0]; -const EXTRA_WORD_COST = 5; -/** time in ms */ -const DEFAULT_COLLECTOR_TIMEOUT = 1000; -const symStopProcessing = Symbol('Collector Stop Processing'); -// comparison function for Suggestion Results. -export function compSuggestionResults(a, b) { - const aPref = (a.isPreferred && -1) || 0; - const bPref = (b.isPreferred && -1) || 0; - return aPref - bPref || a.cost - b.cost || a.word.length - b.word.length || collator.compare(a.word, b.word); -} -export const defaultSuggestionCollectorOptions = Object.freeze({ - numSuggestions: defaultMaxNumberSuggestions, - filter: () => true, - changeLimit: MAX_NUM_CHANGES, - includeTies: false, - ignoreCase: true, - timeout: DEFAULT_COLLECTOR_TIMEOUT, - weightMap: undefined, - compoundSeparator: '', - compoundMethod: undefined, -}); -export function suggestionCollector(wordToMatch, options) { - const { filter = () => true, changeLimit = MAX_NUM_CHANGES, includeTies = false, ignoreCase = true, timeout = DEFAULT_COLLECTOR_TIMEOUT, weightMap, compoundSeparator = defaultSuggestionCollectorOptions.compoundSeparator, } = options; - const numSuggestions = Math.max(options.numSuggestions, 0) || 0; - const numSugToHold = weightMap ? numSuggestions * 2 : numSuggestions; - const sugs = new Map(); - let maxCost = BASE_COST * Math.min(wordToMatch.length * MAX_ALLOWED_COST_SCALE, changeLimit); - const useSeparator = compoundSeparator || - (weightMap ? DEFAULT_COMPOUNDED_WORD_SEPARATOR : defaultSuggestionCollectorOptions.compoundSeparator); - const fnCleanWord = !useSeparator || useSeparator === compoundSeparator ? (w) => w : replaceAllFactory(useSeparator, ''); - if (useSeparator && weightMap) { - addDefToWeightMap(weightMap, { map: useSeparator, insDel: 50 }); - } - const genSuggestionOptions = clean({ - changeLimit, - ignoreCase, - compoundMethod: options.compoundMethod, - compoundSeparator: useSeparator, - }); - let timeRemaining = timeout; - function dropMax() { - if (sugs.size < 2 || !numSuggestions) { - sugs.clear(); - return; - } - const sorted = [...sugs.values()].sort(compSuggestionResults); - let i = numSugToHold - 1; - maxCost = sorted[i].cost; - for (; i < sorted.length && sorted[i].cost <= maxCost; ++i) { - /* empty */ - } - for (; i < sorted.length; ++i) { - sugs.delete(sorted[i].word); - } - } - function adjustCost(sug) { - const words = sug.word.split(regexSeparator); - const extraCost = words.map((w) => wordLengthCost[w.length] || 0).reduce((a, b) => a + b, 0) + - (words.length - 1) * EXTRA_WORD_COST; - return { word: sug.word, cost: sug.cost + extraCost, isPreferred: sug.isPreferred }; - } - function collectSuggestion(suggestion) { - const { word, cost, isPreferred } = adjustCost(suggestion); - if (cost <= maxCost && filter(suggestion.word, cost)) { - const known = sugs.get(word); - if (known) { - known.cost = Math.min(known.cost, cost); - known.isPreferred = known.isPreferred || isPreferred; - } - else { - sugs.set(word, { word, cost, isPreferred }); - if (cost < maxCost && sugs.size > numSugToHold) { - dropMax(); - } - } - } - return maxCost; - } - /** - * Collection suggestions from a SuggestionIterator - * @param src - the SuggestionIterator used to generate suggestions. - * @param timeout - the amount of time in milliseconds to allow for suggestions. - */ - function collect(src, timeout, filter) { - let stop = false; - timeout = timeout ?? timeRemaining; - timeout = Math.min(timeout, timeRemaining); - if (timeout < 0) - return; - const timer = createTimer(); - let ir; - while (!(ir = src.next(stop || maxCost)).done) { - if (timer.elapsed() > timeout) { - stop = symStopProcessing; - } - const { value } = ir; - if (!value) - continue; - if (isSuggestionResult(value)) { - if (!filter || filter(value.word, value.cost)) { - collectSuggestion(value); - } - continue; - } - } - timeRemaining -= timer.elapsed(); - } - function cleanCompoundResult(sr) { - const { word, cost } = sr; - const cWord = fnCleanWord(word); - if (cWord !== word) { - return { - word: cWord, - cost, - compoundWord: word, - isPreferred: undefined, - }; - } - return { ...sr }; - } - function suggestions() { - if (numSuggestions < 1 || !sugs.size) - return []; - const NF = 'NFD'; - const nWordToMatch = wordToMatch.normalize(NF); - const rawValues = [...sugs.values()]; - const values = weightMap - ? rawValues.map(({ word, isPreferred }) => ({ - word, - cost: editDistanceWeighted(nWordToMatch, word.normalize(NF), weightMap, 110), - isPreferred, - })) - : rawValues; - const sorted = values.sort(compSuggestionResults).map(cleanCompoundResult); - let i = Math.min(sorted.length, numSuggestions) - 1; - const limit = includeTies ? sorted.length : Math.min(sorted.length, numSuggestions); - const iCost = sorted[i].cost; - const maxCost = Math.min(iCost, weightMap ? changeLimit * BASE_COST - 1 : iCost); - for (i = 1; i < limit && sorted[i].cost <= maxCost; ++i) { - // loop - } - sorted.length = i; - return sorted; - } - const collector = { - collect, - add: function (suggestion) { - collectSuggestion(suggestion); - return this; - }, - get suggestions() { - return suggestions(); - }, - get maxCost() { - return maxCost; - }, - get word() { - return wordToMatch; - }, - get maxNumSuggestions() { - return numSuggestions; - }, - get changeLimit() { - return changeLimit; - }, - includesTies: includeTies, - ignoreCase, - symbolStopProcessing: symStopProcessing, - genSuggestionOptions, - }; - return collector; -} -/** - * Impersonating a Collector, allows searching for multiple variants on the same word. - * The collection is still in the original collector. - * @param collector - collector to impersonate - * @param word - word to present instead of `collector.word`. - * @returns a SuggestionCollector - */ -export function impersonateCollector(collector, word) { - const r = Object.create(collector); - Object.defineProperty(r, 'word', { value: word, writable: false }); - return r; -} -export function isSuggestionResult(s) { - const r = s; - return r?.cost !== undefined && r.word != undefined; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/trie-util.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/trie-util.js deleted file mode 100644 index c02e52f86..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/trie-util.js +++ /dev/null @@ -1,152 +0,0 @@ -import { genSequence } from 'gensequence'; -import { ChildMap, FLAG_WORD } from './TrieNode.js'; -import { mergeOptionalWithDefaults } from './utils/mergeOptionalWithDefaults.js'; -import { walker } from './walker/walker.js'; -export function insert(text, node = {}) { - if (text.length) { - const head = text[0]; - const tail = text.slice(1); - node.c = node.c || new ChildMap(); - node.c.set(head, insert(tail, node.c.get(head))); - } - else { - node.f = (node.f || 0) | FLAG_WORD; - } - return node; -} -export function isWordTerminationNode(node) { - return ((node.f || 0) & FLAG_WORD) === FLAG_WORD; -} -/** - * Sorts the nodes in a trie in place. - */ -export function orderTrie(node) { - if (!node.c) - return; - const nodes = [...node.c].sort(([a], [b]) => (a < b ? -1 : 1)); - node.c = new Map(nodes); - for (const n of node.c) { - orderTrie(n[1]); - } -} -/** - * Generator an iterator that will walk the Trie parent then children in a depth first fashion that preserves sorted order. - */ -export function walk(node) { - return genSequence(walker(node)); -} -export const iterateTrie = walk; -/** - * Generate a Iterator that can walk a Trie and yield the words. - */ -export function iteratorTrieWords(node) { - return walk(node) - .filter((r) => isWordTerminationNode(r.node)) - .map((r) => r.text); -} -export function createTrieRoot(options) { - const fullOptions = mergeOptionalWithDefaults(options); - return { - ...fullOptions, - c: new Map(), - }; -} -export function createTriFromList(words, options) { - const root = createTrieRoot(options); - for (const word of words) { - if (word.length) { - insert(word, root); - } - } - return root; -} -export function has(node, word) { - let h = word.slice(0, 1); - let t = word.slice(1); - while (node.c && node.c.has(h)) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - node = node.c.get(h); - h = t.slice(0, 1); - t = t.slice(1); - } - return !h.length && !!((node.f || 0) & FLAG_WORD); -} -export function findNode(node, prefix) { - let h = prefix.slice(0, 1); - let t = prefix.slice(1); - let n = node; - while (h.length && n && n.c) { - n = n.c.get(h); - h = t.slice(0, 1); - t = t.slice(1); - } - return n; -} -export function countNodes(root) { - const seen = new Set(); - function walk(n) { - if (seen.has(n)) - return; - seen.add(n); - if (n.c) { - [...n.c.values()].forEach((n) => walk(n)); - } - } - walk(root); - return seen.size; -} -export function countWords(root) { - const visited = new Map(); - function walk(n) { - if (visited.has(n)) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - return visited.get(n); - } - let cnt = n.f ? 1 : 0; - // add the node to the set to avoid getting stuck on circular references. - visited.set(n, cnt); - if (!n.c) { - return cnt; - } - for (const c of n.c.values()) { - cnt += walk(c); - } - visited.set(n, cnt); - return cnt; - } - return walk(root); -} -export function isCircular(root) { - const seen = new Set(); - const inStack = new Set(); - function walk(n) { - if (seen.has(n)) - return { isCircular: false, allSeen: true }; - if (inStack.has(n)) - return { isCircular: true, allSeen: false }; - inStack.add(n); - let r = { isCircular: false, allSeen: true }; - if (n.c) { - r = [...n.c.values()].reduce((acc, n) => { - if (acc.isCircular) - return acc; - const r = walk(n); - r.allSeen = r.allSeen && acc.allSeen; - return r; - }, r); - } - if (r.allSeen) { - seen.add(n); - } - inStack.delete(n); - return r; - } - return walk(root).isCircular; -} -export function trieNodeToRoot(node, options) { - const newOptions = mergeOptionalWithDefaults(options); - return { - ...newOptions, - c: node.c || new Map(), - }; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/trie.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/trie.js deleted file mode 100644 index ba67a8c87..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/trie.js +++ /dev/null @@ -1,211 +0,0 @@ -import { genSequence } from 'gensequence'; -import { CASE_INSENSITIVE_PREFIX, COMPOUND_FIX, FORBID_PREFIX, OPTIONAL_COMPOUND_FIX } from './constants.js'; -import { createFindOptions, findLegacyCompound, findWord, findWordNode, isForbiddenWord } from './find.js'; -import { genSuggestions, suggest } from './suggest.js'; -import { countWords, createTriFromList, insert, isWordTerminationNode, iteratorTrieWords, orderTrie, } from './trie-util.js'; -import { clean } from './utils/clean.js'; -import { mergeOptionalWithDefaults } from './utils/mergeOptionalWithDefaults.js'; -import { replaceAllFactory } from './utils/util.js'; -import { walker } from './walker/index.js'; -export { CASE_INSENSITIVE_PREFIX, COMPOUND_FIX, defaultTrieOptions, FORBID_PREFIX, OPTIONAL_COMPOUND_FIX, } from './constants.js'; -/** @deprecated */ -export const COMPOUND = COMPOUND_FIX; -/** @deprecated */ -export const OPTIONAL_COMPOUND = OPTIONAL_COMPOUND_FIX; -/** @deprecated */ -export const NORMALIZED = CASE_INSENSITIVE_PREFIX; -/** @deprecated */ -export const FORBID = FORBID_PREFIX; -const defaultLegacyMinCompoundLength = 3; -export class Trie { - constructor(root, count) { - this.root = root; - this.count = count; - this.lastCreateFindOptionsMatchCaseMap = new Map(); - this._options = mergeOptionalWithDefaults(root); - this.isLegacy = this.calcIsLegacy(); - this.hasForbidden = !!root.c.get(root.forbiddenWordPrefix); - this._findOptionsDefaults = { - caseInsensitivePrefix: this._options.stripCaseAndAccentsPrefix, - compoundFix: this._options.compoundCharacter, - forbidPrefix: this._options.forbiddenWordPrefix, - }; - this._findOptionsExact = this.createFindOptions({ compoundMode: 'none' }); - } - /** - * Number of words in the Trie - */ - size() { - this.count = this.count ?? countWords(this.root); - return this.count; - } - isSizeKnown() { - return this.count !== undefined; - } - get options() { - return this._options; - } - /** - * @param text - text to find in the Trie - * @param minCompoundLength - deprecated - allows words to be glued together - */ - find(text, minCompoundLength = false) { - const minLength = !minCompoundLength - ? undefined - : minCompoundLength === true - ? defaultLegacyMinCompoundLength - : minCompoundLength; - const options = this.createFindOptions({ - compoundMode: minLength ? 'legacy' : 'compound', - legacyMinCompoundLength: minLength, - }); - return findWordNode(this.root, text, options).node; - } - /** - * - * @param text - text to search for - * @param minCompoundLength - minimum word compound length - * @deprecated - this method is no longer needed since compounding can be explicitly defined by the dictionary words. - */ - findCompound(text, minCompoundLength = defaultLegacyMinCompoundLength) { - const options = this.createFindOptions({ legacyMinCompoundLength: minCompoundLength }); - const r = findLegacyCompound(this.root, text, options); - return r.node; - } - findExact(text) { - return findWordNode(this.root, text, this._findOptionsExact).node; - } - has(word, minLegacyCompoundLength) { - if (this.hasWord(word, false)) - return true; - if (minLegacyCompoundLength) { - const f = this.findWord(word, { useLegacyWordCompounds: minLegacyCompoundLength }); - return !!f.found; - } - return false; - } - /** - * Determine if a word is in the dictionary. - * @param word - the exact word to search for - must be normalized. - * @param caseSensitive - false means also searching a dictionary where the words were normalized to lower case and accents removed. - * @returns true if the word was found and is not forbidden. - */ - hasWord(word, caseSensitive) { - const f = this.findWord(word, { caseSensitive }); - return !!f.found && !f.forbidden; - } - findWord(word, options) { - if (options?.useLegacyWordCompounds) { - const len = options.useLegacyWordCompounds !== true - ? options.useLegacyWordCompounds - : defaultLegacyMinCompoundLength; - const findOptions = this.createFindOptions({ - legacyMinCompoundLength: len, - matchCase: options.caseSensitive, - }); - return findLegacyCompound(this.root, word, findOptions); - } - const findOptions = this.createFindOptionsMatchCase(options?.caseSensitive); - return findWord(this.root, word, findOptions); - } - /** - * Determine if a word is in the forbidden word list. - * @param word the word to lookup. - */ - isForbiddenWord(word) { - return this.hasForbidden && isForbiddenWord(this.root, word, this.options.forbiddenWordPrefix); - } - /** - * Provides an ordered sequence of words with the prefix of text. - */ - completeWord(text) { - const n = this.find(text); - const compoundChar = this.options.compoundCharacter; - const subNodes = iteratorTrieWords(n || {}) - .filter((w) => w[w.length - 1] !== compoundChar) - .map((suffix) => text + suffix); - return genSequence(n && isWordTerminationNode(n) ? [text] : []).concat(subNodes); - } - /** - * Suggest spellings for `text`. The results are sorted by edit distance with changes near the beginning of a word having a greater impact. - * @param text - the text to search for - * @param maxNumSuggestions - the maximum number of suggestions to return. - * @param compoundMethod - Use to control splitting words. - * @param numChanges - the maximum number of changes allowed to text. This is an approximate value, since some changes cost less than others. - * the lower the value, the faster results are returned. Values less than 4 are best. - */ - suggest(text, options) { - return this.suggestWithCost(text, options).map((a) => a.word); - } - /** - * Suggest spellings for `text`. The results are sorted by edit distance with changes near the beginning of a word having a greater impact. - * The results include the word and adjusted edit cost. This is useful for merging results from multiple tries. - */ - suggestWithCost(text, options) { - const sep = options.compoundSeparator; - const adjWord = sep ? replaceAllFactory(sep, '') : (a) => a; - const optFilter = options.filter; - const filter = optFilter - ? (word, cost) => { - const w = adjWord(word); - return !this.isForbiddenWord(w) && optFilter(w, cost); - } - : (word) => !this.isForbiddenWord(adjWord(word)); - const opts = { ...options, filter }; - return suggest(this.root, text, opts); - } - /** - * genSuggestions will generate suggestions and send them to `collector`. `collector` is responsible for returning the max acceptable cost. - * Costs are measured in weighted changes. A cost of 100 is the same as 1 edit. Some edits are considered cheaper. - * Returning a MaxCost < 0 will effectively cause the search for suggestions to stop. - */ - genSuggestions(collector, compoundMethod) { - const filter = (word) => !this.isForbiddenWord(word); - const options = clean({ compoundMethod, ...collector.genSuggestionOptions }); - const suggestions = genSuggestions(this.root, collector.word, options); - collector.collect(suggestions, undefined, filter); - } - /** - * Returns an iterator that can be used to get all words in the trie. For some dictionaries, this can result in millions of words. - */ - words() { - return iteratorTrieWords(this.root); - } - /** - * Allows iteration over the entire tree. - * On the returned Iterator, calling .next(goDeeper: boolean), allows for controlling the depth. - */ - iterate() { - return walker(this.root); - } - insert(word) { - insert(word, this.root); - return this; - } - calcIsLegacy() { - const c = this.root.c; - return !(c?.get(this._options.compoundCharacter) || - c?.get(this._options.stripCaseAndAccentsPrefix) || - c?.get(this._options.forbiddenWordPrefix)); - } - static create(words, options) { - const root = createTriFromList(words, options); - orderTrie(root); - return new Trie(root, undefined); - } - createFindOptions(options = {}) { - const findOptions = createFindOptions({ - ...this._findOptionsDefaults, - ...options, - }); - return findOptions; - } - createFindOptionsMatchCase(matchCase) { - const f = this.lastCreateFindOptionsMatchCaseMap.get(matchCase); - if (f !== undefined) - return f; - const findOptions = this.createFindOptions({ matchCase }); - this.lastCreateFindOptionsMatchCaseMap.set(matchCase, findOptions); - return findOptions; - } -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/types.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/types.js deleted file mode 100644 index 7aaeda682..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/types.js +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Verified - */ -export {}; -// export type UndefinedToOptional = -/* - * Experimental - */ -// type X = { a: string; b?: string; c: number | undefined }; -// type M = MakeOptional; -// type OO = UndefinedToOptional; -// const c: M = { a: 'hello', b: 'h', c: 4 }; -// const x = c; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/autoCacheMap.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/autoCacheMap.js deleted file mode 100644 index 94fe4d45f..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/autoCacheMap.js +++ /dev/null @@ -1,28 +0,0 @@ -export class AutoCacheMap extends Map { - constructor(autoFn) { - super(); - this.autoFn = autoFn; - } - get(v) { - const r = super.get(v); - if (r !== undefined) - return r; - const u = this.autoFn(v); - super.set(v, u); - return u; - } -} -export class AutoCacheWeakMap extends WeakMap { - constructor(autoFn) { - super(); - this.autoFn = autoFn; - } - get(v) { - const r = super.get(v); - if (r !== undefined) - return r; - const u = this.autoFn(v); - super.set(v, u); - return u; - } -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/bufferLines.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/bufferLines.js deleted file mode 100644 index 125ca1b6d..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/bufferLines.js +++ /dev/null @@ -1,26 +0,0 @@ -export function* buffer(iter, bufferSize) { - const buffer = []; - for (const s of iter) { - buffer.push(s); - if (buffer.length >= bufferSize) { - yield buffer; - buffer.length = 0; - } - } - if (buffer.length) { - yield buffer; - buffer.length = 0; - } -} -export function* bufferLines(iter, bufferSize, eol) { - if (eol) { - for (const s of buffer(iter, bufferSize)) { - yield s.join('') + eol; - } - } - else { - for (const s of buffer(iter, bufferSize)) { - yield s.join(''); - } - } -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/clean.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/clean.js deleted file mode 100644 index 1baf89f72..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/clean.js +++ /dev/null @@ -1,9 +0,0 @@ -export function clean(t) { - const copy = { ...t }; - for (const key of Object.keys(copy)) { - if (copy[key] === undefined) { - delete copy[key]; - } - } - return copy; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/isDefined.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/isDefined.js deleted file mode 100644 index 95c418e64..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/isDefined.js +++ /dev/null @@ -1,3 +0,0 @@ -export function isDefined(t) { - return t !== undefined; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/memorizeLastCall.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/memorizeLastCall.js deleted file mode 100644 index f217afa38..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/memorizeLastCall.js +++ /dev/null @@ -1,13 +0,0 @@ -const SymEmpty = Symbol('memorizeLastCall'); -export function memorizeLastCall(fn) { - let lastP = undefined; - let lastR = SymEmpty; - function calc(p) { - if (lastR !== SymEmpty && lastP === p) - return lastR; - lastP = p; - lastR = fn(p); - return lastR; - } - return calc; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/mergeDefaults.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/mergeDefaults.js deleted file mode 100644 index f6bc42fcc..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/mergeDefaults.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Creates a new object of type T based upon the field values from `value`. - * n[k] = value[k] ?? default[k] where k must be a field in default. - * Note: it will remove fields not in defaultValue! - * @param value - * @param defaultValue - */ -export function mergeDefaults(value, defaultValue) { - const result = { ...defaultValue }; - if (value) { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - for (const [k, v] of Object.entries(value)) { - if (k in result) { - result[k] = v ?? result[k]; - } - } - } - return result; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/mergeOptionalWithDefaults.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/mergeOptionalWithDefaults.js deleted file mode 100644 index bee4484b3..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/mergeOptionalWithDefaults.js +++ /dev/null @@ -1,5 +0,0 @@ -import { defaultTrieOptions } from '../constants.js'; -import { mergeDefaults } from './mergeDefaults.js'; -export function mergeOptionalWithDefaults(options) { - return mergeDefaults(options, defaultTrieOptions); -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/normalizeWord.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/normalizeWord.js deleted file mode 100644 index f9ceca28e..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/normalizeWord.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Normalize word unicode. - * @param text - text to normalize - * @returns returns a word normalized to `NFC` - */ -export const normalizeWord = (text) => text.normalize(); -/** - * converts text to lower case and removes any accents. - * @param text - text to convert - * @returns lowercase word without accents - * @deprecated true - */ -export const normalizeWordToLowercase = (text) => text.toLowerCase().normalize('NFD').replace(/\p{M}/gu, ''); -/** - * generate case insensitive forms of a word - * @param text - text to convert - * @returns the forms of the word. - */ -export const normalizeWordForCaseInsensitive = (text) => { - const t = text.toLowerCase(); - return [t, t.normalize('NFD').replace(/\p{M}/gu, '')]; -}; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/secondChanceCache.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/secondChanceCache.js deleted file mode 100644 index d30431192..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/secondChanceCache.js +++ /dev/null @@ -1,55 +0,0 @@ -export class SecondChanceCache { - constructor(maxL0Size) { - this.maxL0Size = maxL0Size; - this.map0 = new Map(); - this.map1 = new Map(); - } - has(key) { - if (this.map0.has(key)) - return true; - if (this.map1.has(key)) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - this.set(key, this.get1(key)); - return true; - } - return false; - } - get(key) { - return this.map0.get(key) ?? this.get1(key); - } - set(key, value) { - if (this.map0.size >= this.maxL0Size && !this.map0.has(key)) { - this.map1 = this.map0; - this.map0 = new Map(); - } - this.map0.set(key, value); - return this; - } - get size() { - return this.map0.size + this.map1.size; - } - get size0() { - return this.map0.size; - } - get size1() { - return this.map1.size; - } - clear() { - this.map0.clear(); - this.map1.clear(); - return this; - } - get1(key) { - if (this.map1.has(key)) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const v = this.map1.get(key); - this.map1.delete(key); - this.set(key, v); - return v; - } - return undefined; - } - toArray() { - return [...this.map1, ...this.map0]; - } -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/text.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/text.js deleted file mode 100644 index 31f257620..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/text.js +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Expand a line into a set of characters. - * - * Example: - * - `a-c` -> `` - * - `ac-` -> `` - * - `-abz` -> `<-,a,b,z>` - * - `\u0300-\u0308` -> `` - * - * @param line - set of characters - * @param rangeChar - the character to indicate ranges, set to empty to not have ranges. - */ -export function expandCharacterSet(line, rangeChar = '-') { - const charSet = new Set(); - let mode = 0; - let prev = ''; - for (const char of line) { - if (mode) { - expandRange(prev, char).forEach((a) => charSet.add(a)); - mode = 0; - } - if (char === rangeChar) { - // store the `-` if there isn't a previous value. - if (prev) { - mode = 1; - continue; - } - } - charSet.add(char); - prev = char; - } - // catch the trailing `-` - if (mode) - charSet.add(rangeChar); - return charSet; -} -/** - * Expands a range between two characters. - * - `a <= b` -- `[a, b]` - * - `a > b` -- `[]` - * @param a - staring character - * @param b - ending character - * @returns array of unicode characters. - */ -export function expandRange(a, b) { - const values = []; - const end = b.codePointAt(0); - const begin = a.codePointAt(0); - if (!(begin && end)) - return values; - for (let i = begin; i <= end; ++i) { - values.push(String.fromCodePoint(i)); - } - return values; -} -/** - * Tries to find the different cases for a letter. - * It can generate multiple forms: - * - `ß` => `['ß', 'SS', 'ss']` - * - `a` => `['a', 'A']` - * - `A` => `['A', 'z']` - * - `Å` => `['A', 'z']` - * @param letter - the letter to generate upper and lower cases. - * @param locale - the locale to use for changing case. - * @returns the set of found cases. - */ -export function caseForms(letter, locale) { - const forms = new Set([letter]); - function tryCases(s) { - forms.add(s.toLocaleLowerCase(locale)); - forms.add(s.toLocaleUpperCase(locale)); - } - tryCases(letter); - [...forms].forEach(tryCases); - return [...forms].filter((a) => !!a); -} -/** - * Generate the different normalized forms of the letters. - * @param letter - letter to normalize. - * @returns combined set of possible forms. - */ -export function accentForms(letter) { - const forms = new Set([letter, letter.normalize('NFC'), letter.normalize('NFD')]); - return forms; -} -/** - * Remove all accents. - * @param characters - unicode characters - * @returns characters with accents removed (if it was possible) - */ -export function stripAccents(characters) { - return characters.normalize('NFD').replace(/\p{M}/gu, ''); -} -/** - * Remove all non accent characters from a string. - * @param characters - characters with accents. - * @returns - only the accents. - */ -export function stripNonAccents(characters) { - return characters.normalize('NFD').replace(/[^\p{M}]/gu, ''); -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/timer.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/timer.js deleted file mode 100644 index d6ab80263..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/timer.js +++ /dev/null @@ -1,22 +0,0 @@ -const _hrTime = process?.hrtime || polyHrTime; -export function createTimer(hrTimeFn = _hrTime) { - let start = hrTimeFn(); - return { - start() { - start = hrTimeFn(); - }, - elapsed() { - return toMilliseconds(hrTimeFn(start)); - }, - }; -} -export function toMilliseconds(t) { - return (t[0] + t[1] * 1e-9) * 1000; -} -export function polyHrTime(time) { - const now = Date.now() - (time ? toMilliseconds(time) : 0); - const inSeconds = now * 1.0e-3; - const s = Math.floor(inSeconds); - const n = (inSeconds - s) * 1.0e9; - return [s, n]; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/util.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/util.js deleted file mode 100644 index f925b1c45..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/utils/util.js +++ /dev/null @@ -1,71 +0,0 @@ -export function isDefined(a) { - return a !== undefined; -} -/** - * Remove any fields with an `undefined` value. - * @param t - object to clean - * @returns t - */ -export function cleanCopy(t) { - const r = { ...t }; - return clean(r); -} -/** - * Remove any fields with an `undefined` value. - * **MODIFIES THE OBJECT** - * @param t - object to clean - * @returns t - */ -export function clean(t) { - for (const prop in t) { - if (t[prop] === undefined) { - delete t[prop]; - } - } - return t; -} -export function unique(a) { - return [...new Set(a)]; -} -export function* flatten(i) { - for (const v of i) { - yield* v; - } -} -export function replaceAll(text, match, withText) { - const fn = replaceAllFactory(match, withText); - return fn(text); -} -/** - * - * @param text verbatim text to be inserted into a regexp - * @returns text that can be used in a regexp. - */ -export function regexQuote(text) { - return text.replace(/([[\]\-+(){},|*.\\])/g, '\\$1'); -} -/** - * Factory to create a function that will replace all occurrences of `match` with `withText` - * @param match - string to match - * @param replaceWithText - the text to substitute. - */ -export function replaceAllFactory(match, replaceWithText) { - const r = RegExp(regexQuote(match), 'g'); - return (text) => text.replace(r, replaceWithText); -} -/** - * Shallow is Equal test. - * @param a - array of values - * @param b - array of values - * @returns true if the values of `a` are exactly equal to the values of `b` - */ -export function isArrayEqual(a, b) { - if (a === b) - return true; - let isMatch = a.length === b.length; - const len = a.length; - for (let i = 0; isMatch && i < len; ++i) { - isMatch = a[i] === b[i]; - } - return isMatch; -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/hintedWalker.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/hintedWalker.js deleted file mode 100644 index baf1b19f7..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/hintedWalker.js +++ /dev/null @@ -1,103 +0,0 @@ -import { isDefined } from '../utils/isDefined.js'; -import { CompoundWordsMethod, JOIN_SEPARATOR, WORD_SEPARATOR } from './walkerTypes.js'; -export function hintedWalker(root, ignoreCase, hint, compoundingMethod, emitWordSeparator) { - return hintedWalkerNext(root, ignoreCase, hint, compoundingMethod, emitWordSeparator); -} -/** - * Walks the Trie and yields a value at each node. - * next(goDeeper: boolean): - */ -function* hintedWalkerNext(root, ignoreCase, hint, compoundingMethod, emitWordSeparator = '') { - const _compoundingMethod = compoundingMethod ?? CompoundWordsMethod.NONE; - const compoundCharacter = root.compoundCharacter; - const noCaseCharacter = root.stripCaseAndAccentsPrefix; - const rawRoots = [root, ignoreCase ? root.c.get(noCaseCharacter) : undefined].filter(isDefined); - const specialRootsPrefix = existMap([compoundCharacter, noCaseCharacter, root.forbiddenWordPrefix]); - function filterRoot(root) { - const children = root.c?.entries(); - const c = children && [...children].filter(([v]) => !(v in specialRootsPrefix)); - return { - c: c && new Map(c), - }; - } - const roots = rawRoots.map(filterRoot); - const compoundRoots = rawRoots.map((r) => r.c?.get(compoundCharacter)).filter(isDefined); - const setOfCompoundRoots = new Set(compoundRoots); - const rootsForCompoundMethods = roots.concat(compoundRoots); - const compoundMethodRoots = { - [CompoundWordsMethod.NONE]: [], - [CompoundWordsMethod.JOIN_WORDS]: [...rootsForCompoundMethods.map((r) => [JOIN_SEPARATOR, r])], - [CompoundWordsMethod.SEPARATE_WORDS]: [...rootsForCompoundMethods.map((r) => [WORD_SEPARATOR, r])], - }; - function* children(n, hintOffset) { - if (n.c) { - const h = hint.slice(hintOffset, hintOffset + 3) + hint.slice(Math.max(0, hintOffset - 2), hintOffset); - const hints = new Set(h); - const c = n.c; - // First yield the hints - yield* [...hints] - .filter((a) => c.has(a)) - .map((letter) => ({ - letter, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - node: c.get(letter), - hintOffset: hintOffset + 1, - })); - // We don't want to suggest the compound character. - hints.add(compoundCharacter); - // Then yield everything else. - yield* [...c] - .filter((a) => !hints.has(a[0])) - .map(([letter, node]) => ({ - letter, - node, - hintOffset: hintOffset + 1, - })); - if (c.has(compoundCharacter) && !setOfCompoundRoots.has(n)) { - for (const compoundRoot of compoundRoots) { - for (const child of children(compoundRoot, hintOffset)) { - const { letter, node, hintOffset } = child; - yield { letter: emitWordSeparator + letter, node, hintOffset }; - } - } - } - } - if (n.f) { - yield* [...compoundMethodRoots[_compoundingMethod]].map(([letter, node]) => ({ - letter: letter, - node, - hintOffset, - })); - } - } - for (const root of roots) { - let depth = 0; - const stack = []; - const stackText = ['']; - stack[depth] = children(root, depth); - let ir; - while (depth >= 0) { - while (!(ir = stack[depth].next()).done) { - const { letter: char, node, hintOffset } = ir.value; - const text = stackText[depth] + char; - const hinting = (yield { text, node, depth }); - if (hinting && hinting.goDeeper) { - depth++; - stackText[depth] = text; - stack[depth] = children(node, hintOffset); - } - } - depth -= 1; - } - } -} -function existMap(values) { - const m = Object.create(null); - for (const v of values) { - m[v] = true; - } - return m; -} -export const __testing__ = { - hintedWalkerNext, -}; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/index.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/index.js deleted file mode 100644 index 2f82f510d..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/index.js +++ /dev/null @@ -1,3 +0,0 @@ -export { hintedWalker } from './hintedWalker.js'; -export * from './walker.js'; -export * from './walkerTypes.js'; diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/walker.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/walker.js deleted file mode 100644 index ccacd889a..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/walker.js +++ /dev/null @@ -1,38 +0,0 @@ -import { CompoundWordsMethod, JOIN_SEPARATOR, WORD_SEPARATOR } from './walkerTypes.js'; -/** - * Walks the Trie and yields a value at each node. - * next(goDeeper: boolean): - */ -export function* walker(root, compoundingMethod = CompoundWordsMethod.NONE) { - const roots = { - [CompoundWordsMethod.NONE]: [], - [CompoundWordsMethod.JOIN_WORDS]: [[JOIN_SEPARATOR, root]], - [CompoundWordsMethod.SEPARATE_WORDS]: [[WORD_SEPARATOR, root]], - }; - function* children(n) { - if (n.c) { - yield* n.c; - } - if (n.f) { - yield* roots[compoundingMethod]; - } - } - let depth = 0; - const stack = []; - stack[depth] = { t: '', c: children(root) }; - let ir; - while (depth >= 0) { - let baseText = stack[depth].t; - while (!(ir = stack[depth].c.next()).done) { - const [char, node] = ir.value; - const text = baseText + char; - const goDeeper = yield { text, node, depth }; - if (goDeeper || goDeeper === undefined) { - depth++; - baseText = text; - stack[depth] = { t: text, c: children(node) }; - } - } - depth -= 1; - } -} diff --git a/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/walkerTypes.js b/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/walkerTypes.js deleted file mode 100644 index 75fd06a06..000000000 --- a/action/node_modules/cspell-trie-lib/dist/esm/lib/walker/walkerTypes.js +++ /dev/null @@ -1,17 +0,0 @@ -export const JOIN_SEPARATOR = '+'; -export const WORD_SEPARATOR = ' '; -export var CompoundWordsMethod; -(function (CompoundWordsMethod) { - /** - * Do not compound words. - */ - CompoundWordsMethod[CompoundWordsMethod["NONE"] = 0] = "NONE"; - /** - * Create word compounds separated by spaces. - */ - CompoundWordsMethod[CompoundWordsMethod["SEPARATE_WORDS"] = 1] = "SEPARATE_WORDS"; - /** - * Create word compounds without separation. - */ - CompoundWordsMethod[CompoundWordsMethod["JOIN_WORDS"] = 2] = "JOIN_WORDS"; -})(CompoundWordsMethod || (CompoundWordsMethod = {})); diff --git a/action/node_modules/cspell-trie-lib/package.json b/action/node_modules/cspell-trie-lib/package.json index f4444a9d2..c258f9d7a 100644 --- a/action/node_modules/cspell-trie-lib/package.json +++ b/action/node_modules/cspell-trie-lib/package.json @@ -1,6 +1,6 @@ { "name": "cspell-trie-lib", - "version": "6.28.0", + "version": "6.29.1", "description": "Trie Data Structure to support cspell.", "type": "commonjs", "main": "dist/cjs/index.js", @@ -14,6 +14,8 @@ }, "files": [ "dist", + "!dist/esm/**/*.js", + "!dist/esm/**/*.ts", "!**/*.tsbuildInfo", "!**/__mocks__", "!**/test/**", @@ -48,8 +50,8 @@ }, "homepage": "https://github.com/streetsidesoftware/cspell#readme", "dependencies": { - "@cspell/cspell-pipe": "6.28.0", - "@cspell/cspell-types": "6.28.0", + "@cspell/cspell-pipe": "6.29.1", + "@cspell/cspell-types": "6.29.1", "gensequence": "^5.0.2" }, "engines": { @@ -59,5 +61,5 @@ "@cspell/dict-en_us": "^3.0.0", "@cspell/dict-es-es": "^2.2.4" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/cspell/bin.js b/action/node_modules/cspell/bin.js index b5936e661..d27ded89e 100755 --- a/action/node_modules/cspell/bin.js +++ b/action/node_modules/cspell/bin.js @@ -1,7 +1,7 @@ #!/usr/bin/env node 'use strict'; -const app = require('./dist/app'); +const app = require('./dist/cjs/app'); const program = require('commander'); app.run(program, process.argv).catch((e) => { diff --git a/action/node_modules/cspell/bin.mjs b/action/node_modules/cspell/bin.mjs new file mode 100755 index 000000000..62c5fc152 --- /dev/null +++ b/action/node_modules/cspell/bin.mjs @@ -0,0 +1,15 @@ +#!/usr/bin/env node +import { program } from 'commander'; + +import * as app from './dist/esm/app.mjs'; + +app.run(program, process.argv).catch((e) => { + if (!(e instanceof program.CommanderError) && !(e instanceof app.CheckFailed)) { + console.log(e); + // It is possible an explicit exit code was set, use it if it was. + process.exitCode = process.exitCode || 1; + } + if (e instanceof app.CheckFailed) { + process.exitCode = e.exitCode; + } +}); diff --git a/action/node_modules/cspell/dist/app.js b/action/node_modules/cspell/dist/cjs/app.js similarity index 52% rename from action/node_modules/cspell/dist/app.js rename to action/node_modules/cspell/dist/cjs/app.js index 87194cbb7..13598491c 100644 --- a/action/node_modules/cspell/dist/app.js +++ b/action/node_modules/cspell/dist/cjs/app.js @@ -3,32 +3,31 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.run = exports.CheckFailed = void 0; const commander_1 = require("commander"); const semver_1 = require("semver"); -const commandCheck_1 = require("./commandCheck"); -const commandLink_1 = require("./commandLink"); -const commandLint_1 = require("./commandLint"); -const commandSuggestion_1 = require("./commandSuggestion"); -const commandTrace_1 = require("./commandTrace"); -const errors_1 = require("./util/errors"); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const npmPackage = require('../package.json'); -var errors_2 = require("./util/errors"); -Object.defineProperty(exports, "CheckFailed", { enumerable: true, get: function () { return errors_2.CheckFailed; } }); +const pkgInfo_cjs_1 = require("../lib/pkgInfo.cjs"); +const commandCheck_js_1 = require("./commandCheck.js"); +const commandLink_js_1 = require("./commandLink.js"); +const commandLint_js_1 = require("./commandLint.js"); +const commandSuggestion_js_1 = require("./commandSuggestion.js"); +const commandTrace_js_1 = require("./commandTrace.js"); +const errors_js_1 = require("./util/errors.js"); +var errors_js_2 = require("./util/errors.js"); +Object.defineProperty(exports, "CheckFailed", { enumerable: true, get: function () { return errors_js_2.CheckFailed; } }); async function run(command, argv) { const prog = command || commander_1.program; const args = argv || process.argv; prog.exitOverride(); - prog.version(npmPackage.version).description('Spelling Checker for Code').name('cspell'); - if (!(0, semver_1.satisfies)(process.versions.node, npmPackage.engines.node)) { - throw new errors_1.ApplicationError(`Unsupported NodeJS version (${process.versions.node}); ${npmPackage.engines.node} is required`); + prog.version(pkgInfo_cjs_1.npmPackage.version).description('Spelling Checker for Code').name('cspell'); + if (!(0, semver_1.satisfies)(process.versions.node, pkgInfo_cjs_1.npmPackage.engines.node)) { + throw new errors_js_1.ApplicationError(`Unsupported NodeJS version (${process.versions.node}); ${pkgInfo_cjs_1.npmPackage.engines.node} is required`); } const optionFlags = new commander_1.Option('-f,--flag ', 'Declare an execution flag value') .hideHelp() .argParser((value, prev) => prev?.concat(value) || [value]); - (0, commandLint_1.commandLint)(prog).addOption(optionFlags); - (0, commandTrace_1.commandTrace)(prog).addOption(optionFlags); - (0, commandCheck_1.commandCheck)(prog).addOption(optionFlags); - (0, commandSuggestion_1.commandSuggestion)(prog).addOption(optionFlags); - (0, commandLink_1.commandLink)(prog); + (0, commandLint_js_1.commandLint)(prog).addOption(optionFlags); + (0, commandTrace_js_1.commandTrace)(prog).addOption(optionFlags); + (0, commandCheck_js_1.commandCheck)(prog).addOption(optionFlags); + (0, commandSuggestion_js_1.commandSuggestion)(prog).addOption(optionFlags); + (0, commandLink_js_1.commandLink)(prog); /* program .command('init') diff --git a/action/node_modules/cspell/dist/application.js b/action/node_modules/cspell/dist/cjs/application.js similarity index 64% rename from action/node_modules/cspell/dist/application.js rename to action/node_modules/cspell/dist/cjs/application.js index b70f92aaa..eaef7c720 100644 --- a/action/node_modules/cspell/dist/application.js +++ b/action/node_modules/cspell/dist/cjs/application.js @@ -26,39 +26,39 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.parseApplicationFeatureFlags = exports.createInit = exports.suggestions = exports.checkText = exports.trace = exports.lint = exports.IncludeExcludeFlag = void 0; const cspell_pipe_1 = require("@cspell/cspell-pipe"); const cspell_lib_1 = require("cspell-lib"); -const cli_reporter_1 = require("./cli-reporter"); -const featureFlags_1 = require("./featureFlags"); -const lint_1 = require("./lint"); -const options_1 = require("./options"); -const repl_1 = require("./repl"); -const fileHelper_1 = require("./util/fileHelper"); -const reporters_1 = require("./util/reporters"); -const stdin_1 = require("./util/stdin"); -const timer_1 = require("./util/timer"); -const util = __importStar(require("./util/util")); +const cli_reporter_js_1 = require("./cli-reporter.js"); +const index_js_1 = require("./featureFlags/index.js"); +const index_js_2 = require("./lint/index.js"); +const options_js_1 = require("./options.js"); +const index_js_3 = require("./repl/index.js"); +const fileHelper_js_1 = require("./util/fileHelper.js"); +const reporters_js_1 = require("./util/reporters.js"); +const stdin_js_1 = require("./util/stdin.js"); +const timer_js_1 = require("./util/timer.js"); +const util = __importStar(require("./util/util.js")); var cspell_lib_2 = require("cspell-lib"); Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return cspell_lib_2.IncludeExcludeFlag; } }); function lint(fileGlobs, options, reporter) { - options = (0, options_1.fixLegacy)(options); - const cfg = new lint_1.LintRequest(fileGlobs, options, (0, reporters_1.finalizeReporter)(reporter) ?? (0, cli_reporter_1.getReporter)({ ...options, fileGlobs })); - return (0, lint_1.runLint)(cfg); + options = (0, options_js_1.fixLegacy)(options); + const cfg = new index_js_2.LintRequest(fileGlobs, options, (0, reporters_js_1.finalizeReporter)(reporter) ?? (0, cli_reporter_js_1.getReporter)({ ...options, fileGlobs })); + return (0, index_js_2.runLint)(cfg); } exports.lint = lint; async function* trace(words, options) { - options = (0, options_1.fixLegacy)(options); - const iWords = options.stdin ? (0, cspell_pipe_1.toAsyncIterable)(words, (0, stdin_1.readStdin)()) : words; + options = (0, options_js_1.fixLegacy)(options); + const iWords = options.stdin ? (0, cspell_pipe_1.toAsyncIterable)(words, (0, stdin_js_1.readStdin)()) : words; const { languageId, locale, allowCompoundWords, ignoreCase } = options; - const configFile = await (0, fileHelper_1.readConfig)(options.config, undefined); + const configFile = await (0, fileHelper_js_1.readConfig)(options.config, undefined); const loadDefault = options.defaultConfiguration ?? configFile.config.loadDefaultConfiguration ?? true; const config = (0, cspell_lib_1.mergeSettings)((0, cspell_lib_1.getDefaultSettings)(loadDefault), (0, cspell_lib_1.getGlobalSettings)(), configFile.config); - yield* (0, cspell_lib_1.traceWordsAsync)(iWords, config, { languageId, locale, ignoreCase, allowCompoundWords }); + yield* (0, cspell_lib_1.traceWordsAsync)(iWords, config, util.clean({ languageId, locale, ignoreCase, allowCompoundWords })); } exports.trace = trace; async function checkText(filename, options) { - options = (0, options_1.fixLegacy)(options); - const fileInfo = await (0, fileHelper_1.readFileInfo)(filename); + options = (0, options_js_1.fixLegacy)(options); + const fileInfo = await (0, fileHelper_js_1.readFileInfo)(filename); const { locale, languageId, validateDirectives } = options; - const doc = (0, fileHelper_1.fileInfoToDocument)(fileInfo, languageId, locale); + const doc = (0, fileHelper_js_1.fileInfoToDocument)(fileInfo, languageId, locale); const checkOptions = { configFile: options.config, validateDirectives, @@ -68,15 +68,15 @@ async function checkText(filename, options) { language: locale, loadDefaultConfiguration: options.defaultConfiguration, }); - return (0, cspell_lib_1.checkTextDocument)(doc, checkOptions, settingsFromCommandLine); + return (0, cspell_lib_1.checkTextDocument)(doc, util.clean({ ...checkOptions }), settingsFromCommandLine); } exports.checkText = checkText; async function* suggestions(words, options) { - options = (0, options_1.fixLegacy)(options); - const configFile = await (0, fileHelper_1.readConfig)(options.config, undefined); + options = (0, options_js_1.fixLegacy)(options); + const configFile = await (0, fileHelper_js_1.readConfig)(options.config, undefined); let timer; function tapStart() { - timer = (0, timer_1.getTimeMeasurer)(); + timer = (0, timer_js_1.getTimeMeasurer)(); } function mapStart(v) { tapStart(); @@ -84,15 +84,15 @@ async function* suggestions(words, options) { } function mapEnd(v) { const elapsedTimeMs = timer?.(); - return { ...v, elapsedTimeMs }; + return elapsedTimeMs ? { ...v, elapsedTimeMs } : v; } const iWords = options.repl - ? (0, cspell_pipe_1.pipeAsync)((0, cspell_pipe_1.toAsyncIterable)(words, (0, repl_1.simpleRepl)()), (0, cspell_pipe_1.opTap)(tapStart)) + ? (0, cspell_pipe_1.pipeAsync)((0, cspell_pipe_1.toAsyncIterable)(words, (0, index_js_3.simpleRepl)()), (0, cspell_pipe_1.opTap)(tapStart)) : options.useStdin - ? (0, cspell_pipe_1.pipeAsync)((0, cspell_pipe_1.toAsyncIterable)(words, (0, stdin_1.readStdin)()), (0, cspell_pipe_1.opTap)(tapStart)) + ? (0, cspell_pipe_1.pipeAsync)((0, cspell_pipe_1.toAsyncIterable)(words, (0, stdin_js_1.readStdin)()), (0, cspell_pipe_1.opTap)(tapStart)) : words.map(mapStart); try { - const results = (0, cspell_pipe_1.pipeAsync)((0, cspell_lib_1.suggestionsForWords)(iWords, options, configFile.config), (0, cspell_pipe_1.opMap)(mapEnd)); + const results = (0, cspell_pipe_1.pipeAsync)((0, cspell_lib_1.suggestionsForWords)(iWords, util.clean({ ...options }), configFile.config), (0, cspell_pipe_1.opMap)(mapEnd)); yield* results; } catch (e) { @@ -108,14 +108,14 @@ function createInit() { } exports.createInit = createInit; function registerApplicationFeatureFlags() { - const ff = (0, featureFlags_1.getFeatureFlags)(); + const ff = (0, index_js_1.getFeatureFlags)(); const flags = [{ name: 'timer', description: 'Display elapsed time for command.' }]; flags.forEach((flag) => ff.register(flag)); return ff; } function parseApplicationFeatureFlags(flags) { const ff = registerApplicationFeatureFlags(); - return (0, featureFlags_1.parseFeatureFlags)(flags, ff); + return (0, index_js_1.parseFeatureFlags)(flags, ff); } exports.parseApplicationFeatureFlags = parseApplicationFeatureFlags; //# sourceMappingURL=application.js.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/cli-reporter.js b/action/node_modules/cspell/dist/cjs/cli-reporter.js similarity index 97% rename from action/node_modules/cspell/dist/cli-reporter.js rename to action/node_modules/cspell/dist/cjs/cli-reporter.js index c49971ebe..18fc07eba 100644 --- a/action/node_modules/cspell/dist/cli-reporter.js +++ b/action/node_modules/cspell/dist/cjs/cli-reporter.js @@ -30,7 +30,7 @@ exports.__testing__ = exports.getReporter = void 0; const chalk_1 = __importDefault(require("chalk")); const cspell_lib_1 = require("cspell-lib"); const path = __importStar(require("path")); -const vscode_uri_1 = require("vscode-uri"); +const uri_cjs_1 = require("../lib/uri.cjs"); const templateIssue = `{green $filename}:{yellow $row:$col} - $message ({red $text})`; const templateIssueWithSuggestions = `{green $filename}:{yellow $row:$col} - $message ({red $text}) Suggestions: {yellow [$suggestions]}`; const templateIssueWithContext = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}`; @@ -66,7 +66,7 @@ function relativeFilename(filename, cwd = process.cwd()) { return '.' + path.sep + rel; } function relativeUriFilename(uri, fsPathRoot) { - const fsPath = vscode_uri_1.URI.parse(uri).fsPath; + const fsPath = uri_cjs_1.URI.parse(uri).fsPath; const rel = path.relative(fsPathRoot, fsPath); if (rel.startsWith('..')) return fsPath; @@ -122,12 +122,12 @@ function getReporter(options) { function infoEmitter(message, msgType) { emitters[msgType]?.(message); } - const root = vscode_uri_1.URI.file(options.root || process.cwd()); + const root = uri_cjs_1.URI.file(options.root || process.cwd()); const fsPathRoot = root.fsPath; function relativeIssue(fn) { const fnFilename = options.relative ? (uri) => relativeUriFilename(uri, fsPathRoot) - : (uri) => vscode_uri_1.URI.parse(uri).fsPath; + : (uri) => uri_cjs_1.URI.parse(uri).fsPath; return (i) => { const filename = i.uri ? fnFilename(i.uri) : ''; const r = { ...i, filename }; diff --git a/action/node_modules/cspell/dist/commandCheck.js b/action/node_modules/cspell/dist/cjs/commandCheck.js similarity index 89% rename from action/node_modules/cspell/dist/commandCheck.js rename to action/node_modules/cspell/dist/cjs/commandCheck.js index 09e587997..73b51a528 100644 --- a/action/node_modules/cspell/dist/commandCheck.js +++ b/action/node_modules/cspell/dist/cjs/commandCheck.js @@ -29,9 +29,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.commandCheck = void 0; const chalk_1 = __importDefault(require("chalk")); const commander_1 = require("commander"); -const App = __importStar(require("./application")); -const application_1 = require("./application"); -const errors_1 = require("./util/errors"); +const App = __importStar(require("./application.js")); +const application_js_1 = require("./application.js"); +const errors_js_1 = require("./util/errors.js"); function commandCheck(prog) { return prog .command('check ') @@ -50,7 +50,7 @@ function commandCheck(prog) { console.log(chalk_1.default.yellowBright(`Check file: ${filename}`)); console.log(); try { - const result = await (0, application_1.checkText)(filename, options); + const result = await (0, application_js_1.checkText)(filename, options); for (const item of result.items) { const fn = item.flagIE === App.IncludeExcludeFlag.EXCLUDE ? chalk_1.default.gray @@ -65,12 +65,12 @@ function commandCheck(prog) { } catch (e) { console.error(`File not found "${filename}"`); - throw new errors_1.CheckFailed('File not found', 1); + throw new errors_js_1.CheckFailed('File not found', 1); } console.log(); } if (issueCount) { - throw new errors_1.CheckFailed('Issues found', 1); + throw new errors_js_1.CheckFailed('Issues found', 1); } }); } diff --git a/action/node_modules/cspell/dist/commandLink.js b/action/node_modules/cspell/dist/cjs/commandLink.js similarity index 60% rename from action/node_modules/cspell/dist/commandLink.js rename to action/node_modules/cspell/dist/cjs/commandLink.js index 2c416672a..89b085047 100644 --- a/action/node_modules/cspell/dist/commandLink.js +++ b/action/node_modules/cspell/dist/cjs/commandLink.js @@ -1,9 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.commandLink = void 0; -const link_1 = require("./link"); -const errors_1 = require("./util/errors"); -const table_1 = require("./util/table"); +const link_js_1 = require("./link.js"); +const errors_js_1 = require("./util/errors.js"); +const table_js_1 = require("./util/table.js"); function commandLink(prog) { const linkCommand = prog .command('link') @@ -13,9 +13,9 @@ function commandLink(prog) { .alias('ls') .description('List currently linked configurations.') .action(() => { - const imports = (0, link_1.listGlobalImports)(); - const table = (0, link_1.listGlobalImportsResultToTable)(imports.list); - (0, table_1.tableToLines)(table).forEach((line) => console.log(line)); + const imports = (0, link_js_1.listGlobalImports)(); + const table = (0, link_js_1.listGlobalImportsResultToTable)(imports.list); + (0, table_js_1.tableToLines)(table).forEach((line) => console.log(line)); return; }); linkCommand @@ -23,12 +23,12 @@ function commandLink(prog) { .alias('a') .description('Add dictionaries any other settings to the cspell global config.') .action((dictionaries) => { - const r = (0, link_1.addPathsToGlobalImports)(dictionaries); - const table = (0, link_1.addPathsToGlobalImportsResultToTable)(r); + const r = (0, link_js_1.addPathsToGlobalImports)(dictionaries); + const table = (0, link_js_1.addPathsToGlobalImportsResultToTable)(r); console.log('Adding:'); - (0, table_1.tableToLines)(table).forEach((line) => console.log(line)); + (0, table_js_1.tableToLines)(table).forEach((line) => console.log(line)); if (r.error) { - throw new errors_1.CheckFailed(r.error, 1); + throw new errors_js_1.CheckFailed(r.error, 1); } return; }); @@ -37,10 +37,10 @@ function commandLink(prog) { .alias('r') .description('Remove matching paths / packages from the global config.') .action((dictionaries) => { - const r = (0, link_1.removePathsFromGlobalImports)(dictionaries); + const r = (0, link_js_1.removePathsFromGlobalImports)(dictionaries); console.log('Removing:'); if (r.error) { - throw new errors_1.CheckFailed(r.error, 1); + throw new errors_js_1.CheckFailed(r.error, 1); } r.removed.map((f) => console.log(f)); return; diff --git a/action/node_modules/cspell/dist/commandLint.js b/action/node_modules/cspell/dist/cjs/commandLint.js similarity index 95% rename from action/node_modules/cspell/dist/commandLint.js rename to action/node_modules/cspell/dist/cjs/commandLint.js index 590e94bfb..d164c0b22 100644 --- a/action/node_modules/cspell/dist/commandLint.js +++ b/action/node_modules/cspell/dist/cjs/commandLint.js @@ -25,9 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.commandLint = void 0; const commander_1 = require("commander"); -const App = __importStar(require("./application")); -const cache_1 = require("./util/cache"); -const errors_1 = require("./util/errors"); +const App = __importStar(require("./application.js")); +const index_js_1 = require("./util/cache/index.js"); +const errors_js_1 = require("./util/errors.js"); // interface InitOptions extends Options {} const usage = `\ [options] [globs...] [file:// ...] [stdin[://]] @@ -113,7 +113,7 @@ function commandLint(prog) { 'metadata', 'content', ])) - .option('--cache-location ', `Path to the cache file or directory. (default: "${cache_1.DEFAULT_CACHE_LOCATION}")`) + .option('--cache-location ', `Path to the cache file or directory. (default: "${index_js_1.DEFAULT_CACHE_LOCATION}")`) .option('--dot', 'Include files and directories starting with `.` (period) when matching globs.') .option('--gitignore', 'Ignore files matching glob patterns found in .gitignore files.') .option('--no-gitignore', 'Do NOT use .gitignore files.') @@ -135,10 +135,10 @@ function commandLint(prog) { return App.lint(fileGlobs, options).then((result) => { if (!fileGlobs.length && !result.files && !result.errors && !fileList) { spellCheckCommand.outputHelp(); - throw new errors_1.CheckFailed('outputHelp', 1); + throw new errors_js_1.CheckFailed('outputHelp', 1); } if (result.issues || result.errors || (mustFindFiles && !result.files)) { - throw new errors_1.CheckFailed('check failed', 1); + throw new errors_js_1.CheckFailed('check failed', 1); } return; }); diff --git a/action/node_modules/cspell/dist/commandSuggestion.js b/action/node_modules/cspell/dist/cjs/commandSuggestion.js similarity index 92% rename from action/node_modules/cspell/dist/commandSuggestion.js rename to action/node_modules/cspell/dist/cjs/commandSuggestion.js index 563c82edb..c6ca8dea1 100644 --- a/action/node_modules/cspell/dist/commandSuggestion.js +++ b/action/node_modules/cspell/dist/cjs/commandSuggestion.js @@ -25,9 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.commandSuggestion = void 0; const commander_1 = require("commander"); -const App = __importStar(require("./application")); -const suggestionsEmitter_1 = require("./emitters/suggestionsEmitter"); -const errors_1 = require("./util/errors"); +const App = __importStar(require("./application.js")); +const suggestionsEmitter_js_1 = require("./emitters/suggestionsEmitter.js"); +const errors_js_1 = require("./util/errors.js"); function collect(value, previous) { value = value.replace(/^=/, ''); if (!previous) { @@ -69,10 +69,10 @@ function commandSuggestion(prog) { options.dictionaries = mergeArrays(options.dictionaries, options.dictionary); if (!words.length && !options.useStdin && !options.repl) { suggestionCommand.outputHelp(); - throw new errors_1.CheckFailed('outputHelp', 1); + throw new errors_js_1.CheckFailed('outputHelp', 1); } for await (const r of App.suggestions(words, options)) { - (0, suggestionsEmitter_1.emitSuggestionResult)(r, options); + (0, suggestionsEmitter_js_1.emitSuggestionResult)(r, options); } }); return suggestionCommand; diff --git a/action/node_modules/cspell/dist/commandTrace.js b/action/node_modules/cspell/dist/cjs/commandTrace.js similarity index 87% rename from action/node_modules/cspell/dist/commandTrace.js rename to action/node_modules/cspell/dist/cjs/commandTrace.js index 96b289ec3..e52631115 100644 --- a/action/node_modules/cspell/dist/commandTrace.js +++ b/action/node_modules/cspell/dist/cjs/commandTrace.js @@ -25,10 +25,10 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.commandTrace = void 0; const commander_1 = require("commander"); -const App = __importStar(require("./application")); -const DictionaryPathFormat_1 = require("./emitters/DictionaryPathFormat"); -const traceEmitter_1 = require("./emitters/traceEmitter"); -const errors_1 = require("./util/errors"); +const App = __importStar(require("./application.js")); +const DictionaryPathFormat_js_1 = require("./emitters/DictionaryPathFormat.js"); +const traceEmitter_js_1 = require("./emitters/traceEmitter.js"); +const errors_js_1 = require("./util/errors.js"); function commandTrace(prog) { return prog .command('trace') @@ -56,22 +56,22 @@ function commandTrace(prog) { .action(async (words, options) => { App.parseApplicationFeatureFlags(options.flag); let numFound = 0; - const dictionaryPathFormat = (0, DictionaryPathFormat_1.isDictionaryPathFormat)(options.dictionaryPath) + const dictionaryPathFormat = (0, DictionaryPathFormat_js_1.isDictionaryPathFormat)(options.dictionaryPath) ? options.dictionaryPath : 'long'; for await (const results of App.trace(words, options)) { const filtered = filterTraceResults(results, options); - (0, traceEmitter_1.emitTraceResults)(filtered, { cwd: process.cwd(), dictionaryPathFormat }); + (0, traceEmitter_js_1.emitTraceResults)(filtered, { cwd: process.cwd(), dictionaryPathFormat }); numFound += results.reduce((n, r) => n + (r.found ? 1 : 0), 0); const numErrors = results.map((r) => r.errors?.length || 0).reduce((n, r) => n + r, 0); if (numErrors) { console.error('Dictionary Errors.'); - throw new errors_1.CheckFailed('dictionary errors', 1); + throw new errors_js_1.CheckFailed('dictionary errors', 1); } } if (!numFound) { console.error('No matches found'); - throw new errors_1.CheckFailed('no matches', 1); + throw new errors_js_1.CheckFailed('no matches', 1); } }); } diff --git a/action/node_modules/cspell/dist/emitters/DictionaryPathFormat.js b/action/node_modules/cspell/dist/cjs/emitters/DictionaryPathFormat.js similarity index 100% rename from action/node_modules/cspell/dist/emitters/DictionaryPathFormat.js rename to action/node_modules/cspell/dist/cjs/emitters/DictionaryPathFormat.js diff --git a/action/node_modules/cspell/dist/emitters/suggestionsEmitter.js b/action/node_modules/cspell/dist/cjs/emitters/suggestionsEmitter.js similarity index 92% rename from action/node_modules/cspell/dist/emitters/suggestionsEmitter.js rename to action/node_modules/cspell/dist/cjs/emitters/suggestionsEmitter.js index 3413763b1..2188e4f7f 100644 --- a/action/node_modules/cspell/dist/emitters/suggestionsEmitter.js +++ b/action/node_modules/cspell/dist/cjs/emitters/suggestionsEmitter.js @@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.emitSuggestionResult = void 0; const chalk_1 = __importDefault(require("chalk")); -const util_1 = require("../util/util"); +const util_js_1 = require("../util/util.js"); const regExpRTL = /([\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC י]+)/g; function reverseRtlText(s) { return s.replace(regExpRTL, (s) => s.split('').reverse().join('')); @@ -30,11 +30,11 @@ function emitSuggestionResult(result, options) { ...s, w: handleRtl(s.compoundWord || s.wordAdjustedToMatchCase || s.word), })); - const sugWidths = mappedSugs.map((s) => (0, util_1.width)(s.w)); + const sugWidths = mappedSugs.map((s) => (0, util_js_1.width)(s.w)); const maxWidth = sugWidths.reduce((max, len) => Math.max(max, len), 0); for (const sug of mappedSugs) { const { cost, dictionaries, w } = sug; - const padding = ' '.repeat((0, util_1.padWidth)(w, maxWidth)); + const padding = ' '.repeat((0, util_js_1.padWidth)(w, maxWidth)); const forbid = sug.forbidden && sug.isPreferred ? chalk_1.default.red('*') : sug.forbidden @@ -43,7 +43,7 @@ function emitSuggestionResult(result, options) { ? chalk_1.default.yellow('*') : ' '; const ignore = sug.noSuggest ? chalk_1.default.yellow('N') : ' '; - const strCost = (0, util_1.padLeft)(cost.toString(10), 4); + const strCost = (0, util_js_1.padLeft)(cost.toString(10), 4); const dicts = dictionaries.map((n) => chalk_1.default.gray(n)).join(', '); output.log(` - ${formatWord(w, sug)}${padding} ${forbid}${ignore} - ${chalk_1.default.yellow(strCost)} ${dicts}`); } diff --git a/action/node_modules/cspell/dist/emitters/traceEmitter.js b/action/node_modules/cspell/dist/cjs/emitters/traceEmitter.js similarity index 91% rename from action/node_modules/cspell/dist/emitters/traceEmitter.js rename to action/node_modules/cspell/dist/cjs/emitters/traceEmitter.js index 1e41bf723..40732344c 100644 --- a/action/node_modules/cspell/dist/emitters/traceEmitter.js +++ b/action/node_modules/cspell/dist/cjs/emitters/traceEmitter.js @@ -30,12 +30,12 @@ exports.__testing__ = exports.emitTraceResults = void 0; const chalk_1 = __importDefault(require("chalk")); const iPath = __importStar(require("path")); const strip_ansi_1 = __importDefault(require("strip-ansi")); -const util_1 = require("../util/util"); +const util_js_1 = require("../util/util.js"); const colWidthDictionaryName = 20; function emitTraceResults(results, options) { const maxWordLength = results .map((r) => r.foundWord || r.word) - .reduce((a, b) => Math.max(a, (0, util_1.width)(b)), 'Word'.length); + .reduce((a, b) => Math.max(a, (0, util_js_1.width)(b)), 'Word'.length); const maxDictNameLength = results .map((r) => r.dictName.length) .reduce((a, b) => Math.max(a, b), colWidthDictionaryName); @@ -53,26 +53,26 @@ function emitTraceResults(results, options) { exports.emitTraceResults = emitTraceResults; function emitHeader(colWidths) { const line = [ - (0, util_1.pad)('Word', colWidths.word), + (0, util_js_1.pad)('Word', colWidths.word), 'F', - (0, util_1.pad)('Dictionary', colWidths.dictName), - colWidths.location ? (0, util_1.pad)('Dictionary Location', colWidths.location) : '', + (0, util_js_1.pad)('Dictionary', colWidths.dictName), + colWidths.location ? (0, util_js_1.pad)('Dictionary Location', colWidths.location) : '', ]; console.log(chalk_1.default.underline(line.join(' ').trim().slice(0, colWidths.terminalWidth))); } function emitTraceResult(r, colWidths, options) { const { word: wordColWidth, terminalWidth, dictName: widthName } = colWidths; const errors = r.errors?.map((e) => e.message)?.join('\n\t') || ''; - const word = (0, util_1.pad)(r.foundWord || r.word, wordColWidth); + const word = (0, util_js_1.pad)(r.foundWord || r.word, wordColWidth); const cWord = word.replace(/[+]/g, chalk_1.default.yellow('+')); const w = r.forbidden ? chalk_1.default.red(cWord) : chalk_1.default.green(cWord); const f = calcFoundChar(r); const a = r.dictActive ? '*' : ' '; - const dictName = (0, util_1.pad)(r.dictName.slice(0, widthName - 1) + a, widthName); + const dictName = (0, util_js_1.pad)(r.dictName.slice(0, widthName - 1) + a, widthName); const dictColor = r.dictActive ? chalk_1.default.yellowBright : chalk_1.default.rgb(200, 128, 50); const n = dictColor(dictName); const info = [w, f, n].join(' ') + ' '; - const used = (0, util_1.width)((0, strip_ansi_1.default)(info)); + const used = (0, util_js_1.width)((0, strip_ansi_1.default)(info)); const widthSrc = terminalWidth - used; const c = colorize(errors ? chalk_1.default.red : chalk_1.default.white); const s = c(formatDictionaryLocation(r.dictSource, widthSrc, { iPath, ...options })); diff --git a/action/node_modules/cspell/dist/featureFlags/featureFlags.js b/action/node_modules/cspell/dist/cjs/featureFlags/featureFlags.js similarity index 100% rename from action/node_modules/cspell/dist/featureFlags/featureFlags.js rename to action/node_modules/cspell/dist/cjs/featureFlags/featureFlags.js diff --git a/action/node_modules/cspell/dist/featureFlags/index.js b/action/node_modules/cspell/dist/cjs/featureFlags/index.js similarity index 59% rename from action/node_modules/cspell/dist/featureFlags/index.js rename to action/node_modules/cspell/dist/cjs/featureFlags/index.js index 393b2e083..95c4f6f31 100644 --- a/action/node_modules/cspell/dist/featureFlags/index.js +++ b/action/node_modules/cspell/dist/cjs/featureFlags/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseFeatureFlags = exports.getFeatureFlags = void 0; -var featureFlags_1 = require("./featureFlags"); -Object.defineProperty(exports, "getFeatureFlags", { enumerable: true, get: function () { return featureFlags_1.getFeatureFlags; } }); -Object.defineProperty(exports, "parseFeatureFlags", { enumerable: true, get: function () { return featureFlags_1.parseFeatureFlags; } }); +var featureFlags_js_1 = require("./featureFlags.js"); +Object.defineProperty(exports, "getFeatureFlags", { enumerable: true, get: function () { return featureFlags_js_1.getFeatureFlags; } }); +Object.defineProperty(exports, "parseFeatureFlags", { enumerable: true, get: function () { return featureFlags_js_1.parseFeatureFlags; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/index.js b/action/node_modules/cspell/dist/cjs/index.js similarity index 84% rename from action/node_modules/cspell/dist/index.js rename to action/node_modules/cspell/dist/cjs/index.js index d0d4615cc..9230af760 100644 --- a/action/node_modules/cspell/dist/index.js +++ b/action/node_modules/cspell/dist/cjs/index.js @@ -15,8 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDefaultReporter = void 0; -__exportStar(require("./application"), exports); -var cli_reporter_1 = require("./cli-reporter"); -Object.defineProperty(exports, "getDefaultReporter", { enumerable: true, get: function () { return cli_reporter_1.getReporter; } }); +__exportStar(require("./application.js"), exports); +var cli_reporter_js_1 = require("./cli-reporter.js"); +Object.defineProperty(exports, "getDefaultReporter", { enumerable: true, get: function () { return cli_reporter_js_1.getReporter; } }); __exportStar(require("@cspell/cspell-types"), exports); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/link.js b/action/node_modules/cspell/dist/cjs/link.js similarity index 100% rename from action/node_modules/cspell/dist/link.js rename to action/node_modules/cspell/dist/cjs/link.js diff --git a/action/node_modules/cspell/dist/lint/LintRequest.js b/action/node_modules/cspell/dist/cjs/lint/LintRequest.js similarity index 91% rename from action/node_modules/cspell/dist/lint/LintRequest.js rename to action/node_modules/cspell/dist/cjs/lint/LintRequest.js index e36dd13d2..a77b5f60a 100644 --- a/action/node_modules/cspell/dist/lint/LintRequest.js +++ b/action/node_modules/cspell/dist/cjs/lint/LintRequest.js @@ -25,8 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.LintRequest = void 0; const path = __importStar(require("path")); -const glob_1 = require("../util/glob"); -const util = __importStar(require("../util/util")); +const glob_js_1 = require("../util/glob.js"); +const util = __importStar(require("../util/util.js")); const defaultContextRange = 20; class LintRequest { constructor(fileGlobs, options, reporter) { @@ -35,7 +35,7 @@ class LintRequest { this.reporter = reporter; this.root = path.resolve(options.root || process.cwd()); this.configFile = options.config; - this.excludes = (0, glob_1.calcExcludeGlobInfo)(this.root, options.exclude); + this.excludes = (0, glob_js_1.calcExcludeGlobInfo)(this.root, options.exclude); this.locale = options.locale || ''; this.enableGlobDot = options.dot; this.uniqueFilter = options.unique ? util.uniqueFilterFnGenerator((issue) => issue.text) : () => true; diff --git a/action/node_modules/cspell/dist/lint/index.js b/action/node_modules/cspell/dist/cjs/lint/index.js similarity index 58% rename from action/node_modules/cspell/dist/lint/index.js rename to action/node_modules/cspell/dist/cjs/lint/index.js index 7c46cf8c1..1356d9497 100644 --- a/action/node_modules/cspell/dist/lint/index.js +++ b/action/node_modules/cspell/dist/cjs/lint/index.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LintRequest = exports.runLint = void 0; -var lint_1 = require("./lint"); -Object.defineProperty(exports, "runLint", { enumerable: true, get: function () { return lint_1.runLint; } }); -var LintRequest_1 = require("./LintRequest"); -Object.defineProperty(exports, "LintRequest", { enumerable: true, get: function () { return LintRequest_1.LintRequest; } }); +var lint_js_1 = require("./lint.js"); +Object.defineProperty(exports, "runLint", { enumerable: true, get: function () { return lint_js_1.runLint; } }); +var LintRequest_js_1 = require("./LintRequest.js"); +Object.defineProperty(exports, "LintRequest", { enumerable: true, get: function () { return LintRequest_js_1.LintRequest; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/lint/lint.js b/action/node_modules/cspell/dist/cjs/lint/lint.js similarity index 85% rename from action/node_modules/cspell/dist/lint/lint.js rename to action/node_modules/cspell/dist/cjs/lint/lint.js index 4fd0d2c8c..b99121e3b 100644 --- a/action/node_modules/cspell/dist/lint/lint.js +++ b/action/node_modules/cspell/dist/cjs/lint/lint.js @@ -36,49 +36,48 @@ const cspell_glob_1 = require("cspell-glob"); const cspell = __importStar(require("cspell-lib")); const path = __importStar(require("path")); const util_1 = require("util"); -const vscode_uri_1 = require("vscode-uri"); -const featureFlags_1 = require("../featureFlags"); -const cache_1 = require("../util/cache"); -const errors_1 = require("../util/errors"); -const fileHelper_1 = require("../util/fileHelper"); -const glob_1 = require("../util/glob"); -const prefetch_1 = require("../util/prefetch"); -const reporters_1 = require("../util/reporters"); -const timer_1 = require("../util/timer"); -const util = __importStar(require("../util/util")); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const npmPackage = require('../../package.json'); -const version = npmPackage.version; +const pkgInfo_cjs_1 = require("../../lib/pkgInfo.cjs"); +const uri_cjs_1 = require("../../lib/uri.cjs"); +const index_js_1 = require("../featureFlags/index.js"); +const index_js_2 = require("../util/cache/index.js"); +const errors_js_1 = require("../util/errors.js"); +const fileHelper_js_1 = require("../util/fileHelper.js"); +const glob_js_1 = require("../util/glob.js"); +const prefetch_js_1 = require("../util/prefetch.js"); +const reporters_js_1 = require("../util/reporters.js"); +const timer_js_1 = require("../util/timer.js"); +const util = __importStar(require("../util/util.js")); +const version = pkgInfo_cjs_1.npmPackage.version; const BATCH_SIZE = 8; const { opFilterAsync } = cspell_pipe_1.operators; async function runLint(cfg) { let { reporter } = cfg; cspell.setLogger(getLoggerFromReporter(reporter)); const configErrors = new Set(); - const timer = (0, timer_1.getTimeMeasurer)(); + const timer = (0, timer_js_1.getTimeMeasurer)(); const lintResult = await run(); await reporter.result(lintResult); const elapsed = timer(); - if ((0, featureFlags_1.getFeatureFlags)().getFlag('timer')) { + if ((0, index_js_1.getFeatureFlags)().getFlag('timer')) { console.log(`Elapsed Time: ${elapsed.toFixed(2)}ms`); } return lintResult; function prefetch(filename, configInfo, cache) { - if ((0, fileHelper_1.isBinaryFile)(filename, cfg.root)) + if ((0, fileHelper_js_1.isBinaryFile)(filename, cfg.root)) return { filename, result: Promise.resolve({ skip: true }) }; async function fetch() { - const getElapsedTimeMs = (0, timer_1.getTimeMeasurer)(); + const getElapsedTimeMs = (0, timer_js_1.getTimeMeasurer)(); const cachedResult = await cache.getCachedLintResults(filename); if (cachedResult) { reporter.debug(`Filename: ${filename}, using cache`); const fileResult = { ...cachedResult, elapsedTimeMs: getElapsedTimeMs() }; return { fileResult }; } - const uri = (0, fileHelper_1.filenameToUri)(filename, cfg.root); + const uri = (0, fileHelper_js_1.filenameToUri)(filename, cfg.root); const checkResult = await cspell.shouldCheckDocument({ uri }, {}, configInfo.config); if (!checkResult.shouldCheck) return { skip: true }; - const fileInfo = await (0, fileHelper_1.readFileInfo)(filename, undefined, true); + const fileInfo = await (0, fileHelper_js_1.readFileInfo)(filename, undefined, true); return { fileInfo }; } const result = fetch(); @@ -87,7 +86,7 @@ async function runLint(cfg) { async function processFile(filename, configInfo, cache, prefetch) { if (prefetch?.fileResult) return prefetch.fileResult; - const getElapsedTimeMs = (0, timer_1.getTimeMeasurer)(); + const getElapsedTimeMs = (0, timer_js_1.getTimeMeasurer)(); const cachedResult = await cache.getCachedLintResults(filename); if (cachedResult) { reporter.debug(`Filename: ${filename}, using cache`); @@ -103,16 +102,16 @@ async function runLint(cfg) { configErrors: 0, elapsedTimeMs: 0, }; - const fileInfo = prefetch?.fileInfo || (await (0, fileHelper_1.readFileInfo)(filename, undefined, true)); + const fileInfo = prefetch?.fileInfo || (await (0, fileHelper_js_1.readFileInfo)(filename, undefined, true)); if (fileInfo.errorCode) { if (fileInfo.errorCode !== 'EISDIR' && cfg.options.mustFindFiles) { - const err = (0, errors_1.toError)(`File not found: "${filename}"`); + const err = (0, errors_js_1.toError)(`File not found: "${filename}"`); reporter.error('Linter:', err); result.errors += 1; } return result; } - const doc = (0, fileHelper_1.fileInfoToDocument)(fileInfo, cfg.options.languageId, cfg.locale); + const doc = (0, fileHelper_js_1.fileInfoToDocument)(fileInfo, cfg.options.languageId, cfg.locale); const { text } = fileInfo; result.fileInfo = fileInfo; let spellResult = {}; @@ -120,14 +119,14 @@ async function runLint(cfg) { try { const { showSuggestions: generateSuggestions, validateDirectives } = cfg.options; const numSuggestions = configInfo.config.numSuggestions ?? 5; - const validateOptions = { generateSuggestions, numSuggestions, validateDirectives }; + const validateOptions = util.clean({ generateSuggestions, numSuggestions, validateDirectives }); const r = await cspell.spellCheckDocument(doc, validateOptions, configInfo.config); spellResult = r; result.processed = r.checked; result.issues = cspell.Text.calculateTextDocumentOffsets(doc.uri, text, r.issues).map(mapIssue); } catch (e) { - reporter.error(`Failed to process "${filename}"`, (0, errors_1.toError)(e)); + reporter.error(`Failed to process "${filename}"`, (0, errors_js_1.toError)(e)); result.errors += 1; } result.elapsedTimeMs = getElapsedTimeMs(); @@ -156,12 +155,12 @@ async function runLint(cfg) { const context = cfg.showContext ? extractContext(tdo, cfg.showContext) : { text: tdo.line.text.trimEnd(), offset: tdo.line.offset }; - return { ...tdo, context }; + return util.clean({ ...tdo, context }); } async function processFiles(files, configInfo, cacheSettings) { const fileCount = files instanceof Array ? files.length : undefined; const status = runResult(); - const cache = (0, cache_1.createCache)(cacheSettings); + const cache = (0, index_js_2.createCache)(cacheSettings); const failFast = cfg.options.failFast ?? configInfo.config.failFast ?? false; const emitProgressBegin = (filename, fileNum, fileCount) => reporter.progress({ type: 'ProgressFileBegin', @@ -169,7 +168,7 @@ async function runLint(cfg) { fileCount, filename, }); - const emitProgressComplete = (filename, fileNum, fileCount, result) => reporter.progress({ + const emitProgressComplete = (filename, fileNum, fileCount, result) => reporter.progress(util.clean({ type: 'ProgressFileComplete', fileNum, fileCount, @@ -178,9 +177,9 @@ async function runLint(cfg) { processed: result?.processed, numErrors: result?.issues.length || result?.errors, cached: result?.cached, - }); + })); function* prefetchFiles(files) { - const iter = (0, prefetch_1.prefetchIterable)((0, sync_1.pipe)(files, (0, sync_1.opMap)((filename) => prefetch(filename, configInfo, cache))), BATCH_SIZE); + const iter = (0, prefetch_js_1.prefetchIterable)((0, sync_1.pipe)(files, (0, sync_1.opMap)((filename) => prefetch(filename, configInfo, cache))), BATCH_SIZE); for (const v of iter) { yield v; } @@ -200,7 +199,7 @@ async function runLint(cfg) { }; async function processPrefetchFileResult(pf, index) { const { filename, result: pFetchResult } = pf; - const getElapsedTimeMs = (0, timer_1.getTimeMeasurer)(); + const getElapsedTimeMs = (0, timer_js_1.getTimeMeasurer)(); const fetchResult = await pFetchResult; emitProgressBegin(filename, index, fileCount ?? index); if (fetchResult?.skip) { @@ -284,18 +283,18 @@ async function runLint(cfg) { if (cfg.options.root) { process.env[cspell.ENV_CSPELL_GLOB_ROOT] = cfg.root; } - const configInfo = await (0, fileHelper_1.readConfig)(cfg.configFile, cfg.root); + const configInfo = await (0, fileHelper_js_1.readConfig)(cfg.configFile, cfg.root); if (cfg.options.defaultConfiguration !== undefined) { configInfo.config.loadDefaultConfiguration = cfg.options.defaultConfiguration; } - const reporterConfig = { + const reporterConfig = util.clean({ maxNumberOfProblems: configInfo.config.maxNumberOfProblems, maxDuplicateProblems: configInfo.config.maxDuplicateProblems, minWordLength: configInfo.config.minWordLength, ...cfg.options, - }; + }); const reporters = cfg.options.reporter ?? configInfo.config.reporters; - reporter = (0, reporters_1.mergeReporters)(...(await (0, reporters_1.loadReporters)(reporters, cfg.reporter, reporterConfig))); + reporter = (0, reporters_js_1.mergeReporters)(...(await (0, reporters_js_1.loadReporters)(reporters, cfg.reporter, reporterConfig))); cspell.setLogger(getLoggerFromReporter(reporter)); const globInfo = await determineGlobs(configInfo, cfg); const { fileGlobs, excludeGlobs } = globInfo; @@ -313,12 +312,12 @@ async function runLint(cfg) { // Get Exclusions from the config files. const { root } = cfg; try { - const cacheSettings = await (0, cache_1.calcCacheSettings)(configInfo.config, { ...cfg.options, version }, root); + const cacheSettings = await (0, index_js_2.calcCacheSettings)(configInfo.config, { ...cfg.options, version }, root); const files = await determineFilesToCheck(configInfo, cfg, reporter, globInfo); return await processFiles(files, configInfo, cacheSettings); } catch (e) { - const err = (0, errors_1.toApplicationError)(e); + const err = (0, errors_js_1.toApplicationError)(e); reporter.error('Linter', err); return runResult({ errors: 1 }); } @@ -343,7 +342,7 @@ function checkGlobs(globs, reporter) { globs .filter((g) => g.startsWith("'") || g.endsWith("'")) .map((glob) => chalk_1.default.yellow(glob)) - .forEach((glob) => reporter.error('Linter', new errors_1.CheckFailed(`Glob starting or ending with ' (single quote) is not likely to match any files: ${glob}.`))); + .forEach((glob) => reporter.error('Linter', new errors_js_1.CheckFailed(`Glob starting or ending with ' (single quote) is not likely to match any files: ${glob}.`))); } async function determineGlobs(configInfo, cfg) { const useGitignore = cfg.options.gitignore ?? configInfo.config.useGitignore ?? false; @@ -351,9 +350,9 @@ async function determineGlobs(configInfo, cfg) { const gitIgnore = useGitignore ? await generateGitIgnore(gitignoreRoots) : undefined; const cliGlobs = cfg.fileGlobs; const allGlobs = cliGlobs.length ? cliGlobs : configInfo.config.files || []; - const combinedGlobs = await (0, glob_1.normalizeFileOrGlobsToRoot)(allGlobs, cfg.root); - const cliExcludeGlobs = (0, glob_1.extractPatterns)(cfg.excludes).map((p) => p.glob); - const normalizedExcludes = (0, glob_1.normalizeGlobsToRoot)(cliExcludeGlobs, cfg.root, true); + const combinedGlobs = await (0, glob_js_1.normalizeFileOrGlobsToRoot)(allGlobs, cfg.root); + const cliExcludeGlobs = (0, glob_js_1.extractPatterns)(cfg.excludes).map((p) => p.glob); + const normalizedExcludes = (0, glob_js_1.normalizeGlobsToRoot)(cliExcludeGlobs, cfg.root, true); const includeGlobs = combinedGlobs.filter((g) => !g.startsWith('!')); const excludeGlobs = combinedGlobs.filter((g) => g.startsWith('!')).concat(normalizedExcludes); const fileGlobs = includeGlobs; @@ -368,8 +367,8 @@ async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) { // Get Exclusions from the config files. const { root } = cfg; const globsToExclude = (configInfo.config.ignorePaths || []).concat(excludeGlobs); - const globMatcher = (0, glob_1.buildGlobMatcher)(globsToExclude, root, true); - const ignoreGlobs = (0, glob_1.extractGlobsFromMatcher)(globMatcher); + const globMatcher = (0, glob_js_1.buildGlobMatcher)(globsToExclude, root, true); + const ignoreGlobs = (0, glob_js_1.extractGlobsFromMatcher)(globMatcher); // cspell:word nodir const globOptions = { root, @@ -384,7 +383,7 @@ async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) { const filterFiles = (0, cspell_pipe_1.opFilter)(filterFilesFn(globMatcher)); const foundFiles = await (hasFileLists ? useFileLists(fileLists, allGlobs, root, enableGlobDot) - : (0, fileHelper_1.findFiles)(fileGlobs, globOptions)); + : (0, fileHelper_js_1.findFiles)(fileGlobs, globOptions)); const filtered = gitIgnore ? await gitIgnore.filterOutIgnored(foundFiles) : foundFiles; const files = (0, cspell_pipe_1.isAsyncIterable)(filtered) ? (0, cspell_pipe_1.pipeAsync)(filtered, filterFiles) @@ -392,7 +391,7 @@ async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) { return files; } function isExcluded(filename, globMatcherExclude) { - if (cspell.isBinaryFile(vscode_uri_1.URI.file(filename))) { + if (cspell.isBinaryFile(uri_cjs_1.URI.file(filename))) { return true; } const { root } = cfg; @@ -494,7 +493,7 @@ async function useFileLists(fileListFiles, includeGlobPatterns, root, dot) { } const globMatcher = new cspell_glob_1.GlobMatcher(includeGlobPatterns, options); const filterFiles = (file) => globMatcher.match(file); - const files = (0, fileHelper_1.readFileListFiles)(fileListFiles); - return (0, cspell_pipe_1.pipeAsync)(files, (0, cspell_pipe_1.opFilter)(filterFiles), opFilterAsync(fileHelper_1.isNotDir)); + const files = (0, fileHelper_js_1.readFileListFiles)(fileListFiles); + return (0, cspell_pipe_1.pipeAsync)(files, (0, cspell_pipe_1.opFilter)(filterFiles), opFilterAsync(fileHelper_js_1.isNotDir)); } //# sourceMappingURL=lint.js.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/options.js b/action/node_modules/cspell/dist/cjs/options.js similarity index 100% rename from action/node_modules/cspell/dist/options.js rename to action/node_modules/cspell/dist/cjs/options.js diff --git a/action/node_modules/cspell/dist/repl/index.js b/action/node_modules/cspell/dist/cjs/repl/index.js similarity index 100% rename from action/node_modules/cspell/dist/repl/index.js rename to action/node_modules/cspell/dist/cjs/repl/index.js diff --git a/action/node_modules/cspell/dist/util/InMemoryReporter.js b/action/node_modules/cspell/dist/cjs/util/InMemoryReporter.js similarity index 100% rename from action/node_modules/cspell/dist/util/InMemoryReporter.js rename to action/node_modules/cspell/dist/cjs/util/InMemoryReporter.js diff --git a/action/node_modules/cspell/dist/util/async.js b/action/node_modules/cspell/dist/cjs/util/async.js similarity index 100% rename from action/node_modules/cspell/dist/util/async.js rename to action/node_modules/cspell/dist/cjs/util/async.js diff --git a/action/node_modules/cspell/dist/util/cache/CSpellLintResultCache.js b/action/node_modules/cspell/dist/cjs/util/cache/CSpellLintResultCache.js similarity index 100% rename from action/node_modules/cspell/dist/util/cache/CSpellLintResultCache.js rename to action/node_modules/cspell/dist/cjs/util/cache/CSpellLintResultCache.js diff --git a/action/node_modules/cspell/dist/util/cache/CacheOptions.js b/action/node_modules/cspell/dist/cjs/util/cache/CacheOptions.js similarity index 100% rename from action/node_modules/cspell/dist/util/cache/CacheOptions.js rename to action/node_modules/cspell/dist/cjs/util/cache/CacheOptions.js diff --git a/action/node_modules/cspell/dist/util/cache/DiskCache.js b/action/node_modules/cspell/dist/cjs/util/cache/DiskCache.js similarity index 87% rename from action/node_modules/cspell/dist/util/cache/DiskCache.js rename to action/node_modules/cspell/dist/cjs/util/cache/DiskCache.js index 672437ca2..56e49ff21 100644 --- a/action/node_modules/cspell/dist/util/cache/DiskCache.js +++ b/action/node_modules/cspell/dist/cjs/util/cache/DiskCache.js @@ -31,9 +31,9 @@ const assert_1 = __importDefault(require("assert")); const crypto = __importStar(require("crypto")); const fs = __importStar(require("fs")); const path_1 = require("path"); -const fileHelper_1 = require("../../util/fileHelper"); -const fileEntryCache_1 = require("./fileEntryCache"); -const ObjectCollection_1 = require("./ObjectCollection"); +const fileHelper_js_1 = require("../../util/fileHelper.js"); +const fileEntryCache_js_1 = require("./fileEntryCache.js"); +const ObjectCollection_js_1 = require("./ObjectCollection.js"); const cacheDataKeys = { v: 'v', r: 'r', @@ -55,15 +55,15 @@ class DiskCache { this.useUniversalCache = useUniversalCache; this.dependencyCache = new Map(); this.dependencyCacheTree = {}; - this.objectCollection = new ObjectCollection_1.ShallowObjectCollection(); - this.ocCacheFileResult = new ObjectCollection_1.ShallowObjectCollection(); + this.objectCollection = new ObjectCollection_js_1.ShallowObjectCollection(); + this.ocCacheFileResult = new ObjectCollection_js_1.ShallowObjectCollection(); this.cacheFileLocation = (0, path_1.resolve)(cacheFileLocation); this.cacheDir = (0, path_1.dirname)(this.cacheFileLocation); - this.fileEntryCache = (0, fileEntryCache_1.createFromFile)(this.cacheFileLocation, useCheckSum, useUniversalCache); + this.fileEntryCache = (0, fileEntryCache_js_1.createFromFile)(this.cacheFileLocation, useCheckSum, useUniversalCache); this.version = calcVersion(cspellVersion); } async getCachedLintResults(filename) { - filename = (0, fileEntryCache_1.normalizePath)(filename); + filename = (0, fileEntryCache_js_1.normalizePath)(filename); const fileDescriptor = this.fileEntryCache.getFileDescriptor(filename); const meta = fileDescriptor.meta; const data = meta?.data; @@ -95,7 +95,7 @@ class DiskCache { return { ...result, elapsedTimeMs: undefined, - fileInfo: shouldReadFile ? await (0, fileHelper_1.readFileInfo)(filename) : { filename }, + fileInfo: shouldReadFile ? await (0, fileHelper_js_1.readFileInfo)(filename) : { filename }, cached, }; } @@ -119,8 +119,8 @@ class DiskCache { this.fileEntryCache.destroy(); this.dependencyCache.clear(); this.dependencyCacheTree = {}; - this.objectCollection = new ObjectCollection_1.ShallowObjectCollection(); - this.ocCacheFileResult = new ObjectCollection_1.ShallowObjectCollection(); + this.objectCollection = new ObjectCollection_js_1.ShallowObjectCollection(); + this.ocCacheFileResult = new ObjectCollection_js_1.ShallowObjectCollection(); } normalizeResult(result) { const { issues, processed, errors, configErrors, ...rest } = result; @@ -188,10 +188,10 @@ class DiskCache { return crypto.createHash('md5').update(buffer).digest('hex'); } resolveFile(file) { - return (0, fileEntryCache_1.normalizePath)((0, path_1.resolve)(this.cacheDir, file)); + return (0, fileEntryCache_js_1.normalizePath)((0, path_1.resolve)(this.cacheDir, file)); } toRelFile(file) { - return (0, fileEntryCache_1.normalizePath)(this.useUniversalCache ? (0, path_1.relative)(this.cacheDir, file) : file); + return (0, fileEntryCache_js_1.normalizePath)(this.useUniversalCache ? (0, path_1.relative)(this.cacheDir, file) : file); } } exports.DiskCache = DiskCache; diff --git a/action/node_modules/cspell/dist/util/cache/DummyCache.js b/action/node_modules/cspell/dist/cjs/util/cache/DummyCache.js similarity index 100% rename from action/node_modules/cspell/dist/util/cache/DummyCache.js rename to action/node_modules/cspell/dist/cjs/util/cache/DummyCache.js diff --git a/action/node_modules/cspell/dist/util/cache/ObjectCollection.js b/action/node_modules/cspell/dist/cjs/util/cache/ObjectCollection.js similarity index 100% rename from action/node_modules/cspell/dist/util/cache/ObjectCollection.js rename to action/node_modules/cspell/dist/cjs/util/cache/ObjectCollection.js diff --git a/action/node_modules/cspell/dist/util/cache/createCache.js b/action/node_modules/cspell/dist/cjs/util/cache/createCache.js similarity index 88% rename from action/node_modules/cspell/dist/util/cache/createCache.js rename to action/node_modules/cspell/dist/cjs/util/cache/createCache.js index ecd465b2a..588758a3b 100644 --- a/action/node_modules/cspell/dist/util/cache/createCache.js +++ b/action/node_modules/cspell/dist/cjs/util/cache/createCache.js @@ -7,9 +7,9 @@ exports.__testing__ = exports.calcCacheSettings = exports.createCache = exports. const assert_1 = __importDefault(require("assert")); const promises_1 = require("fs/promises"); const path_1 = __importDefault(require("path")); -const errors_1 = require("../errors"); -const DiskCache_1 = require("./DiskCache"); -const DummyCache_1 = require("./DummyCache"); +const errors_js_1 = require("../errors.js"); +const DiskCache_js_1 = require("./DiskCache.js"); +const DummyCache_js_1 = require("./DummyCache.js"); // cspell:word cspellcache exports.DEFAULT_CACHE_LOCATION = '.cspellcache'; const versionSuffix = ''; @@ -22,7 +22,7 @@ function createCache(options) { const useChecksum = cacheStrategy === 'content'; const version = normalizeVersion(options.version); const useUniversal = options.cacheFormat === 'universal'; - const cache = useCache ? new DiskCache_1.DiskCache(location, useChecksum, version, useUniversal) : new DummyCache_1.DummyCache(); + const cache = useCache ? new DiskCache_js_1.DiskCache(location, useChecksum, version, useUniversal) : new DummyCache_js_1.DummyCache(); reset && cache.reset(); return cache; } @@ -55,7 +55,7 @@ async function resolveCacheLocation(cacheLocation) { return path_1.default.join(cacheLocation, exports.DEFAULT_CACHE_LOCATION); } catch (err) { - if ((0, errors_1.isError)(err) && err.code === 'ENOENT') { + if ((0, errors_js_1.isError)(err) && err.code === 'ENOENT') { return cacheLocation; } throw err; diff --git a/action/node_modules/cspell/dist/util/cache/fileEntryCache.js b/action/node_modules/cspell/dist/cjs/util/cache/fileEntryCache.js similarity index 95% rename from action/node_modules/cspell/dist/util/cache/fileEntryCache.js rename to action/node_modules/cspell/dist/cjs/util/cache/fileEntryCache.js index c990a5271..39392c60f 100644 --- a/action/node_modules/cspell/dist/util/cache/fileEntryCache.js +++ b/action/node_modules/cspell/dist/cjs/util/cache/fileEntryCache.js @@ -27,15 +27,15 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizePath = exports.createFromFile = void 0; -const file_entry_cache = __importStar(require("file-entry-cache")); const fs_1 = require("fs"); const path = __importStar(require("path")); const worker_threads_1 = require("worker_threads"); +const fec = __importStar(require("../../../lib/file-entry-cache.cjs")); function createFromFile(pathToCache, useCheckSum, useRelative) { const absPathToCache = path.resolve(pathToCache); const relDir = path.dirname(absPathToCache); (0, fs_1.mkdirSync)(relDir, { recursive: true }); - const create = wrap(() => file_entry_cache.createFromFile(absPathToCache, useCheckSum)); + const create = wrap(() => fec.createFromFile(absPathToCache, useCheckSum)); const feCache = create(); const cacheWrapper = { get cache() { diff --git a/action/node_modules/cspell/dist/util/cache/index.js b/action/node_modules/cspell/dist/cjs/util/cache/index.js similarity index 58% rename from action/node_modules/cspell/dist/util/cache/index.js rename to action/node_modules/cspell/dist/cjs/util/cache/index.js index 314c9dd50..8ca4a9ac7 100644 --- a/action/node_modules/cspell/dist/util/cache/index.js +++ b/action/node_modules/cspell/dist/cjs/util/cache/index.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DEFAULT_CACHE_LOCATION = exports.createCache = exports.calcCacheSettings = void 0; -var createCache_1 = require("./createCache"); -Object.defineProperty(exports, "calcCacheSettings", { enumerable: true, get: function () { return createCache_1.calcCacheSettings; } }); -Object.defineProperty(exports, "createCache", { enumerable: true, get: function () { return createCache_1.createCache; } }); -Object.defineProperty(exports, "DEFAULT_CACHE_LOCATION", { enumerable: true, get: function () { return createCache_1.DEFAULT_CACHE_LOCATION; } }); +var createCache_js_1 = require("./createCache.js"); +Object.defineProperty(exports, "calcCacheSettings", { enumerable: true, get: function () { return createCache_js_1.calcCacheSettings; } }); +Object.defineProperty(exports, "createCache", { enumerable: true, get: function () { return createCache_js_1.createCache; } }); +Object.defineProperty(exports, "DEFAULT_CACHE_LOCATION", { enumerable: true, get: function () { return createCache_js_1.DEFAULT_CACHE_LOCATION; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/util/constants.js b/action/node_modules/cspell/dist/cjs/util/constants.js similarity index 100% rename from action/node_modules/cspell/dist/util/constants.js rename to action/node_modules/cspell/dist/cjs/util/constants.js diff --git a/action/node_modules/cspell/dist/util/errors.js b/action/node_modules/cspell/dist/cjs/util/errors.js similarity index 100% rename from action/node_modules/cspell/dist/util/errors.js rename to action/node_modules/cspell/dist/cjs/util/errors.js diff --git a/action/node_modules/cspell/dist/util/fileHelper.js b/action/node_modules/cspell/dist/cjs/util/fileHelper.js similarity index 77% rename from action/node_modules/cspell/dist/util/fileHelper.js rename to action/node_modules/cspell/dist/cjs/util/fileHelper.js index 1f423d0e4..83e77840d 100644 --- a/action/node_modules/cspell/dist/util/fileHelper.js +++ b/action/node_modules/cspell/dist/cjs/util/fileHelper.js @@ -34,12 +34,13 @@ const fs_1 = require("fs"); const get_stdin_1 = __importDefault(require("get-stdin")); const path = __importStar(require("path")); const url_1 = require("url"); -const vscode_uri_1 = require("vscode-uri"); -const async_1 = require("./async"); -const constants_1 = require("./constants"); -const errors_1 = require("./errors"); -const glob_1 = require("./glob"); -const stdin_1 = require("./stdin"); +const uri_cjs_1 = require("../../lib/uri.cjs"); +const async_js_1 = require("./async.js"); +const constants_js_1 = require("./constants.js"); +const errors_js_1 = require("./errors.js"); +const glob_js_1 = require("./glob.js"); +const stdin_js_1 = require("./stdin.js"); +const util_js_1 = require("./util.js"); const doesMatchUrl = /^(file|stdin|https?):\/\//; async function readConfig(configFile, root) { if (configFile) { @@ -55,22 +56,22 @@ function fileInfoToDocument(fileInfo, languageId, locale) { languageId = languageId || undefined; locale = locale || undefined; const uri = filenameToUrlString(filename); - if (uri.startsWith(constants_1.STDINProtocol)) { - return { + if (uri.startsWith(constants_js_1.STDINProtocol)) { + return (0, util_js_1.clean)({ uri, text, languageId, locale, - }; + }); } return (0, cspell_lib_1.fileToDocument)(uri, text, languageId, locale); } exports.fileInfoToDocument = fileInfoToDocument; function filenameToUrlString(filename, cwd = '.') { - if (filename === constants_1.STDIN) + if (filename === constants_js_1.STDIN) return 'stdin:///'; - if (filename.startsWith(constants_1.STDINProtocol)) { - const filePath = filename.slice(constants_1.STDINProtocol.length); + if (filename.startsWith(constants_js_1.STDINProtocol)) { + const filePath = filename.slice(constants_js_1.STDINProtocol.length); const fullPath = path.resolve(cwd, filePath); return (0, url_1.pathToFileURL)(fullPath).toString(); } @@ -80,7 +81,7 @@ function filenameToUrlString(filename, cwd = '.') { } exports.filenameToUrlString = filenameToUrlString; function filenameToUri(filename, cwd) { - return vscode_uri_1.URI.parse(filenameToUrlString(filename, cwd)); + return uri_cjs_1.URI.parse(filenameToUrlString(filename, cwd)); } exports.filenameToUri = filenameToUri; function isBinaryFile(filename, cwd) { @@ -92,31 +93,31 @@ function isBinaryFile(filename, cwd) { exports.isBinaryFile = isBinaryFile; function resolveFilename(filename, cwd) { cwd = cwd || process.cwd(); - if (filename === constants_1.STDIN) - return constants_1.STDINProtocol; - if (filename.startsWith(constants_1.FileProtocol)) { - const url = new URL(filename.slice(constants_1.FileProtocol.length), (0, url_1.pathToFileURL)(cwd + path.sep)); + if (filename === constants_js_1.STDIN) + return constants_js_1.STDINProtocol; + if (filename.startsWith(constants_js_1.FileProtocol)) { + const url = new URL(filename.slice(constants_js_1.FileProtocol.length), (0, url_1.pathToFileURL)(cwd + path.sep)); return (0, url_1.fileURLToPath)(url); } - const scheme = filename.startsWith(constants_1.STDINProtocol) ? constants_1.STDINProtocol : ''; + const scheme = filename.startsWith(constants_js_1.STDINProtocol) ? constants_js_1.STDINProtocol : ''; const pathname = filename.slice(scheme.length); return scheme + path.resolve(cwd, pathname); } exports.resolveFilename = resolveFilename; -function readFileInfo(filename, encoding = constants_1.UTF8, handleNotFound = false) { +function readFileInfo(filename, encoding = constants_js_1.UTF8, handleNotFound = false) { filename = resolveFilename(filename); - const pText = filename.startsWith(constants_1.STDINProtocol) ? (0, get_stdin_1.default)() : (0, cspell_io_1.readFile)(filename, encoding); + const pText = filename.startsWith(constants_js_1.STDINProtocol) ? (0, get_stdin_1.default)() : (0, cspell_io_1.readFile)(filename, encoding); return pText.then((text) => ({ text, filename }), (e) => { - const error = (0, errors_1.toError)(e); + const error = (0, errors_js_1.toError)(e); return handleNotFound && error.code === 'EISDIR' ? Promise.resolve({ text: '', filename, errorCode: error.code }) : handleNotFound && error.code === 'ENOENT' ? Promise.resolve({ text: '', filename, errorCode: error.code }) - : Promise.reject(new errors_1.IOError(`Error reading file: "${filename}"`, error)); + : Promise.reject(new errors_js_1.IOError(`Error reading file: "${filename}"`, error)); }); } exports.readFileInfo = readFileInfo; -function readFile(filename, encoding = constants_1.UTF8) { +function readFile(filename, encoding = constants_js_1.UTF8) { return readFileInfo(filename, encoding).then((info) => info.text); } exports.readFile = readFile; @@ -126,10 +127,10 @@ exports.readFile = readFile; */ async function findFiles(globPatterns, options) { const stdin = []; - const globPats = globPatterns.filter((filename) => filename !== constants_1.STDIN && !filename.startsWith(constants_1.STDINProtocol) && !filename.startsWith(constants_1.FileProtocol) + const globPats = globPatterns.filter((filename) => filename !== constants_js_1.STDIN && !filename.startsWith(constants_js_1.STDINProtocol) && !filename.startsWith(constants_js_1.FileProtocol) ? true : (stdin.push(filename), false)); - const globResults = globPats.length ? await (0, glob_1.globP)(globPats, options) : []; + const globResults = globPats.length ? await (0, glob_js_1.globP)(globPats, options) : []; const cwd = options.cwd || process.cwd(); return [...stdin, ...globResults].map((filename) => resolveFilename(filename, cwd)); } @@ -152,7 +153,7 @@ function calcFinalConfigInfo(configInfo, settingsFromCommandLine, filename, text }; } exports.calcFinalConfigInfo = calcFinalConfigInfo; -const resolveFilenames = (0, async_1.asyncMap)(resolveFilename); +const resolveFilenames = (0, async_js_1.asyncMap)(resolveFilename); /** * Read * @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each @@ -166,10 +167,10 @@ function readFileListFiles(listFiles) { useStdin = useStdin || isStdin; return !isStdin; }); - const found = (0, async_1.asyncPipe)(files, (0, async_1.asyncMap)((file) => readFileListFile(file)), (0, async_1.asyncAwait)(), (0, async_1.asyncFlatten)()); + const found = (0, async_js_1.asyncPipe)(files, (0, async_js_1.asyncMap)((file) => readFileListFile(file)), (0, async_js_1.asyncAwait)(), (0, async_js_1.asyncFlatten)()); // Move `stdin` to the end. - const stdin = useStdin ? (0, stdin_1.readStdin)() : []; - return (0, async_1.asyncPipe)((0, async_1.mergeAsyncIterables)(found, stdin), resolveFilenames); + const stdin = useStdin ? (0, stdin_js_1.readStdin)() : []; + return (0, async_js_1.asyncPipe)((0, async_js_1.mergeAsyncIterables)(found, stdin), resolveFilenames); } exports.readFileListFiles = readFileListFiles; /** @@ -190,7 +191,7 @@ async function readFileListFile(listFile) { return lines; } catch (err) { - throw (0, errors_1.toApplicationError)(err, `Error reading file list from: "${listFile}"`); + throw (0, errors_js_1.toApplicationError)(err, `Error reading file list from: "${listFile}"`); } } exports.readFileListFile = readFileListFile; diff --git a/action/node_modules/cspell/dist/util/glob.js b/action/node_modules/cspell/dist/cjs/util/glob.js similarity index 96% rename from action/node_modules/cspell/dist/util/glob.js rename to action/node_modules/cspell/dist/cjs/util/glob.js index 218ab4b41..3cd3a529b 100644 --- a/action/node_modules/cspell/dist/util/glob.js +++ b/action/node_modules/cspell/dist/cjs/util/glob.js @@ -32,6 +32,7 @@ const fast_glob_1 = __importDefault(require("fast-glob")); const fs_1 = require("fs"); const path = __importStar(require("path")); const path_1 = require("path"); +const util_js_1 = require("./util.js"); const defaultExcludeGlobs = ['node_modules/**']; /** * @@ -44,7 +45,14 @@ async function globP(pattern, options) { const onlyFiles = options?.nodir; const dot = options?.dot; const patterns = typeof pattern === 'string' ? [pattern] : pattern; - const useOptions = { cwd, onlyFiles, dot, ignore, absolute: true, followSymbolicLinks: false }; + const useOptions = (0, util_js_1.clean)({ + cwd, + onlyFiles, + dot, + ignore, + absolute: true, + followSymbolicLinks: false, + }); const compare = new Intl.Collator('en').compare; const absolutePaths = (await (0, fast_glob_1.default)(patterns, useOptions)).sort(compare); const relativePaths = absolutePaths.map((absFilename) => path.relative(cwd, absFilename)); diff --git a/action/node_modules/cspell/dist/util/prefetch.js b/action/node_modules/cspell/dist/cjs/util/prefetch.js similarity index 100% rename from action/node_modules/cspell/dist/util/prefetch.js rename to action/node_modules/cspell/dist/cjs/util/prefetch.js diff --git a/action/node_modules/cspell/dist/util/reporters.js b/action/node_modules/cspell/dist/cjs/util/reporters.js similarity index 88% rename from action/node_modules/cspell/dist/util/reporters.js rename to action/node_modules/cspell/dist/cjs/util/reporters.js index f7bb6c1e8..804c90d24 100644 --- a/action/node_modules/cspell/dist/util/reporters.js +++ b/action/node_modules/cspell/dist/cjs/util/reporters.js @@ -2,7 +2,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.finalizeReporter = exports.loadReporters = exports.mergeReporters = void 0; const dynamic_import_1 = require("@cspell/dynamic-import"); -const errors_1 = require("./errors"); +const pkgInfo_cjs_1 = require("../../lib/pkgInfo.cjs"); +const errors_js_1 = require("./errors.js"); function callAll(methods) { return (...p) => { for (const method of methods) { @@ -48,11 +49,11 @@ async function loadReporters(reporters, defaultReporter, config) { } const [moduleName, settings] = reporterSettings; try { - const { getReporter } = await (0, dynamic_import_1.dynamicImport)(moduleName, [process.cwd(), __dirname]); + const { getReporter } = await (0, dynamic_import_1.dynamicImport)(moduleName, [process.cwd(), pkgInfo_cjs_1.pkgDir]); return getReporter(settings, config); } catch (e) { - throw new errors_1.ApplicationError(`Failed to load reporter ${moduleName}: ${(0, errors_1.toError)(e).message}`); + throw new errors_js_1.ApplicationError(`Failed to load reporter ${moduleName}: ${(0, errors_js_1.toError)(e).message}`); } } reporters = !reporters || !reporters.length ? ['default'] : [...reporters]; diff --git a/action/node_modules/cspell/dist/util/stdin.js b/action/node_modules/cspell/dist/cjs/util/stdin.js similarity index 100% rename from action/node_modules/cspell/dist/util/stdin.js rename to action/node_modules/cspell/dist/cjs/util/stdin.js diff --git a/action/node_modules/cspell/dist/util/table.js b/action/node_modules/cspell/dist/cjs/util/table.js similarity index 100% rename from action/node_modules/cspell/dist/util/table.js rename to action/node_modules/cspell/dist/cjs/util/table.js diff --git a/action/node_modules/cspell/dist/util/timer.js b/action/node_modules/cspell/dist/cjs/util/timer.js similarity index 100% rename from action/node_modules/cspell/dist/util/timer.js rename to action/node_modules/cspell/dist/cjs/util/timer.js diff --git a/action/node_modules/cspell/dist/cjs/util/types.js b/action/node_modules/cspell/dist/cjs/util/types.js new file mode 100644 index 000000000..3a12605d8 --- /dev/null +++ b/action/node_modules/cspell/dist/cjs/util/types.js @@ -0,0 +1,6 @@ +"use strict"; +/** + * Make all properties in T required + */ +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/util/util.js b/action/node_modules/cspell/dist/cjs/util/util.js similarity index 100% rename from action/node_modules/cspell/dist/util/util.js rename to action/node_modules/cspell/dist/cjs/util/util.js diff --git a/action/node_modules/cspell/dist/esm/app.d.mts b/action/node_modules/cspell/dist/esm/app.d.mts new file mode 100644 index 000000000..9ac3c0893 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/app.d.mts @@ -0,0 +1,5 @@ +import type { Command } from 'commander'; +export { LinterCliOptions as Options } from './options.mjs'; +export { CheckFailed } from './util/errors.mjs'; +export declare function run(command?: Command, argv?: string[]): Promise; +//# sourceMappingURL=app.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/app.mjs b/action/node_modules/cspell/dist/esm/app.mjs new file mode 100644 index 000000000..3b7437127 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/app.mjs @@ -0,0 +1,44 @@ +import { Option as CommanderOption, program } from 'commander'; +import { satisfies as semverSatisfies } from 'semver'; +import { npmPackage } from '../lib/pkgInfo.cjs'; +import { commandCheck } from './commandCheck.mjs'; +import { commandLink } from './commandLink.mjs'; +import { commandLint } from './commandLint.mjs'; +import { commandSuggestion } from './commandSuggestion.mjs'; +import { commandTrace } from './commandTrace.mjs'; +import { ApplicationError } from './util/errors.mjs'; +export { CheckFailed } from './util/errors.mjs'; +export async function run(command, argv) { + const prog = command || program; + const args = argv || process.argv; + prog.exitOverride(); + prog.version(npmPackage.version).description('Spelling Checker for Code').name('cspell'); + if (!semverSatisfies(process.versions.node, npmPackage.engines.node)) { + throw new ApplicationError(`Unsupported NodeJS version (${process.versions.node}); ${npmPackage.engines.node} is required`); + } + const optionFlags = new CommanderOption('-f,--flag ', 'Declare an execution flag value') + .hideHelp() + .argParser((value, prev) => prev?.concat(value) || [value]); + commandLint(prog).addOption(optionFlags); + commandTrace(prog).addOption(optionFlags); + commandCheck(prog).addOption(optionFlags); + commandSuggestion(prog).addOption(optionFlags); + commandLink(prog); + /* + program + .command('init') + .description('(Alpha) Initialize a cspell.json file.') + .option('-o, --output ', 'define where to write file.') + .option('--extends ', 'extend an existing cspell.json file.') + .action((options: InitOptions) => { + showHelp = false; + CSpellApplication.createInit(options).then( + () => process.exit(0), + () => process.exit(1) + ); + console.log('Init'); + }); + */ + prog.exitOverride(); + await prog.parseAsync(args); +} diff --git a/action/node_modules/cspell/dist/esm/application.d.mts b/action/node_modules/cspell/dist/esm/application.d.mts new file mode 100644 index 000000000..fc3cd1ae4 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/application.d.mts @@ -0,0 +1,16 @@ +/// +import type { CSpellReporter, RunResult } from '@cspell/cspell-types'; +import type { CheckTextInfo, FeatureFlags, TraceResult } from 'cspell-lib'; +import type { TimedSuggestionsForWordResult } from './emitters/suggestionsEmitter.mjs'; +import type { BaseOptions, LegacyOptions, LinterCliOptions, SuggestionOptions, TraceOptions } from './options.mjs'; +export type { TraceResult } from 'cspell-lib'; +export { IncludeExcludeFlag } from 'cspell-lib'; +export type AppError = NodeJS.ErrnoException; +export declare function lint(fileGlobs: string[], options: LinterCliOptions, reporter?: CSpellReporter): Promise; +export declare function trace(words: string[], options: TraceOptions): AsyncIterableIterator; +export type CheckTextResult = CheckTextInfo; +export declare function checkText(filename: string, options: BaseOptions & LegacyOptions): Promise; +export declare function suggestions(words: string[], options: SuggestionOptions): AsyncIterable; +export declare function createInit(): Promise; +export declare function parseApplicationFeatureFlags(flags: string[] | undefined): FeatureFlags; +//# sourceMappingURL=application.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/application.mjs b/action/node_modules/cspell/dist/esm/application.mjs new file mode 100644 index 000000000..636290ae4 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/application.mjs @@ -0,0 +1,87 @@ +import { opMap, opTap, pipeAsync, toAsyncIterable } from '@cspell/cspell-pipe'; +import { checkTextDocument, getDefaultSettings, getGlobalSettings, mergeSettings, SuggestionError, suggestionsForWords, traceWordsAsync, } from 'cspell-lib'; +import { getReporter } from './cli-reporter.mjs'; +import { getFeatureFlags, parseFeatureFlags } from './featureFlags/index.mjs'; +import { LintRequest, runLint } from './lint/index.mjs'; +import { fixLegacy } from './options.mjs'; +import { simpleRepl } from './repl/index.mjs'; +import { fileInfoToDocument, readConfig, readFileInfo } from './util/fileHelper.mjs'; +import { finalizeReporter } from './util/reporters.mjs'; +import { readStdin } from './util/stdin.mjs'; +import { getTimeMeasurer } from './util/timer.mjs'; +import * as util from './util/util.mjs'; +export { IncludeExcludeFlag } from 'cspell-lib'; +export function lint(fileGlobs, options, reporter) { + options = fixLegacy(options); + const cfg = new LintRequest(fileGlobs, options, finalizeReporter(reporter) ?? getReporter({ ...options, fileGlobs })); + return runLint(cfg); +} +export async function* trace(words, options) { + options = fixLegacy(options); + const iWords = options.stdin ? toAsyncIterable(words, readStdin()) : words; + const { languageId, locale, allowCompoundWords, ignoreCase } = options; + const configFile = await readConfig(options.config, undefined); + const loadDefault = options.defaultConfiguration ?? configFile.config.loadDefaultConfiguration ?? true; + const config = mergeSettings(getDefaultSettings(loadDefault), getGlobalSettings(), configFile.config); + yield* traceWordsAsync(iWords, config, util.clean({ languageId, locale, ignoreCase, allowCompoundWords })); +} +export async function checkText(filename, options) { + options = fixLegacy(options); + const fileInfo = await readFileInfo(filename); + const { locale, languageId, validateDirectives } = options; + const doc = fileInfoToDocument(fileInfo, languageId, locale); + const checkOptions = { + configFile: options.config, + validateDirectives, + }; + const settingsFromCommandLine = util.clean({ + languageId, + language: locale, + loadDefaultConfiguration: options.defaultConfiguration, + }); + return checkTextDocument(doc, util.clean({ ...checkOptions }), settingsFromCommandLine); +} +export async function* suggestions(words, options) { + options = fixLegacy(options); + const configFile = await readConfig(options.config, undefined); + let timer; + function tapStart() { + timer = getTimeMeasurer(); + } + function mapStart(v) { + tapStart(); + return v; + } + function mapEnd(v) { + const elapsedTimeMs = timer?.(); + return elapsedTimeMs ? { ...v, elapsedTimeMs } : v; + } + const iWords = options.repl + ? pipeAsync(toAsyncIterable(words, simpleRepl()), opTap(tapStart)) + : options.useStdin + ? pipeAsync(toAsyncIterable(words, readStdin()), opTap(tapStart)) + : words.map(mapStart); + try { + const results = pipeAsync(suggestionsForWords(iWords, util.clean({ ...options }), configFile.config), opMap(mapEnd)); + yield* results; + } + catch (e) { + if (!(e instanceof SuggestionError)) + throw e; + console.error(e.message); + process.exitCode = 1; + } +} +export function createInit() { + return Promise.reject(); +} +function registerApplicationFeatureFlags() { + const ff = getFeatureFlags(); + const flags = [{ name: 'timer', description: 'Display elapsed time for command.' }]; + flags.forEach((flag) => ff.register(flag)); + return ff; +} +export function parseApplicationFeatureFlags(flags) { + const ff = registerApplicationFeatureFlags(); + return parseFeatureFlags(flags, ff); +} diff --git a/action/node_modules/cspell/dist/esm/cli-reporter.d.mts b/action/node_modules/cspell/dist/esm/cli-reporter.d.mts new file mode 100644 index 000000000..446d4698f --- /dev/null +++ b/action/node_modules/cspell/dist/esm/cli-reporter.d.mts @@ -0,0 +1,16 @@ +import type { Issue } from '@cspell/cspell-types'; +import type { LinterCliOptions } from './options.mjs'; +import type { FinalizedReporter } from './util/reporters.mjs'; +export interface ReporterIssue extends Issue { + filename: string; +} +export interface ReporterOptions extends Pick { + fileGlobs: string[]; +} +export declare function getReporter(options: ReporterOptions): FinalizedReporter; +declare function formatIssue(templateStr: string, issue: ReporterIssue, maxIssueTextWidth: number): string; +export declare const __testing__: { + formatIssue: typeof formatIssue; +}; +export {}; +//# sourceMappingURL=cli-reporter.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/cli-reporter.mjs b/action/node_modules/cspell/dist/esm/cli-reporter.mjs new file mode 100644 index 000000000..3ac7c2f8d --- /dev/null +++ b/action/node_modules/cspell/dist/esm/cli-reporter.mjs @@ -0,0 +1,201 @@ +import chalk from 'chalk'; +import { isSpellingDictionaryLoadError } from 'cspell-lib'; +import * as path from 'path'; +import { URI } from '../lib/uri.cjs'; +const templateIssue = `{green $filename}:{yellow $row:$col} - $message ({red $text})`; +const templateIssueWithSuggestions = `{green $filename}:{yellow $row:$col} - $message ({red $text}) Suggestions: {yellow [$suggestions]}`; +const templateIssueWithContext = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}`; +const templateIssueWithContextWithSuggestions = `{green $filename}:{yellow $row:$col} $padRowCol- $message ({red $text})$padContext -- {gray $contextLeft}{red {underline $text}}{gray $contextRight}\n\t Suggestions: {yellow [$suggestions]}`; +const templateIssueLegacy = `${chalk.green('$filename')}[$row, $col]: $message: ${chalk.red('$text')}`; +const templateIssueWordsOnly = '$text'; +function genIssueEmitter(template) { + const defaultWidth = 10; + let maxWidth = defaultWidth; + let uri; + return function issueEmitter(issue) { + if (uri !== issue.uri) { + maxWidth = defaultWidth; + uri = issue.uri; + } + maxWidth = Math.max(maxWidth * 0.999, issue.text.length, 10); + console.log(formatIssue(template, issue, Math.ceil(maxWidth))); + }; +} +function errorEmitter(message, error) { + if (isSpellingDictionaryLoadError(error)) { + error = error.cause; + } + console.error(chalk.red(message), error.toString()); +} +function nullEmitter() { + /* empty */ +} +function relativeFilename(filename, cwd = process.cwd()) { + const rel = path.relative(cwd, filename); + if (rel.startsWith('..')) + return filename; + return '.' + path.sep + rel; +} +function relativeUriFilename(uri, fsPathRoot) { + const fsPath = URI.parse(uri).fsPath; + const rel = path.relative(fsPathRoot, fsPath); + if (rel.startsWith('..')) + return fsPath; + return '.' + path.sep + rel; +} +function reportProgress(p) { + if (p.type === 'ProgressFileComplete') { + return reportProgressFileComplete(p); + } + if (p.type === 'ProgressFileBegin') { + return reportProgressFileBegin(p); + } +} +function reportProgressFileBegin(p) { + const fc = '' + p.fileCount; + const fn = (' '.repeat(fc.length) + p.fileNum).slice(-fc.length); + const idx = fn + '/' + fc; + const filename = chalk.gray(relativeFilename(p.filename)); + process.stderr.write(`\r${idx} ${filename}`); +} +function reportProgressFileComplete(p) { + const time = reportTime(p.elapsedTimeMs, !!p.cached); + const skipped = p.processed === false ? ' skipped' : ''; + const hasErrors = p.numErrors ? chalk.red ` X` : ''; + console.error(` ${time}${skipped}${hasErrors}`); +} +function reportTime(elapsedTimeMs, cached) { + if (cached) + return chalk.green('cached'); + if (elapsedTimeMs === undefined) + return '-'; + const color = elapsedTimeMs < 1000 ? chalk.white : elapsedTimeMs < 2000 ? chalk.yellow : chalk.redBright; + return color(elapsedTimeMs.toFixed(2) + 'ms'); +} +export function getReporter(options) { + const issueTemplate = options.wordsOnly + ? templateIssueWordsOnly + : options.legacy + ? templateIssueLegacy + : options.showContext + ? options.showSuggestions + ? templateIssueWithContextWithSuggestions + : templateIssueWithContext + : options.showSuggestions + ? templateIssueWithSuggestions + : templateIssue; + const { fileGlobs, silent, summary, issues, progress, verbose, debug } = options; + const emitters = { + Debug: !silent && debug ? (s) => console.info(chalk.cyan(s)) : nullEmitter, + Info: !silent && verbose ? (s) => console.info(chalk.yellow(s)) : nullEmitter, + Warning: (s) => console.info(chalk.yellow(s)), + }; + function infoEmitter(message, msgType) { + emitters[msgType]?.(message); + } + const root = URI.file(options.root || process.cwd()); + const fsPathRoot = root.fsPath; + function relativeIssue(fn) { + const fnFilename = options.relative + ? (uri) => relativeUriFilename(uri, fsPathRoot) + : (uri) => URI.parse(uri).fsPath; + return (i) => { + const filename = i.uri ? fnFilename(i.uri) : ''; + const r = { ...i, filename }; + fn(r); + }; + } + const resultEmitter = (result) => { + if (!fileGlobs.length && !result.files) { + return; + } + if (result.cachedFiles) { + console.error('CSpell\x3a Files checked: %d (%d from cache), Issues found: %d in %d files', result.files, result.cachedFiles, result.issues, result.filesWithIssues.size); + return; + } + console.error('CSpell\x3a Files checked: %d, Issues found: %d in %d files', result.files, result.issues, result.filesWithIssues.size); + }; + return { + issue: relativeIssue(silent || !issues ? nullEmitter : genIssueEmitter(issueTemplate)), + error: silent ? nullEmitter : errorEmitter, + info: infoEmitter, + debug: emitters.Debug, + progress: !silent && progress ? reportProgress : nullEmitter, + result: !silent && summary ? resultEmitter : nullEmitter, + }; +} +function formatIssue(templateStr, issue, maxIssueTextWidth) { + function clean(t) { + return t.replace(/\s+/, ' '); + } + const { uri = '', filename, row, col, text, context, offset } = issue; + const contextLeft = clean(context.text.slice(0, offset - context.offset)); + const contextRight = clean(context.text.slice(offset + text.length - context.offset)); + const contextFull = clean(context.text); + const padContext = ' '.repeat(Math.max(maxIssueTextWidth - text.length, 0)); + const rowText = row.toString(); + const colText = col.toString(); + const padRowCol = ' '.repeat(Math.max(1, 8 - (rowText.length + colText.length))); + const suggestions = formatSuggestions(issue); + const msg = issue.message || (issue.isFlagged ? 'Forbidden word' : 'Unknown word'); + const message = issue.isFlagged ? `{yellow ${msg}}` : msg; + const substitutions = { + $col: colText, + $contextFull: contextFull, + $contextLeft: contextLeft, + $contextRight: contextRight, + $filename: filename, + $padContext: padContext, + $padRowCol: padRowCol, + $row: rowText, + $suggestions: suggestions, + $text: text, + $uri: uri, + }; + const t = template(templateStr.replace(/\$message/g, message)); + return substitute(chalk(t), substitutions); +} +function formatSuggestions(issue) { + if (issue.suggestionsEx) { + return issue.suggestionsEx + .map((sug) => sug.isPreferred + ? chalk.italic(chalk.bold(sug.wordAdjustedToMatchCase || sug.word)) + '*' + : sug.wordAdjustedToMatchCase || sug.word) + .join(', '); + } + if (issue.suggestions) { + return issue.suggestions.join(', '); + } + return ''; +} +class TS extends Array { + constructor(s) { + super(s); + this.raw = [s]; + } +} +function template(s) { + return new TS(s); +} +function substitute(text, substitutions) { + const subs = []; + for (const [match, replaceWith] of Object.entries(substitutions)) { + const len = match.length; + for (let i = text.indexOf(match); i >= 0; i = text.indexOf(match, i + 1)) { + subs.push([i, i + len, replaceWith]); + } + } + subs.sort((a, b) => a[0] - b[0]); + let i = 0; + function sub(r) { + const [a, b, t] = r; + const prefix = text.slice(i, a); + i = b; + return prefix + t; + } + const parts = subs.map(sub); + return parts.join('') + text.slice(i); +} +export const __testing__ = { + formatIssue, +}; diff --git a/action/node_modules/cspell/dist/esm/commandCheck.d.mts b/action/node_modules/cspell/dist/esm/commandCheck.d.mts new file mode 100644 index 000000000..f3b389daa --- /dev/null +++ b/action/node_modules/cspell/dist/esm/commandCheck.d.mts @@ -0,0 +1,3 @@ +import type { Command } from 'commander'; +export declare function commandCheck(prog: Command): Command; +//# sourceMappingURL=commandCheck.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/commandCheck.mjs b/action/node_modules/cspell/dist/esm/commandCheck.mjs new file mode 100644 index 000000000..395b80c82 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/commandCheck.mjs @@ -0,0 +1,47 @@ +import chalk from 'chalk'; +import { Option as CommanderOption } from 'commander'; +import * as App from './application.mjs'; +import { checkText } from './application.mjs'; +import { CheckFailed } from './util/errors.mjs'; +export function commandCheck(prog) { + return prog + .command('check ') + .description('Spell check file(s) and display the result. The full file is displayed in color.') + .option('-c, --config ', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.') + .option('--validate-directives', 'Validate in-document CSpell directives.') + .option('--no-validate-directives', 'Do not validate in-document CSpell directives.') + .option('--no-color', 'Turn off color.') + .option('--color', 'Force color') + .addOption(new CommanderOption('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp()) + .addOption(new CommanderOption('--no-default-configuration', 'Do not load the default configuration and dictionaries.')) + .action(async (files, options) => { + App.parseApplicationFeatureFlags(options.flag); + let issueCount = 0; + for (const filename of files) { + console.log(chalk.yellowBright(`Check file: ${filename}`)); + console.log(); + try { + const result = await checkText(filename, options); + for (const item of result.items) { + const fn = item.flagIE === App.IncludeExcludeFlag.EXCLUDE + ? chalk.gray + : item.isError + ? chalk.red + : chalk.whiteBright; + const t = fn(item.text); + process.stdout.write(t); + issueCount += item.isError ? 1 : 0; + } + console.log(); + } + catch (e) { + console.error(`File not found "${filename}"`); + throw new CheckFailed('File not found', 1); + } + console.log(); + } + if (issueCount) { + throw new CheckFailed('Issues found', 1); + } + }); +} diff --git a/action/node_modules/cspell/dist/esm/commandLink.d.mts b/action/node_modules/cspell/dist/esm/commandLink.d.mts new file mode 100644 index 000000000..3e09dcca7 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/commandLink.d.mts @@ -0,0 +1,3 @@ +import type { Command } from 'commander'; +export declare function commandLink(prog: Command): Command; +//# sourceMappingURL=commandLink.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/commandLink.mjs b/action/node_modules/cspell/dist/esm/commandLink.mjs new file mode 100644 index 000000000..07f0a7a09 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/commandLink.mjs @@ -0,0 +1,46 @@ +import { addPathsToGlobalImports, addPathsToGlobalImportsResultToTable, listGlobalImports, listGlobalImportsResultToTable, removePathsFromGlobalImports, } from './link.mjs'; +import { CheckFailed } from './util/errors.mjs'; +import { tableToLines } from './util/table.mjs'; +export function commandLink(prog) { + const linkCommand = prog + .command('link') + .description('Link dictionaries and other settings to the cspell global config.'); + linkCommand + .command('list', { isDefault: true }) + .alias('ls') + .description('List currently linked configurations.') + .action(() => { + const imports = listGlobalImports(); + const table = listGlobalImportsResultToTable(imports.list); + tableToLines(table).forEach((line) => console.log(line)); + return; + }); + linkCommand + .command('add ') + .alias('a') + .description('Add dictionaries any other settings to the cspell global config.') + .action((dictionaries) => { + const r = addPathsToGlobalImports(dictionaries); + const table = addPathsToGlobalImportsResultToTable(r); + console.log('Adding:'); + tableToLines(table).forEach((line) => console.log(line)); + if (r.error) { + throw new CheckFailed(r.error, 1); + } + return; + }); + linkCommand + .command('remove ') + .alias('r') + .description('Remove matching paths / packages from the global config.') + .action((dictionaries) => { + const r = removePathsFromGlobalImports(dictionaries); + console.log('Removing:'); + if (r.error) { + throw new CheckFailed(r.error, 1); + } + r.removed.map((f) => console.log(f)); + return; + }); + return linkCommand; +} diff --git a/action/node_modules/cspell/dist/esm/commandLint.d.mts b/action/node_modules/cspell/dist/esm/commandLint.d.mts new file mode 100644 index 000000000..261fa9c36 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/commandLint.d.mts @@ -0,0 +1,3 @@ +import type { Command } from 'commander'; +export declare function commandLint(prog: Command): Command; +//# sourceMappingURL=commandLint.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/commandLint.mjs b/action/node_modules/cspell/dist/esm/commandLint.mjs new file mode 100644 index 000000000..b7e1c0bce --- /dev/null +++ b/action/node_modules/cspell/dist/esm/commandLint.mjs @@ -0,0 +1,121 @@ +import { Option as CommanderOption } from 'commander'; +import * as App from './application.mjs'; +import { DEFAULT_CACHE_LOCATION } from './util/cache/index.mjs'; +import { CheckFailed } from './util/errors.mjs'; +// interface InitOptions extends Options {} +const usage = `\ +[options] [globs...] [file:// ...] [stdin[://]] + +Patterns: + - [globs...] Glob Patterns + - [stdin] Read from "stdin" assume text file. + - [stdin://] Read from "stdin", use for file type and config. + - [file://] Check the file at + +Examples: + cspell . Recursively check all files. + cspell lint . The same as "cspell ." + cspell "*.js" Check all .js files in the current directory + cspell "**/*.js" Check all .js files recursively + cspell "src/**/*.js" Only check .js under src + cspell "**/*.txt" "**/*.js" Check both .js and .txt files. + cspell "**/*.{txt,js,md}" Check .txt, .js, and .md files. + cat LICENSE | cspell stdin Check stdin + cspell stdin://docs/doc.md Check stdin as if it was "./docs/doc.md"\ +`; +const advanced = ` +More Examples: + + cspell "**/*.js" --reporter @cspell/cspell-json-reporter + This will spell check all ".js" files recursively and use + "@cspell/cspell-json-reporter". + + cspell . --reporter default + This will force the default reporter to be used overriding + any reporters defined in the configuration. + + cspell . --reporter .//reporter.cjs + Use a custom reporter. See API for details. + +References: + https://cspell.org + https://github.com/streetsidesoftware/cspell +`; +function collect(value, previous) { + if (!previous) { + return [value]; + } + return previous.concat([value]); +} +export function commandLint(prog) { + const spellCheckCommand = prog.command('lint', { isDefault: true }); + spellCheckCommand + .description('Check spelling') + .option('-c, --config ', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.') + .option('-v, --verbose', 'Display more information about the files being checked and the configuration.') + .option('--locale ', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.') + .option('--language-id ', 'Force programming language for unknown extensions. i.e. "php" or "scala"') + .addOption(new CommanderOption('--languageId ', 'Force programming language for unknown extensions. i.e. "php" or "scala"').hideHelp()) + .option('--words-only', 'Only output the words not found in the dictionaries.') + .addOption(new CommanderOption('--wordsOnly', 'Only output the words not found in the dictionaries.').hideHelp()) + .option('-u, --unique', 'Only output the first instance of a word not found in the dictionaries.') + .option('-e, --exclude ', 'Exclude files matching the glob pattern. This option can be used multiple times to add multiple globs. ', collect) + .option('--file-list ', 'Specify a list of files to be spell checked.' + + ' The list is filtered against the glob file patterns.' + + ' Note: the format is 1 file path per line.', collect) + .option('--no-issues', 'Do not show the spelling errors.') + .option('--no-progress', 'Turn off progress messages') + .option('--no-summary', 'Turn off summary message in console.') + .option('-s, --silent', 'Silent mode, suppress error messages.') + .option('--fail-fast', 'Exit after first file with an issue or error.') + .addOption(new CommanderOption('--no-fail-fast', 'Process all files even if there is an error.').hideHelp()) + .option('-r, --root ', 'Root directory, defaults to current directory.') + .option('--relative', 'Issues are displayed relative to root.') + .option('--show-context', 'Show the surrounding text around an issue.') + .option('--show-suggestions', 'Show spelling suggestions.') + .addOption(new CommanderOption('--must-find-files', 'Error if no files are found.').default(true).hideHelp()) + .option('--no-must-find-files', 'Do not error if no files are found.') + // The following options are planned features + // .option('-w, --watch', 'Watch for any changes to the matching files and report any errors') + // .option('--force', 'Force the exit value to always be 0') + .addOption(new CommanderOption('--legacy', 'Legacy output').hideHelp()) + .addOption(new CommanderOption('--local ', 'Deprecated -- Use: --locale').hideHelp()) + .option('--cache', 'Use cache to only check changed files.') + .option('--no-cache', 'Do not use cache.') + .option('--cache-reset', 'Reset the cache file.') + .addOption(new CommanderOption('--cache-strategy ', 'Strategy to use for detecting changed files.').choices([ + 'metadata', + 'content', + ])) + .option('--cache-location ', `Path to the cache file or directory. (default: "${DEFAULT_CACHE_LOCATION}")`) + .option('--dot', 'Include files and directories starting with `.` (period) when matching globs.') + .option('--gitignore', 'Ignore files matching glob patterns found in .gitignore files.') + .option('--no-gitignore', 'Do NOT use .gitignore files.') + .option('--gitignore-root ', 'Prevent searching for .gitignore files past root.', collect) + .option('--validate-directives', 'Validate in-document CSpell directives.') + .option('--no-validate-directives', 'Do not validate in-document CSpell directives.') + .option('--no-color', 'Turn off color.') + .option('--color', 'Force color.') + .addOption(new CommanderOption('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp()) + .addOption(new CommanderOption('--no-default-configuration', 'Do not load the default configuration and dictionaries.')) + .option('--debug', 'Output information useful for debugging cspell.json files.') + .option('--reporter ', 'Specify one or more reporters to use.', collect) + .usage(usage) + .addHelpText('after', advanced) + .arguments('[globs...]') + .action((fileGlobs, options) => { + App.parseApplicationFeatureFlags(options.flag); + const { mustFindFiles, fileList } = options; + return App.lint(fileGlobs, options).then((result) => { + if (!fileGlobs.length && !result.files && !result.errors && !fileList) { + spellCheckCommand.outputHelp(); + throw new CheckFailed('outputHelp', 1); + } + if (result.issues || result.errors || (mustFindFiles && !result.files)) { + throw new CheckFailed('check failed', 1); + } + return; + }); + }); + return spellCheckCommand; +} diff --git a/action/node_modules/cspell/dist/esm/commandSuggestion.d.mts b/action/node_modules/cspell/dist/esm/commandSuggestion.d.mts new file mode 100644 index 000000000..282eb9f35 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/commandSuggestion.d.mts @@ -0,0 +1,3 @@ +import type { Command } from 'commander'; +export declare function commandSuggestion(prog: Command): Command; +//# sourceMappingURL=commandSuggestion.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/commandSuggestion.mjs b/action/node_modules/cspell/dist/esm/commandSuggestion.mjs new file mode 100644 index 000000000..8e26e0beb --- /dev/null +++ b/action/node_modules/cspell/dist/esm/commandSuggestion.mjs @@ -0,0 +1,60 @@ +import { Option as CommanderOption } from 'commander'; +import * as App from './application.mjs'; +import { emitSuggestionResult } from './emitters/suggestionsEmitter.mjs'; +import { CheckFailed } from './util/errors.mjs'; +function collect(value, previous) { + value = value.replace(/^=/, ''); + if (!previous) { + return [value]; + } + return previous.concat([value]); +} +function count(_, previous) { + return (previous || 0) + 1; +} +function asNumber(value, prev) { + return parseInt(value, 10) ?? prev; +} +export function commandSuggestion(prog) { + const suggestionCommand = prog.command('suggestions'); + suggestionCommand + .aliases(['sug', 'suggest']) + .description('Spelling Suggestions for words.') + .option('-c, --config ', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.') + .option('--locale ', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.') + .option('--language-id ', 'Use programming language. i.e. "php" or "scala".') + .addOption(new CommanderOption('--languageId ', 'Use programming language. i.e. "php" or "scala".').hideHelp()) + .option('-s, --no-strict', 'Ignore case and accents when searching for words.') + .option('--ignore-case', 'Alias of --no-strict.') + .option('--num-changes ', 'Number of changes allowed to a word', asNumber, 4) + .option('--num-suggestions ', 'Number of suggestions', asNumber, 8) + .option('--no-include-ties', 'Force the number of suggested to be limited, by not including suggestions that have the same edit cost.') + .option('--stdin', 'Use stdin for input.') + .addOption(new CommanderOption('--repl', 'REPL interface for looking up suggestions.')) + .option('-v, --verbose', 'Show detailed output.', count, 0) + .option('-d, --dictionary ', 'Use the dictionary specified. Only dictionaries specified will be used.', collect) + .option('--dictionaries ', 'Use the dictionaries specified. Only dictionaries specified will be used.') + .option('--no-color', 'Turn off color.') + .option('--color', 'Force color') + .arguments('[words...]') + .action(async (words, options) => { + App.parseApplicationFeatureFlags(options.flag); + options.useStdin = options.stdin; + options.dictionaries = mergeArrays(options.dictionaries, options.dictionary); + if (!words.length && !options.useStdin && !options.repl) { + suggestionCommand.outputHelp(); + throw new CheckFailed('outputHelp', 1); + } + for await (const r of App.suggestions(words, options)) { + emitSuggestionResult(r, options); + } + }); + return suggestionCommand; +} +function mergeArrays(a, b) { + if (a === undefined) + return b; + if (b === undefined) + return a; + return a.concat(b); +} diff --git a/action/node_modules/cspell/dist/esm/commandTrace.d.mts b/action/node_modules/cspell/dist/esm/commandTrace.d.mts new file mode 100644 index 000000000..d3248f7bb --- /dev/null +++ b/action/node_modules/cspell/dist/esm/commandTrace.d.mts @@ -0,0 +1,3 @@ +import type { Command } from 'commander'; +export declare function commandTrace(prog: Command): Command; +//# sourceMappingURL=commandTrace.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/commandTrace.mjs b/action/node_modules/cspell/dist/esm/commandTrace.mjs new file mode 100644 index 000000000..ca5c0f4bf --- /dev/null +++ b/action/node_modules/cspell/dist/esm/commandTrace.mjs @@ -0,0 +1,59 @@ +import { Option as CommanderOption } from 'commander'; +import * as App from './application.mjs'; +import { isDictionaryPathFormat } from './emitters/DictionaryPathFormat.mjs'; +import { emitTraceResults } from './emitters/traceEmitter.mjs'; +import { CheckFailed } from './util/errors.mjs'; +export function commandTrace(prog) { + return prog + .command('trace') + .description(`Trace words -- Search for words in the configuration and dictionaries.`) + .option('-c, --config ', 'Configuration file to use. By default cspell looks for cspell.json in the current directory.') + .option('--locale ', 'Set language locales. i.e. "en,fr" for English and French, or "en-GB" for British English.') + .option('--language-id ', 'Use programming language. i.e. "php" or "scala".') + .addOption(new CommanderOption('--languageId ', 'Use programming language. i.e. "php" or "scala".').hideHelp()) + .option('--allow-compound-words', 'Turn on allowCompoundWords') + .addOption(new CommanderOption('--allowCompoundWords', 'Turn on allowCompoundWords.').hideHelp()) + .option('--no-allow-compound-words', 'Turn off allowCompoundWords') + .option('--ignore-case', 'Ignore case and accents when searching for words.') + .option('--no-ignore-case', 'Do not ignore case and accents when searching for words.') + .addOption(new CommanderOption('--dictionary-path ', 'Configure how to display the dictionary path.') + .choices(['hide', 'short', 'long', 'full']) + .default('long', 'Display most of the path.')) + .option('--stdin', 'Read words from stdin.') + .option('--all', 'Show all dictionaries.') + .addOption(new CommanderOption('--only-found', 'Show only dictionaries that have the words.').conflicts('all')) + .option('--no-color', 'Turn off color.') + .option('--color', 'Force color') + .addOption(new CommanderOption('--default-configuration', 'Load the default configuration and dictionaries.').hideHelp()) + .addOption(new CommanderOption('--no-default-configuration', 'Do not load the default configuration and dictionaries.')) + .arguments('[words...]') + .action(async (words, options) => { + App.parseApplicationFeatureFlags(options.flag); + let numFound = 0; + const dictionaryPathFormat = isDictionaryPathFormat(options.dictionaryPath) + ? options.dictionaryPath + : 'long'; + for await (const results of App.trace(words, options)) { + const filtered = filterTraceResults(results, options); + emitTraceResults(filtered, { cwd: process.cwd(), dictionaryPathFormat }); + numFound += results.reduce((n, r) => n + (r.found ? 1 : 0), 0); + const numErrors = results.map((r) => r.errors?.length || 0).reduce((n, r) => n + r, 0); + if (numErrors) { + console.error('Dictionary Errors.'); + throw new CheckFailed('dictionary errors', 1); + } + } + if (!numFound) { + console.error('No matches found'); + throw new CheckFailed('no matches', 1); + } + }); +} +function filterTraceResults(results, options) { + if (options.all) + return results; + return results.filter((r) => filterTraceResult(r, options.onlyFound)); +} +function filterTraceResult(result, onlyFound) { + return result.found || result.forbidden || result.noSuggest || (!onlyFound && result.dictActive); +} diff --git a/action/node_modules/cspell/dist/esm/emitters/DictionaryPathFormat.d.mts b/action/node_modules/cspell/dist/esm/emitters/DictionaryPathFormat.d.mts new file mode 100644 index 000000000..cd3061629 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/emitters/DictionaryPathFormat.d.mts @@ -0,0 +1,3 @@ +export type DictionaryPathFormat = 'hide' | 'long' | 'short' | 'full'; +export declare function isDictionaryPathFormat(value: string | undefined): value is DictionaryPathFormat; +//# sourceMappingURL=DictionaryPathFormat.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/emitters/DictionaryPathFormat.mjs b/action/node_modules/cspell/dist/esm/emitters/DictionaryPathFormat.mjs new file mode 100644 index 000000000..bb4c650db --- /dev/null +++ b/action/node_modules/cspell/dist/esm/emitters/DictionaryPathFormat.mjs @@ -0,0 +1,11 @@ +const formats = { + full: true, + hide: true, + long: true, + short: true, +}; +export function isDictionaryPathFormat(value) { + if (!value || typeof value !== 'string') + return false; + return value in formats; +} diff --git a/action/node_modules/cspell/dist/esm/emitters/suggestionsEmitter.d.mts b/action/node_modules/cspell/dist/esm/emitters/suggestionsEmitter.d.mts new file mode 100644 index 000000000..83a5904c5 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/emitters/suggestionsEmitter.d.mts @@ -0,0 +1,13 @@ +import type { SuggestionsForWordResult } from 'cspell-lib'; +export interface EmitSuggestionOptions { + verbose?: number; + lineWidth?: number; + output?: { + log: (text: string) => void; + }; +} +export interface TimedSuggestionsForWordResult extends SuggestionsForWordResult { + elapsedTimeMs?: number; +} +export declare function emitSuggestionResult(result: TimedSuggestionsForWordResult, options: EmitSuggestionOptions): void; +//# sourceMappingURL=suggestionsEmitter.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/emitters/suggestionsEmitter.mjs b/action/node_modules/cspell/dist/esm/emitters/suggestionsEmitter.mjs new file mode 100644 index 000000000..faa1d0c6e --- /dev/null +++ b/action/node_modules/cspell/dist/esm/emitters/suggestionsEmitter.mjs @@ -0,0 +1,76 @@ +import chalk from 'chalk'; +import { padLeft, padWidth, width } from '../util/util.mjs'; +const regExpRTL = /([\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC י]+)/g; +function reverseRtlText(s) { + return s.replace(regExpRTL, (s) => s.split('').reverse().join('')); +} +export function emitSuggestionResult(result, options) { + const { word, suggestions } = result; + const { verbose, output = console } = options; + const elapsed = verbose && verbose > 1 && result.elapsedTimeMs ? ` ${result.elapsedTimeMs.toFixed(2)} ms` : ''; + const rWord = reverseRtlText(word); + const wordEx = rWord !== word ? ` (${chalk.yellow(rWord)})` : ''; + output.log((word ? chalk.yellow(word) + wordEx : chalk.yellow('')) + ':' + elapsed); + if (!suggestions.length) { + console.log(chalk.yellow(' ')); + return; + } + function handleRtl(word) { + const r = reverseRtlText(word); + return r === word ? word : `${word} (${r})`; + } + if (verbose) { + const mappedSugs = suggestions.map((s) => ({ + ...s, + w: handleRtl(s.compoundWord || s.wordAdjustedToMatchCase || s.word), + })); + const sugWidths = mappedSugs.map((s) => width(s.w)); + const maxWidth = sugWidths.reduce((max, len) => Math.max(max, len), 0); + for (const sug of mappedSugs) { + const { cost, dictionaries, w } = sug; + const padding = ' '.repeat(padWidth(w, maxWidth)); + const forbid = sug.forbidden && sug.isPreferred + ? chalk.red('*') + : sug.forbidden + ? chalk.red('X') + : sug.isPreferred + ? chalk.yellow('*') + : ' '; + const ignore = sug.noSuggest ? chalk.yellow('N') : ' '; + const strCost = padLeft(cost.toString(10), 4); + const dicts = dictionaries.map((n) => chalk.gray(n)).join(', '); + output.log(` - ${formatWord(w, sug)}${padding} ${forbid}${ignore} - ${chalk.yellow(strCost)} ${dicts}`); + } + } + else { + const mappedSugs = suggestions.map((s) => ({ ...s, word: handleRtl(s.wordAdjustedToMatchCase || s.word) })); + for (const r of mappedSugs) { + output.log(` - ${formatWordSingle(r)}`); + } + } +} +function formatWord(word, r) { + return r.forbidden || r.noSuggest + ? chalk.gray(chalk.strikethrough(word)) + : word === r.wordAdjustedToMatchCase + ? diff(word, r.word) + : word; +} +function diff(wordA, wordB) { + const a = [...wordA]; + const b = [...wordB]; + const parts = []; + for (let idx = 0; idx < a.length; ++idx) { + const aa = a[idx]; + const bb = b[idx]; + parts.push(aa === bb ? aa : chalk.yellow(aa)); + } + return parts.join(''); +} +function formatWordSingle(s) { + let word = formatWord(s.word, s); + word = s.forbidden ? word + chalk.red(' X') : word; + word = s.noSuggest ? word + chalk.yellow(' Not suggested.') : word; + word = s.isPreferred ? chalk.yellow(word + ' *') : word; + return word; +} diff --git a/action/node_modules/cspell/dist/esm/emitters/traceEmitter.d.mts b/action/node_modules/cspell/dist/esm/emitters/traceEmitter.d.mts new file mode 100644 index 000000000..f5d433cf6 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/emitters/traceEmitter.d.mts @@ -0,0 +1,21 @@ +import type { TraceResult } from '../application.mjs'; +import type { DictionaryPathFormat } from './DictionaryPathFormat.mjs'; +interface PathInterface { + relative(from: string, to: string): string; + basename(path: string): string; + sep: string; +} +export interface EmitTraceOptions { + /** current working directory */ + cwd: string; + lineWidth?: number; + dictionaryPathFormat: DictionaryPathFormat; + iPath?: PathInterface; +} +export declare function emitTraceResults(results: TraceResult[], options: EmitTraceOptions): void; +declare function trimMidPath(s: string, w: number, sep: string): string; +export declare const __testing__: { + trimMidPath: typeof trimMidPath; +}; +export {}; +//# sourceMappingURL=traceEmitter.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/emitters/traceEmitter.mjs b/action/node_modules/cspell/dist/esm/emitters/traceEmitter.mjs new file mode 100644 index 000000000..a0105915d --- /dev/null +++ b/action/node_modules/cspell/dist/esm/emitters/traceEmitter.mjs @@ -0,0 +1,140 @@ +import chalk from 'chalk'; +import * as iPath from 'path'; +import strip from 'strip-ansi'; +import { pad, width } from '../util/util.mjs'; +const colWidthDictionaryName = 20; +export function emitTraceResults(results, options) { + const maxWordLength = results + .map((r) => r.foundWord || r.word) + .reduce((a, b) => Math.max(a, width(b)), 'Word'.length); + const maxDictNameLength = results + .map((r) => r.dictName.length) + .reduce((a, b) => Math.max(a, b), colWidthDictionaryName); + const cols = { + word: maxWordLength, + dictName: maxDictNameLength, + terminalWidth: options.lineWidth ?? (process.stdout.columns || 120), + location: options.dictionaryPathFormat === 'hide' ? 0 : 30, + }; + const col = new Intl.Collator(); + results.sort((a, b) => col.compare(a.dictName, b.dictName)); + emitHeader(cols); + results.forEach((r) => emitTraceResult(r, cols, options)); +} +function emitHeader(colWidths) { + const line = [ + pad('Word', colWidths.word), + 'F', + pad('Dictionary', colWidths.dictName), + colWidths.location ? pad('Dictionary Location', colWidths.location) : '', + ]; + console.log(chalk.underline(line.join(' ').trim().slice(0, colWidths.terminalWidth))); +} +function emitTraceResult(r, colWidths, options) { + const { word: wordColWidth, terminalWidth, dictName: widthName } = colWidths; + const errors = r.errors?.map((e) => e.message)?.join('\n\t') || ''; + const word = pad(r.foundWord || r.word, wordColWidth); + const cWord = word.replace(/[+]/g, chalk.yellow('+')); + const w = r.forbidden ? chalk.red(cWord) : chalk.green(cWord); + const f = calcFoundChar(r); + const a = r.dictActive ? '*' : ' '; + const dictName = pad(r.dictName.slice(0, widthName - 1) + a, widthName); + const dictColor = r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50); + const n = dictColor(dictName); + const info = [w, f, n].join(' ') + ' '; + const used = width(strip(info)); + const widthSrc = terminalWidth - used; + const c = colorize(errors ? chalk.red : chalk.white); + const s = c(formatDictionaryLocation(r.dictSource, widthSrc, { iPath, ...options })); + const line = info + s; + console.log(line.trim()); + if (errors) { + console.error('\t' + chalk.red(errors)); + } +} +function trimMid(s, w) { + s = s.trim(); + if (s.length <= w) { + return s; + } + const l = Math.floor((w - 3) / 2); + const r = Math.ceil((w - 3) / 2); + return s.slice(0, l) + '...' + s.slice(-r); +} +function calcFoundChar(r) { + const errors = r.errors?.map((e) => e.message)?.join('\n\t') || ''; + let color = chalk.dim; + color = r.found ? chalk.whiteBright : color; + color = r.forbidden ? chalk.red : color; + color = r.noSuggest ? chalk.yellowBright : color; + color = errors ? chalk.red : color; + let char = '-'; + char = r.found ? '*' : char; + char = r.forbidden ? '!' : char; + char = r.noSuggest ? 'I' : char; + char = errors ? 'X' : char; + return color(char); +} +function formatDictionaryLocation(dictSource, maxWidth, { cwd, dictionaryPathFormat: format, iPath, }) { + let relPath = cwd ? iPath.relative(cwd, dictSource) : dictSource; + const idxNodeModule = relPath.lastIndexOf('node_modules'); + const isNodeModule = idxNodeModule >= 0; + if (format === 'hide') + return ''; + if (format === 'short') { + const prefix = isNodeModule + ? '[node_modules]/' + : relPath.startsWith('..' + iPath.sep + '..') + ? '.../' + : relPath.startsWith('..' + iPath.sep) + ? '../' + : ''; + return prefix + iPath.basename(dictSource); + } + if (format === 'full') + return dictSource; + relPath = isNodeModule ? relPath.slice(idxNodeModule) : relPath; + const usePath = relPath.length < dictSource.length ? relPath : dictSource; + return trimMidPath(usePath, maxWidth, iPath.sep); +} +function colorize(fn) { + return (s) => (s ? fn(s) : ''); +} +function trimMidPath(s, w, sep) { + if (s.length <= w) + return s; + const parts = s.split(sep); + if (parts[parts.length - 1].length > w) + return trimMid(s, w); + function join(left, right) { + // if (left === right) return parts.join(sep); + return [...parts.slice(0, left), '...', ...parts.slice(right)].join(sep); + } + let left = 0, right = parts.length, last = ''; + for (let i = 0; i < parts.length; ++i) { + const incLeft = i & 1 ? 1 : 0; + const incRight = incLeft ? 0 : -1; + const next = join(left + incLeft, right + incRight); + if (next.length > w) + break; + left += incLeft; + right += incRight; + last = next; + } + for (let i = left + 1; i < right; ++i) { + const next = join(i, right); + if (next.length > w) + break; + last = next; + } + for (let i = right - 1; i > left; --i) { + const next = join(left, i); + if (next.length > w) + break; + last = next; + } + return last || trimMid(s, w); +} +export const __testing__ = { + trimMidPath, +}; diff --git a/action/node_modules/cspell/dist/esm/featureFlags/featureFlags.d.mts b/action/node_modules/cspell/dist/esm/featureFlags/featureFlags.d.mts new file mode 100644 index 000000000..78ece3dc7 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/featureFlags/featureFlags.d.mts @@ -0,0 +1,4 @@ +import type { FeatureFlags } from 'cspell-lib'; +export declare function getFeatureFlags(): FeatureFlags; +export declare function parseFeatureFlags(flags: string[] | undefined, featureFlags?: FeatureFlags): FeatureFlags; +//# sourceMappingURL=featureFlags.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/featureFlags/featureFlags.mjs b/action/node_modules/cspell/dist/esm/featureFlags/featureFlags.mjs new file mode 100644 index 000000000..4db52924d --- /dev/null +++ b/action/node_modules/cspell/dist/esm/featureFlags/featureFlags.mjs @@ -0,0 +1,19 @@ +import { getSystemFeatureFlags } from 'cspell-lib'; +export function getFeatureFlags() { + return getSystemFeatureFlags(); +} +export function parseFeatureFlags(flags, featureFlags = getFeatureFlags()) { + if (!flags) + return featureFlags; + const flagsKvP = flags.map((f) => f.split(':', 2)); + for (const flag of flagsKvP) { + const [name, value] = flag; + try { + featureFlags.setFlag(name, value); + } + catch (e) { + console.warn(`Unknown flag: "${name}"`); + } + } + return featureFlags; +} diff --git a/action/node_modules/cspell/dist/esm/featureFlags/index.d.mts b/action/node_modules/cspell/dist/esm/featureFlags/index.d.mts new file mode 100644 index 000000000..6fe1067f7 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/featureFlags/index.d.mts @@ -0,0 +1,2 @@ +export { getFeatureFlags, parseFeatureFlags } from './featureFlags.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/featureFlags/index.mjs b/action/node_modules/cspell/dist/esm/featureFlags/index.mjs new file mode 100644 index 000000000..5943b59f8 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/featureFlags/index.mjs @@ -0,0 +1 @@ +export { getFeatureFlags, parseFeatureFlags } from './featureFlags.mjs'; diff --git a/action/node_modules/cspell/dist/esm/index.d.mts b/action/node_modules/cspell/dist/esm/index.d.mts new file mode 100644 index 000000000..0c579e129 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/index.d.mts @@ -0,0 +1,5 @@ +export * from './application.mjs'; +export { getReporter as getDefaultReporter } from './cli-reporter.mjs'; +export type { BaseOptions, LinterCliOptions as CSpellApplicationOptions, TraceOptions } from './options.mjs'; +export * from '@cspell/cspell-types'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/index.mjs b/action/node_modules/cspell/dist/esm/index.mjs new file mode 100644 index 000000000..b9c9c8147 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/index.mjs @@ -0,0 +1,3 @@ +export * from './application.mjs'; +export { getReporter as getDefaultReporter } from './cli-reporter.mjs'; +export * from '@cspell/cspell-types'; diff --git a/action/node_modules/cspell/dist/esm/link.d.mts b/action/node_modules/cspell/dist/esm/link.d.mts new file mode 100644 index 000000000..a9b7f23fb --- /dev/null +++ b/action/node_modules/cspell/dist/esm/link.d.mts @@ -0,0 +1,8 @@ +import { Link } from 'cspell-lib'; +import type { Table } from './util/table.mjs'; +export declare const listGlobalImports: typeof Link.listGlobalImports; +export declare const addPathsToGlobalImports: typeof Link.addPathsToGlobalImports; +export declare const removePathsFromGlobalImports: typeof Link.removePathsFromGlobalImports; +export declare function listGlobalImportsResultToTable(results: Link.ListGlobalImportsResult[]): Table; +export declare function addPathsToGlobalImportsResultToTable(results: Link.AddPathsToGlobalImportsResults): Table; +//# sourceMappingURL=link.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/link.mjs b/action/node_modules/cspell/dist/esm/link.mjs new file mode 100644 index 000000000..7a72c66f2 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/link.mjs @@ -0,0 +1,38 @@ +import chalk from 'chalk'; +import { Link } from 'cspell-lib'; +export const listGlobalImports = Link.listGlobalImports; +export const addPathsToGlobalImports = Link.addPathsToGlobalImports; +export const removePathsFromGlobalImports = Link.removePathsFromGlobalImports; +export function listGlobalImportsResultToTable(results) { + const header = ['id', 'package', 'name', 'filename', 'dictionaries', 'errors']; + const decorate = (isError) => (isError ? (s) => chalk.red(s) : (s) => s); + function toColumns(r) { + return [ + r.id, + r.package?.name, + r.name, + r.filename, + r.dictionaryDefinitions?.map((def) => def.name).join(', '), + r.error ? 'Failed to read file.' : '', + ] + .map((c) => c || '') + .map(decorate(!!r.error)); + } + return { + header, + rows: results.map(toColumns), + }; +} +export function addPathsToGlobalImportsResultToTable(results) { + const header = ['filename', 'errors']; + const decorate = (isError) => (isError ? (s) => chalk.red(s) : (s) => s); + function toColumns(r) { + return [r.resolvedToFilename || r.filename, r.error ? 'Failed to read file.' : ''] + .map((c) => c || '') + .map(decorate(!!r.error)); + } + return { + header, + rows: results.resolvedSettings.map(toColumns), + }; +} diff --git a/action/node_modules/cspell/dist/esm/lint/LintRequest.d.mts b/action/node_modules/cspell/dist/esm/lint/LintRequest.d.mts new file mode 100644 index 000000000..ece08a690 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/lint/LintRequest.d.mts @@ -0,0 +1,23 @@ +import type { Issue } from '@cspell/cspell-types'; +import type { LinterOptions } from '../options.mjs'; +import type { GlobSrcInfo } from '../util/glob.mjs'; +import type { FinalizedReporter } from '../util/reporters.mjs'; +interface Deprecated { + fileLists?: LinterOptions['fileList']; +} +export declare class LintRequest { + readonly fileGlobs: string[]; + readonly options: LinterOptions & Deprecated; + readonly reporter: FinalizedReporter; + readonly uniqueFilter: (issue: Issue) => boolean; + readonly locale: string; + readonly configFile: string | undefined; + readonly excludes: GlobSrcInfo[]; + readonly root: string; + readonly showContext: number; + readonly enableGlobDot: boolean | undefined; + readonly fileLists: string[]; + constructor(fileGlobs: string[], options: LinterOptions & Deprecated, reporter: FinalizedReporter); +} +export {}; +//# sourceMappingURL=LintRequest.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/lint/LintRequest.mjs b/action/node_modules/cspell/dist/esm/lint/LintRequest.mjs new file mode 100644 index 000000000..9063af7ac --- /dev/null +++ b/action/node_modules/cspell/dist/esm/lint/LintRequest.mjs @@ -0,0 +1,20 @@ +import * as path from 'path'; +import { calcExcludeGlobInfo } from '../util/glob.mjs'; +import * as util from '../util/util.mjs'; +const defaultContextRange = 20; +export class LintRequest { + constructor(fileGlobs, options, reporter) { + this.fileGlobs = fileGlobs; + this.options = options; + this.reporter = reporter; + this.root = path.resolve(options.root || process.cwd()); + this.configFile = options.config; + this.excludes = calcExcludeGlobInfo(this.root, options.exclude); + this.locale = options.locale || ''; + this.enableGlobDot = options.dot; + this.uniqueFilter = options.unique ? util.uniqueFilterFnGenerator((issue) => issue.text) : () => true; + this.showContext = + options.showContext === true ? defaultContextRange : options.showContext ? options.showContext : 0; + this.fileLists = (options.fileList ?? options.fileLists) || []; + } +} diff --git a/action/node_modules/cspell/dist/esm/lint/index.d.mts b/action/node_modules/cspell/dist/esm/lint/index.d.mts new file mode 100644 index 000000000..ea2183f38 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/lint/index.d.mts @@ -0,0 +1,3 @@ +export { runLint } from './lint.mjs'; +export { LintRequest } from './LintRequest.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/lint/index.mjs b/action/node_modules/cspell/dist/esm/lint/index.mjs new file mode 100644 index 000000000..4dd866f48 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/lint/index.mjs @@ -0,0 +1,2 @@ +export { runLint } from './lint.mjs'; +export { LintRequest } from './LintRequest.mjs'; diff --git a/action/node_modules/cspell/dist/esm/lint/lint.d.mts b/action/node_modules/cspell/dist/esm/lint/lint.d.mts new file mode 100644 index 000000000..951c4e8e5 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/lint/lint.d.mts @@ -0,0 +1,4 @@ +import type { RunResult } from '@cspell/cspell-types'; +import type { LintRequest } from './LintRequest.mjs'; +export declare function runLint(cfg: LintRequest): Promise; +//# sourceMappingURL=lint.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/lint/lint.mjs b/action/node_modules/cspell/dist/esm/lint/lint.mjs new file mode 100644 index 000000000..52c292c6c --- /dev/null +++ b/action/node_modules/cspell/dist/esm/lint/lint.mjs @@ -0,0 +1,468 @@ +import { isAsyncIterable, operators, opFilter, pipeAsync, pipeSync } from '@cspell/cspell-pipe'; +import { opMap, pipe } from '@cspell/cspell-pipe/sync'; +import { MessageTypes } from '@cspell/cspell-types'; +import chalk from 'chalk'; +import { findRepoRoot, GitIgnore } from 'cspell-gitignore'; +import { GlobMatcher } from 'cspell-glob'; +import * as cspell from 'cspell-lib'; +import * as path from 'path'; +import { format } from 'util'; +import { npmPackage } from '../../lib/pkgInfo.cjs'; +import { URI } from '../../lib/uri.cjs'; +import { getFeatureFlags } from '../featureFlags/index.mjs'; +import { calcCacheSettings, createCache } from '../util/cache/index.mjs'; +import { CheckFailed, toApplicationError, toError } from '../util/errors.mjs'; +import { fileInfoToDocument, filenameToUri, findFiles, isBinaryFile, isNotDir, readConfig, readFileInfo, readFileListFiles, } from '../util/fileHelper.mjs'; +import { buildGlobMatcher, extractGlobsFromMatcher, extractPatterns, normalizeFileOrGlobsToRoot, normalizeGlobsToRoot, } from '../util/glob.mjs'; +import { prefetchIterable } from '../util/prefetch.mjs'; +import { loadReporters, mergeReporters } from '../util/reporters.mjs'; +import { getTimeMeasurer } from '../util/timer.mjs'; +import * as util from '../util/util.mjs'; +const version = npmPackage.version; +const BATCH_SIZE = 8; +const { opFilterAsync } = operators; +export async function runLint(cfg) { + let { reporter } = cfg; + cspell.setLogger(getLoggerFromReporter(reporter)); + const configErrors = new Set(); + const timer = getTimeMeasurer(); + const lintResult = await run(); + await reporter.result(lintResult); + const elapsed = timer(); + if (getFeatureFlags().getFlag('timer')) { + console.log(`Elapsed Time: ${elapsed.toFixed(2)}ms`); + } + return lintResult; + function prefetch(filename, configInfo, cache) { + if (isBinaryFile(filename, cfg.root)) + return { filename, result: Promise.resolve({ skip: true }) }; + async function fetch() { + const getElapsedTimeMs = getTimeMeasurer(); + const cachedResult = await cache.getCachedLintResults(filename); + if (cachedResult) { + reporter.debug(`Filename: ${filename}, using cache`); + const fileResult = { ...cachedResult, elapsedTimeMs: getElapsedTimeMs() }; + return { fileResult }; + } + const uri = filenameToUri(filename, cfg.root); + const checkResult = await cspell.shouldCheckDocument({ uri }, {}, configInfo.config); + if (!checkResult.shouldCheck) + return { skip: true }; + const fileInfo = await readFileInfo(filename, undefined, true); + return { fileInfo }; + } + const result = fetch(); + return { filename, result }; + } + async function processFile(filename, configInfo, cache, prefetch) { + if (prefetch?.fileResult) + return prefetch.fileResult; + const getElapsedTimeMs = getTimeMeasurer(); + const cachedResult = await cache.getCachedLintResults(filename); + if (cachedResult) { + reporter.debug(`Filename: ${filename}, using cache`); + return { ...cachedResult, elapsedTimeMs: getElapsedTimeMs() }; + } + const result = { + fileInfo: { + filename, + }, + issues: [], + processed: false, + errors: 0, + configErrors: 0, + elapsedTimeMs: 0, + }; + const fileInfo = prefetch?.fileInfo || (await readFileInfo(filename, undefined, true)); + if (fileInfo.errorCode) { + if (fileInfo.errorCode !== 'EISDIR' && cfg.options.mustFindFiles) { + const err = toError(`File not found: "${filename}"`); + reporter.error('Linter:', err); + result.errors += 1; + } + return result; + } + const doc = fileInfoToDocument(fileInfo, cfg.options.languageId, cfg.locale); + const { text } = fileInfo; + result.fileInfo = fileInfo; + let spellResult = {}; + reporter.info(`Checking: ${filename}, File type: ${doc.languageId ?? 'auto'}, Language: ${doc.locale ?? 'default'}`, MessageTypes.Info); + try { + const { showSuggestions: generateSuggestions, validateDirectives } = cfg.options; + const numSuggestions = configInfo.config.numSuggestions ?? 5; + const validateOptions = util.clean({ generateSuggestions, numSuggestions, validateDirectives }); + const r = await cspell.spellCheckDocument(doc, validateOptions, configInfo.config); + spellResult = r; + result.processed = r.checked; + result.issues = cspell.Text.calculateTextDocumentOffsets(doc.uri, text, r.issues).map(mapIssue); + } + catch (e) { + reporter.error(`Failed to process "${filename}"`, toError(e)); + result.errors += 1; + } + result.elapsedTimeMs = getElapsedTimeMs(); + const config = spellResult.settingsUsed ?? {}; + result.configErrors += await reportConfigurationErrors(config); + const elapsed = result.elapsedTimeMs / 1000.0; + const dictionaries = config.dictionaries || []; + reporter.info(`Checked: ${filename}, File type: ${config.languageId}, Language: ${config.language} ... Issues: ${result.issues.length} ${elapsed}S`, MessageTypes.Info); + reporter.info(`Config file Used: ${spellResult.localConfigFilepath || configInfo.source}`, MessageTypes.Info); + reporter.info(`Dictionaries Used: ${dictionaries.join(', ')}`, MessageTypes.Info); + if (cfg.options.debug) { + const { id: _id, name: _name, __imports, __importRef, ...cfg } = config; + const debugCfg = { + filename, + languageId: doc.languageId ?? cfg.languageId ?? 'default', + config: { ...cfg, source: null }, + source: spellResult.localConfigFilepath, + }; + reporter.debug(JSON.stringify(debugCfg, undefined, 2)); + } + const dep = calcDependencies(config); + cache.setCachedLintResults(result, dep.files); + return result; + } + function mapIssue({ doc: _, ...tdo }) { + const context = cfg.showContext + ? extractContext(tdo, cfg.showContext) + : { text: tdo.line.text.trimEnd(), offset: tdo.line.offset }; + return util.clean({ ...tdo, context }); + } + async function processFiles(files, configInfo, cacheSettings) { + const fileCount = files instanceof Array ? files.length : undefined; + const status = runResult(); + const cache = createCache(cacheSettings); + const failFast = cfg.options.failFast ?? configInfo.config.failFast ?? false; + const emitProgressBegin = (filename, fileNum, fileCount) => reporter.progress({ + type: 'ProgressFileBegin', + fileNum, + fileCount, + filename, + }); + const emitProgressComplete = (filename, fileNum, fileCount, result) => reporter.progress(util.clean({ + type: 'ProgressFileComplete', + fileNum, + fileCount, + filename, + elapsedTimeMs: result?.elapsedTimeMs, + processed: result?.processed, + numErrors: result?.issues.length || result?.errors, + cached: result?.cached, + })); + function* prefetchFiles(files) { + const iter = prefetchIterable(pipe(files, opMap((filename) => prefetch(filename, configInfo, cache))), BATCH_SIZE); + for (const v of iter) { + yield v; + } + } + async function* prefetchFilesAsync(files) { + for await (const filename of files) { + yield prefetch(filename, configInfo, cache); + } + } + const emptyResult = { + fileInfo: { filename: '' }, + issues: [], + processed: false, + errors: 0, + configErrors: 0, + elapsedTimeMs: 1, + }; + async function processPrefetchFileResult(pf, index) { + const { filename, result: pFetchResult } = pf; + const getElapsedTimeMs = getTimeMeasurer(); + const fetchResult = await pFetchResult; + emitProgressBegin(filename, index, fileCount ?? index); + if (fetchResult?.skip) { + return { + filename, + fileNum: index, + result: { ...emptyResult, fileInfo: { filename }, elapsedTimeMs: getElapsedTimeMs() }, + }; + } + const result = await processFile(filename, configInfo, cache, fetchResult); + return { filename, fileNum: index, result }; + } + async function* loadAndProcessFiles() { + let i = 0; + if (isAsyncIterable(files)) { + for await (const pf of prefetchFilesAsync(files)) { + yield processPrefetchFileResult(pf, ++i); + } + } + else { + for (const pf of prefetchFiles(files)) { + await pf.result; + yield await processPrefetchFileResult(pf, ++i); + } + } + } + for await (const fileP of loadAndProcessFiles()) { + const { filename, fileNum, result } = await fileP; + status.files += 1; + status.cachedFiles = (status.cachedFiles || 0) + (result.cached ? 1 : 0); + emitProgressComplete(filename, fileNum, fileCount ?? fileNum, result); + // Show the spelling errors after emitting the progress. + result.issues.filter(cfg.uniqueFilter).forEach((issue) => reporter.issue(issue)); + if (result.issues.length || result.errors) { + status.filesWithIssues.add(filename); + status.issues += result.issues.length; + status.errors += result.errors; + if (failFast) { + return status; + } + } + status.errors += result.configErrors; + } + cache.reconcile(); + return status; + } + function calcDependencies(config) { + const { configFiles, dictionaryFiles } = cspell.extractDependencies(config); + return { files: configFiles.concat(dictionaryFiles) }; + } + async function reportConfigurationErrors(config) { + const errors = cspell.extractImportErrors(config); + let count = 0; + errors.forEach((ref) => { + const key = ref.error.toString(); + if (configErrors.has(key)) + return; + configErrors.add(key); + count += 1; + reporter.error('Configuration', ref.error); + }); + const dictCollection = await cspell.getDictionary(config); + dictCollection.dictionaries.forEach((dict) => { + const dictErrors = dict.getErrors?.() || []; + const msg = `Dictionary Error with (${dict.name})`; + dictErrors.forEach((error) => { + const key = msg + error.toString(); + if (configErrors.has(key)) + return; + configErrors.add(key); + count += 1; + reporter.error(msg, error); + }); + }); + return count; + } + function countConfigErrors(configInfo) { + return reportConfigurationErrors(configInfo.config); + } + async function run() { + if (cfg.options.root) { + process.env[cspell.ENV_CSPELL_GLOB_ROOT] = cfg.root; + } + const configInfo = await readConfig(cfg.configFile, cfg.root); + if (cfg.options.defaultConfiguration !== undefined) { + configInfo.config.loadDefaultConfiguration = cfg.options.defaultConfiguration; + } + const reporterConfig = util.clean({ + maxNumberOfProblems: configInfo.config.maxNumberOfProblems, + maxDuplicateProblems: configInfo.config.maxDuplicateProblems, + minWordLength: configInfo.config.minWordLength, + ...cfg.options, + }); + const reporters = cfg.options.reporter ?? configInfo.config.reporters; + reporter = mergeReporters(...(await loadReporters(reporters, cfg.reporter, reporterConfig))); + cspell.setLogger(getLoggerFromReporter(reporter)); + const globInfo = await determineGlobs(configInfo, cfg); + const { fileGlobs, excludeGlobs } = globInfo; + const hasFileLists = !!cfg.fileLists.length; + if (!fileGlobs.length && !hasFileLists) { + // Nothing to do. + return runResult(); + } + header(fileGlobs, excludeGlobs); + checkGlobs(fileGlobs, reporter); + reporter.info(`Config Files Found:\n ${configInfo.source}\n`, MessageTypes.Info); + const configErrors = await countConfigErrors(configInfo); + if (configErrors) + return runResult({ errors: configErrors }); + // Get Exclusions from the config files. + const { root } = cfg; + try { + const cacheSettings = await calcCacheSettings(configInfo.config, { ...cfg.options, version }, root); + const files = await determineFilesToCheck(configInfo, cfg, reporter, globInfo); + return await processFiles(files, configInfo, cacheSettings); + } + catch (e) { + const err = toApplicationError(e); + reporter.error('Linter', err); + return runResult({ errors: 1 }); + } + } + function header(files, cliExcludes) { + const formattedFiles = files.length > 100 ? files.slice(0, 100).concat(['...']) : files; + reporter.info(` +cspell; +Date: ${new Date().toUTCString()} +Options: + verbose: ${yesNo(!!cfg.options.verbose)} + config: ${cfg.configFile || 'default'} + exclude: ${cliExcludes.join('\n ')} + files: ${formattedFiles} + wordsOnly: ${yesNo(!!cfg.options.wordsOnly)} + unique: ${yesNo(!!cfg.options.unique)} +`, MessageTypes.Info); + } +} +function checkGlobs(globs, reporter) { + globs + .filter((g) => g.startsWith("'") || g.endsWith("'")) + .map((glob) => chalk.yellow(glob)) + .forEach((glob) => reporter.error('Linter', new CheckFailed(`Glob starting or ending with ' (single quote) is not likely to match any files: ${glob}.`))); +} +async function determineGlobs(configInfo, cfg) { + const useGitignore = cfg.options.gitignore ?? configInfo.config.useGitignore ?? false; + const gitignoreRoots = cfg.options.gitignoreRoot ?? configInfo.config.gitignoreRoot; + const gitIgnore = useGitignore ? await generateGitIgnore(gitignoreRoots) : undefined; + const cliGlobs = cfg.fileGlobs; + const allGlobs = cliGlobs.length ? cliGlobs : configInfo.config.files || []; + const combinedGlobs = await normalizeFileOrGlobsToRoot(allGlobs, cfg.root); + const cliExcludeGlobs = extractPatterns(cfg.excludes).map((p) => p.glob); + const normalizedExcludes = normalizeGlobsToRoot(cliExcludeGlobs, cfg.root, true); + const includeGlobs = combinedGlobs.filter((g) => !g.startsWith('!')); + const excludeGlobs = combinedGlobs.filter((g) => g.startsWith('!')).concat(normalizedExcludes); + const fileGlobs = includeGlobs; + const appGlobs = { allGlobs, gitIgnore, fileGlobs, excludeGlobs, normalizedExcludes }; + return appGlobs; +} +async function determineFilesToCheck(configInfo, cfg, reporter, globInfo) { + async function _determineFilesToCheck() { + const { fileLists } = cfg; + const hasFileLists = !!fileLists.length; + const { allGlobs, gitIgnore, fileGlobs, excludeGlobs, normalizedExcludes } = globInfo; + // Get Exclusions from the config files. + const { root } = cfg; + const globsToExclude = (configInfo.config.ignorePaths || []).concat(excludeGlobs); + const globMatcher = buildGlobMatcher(globsToExclude, root, true); + const ignoreGlobs = extractGlobsFromMatcher(globMatcher); + // cspell:word nodir + const globOptions = { + root, + cwd: root, + ignore: ignoreGlobs.concat(normalizedExcludes), + nodir: true, + }; + const enableGlobDot = cfg.enableGlobDot ?? configInfo.config.enableGlobDot; + if (enableGlobDot !== undefined) { + globOptions.dot = enableGlobDot; + } + const filterFiles = opFilter(filterFilesFn(globMatcher)); + const foundFiles = await (hasFileLists + ? useFileLists(fileLists, allGlobs, root, enableGlobDot) + : findFiles(fileGlobs, globOptions)); + const filtered = gitIgnore ? await gitIgnore.filterOutIgnored(foundFiles) : foundFiles; + const files = isAsyncIterable(filtered) + ? pipeAsync(filtered, filterFiles) + : [...pipeSync(filtered, filterFiles)]; + return files; + } + function isExcluded(filename, globMatcherExclude) { + if (cspell.isBinaryFile(URI.file(filename))) { + return true; + } + const { root } = cfg; + const absFilename = path.resolve(root, filename); + const r = globMatcherExclude.matchEx(absFilename); + if (r.matched) { + const { glob, source } = extractGlobSource(r.pattern); + reporter.info(`Excluded File: ${path.relative(root, absFilename)}; Excluded by ${glob} from ${source}`, MessageTypes.Info); + } + return r.matched; + } + function filterFilesFn(globMatcherExclude) { + const patterns = globMatcherExclude.patterns; + const excludeInfo = patterns + .map(extractGlobSource) + .map(({ glob, source }) => `Glob: ${glob} from ${source}`) + .filter(util.uniqueFn()); + reporter.info(`Exclusion Globs: \n ${excludeInfo.join('\n ')}\n`, MessageTypes.Info); + return (filename) => !isExcluded(filename, globMatcherExclude); + } + return _determineFilesToCheck(); +} +function extractContext(tdo, contextRange) { + const { line, offset } = tdo; + const textOffsetInLine = offset - line.offset; + let left = Math.max(textOffsetInLine - contextRange, 0); + let right = Math.min(line.text.length, textOffsetInLine + contextRange + tdo.text.length); + const lineText = line.text; + const isLetter = /^[a-z]$/i; + const isSpace = /^\s$/; + for (let n = contextRange / 2; n > 0 && left > 0; n--, left--) { + if (!isLetter.test(lineText[left - 1])) { + break; + } + } + for (let n = contextRange / 2; n > 0 && right < lineText.length; n--, right++) { + if (!isLetter.test(lineText[right])) { + break; + } + } + // remove leading space + for (; left < textOffsetInLine && isSpace.test(lineText[left]); left++) { + /* do nothing */ + } + const context = { + text: line.text.slice(left, right).trimEnd(), + offset: left + line.offset, + }; + return context; +} +function extractGlobSource(g) { + const { glob, rawGlob, source } = g; + return { + glob: rawGlob || glob, + source, + }; +} +function runResult(init = {}) { + const { files = 0, filesWithIssues = new Set(), issues = 0, errors = 0, cachedFiles = 0 } = init; + return { files, filesWithIssues, issues, errors, cachedFiles }; +} +function yesNo(value) { + return value ? 'Yes' : 'No'; +} +function getLoggerFromReporter(reporter) { + const log = (...params) => { + const msg = format(...params); + reporter.info(msg, 'Info'); + }; + const error = (...params) => { + const msg = format(...params); + const err = { message: '', name: 'error', toString: () => '' }; + reporter.error(msg, err); + }; + const warn = (...params) => { + const msg = format(...params); + reporter.info(msg, 'Warning'); + }; + return { + log, + warn, + error, + }; +} +async function generateGitIgnore(roots) { + const root = (typeof roots === 'string' ? [roots].filter((r) => !!r) : roots) || []; + if (!root?.length) { + const cwd = process.cwd(); + const repo = (await findRepoRoot(cwd)) || cwd; + root.push(repo); + } + return new GitIgnore(root?.map((p) => path.resolve(p))); +} +async function useFileLists(fileListFiles, includeGlobPatterns, root, dot) { + includeGlobPatterns = includeGlobPatterns.length ? includeGlobPatterns : ['**']; + const options = { root, mode: 'include' }; + if (dot !== undefined) { + options.dot = dot; + } + const globMatcher = new GlobMatcher(includeGlobPatterns, options); + const filterFiles = (file) => globMatcher.match(file); + const files = readFileListFiles(fileListFiles); + return pipeAsync(files, opFilter(filterFiles), opFilterAsync(isNotDir)); +} diff --git a/action/node_modules/cspell/dist/esm/options.d.mts b/action/node_modules/cspell/dist/esm/options.d.mts new file mode 100644 index 000000000..f67e20880 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/options.d.mts @@ -0,0 +1,178 @@ +import type { CacheOptions } from './util/cache/index.mjs'; +export interface LinterOptions extends BaseOptions, Omit { + /** + * Display verbose information + */ + verbose?: boolean; + /** + * Show extensive output. + */ + debug?: boolean; + /** + * a globs to exclude files from being checked. + */ + exclude?: string[] | string; + /** + * Only report the words, no line numbers or file names. + */ + wordsOnly?: boolean; + /** + * unique errors per file only. + */ + unique?: boolean; + /** + * root directory, defaults to `cwd` + */ + root?: string; + /** + * Determine if files / directories starting with `.` should be part + * of the glob search. + * @default false + */ + dot?: boolean; + /** + * Show part of a line where an issue is found. + * if true, it will show the default number of characters on either side. + * if a number, it will shat number of characters on either side. + */ + showContext?: boolean | number; + /** + * Show suggestions for spelling errors. + */ + showSuggestions?: boolean; + /** + * Enable filtering out files matching globs found in `.gitignore` files. + */ + gitignore?: boolean; + /** + * Stop searching for a `.gitignore`s when a root is reached. + */ + gitignoreRoot?: string | string[]; + /** + * List of files that contains the paths to files to be spell checked. + * The files in the lists will be filtered against the glob patterns. + * - an entry of `stdin` means to read the file list from **`stdin`** + */ + fileList?: string[] | undefined; + /** + * Files must be found and processed otherwise it is considered an error. + */ + mustFindFiles?: boolean; + /** + * Stop processing and exit if an issue or error is found. + */ + failFast?: boolean; + /** + * Optional list of reporters to use, overriding any specified in the + * configuration. + */ + reporter?: string[]; +} +export interface TraceOptions extends BaseOptions { + stdin?: boolean; + allowCompoundWords?: boolean; + ignoreCase?: boolean; + all?: boolean; + onlyFound?: boolean; + dictionaryPath?: 'hide' | 'long' | 'short' | 'full'; +} +export interface SuggestionOptions extends BaseOptions { + /** + * Strict case and accent checking + * @default true + */ + strict?: boolean; + /** + * List of dictionaries to use. If specified, only that list of dictionaries will be used. + */ + dictionaries?: string[] | undefined; + /** + * The number of suggestions to make. + * @default 8 + */ + numSuggestions?: number; + /** + * Max number of changes / edits to the word to get to a suggestion matching suggestion. + * @default 4 + */ + numChanges?: number; + /** + * If multiple suggestions have the same edit / change "cost", then included them even if + * it causes more than `numSuggestions` to be returned. + * @default true + */ + includeTies?: boolean; + /** + * Use stdin for the input + */ + useStdin?: boolean | undefined; + /** + * Use REPL interface for making suggestions. + */ + repl?: boolean; +} +export interface LegacyOptions { + local?: string; +} +export interface BaseOptions { + /** + * Path to configuration file. + */ + config?: string; + /** + * Programming Language ID. + */ + languageId?: string; + /** + * Locale to use. + */ + locale?: string; + /** + * Load the default configuration + * @default true + */ + defaultConfiguration?: boolean; + /** + * Check In-Document CSpell directives for correctness. + */ + validateDirectives?: boolean; + /** + * Execution flags. + * Used primarily for releasing experimental features. + * Flags are of the form key:value + */ + flag?: string[]; +} +export interface LinterCliOptions extends LinterOptions { + /** + * Show legacy output + */ + legacy?: boolean; + /** + * Show summary at the end + */ + summary?: boolean; + /** + * Show issues + */ + issues?: boolean; + /** + * Run in silent mode. + * @default false + */ + silent?: boolean; + /** + * Show progress + */ + progress?: boolean; + /** + * issues are shown with a relative path to the root or `cwd` + */ + relative?: boolean; + /** + * Files must be found or cli will exit with an error. + */ + mustFindFiles?: boolean; +} +export declare function fixLegacy(opts: T & LegacyOptions): Omit; +//# sourceMappingURL=options.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/options.mjs b/action/node_modules/cspell/dist/esm/options.mjs new file mode 100644 index 000000000..3a422c327 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/options.mjs @@ -0,0 +1,7 @@ +export function fixLegacy(opts) { + const { local, ...rest } = opts; + if (local && !rest.locale) { + rest.locale = local; + } + return rest; +} diff --git a/action/node_modules/cspell/dist/esm/repl/index.d.mts b/action/node_modules/cspell/dist/esm/repl/index.d.mts new file mode 100644 index 000000000..b4e0c9e0d --- /dev/null +++ b/action/node_modules/cspell/dist/esm/repl/index.d.mts @@ -0,0 +1,18 @@ +export declare function simpleRepl(): AsyncIterable; +export type CompleterResult = [string[], string]; +export type Completer = (line: string) => CompleterResult; +export declare class SimpleRepl implements AsyncIterable { + prompt: string; + beforeEach: undefined | (() => void); + completer: undefined | Completer; + private _history; + private rl; + constructor(prompt?: string); + question(query: string): Promise; + private _completer; + get history(): string[]; + [Symbol.asyncIterator](): { + next: () => Promise>; + }; +} +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/repl/index.mjs b/action/node_modules/cspell/dist/esm/repl/index.mjs new file mode 100644 index 000000000..73b4fb137 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/repl/index.mjs @@ -0,0 +1,46 @@ +import * as readline from 'readline'; +export function simpleRepl() { + return new SimpleRepl(); +} +export class SimpleRepl { + constructor(prompt = '> ') { + this.prompt = prompt; + this._history = []; + this.rl = readline.createInterface({ + input: process.stdin, + output: process.stdout, + prompt, + history: this._history, + historySize: 100, + completer: (line) => this._completer(line), + }); + this.rl.on('history', (h) => ((this._history = h), undefined)); + } + question(query) { + return new Promise((resolve) => { + this.rl.question(query, resolve); + }); + } + _completer(line) { + // console.log('Complete: %s', line); + // console.log('History: %o', this._history); + if (this.completer) + return this.completer(line); + const hist = this._history.filter((h) => h.startsWith(line)); + return [hist, line]; + } + get history() { + return this._history; + } + [Symbol.asyncIterator]() { + const next = () => { + if (this.beforeEach) + this.beforeEach(); + // console.log('%o', this.rl); + return this.question(this.prompt) + .then((value) => ({ value })) + .catch(() => ({ done: true, value: undefined })); + }; + return { next }; + } +} diff --git a/action/node_modules/cspell/dist/esm/util/InMemoryReporter.d.mts b/action/node_modules/cspell/dist/esm/util/InMemoryReporter.d.mts new file mode 100644 index 000000000..f8da6a7f2 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/InMemoryReporter.d.mts @@ -0,0 +1,28 @@ +import type { CSpellReporter, Issue, ProgressItem, RunResult } from '@cspell/cspell-types'; +export interface InMemoryResult { + log: string[]; + issues: Issue[]; + runResult: RunResult | undefined; +} +/** + * Simple reporter for test purposes + */ +export declare class InMemoryReporter implements CSpellReporter, InMemoryResult { + log: string[]; + errors: Error[]; + issueCount: number; + errorCount: number; + debugCount: number; + infoCount: number; + progressCount: number; + issues: Issue[]; + runResult: RunResult | undefined; + issue: (issue: Issue) => void; + error: (message: string, error: Error) => void; + info: (message: string) => void; + debug: (message: string) => void; + progress: (p: ProgressItem) => void; + result: (r: RunResult) => void; + dump: () => InMemoryResult; +} +//# sourceMappingURL=InMemoryReporter.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/InMemoryReporter.mjs b/action/node_modules/cspell/dist/esm/util/InMemoryReporter.mjs new file mode 100644 index 000000000..4a0b3f0f1 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/InMemoryReporter.mjs @@ -0,0 +1,42 @@ +/** + * Simple reporter for test purposes + */ +export class InMemoryReporter { + constructor() { + this.log = []; + this.errors = []; + this.issueCount = 0; + this.errorCount = 0; + this.debugCount = 0; + this.infoCount = 0; + this.progressCount = 0; + this.issues = []; + this.issue = (issue) => { + this.issues.push(issue); + this.issueCount += 1; + const { uri, row, col, text } = issue; + this.log.push(`Issue: ${uri}[${row}, ${col}]: Unknown word: ${text}`); + }; + this.error = (message, error) => { + this.errorCount += 1; + this.errors.push(error); + this.log.push(`Error: ${message} ${error.toString()}`); + }; + this.info = (message) => { + this.infoCount += 1; + this.log.push(`Info: ${message}`); + }; + this.debug = (message) => { + this.debugCount += 1; + this.log.push(`Debug: ${message}`); + }; + this.progress = (p) => { + this.progressCount += 1; + this.log.push(`Progress: ${p.type} ${p.fileNum} ${p.fileCount} ${p.filename}`); + }; + this.result = (r) => { + this.runResult = r; + }; + this.dump = () => ({ log: this.log, issues: this.issues, runResult: this.runResult }); + } +} diff --git a/action/node_modules/cspell/dist/esm/util/async.d.mts b/action/node_modules/cspell/dist/esm/util/async.d.mts new file mode 100644 index 000000000..51b12de2d --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/async.d.mts @@ -0,0 +1,3 @@ +export { helpers as asyncHelpers, toArray as asyncIterableToArray, operators as asyncOperators, pipeAsync as asyncPipe, toAsyncIterable as mergeAsyncIterables, } from '@cspell/cspell-pipe'; +export declare const asyncMap: typeof import("@cspell/cspell-pipe/operators").opMapAsync, asyncFilter: typeof import("@cspell/cspell-pipe/operators").opFilterAsync, asyncAwait: typeof import("@cspell/cspell-pipe").opAwaitAsync, asyncFlatten: typeof import("@cspell/cspell-pipe/operators").opFlattenAsync; +//# sourceMappingURL=async.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/async.mjs b/action/node_modules/cspell/dist/esm/util/async.mjs new file mode 100644 index 000000000..fa4e33cb7 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/async.mjs @@ -0,0 +1,3 @@ +import { operators } from '@cspell/cspell-pipe'; +export { helpers as asyncHelpers, toArray as asyncIterableToArray, operators as asyncOperators, pipeAsync as asyncPipe, toAsyncIterable as mergeAsyncIterables, } from '@cspell/cspell-pipe'; +export const { opMapAsync: asyncMap, opFilterAsync: asyncFilter, opAwaitAsync: asyncAwait, opFlattenAsync: asyncFlatten, } = operators; diff --git a/action/node_modules/cspell/dist/esm/util/cache/CSpellLintResultCache.d.mts b/action/node_modules/cspell/dist/esm/util/cache/CSpellLintResultCache.d.mts new file mode 100644 index 000000000..8e1f1d3e1 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/CSpellLintResultCache.d.mts @@ -0,0 +1,20 @@ +import type { FileResult } from '../fileHelper.mjs'; +export interface CSpellLintResultCache { + /** + * Retrieve cached lint results for a given file name, if present in the cache. + */ + getCachedLintResults(filename: string): Promise; + /** + * Set the cached lint results. + */ + setCachedLintResults(result: FileResult, dependsUponFiles: string[]): void; + /** + * Persists the in-memory cache to disk. + */ + reconcile(): void; + /** + * Resets the cache. + */ + reset(): void; +} +//# sourceMappingURL=CSpellLintResultCache.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/cache/CSpellLintResultCache.mjs b/action/node_modules/cspell/dist/esm/util/cache/CSpellLintResultCache.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/CSpellLintResultCache.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell/dist/esm/util/cache/CacheOptions.d.mts b/action/node_modules/cspell/dist/esm/util/cache/CacheOptions.d.mts new file mode 100644 index 000000000..933c44ac0 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/CacheOptions.d.mts @@ -0,0 +1,34 @@ +import type { CacheFormat, CacheStrategy } from '@cspell/cspell-types'; +export interface CacheOptions { + /** + * The version of `cspell` that made the cache entry. + * Cache entries must match the `major.minor` version. + */ + version: string; + /** + * Store the info about processed files in order to only operate on the changed ones. + */ + cache?: boolean; + /** + * Path to the cache location. Can be a file or a directory. + * If none specified .cspellcache will be used. + * The file will be created in the directory where the cspell command is executed. + */ + cacheLocation?: string; + /** + * Strategy to use for detecting changed files, default: metadata + */ + cacheStrategy?: CacheStrategy; + /** + * Resets the cache + */ + cacheReset?: boolean; + /** + * Format of the cache file. + * - `legacy` - use absolute paths in the cache file + * - `universal` - use a sharable format. + * @default 'legacy' + */ + cacheFormat?: CacheFormat; +} +//# sourceMappingURL=CacheOptions.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/cache/CacheOptions.mjs b/action/node_modules/cspell/dist/esm/util/cache/CacheOptions.mjs new file mode 100644 index 000000000..cb0ff5c3b --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/CacheOptions.mjs @@ -0,0 +1 @@ +export {}; diff --git a/action/node_modules/cspell/dist/esm/util/cache/DiskCache.d.mts b/action/node_modules/cspell/dist/esm/util/cache/DiskCache.d.mts new file mode 100644 index 000000000..54a51e09a --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/DiskCache.d.mts @@ -0,0 +1,63 @@ +import type { FileResult } from '../fileHelper.mjs'; +import type { CSpellLintResultCache } from './CSpellLintResultCache.mjs'; +import type { FileDescriptor } from './fileEntryCache.mjs'; +export type CachedFileResult = Omit; +/** + * This is the data cached. + * Property names are short to help keep the cache file size small. + */ +interface CachedData { + /** meta version + suffix */ + v?: string | undefined; + /** results */ + r?: CachedFileResult | undefined; + /** dependencies */ + d?: Dependency[] | undefined; +} +interface Dependency { + /** filename */ + f: string; + /** hash of file contents */ + h?: string | undefined; +} +interface CSpellCachedMetaData { + data?: CachedData; +} +type Meta = FileDescriptor['meta']; +export type CSpellCacheMeta = (Meta & CSpellCachedMetaData) | undefined; +/** + * Caches cspell results on disk + */ +export declare class DiskCache implements CSpellLintResultCache { + readonly useCheckSum: boolean; + readonly cspellVersion: string; + readonly useUniversalCache: boolean; + readonly cacheFileLocation: string; + private cacheDir; + private fileEntryCache; + private dependencyCache; + private dependencyCacheTree; + private objectCollection; + private ocCacheFileResult; + readonly version: string; + constructor(cacheFileLocation: string, useCheckSum: boolean, cspellVersion: string, useUniversalCache: boolean); + getCachedLintResults(filename: string): Promise; + setCachedLintResults({ fileInfo, elapsedTimeMs, cached, ...result }: FileResult, dependsUponFiles: string[]): void; + reconcile(): void; + reset(): void; + private normalizeResult; + private calcDependencyHashes; + private checkDependency; + private getDependency; + private getFileDep; + private checkDependencies; + private getHash; + private resolveFile; + private toRelFile; +} +declare function calcVersion(version: string): string; +export declare const __testing__: { + calcVersion: typeof calcVersion; +}; +export {}; +//# sourceMappingURL=DiskCache.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/cache/DiskCache.mjs b/action/node_modules/cspell/dist/esm/util/cache/DiskCache.mjs new file mode 100644 index 000000000..51e810307 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/DiskCache.mjs @@ -0,0 +1,206 @@ +import assert from 'assert'; +import * as crypto from 'crypto'; +import * as fs from 'fs'; +import { dirname, isAbsolute as isAbsolutePath, relative as relativePath, resolve as resolvePath } from 'path'; +import { readFileInfo } from '../fileHelper.mjs'; +import { createFromFile, normalizePath } from './fileEntryCache.mjs'; +import { ShallowObjectCollection } from './ObjectCollection.mjs'; +const cacheDataKeys = { + v: 'v', + r: 'r', + d: 'd', +}; +/** + * Meta Data Version is used to detect if the structure of the meta data has changed. + * This is used in combination with the Suffix and the version of CSpell. + */ +const META_DATA_BASE_VERSION = '1'; +const META_DATA_VERSION_SUFFIX = '-' + META_DATA_BASE_VERSION + '-' + Object.keys(cacheDataKeys).join('|'); +/** + * Caches cspell results on disk + */ +export class DiskCache { + constructor(cacheFileLocation, useCheckSum, cspellVersion, useUniversalCache) { + this.useCheckSum = useCheckSum; + this.cspellVersion = cspellVersion; + this.useUniversalCache = useUniversalCache; + this.dependencyCache = new Map(); + this.dependencyCacheTree = {}; + this.objectCollection = new ShallowObjectCollection(); + this.ocCacheFileResult = new ShallowObjectCollection(); + this.cacheFileLocation = resolvePath(cacheFileLocation); + this.cacheDir = dirname(this.cacheFileLocation); + this.fileEntryCache = createFromFile(this.cacheFileLocation, useCheckSum, useUniversalCache); + this.version = calcVersion(cspellVersion); + } + async getCachedLintResults(filename) { + filename = normalizePath(filename); + const fileDescriptor = this.fileEntryCache.getFileDescriptor(filename); + const meta = fileDescriptor.meta; + const data = meta?.data; + const result = data?.r; + const versionMatches = this.version === data?.v; + // Cached lint results are valid if and only if: + // 1. The file is present in the filesystem + // 2. The file has not changed since the time it was previously linted + // 3. The CSpell configuration has not changed since the time the file was previously linted + // If any of these are not true, we will not reuse the lint results. + if (fileDescriptor.notFound || + fileDescriptor.changed || + !meta || + !result || + !versionMatches || + !this.checkDependencies(data.d)) { + return undefined; + } + const dd = { ...data }; + if (dd.d) { + dd.d = setTreeEntry(this.dependencyCacheTree, dd.d); + } + dd.r = dd.r && this.normalizeResult(dd.r); + meta.data = this.objectCollection.get(dd); + // Skip reading empty files and files without lint error + const hasErrors = !!result && (result.errors > 0 || result.configErrors > 0 || result.issues.length > 0); + const cached = true; + const shouldReadFile = cached && hasErrors; + return { + ...result, + elapsedTimeMs: undefined, + fileInfo: shouldReadFile ? await readFileInfo(filename) : { filename }, + cached, + }; + } + setCachedLintResults({ fileInfo, elapsedTimeMs: _, cached: __, ...result }, dependsUponFiles) { + const fileDescriptor = this.fileEntryCache.getFileDescriptor(fileInfo.filename); + const meta = fileDescriptor.meta; + if (fileDescriptor.notFound || !meta) { + return; + } + const data = this.objectCollection.get({ + v: this.version, + r: this.normalizeResult(result), + d: this.calcDependencyHashes(dependsUponFiles), + }); + meta.data = data; + } + reconcile() { + this.fileEntryCache.reconcile(); + } + reset() { + this.fileEntryCache.destroy(); + this.dependencyCache.clear(); + this.dependencyCacheTree = {}; + this.objectCollection = new ShallowObjectCollection(); + this.ocCacheFileResult = new ShallowObjectCollection(); + } + normalizeResult(result) { + const { issues, processed, errors, configErrors, ...rest } = result; + if (!Object.keys(rest).length) { + return this.ocCacheFileResult.get(result); + } + return this.ocCacheFileResult.get({ issues, processed, errors, configErrors }); + } + calcDependencyHashes(dependsUponFiles) { + dependsUponFiles.sort(); + const c = getTreeEntry(this.dependencyCacheTree, dependsUponFiles); + if (c?.d) { + return c.d; + } + const dependencies = dependsUponFiles.map((f) => this.getDependency(f)); + return setTreeEntry(this.dependencyCacheTree, dependencies); + } + checkDependency(dep) { + const depFile = this.resolveFile(dep.f); + const cDep = this.dependencyCache.get(depFile); + if (cDep && compDep(dep, cDep)) + return true; + if (cDep) + return false; + const d = this.getFileDep(depFile); + if (compDep(dep, d)) { + this.dependencyCache.set(depFile, dep); + return true; + } + this.dependencyCache.set(depFile, d); + return false; + } + getDependency(file) { + const dep = this.dependencyCache.get(file); + if (dep) + return dep; + const d = this.getFileDep(file); + this.dependencyCache.set(file, d); + return d; + } + getFileDep(file) { + assert(isAbsolutePath(file), `Dependency must be absolute "${file}"`); + const f = this.toRelFile(file); + let h; + try { + const buffer = fs.readFileSync(file); + h = this.getHash(buffer); + } + catch (e) { + return { f }; + } + return { f, h }; + } + checkDependencies(dependencies) { + if (!dependencies) + return false; + for (const dep of dependencies) { + if (!this.checkDependency(dep)) { + return false; + } + } + return true; + } + getHash(buffer) { + return crypto.createHash('md5').update(buffer).digest('hex'); + } + resolveFile(file) { + return normalizePath(resolvePath(this.cacheDir, file)); + } + toRelFile(file) { + return normalizePath(this.useUniversalCache ? relativePath(this.cacheDir, file) : file); + } +} +function getTreeEntry(tree, keys) { + let r = tree; + for (const k of keys) { + r = r.c?.get(k); + if (!r) + return r; + } + return r; +} +function setTreeEntry(tree, deps, update = false) { + let r = tree; + for (const d of deps) { + const k = d.f; + if (!r.c) { + r.c = new Map(); + } + const cn = r.c.get(k); + const n = cn ?? {}; + if (!cn) { + r.c.set(k, n); + } + r = n; + } + let d = r.d; + if (!d || (r.d && update)) { + r.d = deps; + d = deps; + } + return d; +} +function compDep(a, b) { + return a.f === b.f && a.h === b.h; +} +function calcVersion(version) { + return version + META_DATA_VERSION_SUFFIX; +} +export const __testing__ = { + calcVersion, +}; diff --git a/action/node_modules/cspell/dist/esm/util/cache/DummyCache.d.mts b/action/node_modules/cspell/dist/esm/util/cache/DummyCache.d.mts new file mode 100644 index 000000000..55b32dd81 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/DummyCache.d.mts @@ -0,0 +1,11 @@ +import type { CSpellLintResultCache } from './CSpellLintResultCache.mjs'; +/** + * Dummy cache implementation that should be usd if caching option is disabled. + */ +export declare class DummyCache implements CSpellLintResultCache { + getCachedLintResults(): Promise; + setCachedLintResults(): void; + reconcile(): void; + reset(): void; +} +//# sourceMappingURL=DummyCache.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/cache/DummyCache.mjs b/action/node_modules/cspell/dist/esm/util/cache/DummyCache.mjs new file mode 100644 index 000000000..5b1f40b76 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/DummyCache.mjs @@ -0,0 +1,17 @@ +/** + * Dummy cache implementation that should be usd if caching option is disabled. + */ +export class DummyCache { + getCachedLintResults() { + return Promise.resolve(undefined); + } + setCachedLintResults() { + return; + } + reconcile() { + return; + } + reset() { + return; + } +} diff --git a/action/node_modules/cspell/dist/esm/util/cache/ObjectCollection.d.mts b/action/node_modules/cspell/dist/esm/util/cache/ObjectCollection.d.mts new file mode 100644 index 000000000..f1a252b4a --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/ObjectCollection.d.mts @@ -0,0 +1,17 @@ +export declare class ShallowObjectCollection { + private tree; + get(v: T): T; +} +export declare class Collection { + private col; + /** + * Add a plain object to the collection. + * The actual object used is returned. + * By adding the object to the collection, it is now owned by the collection. + * Do not add class objects. + * @param v any object or primitive + * @returns v or the matching object. + */ + add(v: T): T; +} +//# sourceMappingURL=ObjectCollection.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/cache/ObjectCollection.mjs b/action/node_modules/cspell/dist/esm/util/cache/ObjectCollection.mjs new file mode 100644 index 000000000..04b5dea34 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/ObjectCollection.mjs @@ -0,0 +1,130 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +const compare = Intl.Collator().compare; +export class ShallowObjectCollection { + constructor() { + this.tree = {}; + } + get(v) { + if (typeof v !== 'object' || v === null) { + return v; + } + const keys = Object.entries(v) + .filter((entry) => entry[1] !== undefined) + .sort((a, b) => compare(a[0], b[0])); + let t = this.tree; + for (const [key, obj] of keys) { + if (!t.c) { + t.c = new Map(); + } + const c0 = t.c.get(key); + const cc = c0 || new Map(); + if (!c0) { + t.c.set(key, cc); + } + const c1 = cc.get(obj); + const ccc = c1 || {}; + if (!c1) { + cc.set(obj, ccc); + } + t = ccc; + } + if (t.v) + return t.v; + t.v = v; + return v; + } +} +export class Collection { + constructor() { + this.col = { contains: new Map() }; + } + /** + * Add a plain object to the collection. + * The actual object used is returned. + * By adding the object to the collection, it is now owned by the collection. + * Do not add class objects. + * @param v any object or primitive + * @returns v or the matching object. + */ + add(v) { + return addToCollection(this.col, v); + } +} +// const objectLike: TypeMask = { +// array: true, +// object: true, +// }; +function addToCollection(root, v) { + const known = root.contains; + function addValToCol(c, v) { + const t = toValueType(v); + const val = c.v || Object.create(null); + const r = val[t] ?? v; + val[t] = r; + c.v = val; + return val[t]; + } + function walk(col, path) { + path = path.filter((entry) => entry[1] !== undefined).sort((a, b) => compare(a[0], b[0])); + for (const [k, v] of path) { + const c = col.c || Object.create(null); + col.c = c; + const m = c[k] || new Map(); + c[k] = m; + const has = m.get(v); + col = has || Object.create(null); + if (!has) { + m.set(v, col); + } + } + return col; + } + function normalizeObjectEntries(entries) { + for (const entry of entries) { + entry[1] = add(entry[1]); + } + return entries; + } + function normalizeToPath(v) { + if (typeof v !== 'object' || !v) { + return [['', v]]; + } + const entries = normalizeObjectEntries(Object.entries(v)); + const obj = v; + if (!Object.isFrozen(v)) { + for (const [k, v] of entries) { + obj[k] = v; + } + Object.freeze(obj); + } + return entries; + } + function add(v) { + const isObjectLike = typeof v === 'object' && !!v; + if (isObjectLike) { + const cached = known.get(v); + if (cached !== undefined) { + return cached; + } + known.set(v, v); + } + const path = normalizeToPath(v); + const c = walk(root, path); + const r = addValToCol(c, v); + if (isObjectLike) { + known.set(v, r); + } + return r; + } + return add(v); +} +function toValueType(v) { + const t = typeof v; + if (t !== 'object') + return t; + if (v instanceof Array) + return 'array'; + if (v === null) + return 'null'; + return t; +} diff --git a/action/node_modules/cspell/dist/esm/util/cache/createCache.d.mts b/action/node_modules/cspell/dist/esm/util/cache/createCache.d.mts new file mode 100644 index 000000000..ce64a1695 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/createCache.d.mts @@ -0,0 +1,31 @@ +import type { CacheSettings, CSpellSettings } from '@cspell/cspell-types'; +import type { CacheOptions } from './CacheOptions.mjs'; +import type { CSpellLintResultCache } from './CSpellLintResultCache.mjs'; +export declare const DEFAULT_CACHE_LOCATION = ".cspellcache"; +export interface CreateCacheSettings extends Required { + /** + * cspell version used to validate cache entries. + */ + version: string; + /** + * When true, causes the cache to be reset, removing any entries + * or cache files. + */ + reset?: true; +} +/** + * Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise) + */ +export declare function createCache(options: CreateCacheSettings): CSpellLintResultCache; +export declare function calcCacheSettings(config: CSpellSettings, cacheOptions: CacheOptions, root: string): Promise; +/** + * Normalizes the version and return only `major.minor + versionSuffix` + * @param version The cspell semantic version. + */ +declare function normalizeVersion(version: string): string; +export declare const __testing__: { + normalizeVersion: typeof normalizeVersion; + versionSuffix: string; +}; +export {}; +//# sourceMappingURL=createCache.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/cache/createCache.mjs b/action/node_modules/cspell/dist/esm/util/cache/createCache.mjs new file mode 100644 index 000000000..eae6e14f6 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/createCache.mjs @@ -0,0 +1,68 @@ +import assert from 'assert'; +import { stat } from 'fs/promises'; +import path from 'path'; +import { isError } from '../errors.mjs'; +import { DiskCache } from './DiskCache.mjs'; +import { DummyCache } from './DummyCache.mjs'; +// cspell:word cspellcache +export const DEFAULT_CACHE_LOCATION = '.cspellcache'; +const versionSuffix = ''; +/** + * Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise) + */ +export function createCache(options) { + const { useCache, cacheLocation, cacheStrategy, reset } = options; + const location = path.resolve(cacheLocation); + const useChecksum = cacheStrategy === 'content'; + const version = normalizeVersion(options.version); + const useUniversal = options.cacheFormat === 'universal'; + const cache = useCache ? new DiskCache(location, useChecksum, version, useUniversal) : new DummyCache(); + reset && cache.reset(); + return cache; +} +export async function calcCacheSettings(config, cacheOptions, root) { + const cs = config.cache ?? {}; + const useCache = cacheOptions.cache ?? cs.useCache ?? false; + const cacheLocation = await resolveCacheLocation(path.resolve(root, cacheOptions.cacheLocation ?? cs.cacheLocation ?? DEFAULT_CACHE_LOCATION)); + const cacheStrategy = cacheOptions.cacheStrategy ?? cs.cacheStrategy ?? 'metadata'; + const cacheFormat = cacheOptions.cacheFormat ?? cs.cacheFormat ?? 'legacy'; + const optionals = {}; + if (cacheOptions.cacheReset) { + optionals.reset = true; + } + return { + ...optionals, + useCache, + cacheLocation, + cacheStrategy, + version: cacheOptions.version, + cacheFormat, + }; +} +async function resolveCacheLocation(cacheLocation) { + try { + const s = await stat(cacheLocation); + if (s.isFile()) + return cacheLocation; + return path.join(cacheLocation, DEFAULT_CACHE_LOCATION); + } + catch (err) { + if (isError(err) && err.code === 'ENOENT') { + return cacheLocation; + } + throw err; + } +} +/** + * Normalizes the version and return only `major.minor + versionSuffix` + * @param version The cspell semantic version. + */ +function normalizeVersion(version) { + const parts = version.split('.').slice(0, 2); + assert(parts.length === 2); + return parts.join('.') + versionSuffix; +} +export const __testing__ = { + normalizeVersion, + versionSuffix, +}; diff --git a/action/node_modules/cspell/dist/esm/util/cache/fileEntryCache.d.mts b/action/node_modules/cspell/dist/esm/util/cache/fileEntryCache.d.mts new file mode 100644 index 000000000..67607609b --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/fileEntryCache.d.mts @@ -0,0 +1,9 @@ +/** + * This is a wrapper for 'file-entry-cache' + */ +export type { FileDescriptor } from '../../../lib/file-entry-cache.cjs'; +import type { FileEntryCache as FecFileEntryCache } from '../../../lib/file-entry-cache.cjs'; +export type FileEntryCache = FecFileEntryCache; +export declare function createFromFile(pathToCache: string, useCheckSum: boolean, useRelative: boolean): FileEntryCache; +export declare function normalizePath(filePath: string): string; +//# sourceMappingURL=fileEntryCache.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/cache/fileEntryCache.mjs b/action/node_modules/cspell/dist/esm/util/cache/fileEntryCache.mjs new file mode 100644 index 000000000..c035e8f47 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/fileEntryCache.mjs @@ -0,0 +1,78 @@ +/** + * This is a wrapper for 'file-entry-cache' + */ +import { mkdirSync } from 'fs'; +import * as path from 'path'; +import { isMainThread } from 'worker_threads'; +import * as fec from '../../../lib/file-entry-cache.cjs'; +export function createFromFile(pathToCache, useCheckSum, useRelative) { + const absPathToCache = path.resolve(pathToCache); + const relDir = path.dirname(absPathToCache); + mkdirSync(relDir, { recursive: true }); + const create = wrap(() => fec.createFromFile(absPathToCache, useCheckSum)); + const feCache = create(); + const cacheWrapper = { + get cache() { + return feCache.cache; + }, + getHash(buffer) { + return feCache.getHash(buffer); + }, + hasFileChanged: wrap((cwd, file) => { + console.log(file); + return feCache.hasFileChanged(resolveFile(cwd, file)); + }), + analyzeFiles: wrap((cwd, files) => { + return feCache.analyzeFiles(resolveFiles(cwd, files)); + }), + getFileDescriptor: wrap((cwd, file) => { + return feCache.getFileDescriptor(resolveFile(cwd, file)); + }), + getUpdatedFiles: wrap((cwd, files) => { + return feCache.getUpdatedFiles(resolveFiles(cwd, files)); + }), + normalizeEntries: wrap((cwd, files) => { + return feCache.normalizeEntries(resolveFiles(cwd, files)); + }), + removeEntry: wrap((cwd, file) => { + console.log(file); + return feCache.removeEntry(resolveFile(cwd, file)); + }), + deleteCacheFile() { + feCache.deleteCacheFile(); + }, + destroy() { + feCache.destroy(); + }, + reconcile: wrap((_cwd, noPrune) => { + feCache.reconcile(noPrune); + }), + }; + return cacheWrapper; + function resolveFile(cwd, file) { + if (!useRelative) + return file; + const r = path.relative(relDir, path.resolve(cwd, file)); + return normalizePath(r); + } + function resolveFiles(cwd, files) { + return files?.map((file) => resolveFile(cwd, file)); + } + function wrap(fn) { + return (...params) => { + const cwd = process.cwd(); + try { + isMainThread && process.chdir(relDir); + return fn(cwd, ...params); + } + finally { + isMainThread && process.chdir(cwd); + } + }; + } +} +export function normalizePath(filePath) { + return filePath; + // if (path.sep !== '\\') return filePath; + // return filePath.replace(/\\/g, '/'); +} diff --git a/action/node_modules/cspell/dist/esm/util/cache/index.d.mts b/action/node_modules/cspell/dist/esm/util/cache/index.d.mts new file mode 100644 index 000000000..ebb75f58f --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/index.d.mts @@ -0,0 +1,4 @@ +export type { CacheOptions } from './CacheOptions.mjs'; +export { calcCacheSettings, createCache, type CreateCacheSettings, DEFAULT_CACHE_LOCATION } from './createCache.mjs'; +export type { CSpellLintResultCache } from './CSpellLintResultCache.mjs'; +//# sourceMappingURL=index.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/cache/index.mjs b/action/node_modules/cspell/dist/esm/util/cache/index.mjs new file mode 100644 index 000000000..6e559d2b8 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/cache/index.mjs @@ -0,0 +1 @@ +export { calcCacheSettings, createCache, DEFAULT_CACHE_LOCATION } from './createCache.mjs'; diff --git a/action/node_modules/cspell/dist/esm/util/constants.d.mts b/action/node_modules/cspell/dist/esm/util/constants.d.mts new file mode 100644 index 000000000..fdaf0e3a4 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/constants.d.mts @@ -0,0 +1,6 @@ +/// +export declare const UTF8: BufferEncoding; +export declare const STDIN = "stdin"; +export declare const STDINProtocol = "stdin://"; +export declare const FileProtocol = "file://"; +//# sourceMappingURL=constants.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/constants.mjs b/action/node_modules/cspell/dist/esm/util/constants.mjs new file mode 100644 index 000000000..be78647b4 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/constants.mjs @@ -0,0 +1,4 @@ +export const UTF8 = 'utf8'; +export const STDIN = 'stdin'; +export const STDINProtocol = 'stdin://'; +export const FileProtocol = 'file://'; diff --git a/action/node_modules/cspell/dist/esm/util/errors.d.mts b/action/node_modules/cspell/dist/esm/util/errors.d.mts new file mode 100644 index 000000000..10ee76d0a --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/errors.d.mts @@ -0,0 +1,23 @@ +export declare class CheckFailed extends Error { + readonly exitCode: number; + constructor(message: string, exitCode?: number); +} +export declare class ApplicationError extends Error { + readonly exitCode: number; + readonly cause?: Error | undefined; + constructor(message: string, exitCode?: number, cause?: Error | undefined); +} +export declare class IOError extends ApplicationError { + readonly cause: NodeError; + constructor(message: string, cause: NodeError); + get code(): string | undefined; + isNotFound(): boolean; +} +export declare function toError(e: unknown): NodeError; +export declare function isError(e: unknown): e is NodeError; +export declare function toApplicationError(e: unknown, message?: string): ApplicationError; +export interface NodeError extends Error { + code?: string; + toString?: () => string; +} +//# sourceMappingURL=errors.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/errors.mjs b/action/node_modules/cspell/dist/esm/util/errors.mjs new file mode 100644 index 000000000..b5caafa31 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/errors.mjs @@ -0,0 +1,50 @@ +import { format } from 'util'; +export class CheckFailed extends Error { + constructor(message, exitCode = 1) { + super(message); + this.exitCode = exitCode; + } +} +export class ApplicationError extends Error { + constructor(message, exitCode = 1, cause) { + super(message); + this.exitCode = exitCode; + this.cause = cause; + } +} +export class IOError extends ApplicationError { + constructor(message, cause) { + super(message, undefined, cause); + this.cause = cause; + } + get code() { + return this.cause.code; + } + isNotFound() { + return this.cause.code === 'ENOENT'; + } +} +export function toError(e) { + if (isError(e)) + return e; + const message = format(e); + return { + name: 'error', + message, + toString: () => message, + }; +} +export function isError(e) { + if (e instanceof Error) + return true; + if (!e || typeof e !== 'object') + return false; + const ex = e; + return typeof ex.message === 'string'; +} +export function toApplicationError(e, message) { + if (e instanceof ApplicationError && !message) + return e; + const err = toError(e); + return new ApplicationError(message ?? err.message, undefined, err); +} diff --git a/action/node_modules/cspell/dist/esm/util/fileHelper.d.mts b/action/node_modules/cspell/dist/esm/util/fileHelper.d.mts new file mode 100644 index 000000000..98ac25331 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/fileHelper.d.mts @@ -0,0 +1,63 @@ +/// +import type { CSpellUserSettings, Document, Issue } from 'cspell-lib'; +import { URI } from '../../lib/uri.cjs'; +import type { GlobOptions } from './glob.mjs'; +export interface ConfigInfo { + source: string; + config: CSpellUserSettings; +} +export interface FileConfigInfo { + configInfo: ConfigInfo; + filename: string; + text: string; + languageIds: string[]; +} +export declare function readConfig(configFile: string | undefined, root: string | undefined): Promise; +export interface FileInfo { + filename: string; + text?: string; + errorCode?: string; +} +export interface FileResult { + fileInfo: FileInfo; + processed: boolean; + issues: Issue[]; + errors: number; + configErrors: number; + elapsedTimeMs: number | undefined; + cached?: boolean; +} +export declare function fileInfoToDocument(fileInfo: FileInfo, languageId: string | undefined, locale: string | undefined): Document; +export declare function filenameToUrlString(filename: string, cwd?: string): string; +export declare function filenameToUri(filename: string, cwd?: string): URI; +export declare function isBinaryFile(filename: string, cwd?: string): boolean; +export interface ReadFileInfoResult extends FileInfo { + text: string; +} +export declare function resolveFilename(filename: string, cwd?: string): string; +export declare function readFileInfo(filename: string, encoding?: BufferEncoding, handleNotFound?: boolean): Promise; +export declare function readFile(filename: string, encoding?: BufferEncoding): Promise; +/** + * Looks for matching glob patterns or stdin + * @param globPatterns patterns or stdin + */ +export declare function findFiles(globPatterns: string[], options: GlobOptions): Promise; +export declare function calcFinalConfigInfo(configInfo: ConfigInfo, settingsFromCommandLine: CSpellUserSettings, filename: string, text: string): FileConfigInfo; +/** + * Read + * @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each + * file will be resolved relative to the containing file. + * @returns - a list of files to be processed. + */ +export declare function readFileListFiles(listFiles: string[]): AsyncIterable; +/** + * Read a `listFile` and return the containing file paths resolved relative to the `listFile`. + * @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each + * file will be resolved relative to the containing file. + * @returns - a list of files to be processed. + */ +export declare function readFileListFile(listFile: string): Promise; +export declare function isFile(filename: string): Promise; +export declare function isDir(filename: string): Promise; +export declare function isNotDir(filename: string): Promise; +//# sourceMappingURL=fileHelper.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/fileHelper.mjs b/action/node_modules/cspell/dist/esm/util/fileHelper.mjs new file mode 100644 index 000000000..73a260b09 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/fileHelper.mjs @@ -0,0 +1,177 @@ +import { readFile as cioReadFile } from 'cspell-io'; +import * as cspell from 'cspell-lib'; +import { fileToDocument, isBinaryFile as isUriBinaryFile } from 'cspell-lib'; +import { promises as fsp } from 'fs'; +import getStdin from 'get-stdin'; +import * as path from 'path'; +import { fileURLToPath, pathToFileURL } from 'url'; +import { URI } from '../../lib/uri.cjs'; +import { asyncAwait, asyncFlatten, asyncMap, asyncPipe, mergeAsyncIterables } from './async.mjs'; +import { FileProtocol, STDIN, STDINProtocol, UTF8 } from './constants.mjs'; +import { IOError, toApplicationError, toError } from './errors.mjs'; +import { globP } from './glob.mjs'; +import { readStdin } from './stdin.mjs'; +import { clean } from './util.mjs'; +const doesMatchUrl = /^(file|stdin|https?):\/\//; +export async function readConfig(configFile, root) { + if (configFile) { + const config = (await cspell.loadConfig(configFile)) || {}; + return { source: configFile, config }; + } + const config = await cspell.searchForConfig(root); + return { source: config?.__importRef?.filename || 'None found', config: config || {} }; +} +export function fileInfoToDocument(fileInfo, languageId, locale) { + const { filename, text } = fileInfo; + languageId = languageId || undefined; + locale = locale || undefined; + const uri = filenameToUrlString(filename); + if (uri.startsWith(STDINProtocol)) { + return clean({ + uri, + text, + languageId, + locale, + }); + } + return fileToDocument(uri, text, languageId, locale); +} +export function filenameToUrlString(filename, cwd = '.') { + if (filename === STDIN) + return 'stdin:///'; + if (filename.startsWith(STDINProtocol)) { + const filePath = filename.slice(STDINProtocol.length); + const fullPath = path.resolve(cwd, filePath); + return pathToFileURL(fullPath).toString(); + } + if (doesMatchUrl.test(filename)) + return filename; + return pathToFileURL(path.resolve(cwd, filename)).toString(); +} +export function filenameToUri(filename, cwd) { + return URI.parse(filenameToUrlString(filename, cwd)); +} +export function isBinaryFile(filename, cwd) { + const uri = filenameToUri(filename, cwd); + if (uri.scheme.startsWith('stdin')) + return false; + return isUriBinaryFile(uri); +} +export function resolveFilename(filename, cwd) { + cwd = cwd || process.cwd(); + if (filename === STDIN) + return STDINProtocol; + if (filename.startsWith(FileProtocol)) { + const url = new URL(filename.slice(FileProtocol.length), pathToFileURL(cwd + path.sep)); + return fileURLToPath(url); + } + const scheme = filename.startsWith(STDINProtocol) ? STDINProtocol : ''; + const pathname = filename.slice(scheme.length); + return scheme + path.resolve(cwd, pathname); +} +export function readFileInfo(filename, encoding = UTF8, handleNotFound = false) { + filename = resolveFilename(filename); + const pText = filename.startsWith(STDINProtocol) ? getStdin() : cioReadFile(filename, encoding); + return pText.then((text) => ({ text, filename }), (e) => { + const error = toError(e); + return handleNotFound && error.code === 'EISDIR' + ? Promise.resolve({ text: '', filename, errorCode: error.code }) + : handleNotFound && error.code === 'ENOENT' + ? Promise.resolve({ text: '', filename, errorCode: error.code }) + : Promise.reject(new IOError(`Error reading file: "${filename}"`, error)); + }); +} +export function readFile(filename, encoding = UTF8) { + return readFileInfo(filename, encoding).then((info) => info.text); +} +/** + * Looks for matching glob patterns or stdin + * @param globPatterns patterns or stdin + */ +export async function findFiles(globPatterns, options) { + const stdin = []; + const globPats = globPatterns.filter((filename) => filename !== STDIN && !filename.startsWith(STDINProtocol) && !filename.startsWith(FileProtocol) + ? true + : (stdin.push(filename), false)); + const globResults = globPats.length ? await globP(globPats, options) : []; + const cwd = options.cwd || process.cwd(); + return [...stdin, ...globResults].map((filename) => resolveFilename(filename, cwd)); +} +export function calcFinalConfigInfo(configInfo, settingsFromCommandLine, filename, text) { + const basename = path.basename(filename); + const fileSettings = cspell.calcOverrideSettings(configInfo.config, path.resolve(filename)); + const loadDefault = settingsFromCommandLine.loadDefaultConfiguration ?? + configInfo.config.loadDefaultConfiguration ?? + fileSettings.loadDefaultConfiguration ?? + true; + const settings = cspell.mergeSettings(cspell.getDefaultSettings(loadDefault), cspell.getGlobalSettings(), fileSettings, settingsFromCommandLine); + const languageIds = settings.languageId ? [settings.languageId] : cspell.getLanguageIdsForBaseFilename(basename); + const config = cspell.constructSettingsForText(settings, text, languageIds); + return { + configInfo: { ...configInfo, config }, + filename, + text, + languageIds, + }; +} +const resolveFilenames = asyncMap(resolveFilename); +/** + * Read + * @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each + * file will be resolved relative to the containing file. + * @returns - a list of files to be processed. + */ +export function readFileListFiles(listFiles) { + let useStdin = false; + const files = listFiles.filter((file) => { + const isStdin = file === 'stdin'; + useStdin = useStdin || isStdin; + return !isStdin; + }); + const found = asyncPipe(files, asyncMap((file) => readFileListFile(file)), asyncAwait(), asyncFlatten()); + // Move `stdin` to the end. + const stdin = useStdin ? readStdin() : []; + return asyncPipe(mergeAsyncIterables(found, stdin), resolveFilenames); +} +/** + * Read a `listFile` and return the containing file paths resolved relative to the `listFile`. + * @param listFiles - array of file paths to read that will contain a list of files. Paths contained in each + * file will be resolved relative to the containing file. + * @returns - a list of files to be processed. + */ +export async function readFileListFile(listFile) { + try { + const relTo = path.resolve(path.dirname(listFile)); + const content = await readFile(listFile); + const lines = content + .split('\n') + .map((a) => a.trim()) + .filter((a) => !!a) + .map((file) => path.resolve(relTo, file)); + return lines; + } + catch (err) { + throw toApplicationError(err, `Error reading file list from: "${listFile}"`); + } +} +export async function isFile(filename) { + try { + const stat = await fsp.stat(filename); + return stat.isFile(); + } + catch (e) { + return false; + } +} +export async function isDir(filename) { + try { + const stat = await fsp.stat(filename); + return stat.isDirectory(); + } + catch (e) { + return false; + } +} +export function isNotDir(filename) { + return isDir(filename).then((a) => !a); +} diff --git a/action/node_modules/cspell/dist/esm/util/glob.d.mts b/action/node_modules/cspell/dist/esm/util/glob.d.mts new file mode 100644 index 000000000..3d3f54909 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/glob.d.mts @@ -0,0 +1,45 @@ +import type { CSpellUserSettings, Glob } from '@cspell/cspell-types'; +import type { GlobPatternWithRoot } from 'cspell-glob'; +import { GlobMatcher } from 'cspell-glob'; +/** + * This is a subset of IOptions from 'glob'. + */ +export interface GlobOptions { + cwd?: string | undefined; + root?: string | undefined; + dot?: boolean | undefined; + nodir?: boolean | undefined; + ignore?: string | Array | undefined; +} +/** + * + * @param pattern - glob patterns and NOT file paths. It can be a file path turned into a glob. + * @param options - search options. + */ +export declare function globP(pattern: string | string[], options?: GlobOptions): Promise; +export declare function calcGlobs(commandLineExclude: string[] | undefined): { + globs: string[]; + source: string; +}; +export interface GlobSrcInfo { + matcher: GlobMatcher; + source: string; +} +interface ExtractPatternResult { + glob: GlobPatternWithRoot; + source: string; +} +export declare function extractPatterns(globs: GlobSrcInfo[]): ExtractPatternResult[]; +export declare function calcExcludeGlobInfo(root: string, commandLineExclude: string[] | string | undefined): GlobSrcInfo[]; +export declare function extractGlobExcludesFromConfig(root: string, source: string, config: CSpellUserSettings): GlobSrcInfo[]; +/** + * Build GlobMatcher from command line or config file globs. + * @param globs Glob patterns or file paths + * @param root - directory to use as the root + */ +export declare function buildGlobMatcher(globs: Glob[], root: string, isExclude: boolean): GlobMatcher; +export declare function extractGlobsFromMatcher(globMatcher: GlobMatcher): string[]; +export declare function normalizeGlobsToRoot(globs: Glob[], root: string, isExclude: boolean): string[]; +export declare function normalizeFileOrGlobsToRoot(globs: Glob[], root: string): Promise; +export {}; +//# sourceMappingURL=glob.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/glob.mjs b/action/node_modules/cspell/dist/esm/util/glob.mjs new file mode 100644 index 000000000..e007d47bb --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/glob.mjs @@ -0,0 +1,136 @@ +import { fileOrGlobToGlob, GlobMatcher } from 'cspell-glob'; +import glob from 'fast-glob'; +import { promises as fs } from 'fs'; +import * as path from 'path'; +import { posix } from 'path'; +import { clean } from './util.mjs'; +const defaultExcludeGlobs = ['node_modules/**']; +/** + * + * @param pattern - glob patterns and NOT file paths. It can be a file path turned into a glob. + * @param options - search options. + */ +export async function globP(pattern, options) { + const cwd = options?.root || options?.cwd || process.cwd(); + const ignore = typeof options?.ignore === 'string' ? [options.ignore] : options?.ignore; + const onlyFiles = options?.nodir; + const dot = options?.dot; + const patterns = typeof pattern === 'string' ? [pattern] : pattern; + const useOptions = clean({ + cwd, + onlyFiles, + dot, + ignore, + absolute: true, + followSymbolicLinks: false, + }); + const compare = new Intl.Collator('en').compare; + const absolutePaths = (await glob(patterns, useOptions)).sort(compare); + const relativePaths = absolutePaths.map((absFilename) => path.relative(cwd, absFilename)); + return relativePaths; +} +export function calcGlobs(commandLineExclude) { + const globs = new Set((commandLineExclude || []).flatMap((glob) => glob.split(/(? g.replace(/\\ /g, ' '))); + const commandLineExcludes = { + globs: [...globs], + source: 'arguments', + }; + const defaultExcludes = { + globs: defaultExcludeGlobs, + source: 'default', + }; + return commandLineExcludes.globs.length ? commandLineExcludes : defaultExcludes; +} +export function extractPatterns(globs) { + const r = globs.reduce((info, g) => { + const source = g.source; + const patterns = g.matcher.patternsNormalizedToRoot; + return info.concat(patterns.map((glob) => ({ glob, source }))); + }, []); + return r; +} +export function calcExcludeGlobInfo(root, commandLineExclude) { + commandLineExclude = typeof commandLineExclude === 'string' ? [commandLineExclude] : commandLineExclude; + const choice = calcGlobs(commandLineExclude); + const matcher = new GlobMatcher(choice.globs, { root, dot: true }); + return [ + { + matcher, + source: choice.source, + }, + ]; +} +export function extractGlobExcludesFromConfig(root, source, config) { + if (!config.ignorePaths || !config.ignorePaths.length) { + return []; + } + const matcher = new GlobMatcher(config.ignorePaths, { root, dot: true }); + return [{ source, matcher }]; +} +/** + * Build GlobMatcher from command line or config file globs. + * @param globs Glob patterns or file paths + * @param root - directory to use as the root + */ +export function buildGlobMatcher(globs, root, isExclude) { + const withRoots = globs.map((g) => { + const source = typeof g === 'string' ? 'command line' : undefined; + return { source, ...fileOrGlobToGlob(g, root) }; + }); + return new GlobMatcher(withRoots, { root, mode: isExclude ? 'exclude' : 'include' }); +} +export function extractGlobsFromMatcher(globMatcher) { + return globMatcher.patternsNormalizedToRoot.map((g) => g.glob); +} +export function normalizeGlobsToRoot(globs, root, isExclude) { + const urls = globs.filter((g) => typeof g === 'string' && isPossibleUrlRegExp.test(g)); + const onlyGlobs = globs.filter((g) => typeof g !== 'string' || !isPossibleUrlRegExp.test(g)); + return [urls, extractGlobsFromMatcher(buildGlobMatcher(onlyGlobs, root, isExclude))].flatMap((a) => a); +} +const isPossibleGlobRegExp = /[*{}()?[]/; +const isPossibleUrlRegExp = /^[-a-z_0-9]{3,}:\/\//; +/** + * If a 'glob' is a path to a directory, then append `**` so that + * directory searches work. + * @param glob - a glob, file, or directory + * @param root - root to use. + * @returns `**` is appended directories. + */ +async function adjustPossibleDirectory(glob, root) { + const g = typeof glob === 'string' + ? { + glob, + root, + } + : { + glob: glob.glob, + root: glob.root ?? root, + }; + // Do not ask the file system to look up obvious glob patterns. + if (isPossibleGlobRegExp.test(g.glob)) { + return glob; + } + if (isPossibleUrlRegExp.test(g.glob)) { + return glob; + } + const dirPath = path.resolve(g.root, g.glob); + try { + const stat = await fs.stat(dirPath); + if (stat.isDirectory()) { + const useGlob = posix.join(posixPath(g.glob), '**'); + return typeof glob === 'string' ? useGlob : { ...glob, glob: useGlob }; + } + } + catch (e) { + // it was not possible to access the dirPath, no problem, just let the file glob search look for it. + return glob; + } + return glob; +} +function posixPath(p) { + return path.sep === '\\' ? p.replace(/\\/g, '/') : p; +} +export async function normalizeFileOrGlobsToRoot(globs, root) { + const adjustedGlobs = await Promise.all(globs.map((g) => adjustPossibleDirectory(g, root))); + return normalizeGlobsToRoot(adjustedGlobs, root, false); +} diff --git a/action/node_modules/cspell/dist/esm/util/prefetch.d.mts b/action/node_modules/cspell/dist/esm/util/prefetch.d.mts new file mode 100644 index 000000000..5c27431e2 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/prefetch.d.mts @@ -0,0 +1,2 @@ +export declare function prefetchIterable(iterable: Iterable, size: number): Iterable; +//# sourceMappingURL=prefetch.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/prefetch.mjs b/action/node_modules/cspell/dist/esm/util/prefetch.mjs new file mode 100644 index 000000000..44649d73d --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/prefetch.mjs @@ -0,0 +1,15 @@ +import assert from 'assert'; +export function* prefetchIterable(iterable, size) { + assert(size >= 0); + const iter = iterable[Symbol.iterator](); + const buffer = []; + for (let next = iter.next(); !next.done; next = iter.next()) { + buffer.push(next.value); + if (buffer.length >= size - 1) { + const value = buffer[0]; + buffer.shift(); + yield value; + } + } + yield* buffer; +} diff --git a/action/node_modules/cspell/dist/esm/util/reporters.d.mts b/action/node_modules/cspell/dist/esm/util/reporters.d.mts new file mode 100644 index 000000000..1eb9857d9 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/reporters.d.mts @@ -0,0 +1,14 @@ +import type { CSpellReporter, FileSettings, ReporterConfiguration } from '@cspell/cspell-types'; +export type FinalizedReporter = Required; +/** + * Mergers several cspell reporters into a single one + */ +export declare function mergeReporters(...reporters: ReadonlyArray): FinalizedReporter; +/** + * Loads reporter modules configured in cspell config file + */ +export declare function loadReporters(reporters: FileSettings['reporters'], defaultReporter: CSpellReporter, config: ReporterConfiguration): Promise>; +export declare function finalizeReporter(reporter: undefined): undefined; +export declare function finalizeReporter(reporter: CSpellReporter): FinalizedReporter; +export declare function finalizeReporter(reporter: CSpellReporter | undefined): FinalizedReporter | undefined; +//# sourceMappingURL=reporters.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/reporters.mjs b/action/node_modules/cspell/dist/esm/util/reporters.mjs new file mode 100644 index 000000000..6b2ec0fbd --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/reporters.mjs @@ -0,0 +1,61 @@ +import { dynamicImport } from '@cspell/dynamic-import'; +import { pkgDir } from '../../lib/pkgInfo.cjs'; +import { ApplicationError, toError } from './errors.mjs'; +function callAll(methods) { + return (...p) => { + for (const method of methods) { + method(...p); + } + return; + }; +} +function extractEmitter(reporters, emitterName) { + // The `bind` is used in case the reporter is a class. + return reporters + .map((r) => r[emitterName]?.bind(r)) + .filter((r) => !!r); +} +function mergeResultEmitters(reporters) { + return async (result) => { + await Promise.all(reporters.map((reporter) => reporter.result?.(result))); + }; +} +/** + * Mergers several cspell reporters into a single one + */ +export function mergeReporters(...reporters) { + return { + issue: callAll(extractEmitter(reporters, 'issue')), + info: callAll(extractEmitter(reporters, 'info')), + debug: callAll(extractEmitter(reporters, 'debug')), + progress: callAll(extractEmitter(reporters, 'progress')), + error: callAll(extractEmitter(reporters, 'error')), + result: mergeResultEmitters(reporters), + }; +} +/** + * Loads reporter modules configured in cspell config file + */ +export async function loadReporters(reporters, defaultReporter, config) { + async function loadReporter(reporterSettings) { + if (reporterSettings === 'default') + return defaultReporter; + if (!Array.isArray(reporterSettings)) { + reporterSettings = [reporterSettings]; + } + const [moduleName, settings] = reporterSettings; + try { + const { getReporter } = await dynamicImport(moduleName, [process.cwd(), pkgDir]); + return getReporter(settings, config); + } + catch (e) { + throw new ApplicationError(`Failed to load reporter ${moduleName}: ${toError(e).message}`); + } + } + reporters = !reporters || !reporters.length ? ['default'] : [...reporters]; + const loadedReporters = await Promise.all(reporters.map(loadReporter)); + return loadedReporters.filter((v) => v !== undefined); +} +export function finalizeReporter(reporter) { + return reporter && mergeReporters(reporter); +} diff --git a/action/node_modules/cspell/dist/esm/util/stdin.d.mts b/action/node_modules/cspell/dist/esm/util/stdin.d.mts new file mode 100644 index 000000000..46dad1535 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/stdin.d.mts @@ -0,0 +1,2 @@ +export declare function readStdin(): AsyncIterable; +//# sourceMappingURL=stdin.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/stdin.mjs b/action/node_modules/cspell/dist/esm/util/stdin.mjs new file mode 100644 index 000000000..d1c1b9980 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/stdin.mjs @@ -0,0 +1,4 @@ +import * as readline from 'readline'; +export function readStdin() { + return readline.createInterface(process.stdin); +} diff --git a/action/node_modules/cspell/dist/esm/util/table.d.mts b/action/node_modules/cspell/dist/esm/util/table.d.mts new file mode 100644 index 000000000..c8cca49fc --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/table.d.mts @@ -0,0 +1,10 @@ +export interface Table { + header: string[]; + rows: string[][]; + deliminator?: string; +} +export declare function tableToLines(table: Table, deliminator?: string): string[]; +type TextDecorator = (t: string, index: number) => string; +export declare function decorateRowWith(row: string[], ...decorators: TextDecorator[]): string[]; +export {}; +//# sourceMappingURL=table.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/table.mjs b/action/node_modules/cspell/dist/esm/util/table.mjs new file mode 100644 index 000000000..8e0ee782b --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/table.mjs @@ -0,0 +1,31 @@ +import chalk from 'chalk'; +import strip from 'strip-ansi'; +export function tableToLines(table, deliminator) { + deliminator = deliminator || table.deliminator || ' | '; + const columnWidths = []; + const { header, rows } = table; + function recordWidths(row) { + row.forEach((col, idx) => { + columnWidths[idx] = Math.max(strip(col).length, columnWidths[idx] || 0); + }); + } + function justifyRow(c, i) { + return c + ' '.repeat(columnWidths[i] - strip(c).length); + } + function toLine(row) { + return decorateRowWith(row, justifyRow).join(deliminator); + } + function* process() { + yield toLine(decorateRowWith(header, headerDecorator)); + yield* rows.map(toLine); + } + recordWidths(header); + rows.forEach(recordWidths); + return [...process()]; +} +function headerDecorator(t) { + return chalk.bold(chalk.underline(t)); +} +export function decorateRowWith(row, ...decorators) { + return decorators.reduce((row, decorator) => row.map(decorator), row); +} diff --git a/action/node_modules/cspell/dist/esm/util/timer.d.mts b/action/node_modules/cspell/dist/esm/util/timer.d.mts new file mode 100644 index 000000000..fe3512623 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/timer.d.mts @@ -0,0 +1,8 @@ +export interface MeasurePromiseResult { + elapsedTimeMs: number; + success: boolean; +} +export declare function getTimeMeasurer(): () => number; +export declare function elapsedTimeMsFrom(relativeTo: [number, number]): number; +export declare function hrTimeToMs(hrTime: [number, number]): number; +//# sourceMappingURL=timer.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/timer.mjs b/action/node_modules/cspell/dist/esm/util/timer.mjs new file mode 100644 index 000000000..ca1493a9f --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/timer.mjs @@ -0,0 +1,10 @@ +export function getTimeMeasurer() { + const start = process.hrtime(); + return () => hrTimeToMs(process.hrtime(start)); +} +export function elapsedTimeMsFrom(relativeTo) { + return hrTimeToMs(process.hrtime(relativeTo)); +} +export function hrTimeToMs(hrTime) { + return hrTime[0] * 1.0e3 + hrTime[1] * 1.0e-6; +} diff --git a/action/node_modules/cspell/dist/esm/util/types.d.mts b/action/node_modules/cspell/dist/esm/util/types.d.mts new file mode 100644 index 000000000..30392e583 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/types.d.mts @@ -0,0 +1,7 @@ +/** + * Make all properties in T required + */ +export type RemoveUndefined = { + [P in keyof T]: Exclude; +}; +//# sourceMappingURL=types.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/types.mjs b/action/node_modules/cspell/dist/esm/util/types.mjs new file mode 100644 index 000000000..07e27a35e --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/types.mjs @@ -0,0 +1,4 @@ +/** + * Make all properties in T required + */ +export {}; diff --git a/action/node_modules/cspell/dist/esm/util/util.d.mts b/action/node_modules/cspell/dist/esm/util/util.d.mts new file mode 100644 index 000000000..0af27ff15 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/util.d.mts @@ -0,0 +1,13 @@ +import type { RemoveUndefined } from './types.mjs'; +export declare const uniqueFn: typeof uniqueFilterFnGenerator; +type FilterFn = (_v: T) => boolean; +export declare function uniqueFilterFnGenerator(): FilterFn; +export declare function uniqueFilterFnGenerator(extractFn: (v: T) => U): FilterFn; +export declare function unique(src: T[]): T[]; +export declare function clean(src: T): RemoveUndefined; +export declare function padWidth(s: string, target: number): number; +export declare function pad(s: string, w: number): string; +export declare function padLeft(s: string, w: number): string; +export declare function width(s: string): number; +export {}; +//# sourceMappingURL=util.d.mts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/esm/util/util.mjs b/action/node_modules/cspell/dist/esm/util/util.mjs new file mode 100644 index 000000000..108393a17 --- /dev/null +++ b/action/node_modules/cspell/dist/esm/util/util.mjs @@ -0,0 +1,44 @@ +// alias for uniqueFilterFnGenerator +export const uniqueFn = uniqueFilterFnGenerator; +export function uniqueFilterFnGenerator(extractFn) { + const values = new Set(); + const extractor = extractFn || ((a) => a); + return (v) => { + const vv = extractor(v); + const ret = !values.has(vv); + values.add(vv); + return ret; + }; +} +export function unique(src) { + return [...new Set(src)]; +} +export function clean(src) { + const r = src; + for (const key of Object.keys(r)) { + if (r[key] === undefined) { + delete r[key]; + } + } + return r; +} +export function padWidth(s, target) { + const sWidth = width(s); + return Math.max(target - sWidth, 0); +} +export function pad(s, w) { + const p = padWidth(s, w); + if (!p) + return s; + return s + ' '.repeat(p); +} +export function padLeft(s, w) { + const p = padWidth(s, w); + if (!p) + return s; + return ' '.repeat(p) + s; +} +export function width(s) { + // eslint-disable-next-line no-control-regex + return s.replace(/[\u0300-\u036f\x00-\x1f]/g, '').length; +} diff --git a/action/node_modules/cspell/dist/lib/file-entry-cache.cjs b/action/node_modules/cspell/dist/lib/file-entry-cache.cjs new file mode 100644 index 000000000..4426da4c7 --- /dev/null +++ b/action/node_modules/cspell/dist/lib/file-entry-cache.cjs @@ -0,0 +1,32 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createFromFile = void 0; +const file_entry_cache = __importStar(require("file-entry-cache")); +function createFromFile(pathToCache, useChecksum) { + return file_entry_cache.createFromFile(pathToCache, useChecksum); +} +exports.createFromFile = createFromFile; +//# sourceMappingURL=file-entry-cache.cjs.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/lib/file-entry-cache.d.cts b/action/node_modules/cspell/dist/lib/file-entry-cache.d.cts new file mode 100644 index 000000000..c96efaa58 --- /dev/null +++ b/action/node_modules/cspell/dist/lib/file-entry-cache.d.cts @@ -0,0 +1,4 @@ +export type { FileDescriptor, FileEntryCache } from 'file-entry-cache'; +import * as file_entry_cache from 'file-entry-cache'; +export declare function createFromFile(pathToCache: string, useChecksum?: boolean): file_entry_cache.FileEntryCache; +//# sourceMappingURL=file-entry-cache.d.cts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/lib/pkgInfo.cjs b/action/node_modules/cspell/dist/lib/pkgInfo.cjs new file mode 100644 index 000000000..6a41f7a0d --- /dev/null +++ b/action/node_modules/cspell/dist/lib/pkgInfo.cjs @@ -0,0 +1,30 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.npmPackage = exports.pkgDir = void 0; +const path = __importStar(require("path")); +exports.pkgDir = path.join(__dirname, '../..'); +exports.npmPackage = require('../../package.json'); +//# sourceMappingURL=pkgInfo.cjs.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/lib/pkgInfo.d.cts b/action/node_modules/cspell/dist/lib/pkgInfo.d.cts new file mode 100644 index 000000000..cbcf5e078 --- /dev/null +++ b/action/node_modules/cspell/dist/lib/pkgInfo.d.cts @@ -0,0 +1,3 @@ +export declare const pkgDir: string; +export declare const npmPackage: any; +//# sourceMappingURL=pkgInfo.d.cts.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/lib/uri.cjs b/action/node_modules/cspell/dist/lib/uri.cjs new file mode 100644 index 000000000..aed89ba56 --- /dev/null +++ b/action/node_modules/cspell/dist/lib/uri.cjs @@ -0,0 +1,7 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Utils = exports.URI = void 0; +var vscode_uri_1 = require("vscode-uri"); +Object.defineProperty(exports, "URI", { enumerable: true, get: function () { return vscode_uri_1.URI; } }); +Object.defineProperty(exports, "Utils", { enumerable: true, get: function () { return vscode_uri_1.Utils; } }); +//# sourceMappingURL=uri.cjs.map \ No newline at end of file diff --git a/action/node_modules/cspell/dist/lib/uri.d.cts b/action/node_modules/cspell/dist/lib/uri.d.cts new file mode 100644 index 000000000..5ca732983 --- /dev/null +++ b/action/node_modules/cspell/dist/lib/uri.d.cts @@ -0,0 +1,2 @@ +export { URI, Utils } from 'vscode-uri'; +//# sourceMappingURL=uri.d.cts.map \ No newline at end of file diff --git a/action/node_modules/cspell/node_modules/.bin/cspell-gitignore b/action/node_modules/cspell/node_modules/.bin/cspell-gitignore index a76f45c95..8e931855a 120000 --- a/action/node_modules/cspell/node_modules/.bin/cspell-gitignore +++ b/action/node_modules/cspell/node_modules/.bin/cspell-gitignore @@ -1 +1 @@ -../../../cspell-gitignore/bin.js \ No newline at end of file +../../../cspell-gitignore/bin.mjs \ No newline at end of file diff --git a/action/node_modules/cspell/package.json b/action/node_modules/cspell/package.json index 360c50578..ae0b69969 100644 --- a/action/node_modules/cspell/package.json +++ b/action/node_modules/cspell/package.json @@ -1,57 +1,69 @@ { "name": "cspell", - "version": "6.28.0", + "version": "6.29.1", "description": "A Spelling Checker for Code!", "funding": "https://github.com/streetsidesoftware/cspell?sponsor=1", - "main": "dist/index.js", - "typings": "dist/index.d.ts", "bin": { - "cspell": "bin.js" + "cspell": "bin.js", + "cspell-esm": "bin.mjs" }, + "type": "commonjs", + "main": "dist/cjs/index.js", + "types": "dist/cjs/index.d.ts", + "module": "dist/esm/index.mjs", "exports": { - ".": "./dist/index.js", - "./app": "./dist/app.js", - "./bin": "./bin.js", - "./bin.js": "./bin.js", - "./application": "./dist/application.js", - "./dist/app": "./dist/app.js", - "./dist/application": "./dist/application.js" - }, - "typesVersions": { - ">=4.0": { - "*": [ - "dist/*", - "*" - ] + ".": { + "import": "./dist/esm/index.mjs", + "require": "./dist/cjs/index.js" + }, + "./app": { + "import": "./dist/esm/app.mjs", + "require": "./dist/cjs/app.js" + }, + "./bin": { + "import": "./bin.mjs", + "require": "./bin.js" + }, + "./application": { + "import": "./dist/esm/application.mjs", + "require": "./dist/cjs/application.js" } }, - "files:comment": "Due to a lerna bug, patterns like `!**/*.map` are not getting recursively honored", "files": [ "bin.js", + "bin.mjs", "dist", + "!dist/esm/**/*.js", + "!dist/esm/**/*.ts", "!**/*.tsbuildInfo", "!**/__mocks__", + "!**/test/**", "!**/*.test.*", "!**/*.spec.*", "!**/*.map" ], "scripts": { - "clean": "shx rm -rf dist coverage .tsbuildinfo", - "build": "pnpm run compile && pnpm run build-api", - "build-api": "rollup -c rollup.config.mjs", + "clean": "shx rm -rf dist coverage temp .tsbuildinfo", + "build": "tsc -b . && ts2mjs dist/esm && pnpm run build:api", + "build:api": "rollup -c rollup.config.mjs", + "build:cjs": "tsc -b tsconfig.cjs.json", + "build:esm": "tsc -b tsconfig.esm.json", + "build:esm:ts2mjs": "tsc -b tsconfig.esm.json && ts2mjs dist/esm", + "build:lib": "tsc -b src/lib/tsconfig.json", "build:readme": "pnpm build:readme:help", "build:readme:help": "pnpm build:readme:help:lint && pnpm build:readme:help:trace && inject-markdown README.md && prettier -w README.md", "build:readme:help:lint": "./bin.js lint --help > static/help-lint.txt", "build:readme:help:trace": "./bin.js trace --help > static/help-trace.txt", "clean-build": "pnpm run clean && pnpm run build", - "compile": "tsc -p .", - "watch": "tsc --watch -p .", "coverage": "pnpm coverage:vitest && pnpm coverage:fix", "coverage:vitest": "vitest run --coverage", "coverage:fix": "nyc report --temp-dir \"$(pwd)/coverage\" --reporter lcov --report-dir \"$(pwd)/coverage\" --cwd ../..", + "test:watch": "vitest", + "test": "vitest run", + "watch": "tsc -b . -w", + "compile": "tsc -p .", "test-watch": "vitest", "prepublishOnly": "pnpm run clean-build", - "test": "vitest run", "test:update-snapshot": "vitest run --update" }, "repository": { @@ -76,14 +88,14 @@ }, "homepage": "https://streetsidesoftware.github.io/cspell/", "dependencies": { - "@cspell/cspell-pipe": "6.28.0", - "@cspell/dynamic-import": "6.28.0", + "@cspell/cspell-pipe": "6.29.1", + "@cspell/dynamic-import": "6.29.1", "chalk": "^4.1.2", "commander": "^10.0.0", - "cspell-gitignore": "6.28.0", - "cspell-glob": "6.28.0", - "cspell-io": "6.28.0", - "cspell-lib": "6.28.0", + "cspell-gitignore": "6.29.1", + "cspell-glob": "6.29.1", + "cspell-io": "6.29.1", + "cspell-lib": "6.29.1", "fast-glob": "^3.2.12", "fast-json-stable-stringify": "^2.1.0", "file-entry-cache": "^6.0.1", @@ -97,8 +109,8 @@ "node": ">=14" }, "devDependencies": { - "@cspell/cspell-json-reporter": "6.28.0", - "@cspell/cspell-types": "6.28.0", + "@cspell/cspell-json-reporter": "6.29.1", + "@cspell/cspell-types": "6.29.1", "@types/file-entry-cache": "^5.0.2", "@types/glob": "^8.1.0", "@types/imurmurhash": "^0.1.1", @@ -107,5 +119,5 @@ "micromatch": "^4.0.5", "minimatch": "^7.4.2" }, - "gitHead": "1c314413e76908e5fbf61fd2555726112b177c0e" + "gitHead": "e524c611f3529b22a7e8ae3449a5c9a01332d44f" } diff --git a/action/node_modules/import-meta-resolve/lib/get-format.js b/action/node_modules/import-meta-resolve/lib/get-format.js index 287d5740b..7d8f71af7 100644 --- a/action/node_modules/import-meta-resolve/lib/get-format.js +++ b/action/node_modules/import-meta-resolve/lib/get-format.js @@ -4,7 +4,7 @@ import path from 'node:path' import {URL, fileURLToPath} from 'node:url' -import {getPackageType} from './resolve.js' +import {getPackageType} from './resolve-get-package-type.js' import {codes} from './errors.js' const {ERR_UNKNOWN_FILE_EXTENSION} = codes diff --git a/action/node_modules/import-meta-resolve/lib/resolve-get-package-type.js b/action/node_modules/import-meta-resolve/lib/resolve-get-package-type.js new file mode 100644 index 000000000..c8515cedd --- /dev/null +++ b/action/node_modules/import-meta-resolve/lib/resolve-get-package-type.js @@ -0,0 +1,23 @@ +// Manually “tree shaken” from: +// +// Last checked on: Jan 6, 2023. +// +// This file solves a circular dependency. +// In Node.js, `getPackageType` is in `resolve.js`. +// `resolve.js` imports `get-format.js`, which needs `getPackageType`. +// We split that up so that bundlers don’t fail. + +/** + * @typedef {import('./package-config.js').PackageType} PackageType + */ + +import {getPackageScopeConfig} from './package-config.js' + +/** + * @param {URL} url + * @returns {PackageType} + */ +export function getPackageType(url) { + const packageConfig = getPackageScopeConfig(url) + return packageConfig.type +} diff --git a/action/node_modules/import-meta-resolve/lib/resolve.js b/action/node_modules/import-meta-resolve/lib/resolve.js index e3f1563f3..dd4cd66df 100644 --- a/action/node_modules/import-meta-resolve/lib/resolve.js +++ b/action/node_modules/import-meta-resolve/lib/resolve.js @@ -5,7 +5,6 @@ /** * @typedef {import('./errors.js').ErrnoException} ErrnoException * @typedef {import('./package-config.js').PackageConfig} PackageConfig - * @typedef {import('./package-config.js').PackageType} PackageType */ import assert from 'node:assert' @@ -883,14 +882,9 @@ function packageImportsResolve(name, base, conditions) { throw importNotDefined(name, packageJsonUrl, base) } -/** - * @param {URL} url - * @returns {PackageType} - */ -export function getPackageType(url) { - const packageConfig = getPackageScopeConfig(url) - return packageConfig.type -} +// Note: In Node.js, `getPackageType` is here. +// To prevent a circular dependency, we move it to +// `resolve-get-package-type.js`. /** * @param {string} specifier diff --git a/action/node_modules/import-meta-resolve/package.json b/action/node_modules/import-meta-resolve/package.json index f8e014142..06fcf0648 100644 --- a/action/node_modules/import-meta-resolve/package.json +++ b/action/node_modules/import-meta-resolve/package.json @@ -1,6 +1,6 @@ { "name": "import-meta-resolve", - "version": "2.2.1", + "version": "2.2.2", "description": "Resolve things like Node.js — ponyfill for `import.meta.resolve`", "license": "MIT", "keywords": [ diff --git a/action/package.json b/action/package.json index 31e08b01e..48978b1f3 100644 --- a/action/package.json +++ b/action/package.json @@ -14,8 +14,8 @@ "@octokit/core": "^4.2.0", "@octokit/plugin-rest-endpoint-methods": "^7.0.1", "@octokit/rest": "^19.0.7", - "cspell": "^6.28.0", - "cspell-glob": "^6.28.0", + "cspell": "^6.29.1", + "cspell-glob": "^6.29.1", "vscode-uri": "^3.0.7" } } diff --git a/yarn.lock b/yarn.lock index c6a7506de..83a925316 100644 --- a/yarn.lock +++ b/yarn.lock @@ -324,15 +324,15 @@ resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@cspell/cspell-bundled-dicts@6.28.0": - version "6.28.0" - resolved "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-6.28.0.tgz#4f00e81a50576d6c0961a21e07f19d9e04a4b0ce" - integrity sha512-RjAf67eejzQVXPX45xmIGFgSewtUeY5R+xun6xz1pQFIIrgsoxYNZ1hbdj72sX6+QdkJDf1WF3S9zMfiRVlOXQ== +"@cspell/cspell-bundled-dicts@6.29.1": + version "6.29.1" + resolved "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-6.29.1.tgz#8ce10ec47015c6bbbd358fdc4f356204b8f906cc" + integrity sha512-tG7hdE2ezLlWCOG9YJPAhCMS7hr8packQvPWFeJxAJKFQFlcVkOl6h+EXkG+/Q/46nVgYwAt30ADXTw4qZGjuA== dependencies: "@cspell/dict-ada" "^4.0.1" "@cspell/dict-aws" "^3.0.0" "@cspell/dict-bash" "^4.1.1" - "@cspell/dict-companies" "^3.0.8" + "@cspell/dict-companies" "^3.0.9" "@cspell/dict-cpp" "^4.0.3" "@cspell/dict-cryptocurrencies" "^3.0.1" "@cspell/dict-csharp" "^4.0.2" @@ -364,32 +364,32 @@ "@cspell/dict-php" "^3.0.4" "@cspell/dict-powershell" "^4.0.2" "@cspell/dict-public-licenses" "^2.0.1" - "@cspell/dict-python" "^4.0.1" + "@cspell/dict-python" "^4.0.2" "@cspell/dict-r" "^2.0.1" "@cspell/dict-ruby" "^4.0.2" "@cspell/dict-rust" "^4.0.1" "@cspell/dict-scala" "^4.0.1" "@cspell/dict-software-terms" "^3.1.5" - "@cspell/dict-sql" "^2.0.2" + "@cspell/dict-sql" "^2.1.0" "@cspell/dict-svelte" "^1.0.2" "@cspell/dict-swift" "^2.0.1" "@cspell/dict-typescript" "^3.1.1" "@cspell/dict-vue" "^3.0.0" -"@cspell/cspell-pipe@6.28.0": - version "6.28.0" - resolved "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-6.28.0.tgz#2326845d34a3ccbf8039ca175d850803045789f0" - integrity sha512-/D8cmitszZCethV4ekz+RMigwlkk5kLcOiVdjKBx/YHC5CtpkQ+v5ZlaTpxAKCoOyfyKW6hI8UNhNIx7ZyrizQ== +"@cspell/cspell-pipe@6.29.1": + version "6.29.1" + resolved "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-6.29.1.tgz#8fa59b28b775a8aba673cf9f13158267b1b1596c" + integrity sha512-5AB/IlvLV+d/MqmjiQVKyWvpNy9AQOJUkj7Uw02u33rm0JFcZEUvwUEhy/kggTawv8FGFLF7aJm0RhXivWH1Nw== -"@cspell/cspell-service-bus@6.28.0": - version "6.28.0" - resolved "https://registry.npmjs.org/@cspell/cspell-service-bus/-/cspell-service-bus-6.28.0.tgz#2a4744f568bc999bccc821e1920bbde8099fdf07" - integrity sha512-l3PtT8wZTTB3HcCFg0WYAamzt9MO4fVevOj+6lOaTTQDh5iV+4+XmutkdKGoDmMpe3EdqOeYJ5SC96NUb6U5CA== +"@cspell/cspell-service-bus@6.29.1": + version "6.29.1" + resolved "https://registry.npmjs.org/@cspell/cspell-service-bus/-/cspell-service-bus-6.29.1.tgz#42eaa173126671acd18c31262ddc2c87dae3e599" + integrity sha512-sclUr+5+UaT/3JeeYolAUNcFLhFq6Yxb3EqsJwjSKH3pws+EZaDKUWKXAGgunEGAMLFZ/HZN+nCbL7hHNVPgEQ== -"@cspell/cspell-types@6.28.0": - version "6.28.0" - resolved "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-6.28.0.tgz#a17fe6085b431e7ca4fe3a8eb1a47bc49cc6f7c7" - integrity sha512-+LJ7IlD4X9eaw8fBPtHYH8g5eFIkEZssLrjAOLA2hIps5aVNZ6J6oS4lUOVdKaDjdn6qsPgTpHGZJ2rV/RSrCA== +"@cspell/cspell-types@6.29.1": + version "6.29.1" + resolved "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-6.29.1.tgz#18412e1bbedee0ad5eda952ae40c8029e8d9eceb" + integrity sha512-tQCanGyaXAeUwxCysbCUmawYch3dVLjivTP475hH9BUqn84aeQi06OymmMbUdQE8krmbbzqakSVJPA++znYSdg== "@cspell/dict-ada@^4.0.1": version "4.0.1" @@ -406,7 +406,7 @@ resolved "https://registry.npmjs.org/@cspell/dict-bash/-/dict-bash-4.1.1.tgz#fe28016096f44d4a09fe4c5bcaf6fa40f33d98c6" integrity sha512-8czAa/Mh96wu2xr0RXQEGMTBUGkTvYn/Pb0o+gqOO1YW+poXGQc3gx0YPqILDryP/KCERrNvkWUJz3iGbvwC2A== -"@cspell/dict-companies@^3.0.8": +"@cspell/dict-companies@^3.0.9": version "3.0.9" resolved "https://registry.npmjs.org/@cspell/dict-companies/-/dict-companies-3.0.9.tgz#dfc35ad35478c8bee20a8ecd9f7509c359fe334b" integrity sha512-wSkVIJjk33Sm3LhieNv9TsSvUSeP0R/h8xx06NqbMYF43w9J8hZiMHlbB3FzaSOHRpXT5eBIJBVTeFbceZdiqg== @@ -566,10 +566,10 @@ resolved "https://registry.npmjs.org/@cspell/dict-public-licenses/-/dict-public-licenses-2.0.1.tgz#cfb5a7db67f48b17676d3772e375db8d1cf4a09c" integrity sha512-NZNwzkL5BqKddepDxvX/Qbji378Mso1TdnV4RFAN8hJoo6dSR0fv2TTI/Y0i/YWBmfmQGyTpEztBXtAw4qgjiA== -"@cspell/dict-python@^4.0.1": - version "4.0.1" - resolved "https://registry.npmjs.org/@cspell/dict-python/-/dict-python-4.0.1.tgz#ae058b5ba16abcffc626e79415cd0a32d2348058" - integrity sha512-1wtUgyaTqRiQY0/fryk0oW22lcxNUnZ5DwteTzfatMdbgR0OHXTlHbI8vYxpHLWalSoch7EpLsnaymG+fOrt8g== +"@cspell/dict-python@^4.0.2": + version "4.0.2" + resolved "https://registry.npmjs.org/@cspell/dict-python/-/dict-python-4.0.2.tgz#36582b21c1fda7f54d95052968b845dd595b585f" + integrity sha512-w1jSWDR1CkO23cZFbSYgnD/ZqknDZSVCI1AOE6sSszOJR8shmBkV3lMBYd+vpLsWhmkLLBcZTXDkiqFLXDGowQ== "@cspell/dict-r@^2.0.1": version "2.0.1" @@ -596,10 +596,10 @@ resolved "https://registry.npmjs.org/@cspell/dict-software-terms/-/dict-software-terms-3.1.5.tgz#9000ba07df6d868df257ca2438df36a0eb74acc6" integrity sha512-wmkWHHkp2AN9EDWNBLB0VASB5OtsC3KnhoAHxCJzC6AB3xjYoBfKsvgI/o50gfbsCVQceHpqXjOEYSw/xxTKNw== -"@cspell/dict-sql@^2.0.2": - version "2.0.2" - resolved "https://registry.npmjs.org/@cspell/dict-sql/-/dict-sql-2.0.2.tgz#1b23ace554bafb2acd3024bb69aadd0c855ab53e" - integrity sha512-XxUoamMFU9OGcDHLY6+pTlQDsqq9wcY7Oc4C55hqmotxFeFaaqinoD1UIAm1yDngRP7fKK4mVPPFmJI6bmspHg== +"@cspell/dict-sql@^2.1.0": + version "2.1.0" + resolved "https://registry.npmjs.org/@cspell/dict-sql/-/dict-sql-2.1.0.tgz#4210e83b9fc05ef91f577ae44fd264825ccfbf71" + integrity sha512-Bb+TNWUrTNNABO0bmfcYXiTlSt0RD6sB2MIY+rNlaMyIwug43jUjeYmkLz2tPkn3+2uvySeFEOMVYhMVfcuDKg== "@cspell/dict-svelte@^1.0.2": version "1.0.2" @@ -621,17 +621,17 @@ resolved "https://registry.npmjs.org/@cspell/dict-vue/-/dict-vue-3.0.0.tgz#68ccb432ad93fcb0fd665352d075ae9a64ea9250" integrity sha512-niiEMPWPV9IeRBRzZ0TBZmNnkK3olkOPYxC1Ny2AX4TGlYRajcW0WUtoSHmvvjZNfWLSg2L6ruiBeuPSbjnG6A== -"@cspell/dynamic-import@6.28.0": - version "6.28.0" - resolved "https://registry.npmjs.org/@cspell/dynamic-import/-/dynamic-import-6.28.0.tgz#0fe615d7d99ced04de4836d03582a70b3e2f4f82" - integrity sha512-drPfcTDDnWfQqSA3TqYMewocbFnPIW08/xKnouC7QFThgNocLD6TkBExa9timCATEsL7HujeAFEgMaPPTPFMqA== +"@cspell/dynamic-import@6.29.1": + version "6.29.1" + resolved "https://registry.npmjs.org/@cspell/dynamic-import/-/dynamic-import-6.29.1.tgz#21f3da2770ac836ff7aabf353b174fa39153d738" + integrity sha512-AqoZVBIkr0jghEK7yTm8i80sJVhXj0U8gND7IPgB6kbvlFc4kvMf2oMDSJTECu06MfXXNcb7ttUgk6aUz9RhfQ== dependencies: - import-meta-resolve "^2.2.1" + import-meta-resolve "^2.2.2" -"@cspell/strong-weak-map@6.28.0": - version "6.28.0" - resolved "https://registry.npmjs.org/@cspell/strong-weak-map/-/strong-weak-map-6.28.0.tgz#c9259111b28c7b29d83d433b7684c8a29bcc4452" - integrity sha512-M8qffYu672xMbF3JH5TmlXydfoglhiO/Tuy2fziQHtaTRm5Qp0KrSioSvHq+3QxnmHVTa91vYuzmr6qoAxqPjQ== +"@cspell/strong-weak-map@6.29.1": + version "6.29.1" + resolved "https://registry.npmjs.org/@cspell/strong-weak-map/-/strong-weak-map-6.29.1.tgz#2f6422469a80ca7a3a5a55dad050fc98eef5b399" + integrity sha512-bdz34Z4VPQ0MW4xwrfhkvcunyo0n7l5mBGOXORkN13UVk/nQEkTaoDoJGqI0RTXY8W1vrLYq+Nt0iflGaO/PQA== "@eslint/eslintrc@^2.0.0": version "2.0.0" @@ -1911,66 +1911,66 @@ crypto-random-string@^2.0.0: resolved "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5" integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== -cspell-dictionary@6.28.0: - version "6.28.0" - resolved "https://registry.npmjs.org/cspell-dictionary/-/cspell-dictionary-6.28.0.tgz#4ff23c30057408c275fbb784724f7232272927dc" - integrity sha512-7RSap81rJ2JVENuErrcKqfN1rBfDN8UIJSn5uoQZj2Boz/IfV24wGs0izXcJ+jpZI9L5PoT0XpMyuT93rwo+hA== +cspell-dictionary@6.29.1: + version "6.29.1" + resolved "https://registry.npmjs.org/cspell-dictionary/-/cspell-dictionary-6.29.1.tgz#214fc5522eff2cd6a8cc7816ed513e531d19014d" + integrity sha512-X6qzVskOsV4egtx4a6P+0BpFb8Sd/HjykipxTI57lJ2Nzk2q51lru3v29wlpjeeSHrZSeNmLRjGyQyD8BFlRag== dependencies: - "@cspell/cspell-pipe" "6.28.0" - "@cspell/cspell-types" "6.28.0" - cspell-trie-lib "6.28.0" + "@cspell/cspell-pipe" "6.29.1" + "@cspell/cspell-types" "6.29.1" + cspell-trie-lib "6.29.1" fast-equals "^4.0.3" gensequence "^5.0.2" -cspell-gitignore@6.28.0: - version "6.28.0" - resolved "https://registry.npmjs.org/cspell-gitignore/-/cspell-gitignore-6.28.0.tgz#806e96a6906d2d5848464a4cf110bbeb9afc166f" - integrity sha512-AOlblIJsoMk8F7+CznmhUIM+jGpIP/rBFERo5yT7bF7GarO2MoONxFA5MauSDnRaIDxMuik/gCn4MzvgT8ZZgw== +cspell-gitignore@6.29.1: + version "6.29.1" + resolved "https://registry.npmjs.org/cspell-gitignore/-/cspell-gitignore-6.29.1.tgz#13d8383164f7dd0cf9529be034b1341ed31e93ee" + integrity sha512-qwprWH9DXf7NLdVALfHBKASN3iSFn6AO0oAyKup2Mc5+7zcSfDiusrpqmJjCaOWiCN2n3VT+rzcr+wLpITWeFA== dependencies: - cspell-glob "6.28.0" + cspell-glob "6.29.1" find-up "^5.0.0" -cspell-glob@6.28.0, cspell-glob@^6.28.0: - version "6.28.0" - resolved "https://registry.npmjs.org/cspell-glob/-/cspell-glob-6.28.0.tgz#8e064318ec811384528843612f93245e9847d927" - integrity sha512-588E4RdswSNRoXf9mPtDxc+aSP3rpRwmJCrLEPtV6FdbG0YJDQOAmV2jP2qRqVouWOHjZZ84HwN79jfWt1ROsA== +cspell-glob@6.29.1, cspell-glob@^6.29.1: + version "6.29.1" + resolved "https://registry.npmjs.org/cspell-glob/-/cspell-glob-6.29.1.tgz#479785ee7b48f1487c524cacfb8e69470d09d814" + integrity sha512-P66PFR39BRSs/l4NkiTYV/3YYeMyhvXnnL8V1ngtUlUuEKoUr87xl6nu8WjIzFv3LPCz/tBQ0mT6h3Mw3CWcTQ== dependencies: micromatch "^4.0.5" -cspell-grammar@6.28.0: - version "6.28.0" - resolved "https://registry.npmjs.org/cspell-grammar/-/cspell-grammar-6.28.0.tgz#3bc0cb456b59efc902f2dc19f88294f130ca98d9" - integrity sha512-MQaaGn+aJxsUnYxi6yHeU0RvsD3ARo6/14aipbrx11uZYZjm8dDQVPFabW98aPjO7zd0qNuB6FBS/3FK6nbKkg== +cspell-grammar@6.29.1: + version "6.29.1" + resolved "https://registry.npmjs.org/cspell-grammar/-/cspell-grammar-6.29.1.tgz#02d92a94096ab0d2ffd5f8b354da79f850c887a3" + integrity sha512-huyNK64LT1Nj+EJxZZ/2CbvJxLKkVfE1UplkWAwWZlFVNfjgC31s3uJ+LFvGfyHDAiVDsJwLEA1Vr5bKmdDxwg== dependencies: - "@cspell/cspell-pipe" "6.28.0" - "@cspell/cspell-types" "6.28.0" + "@cspell/cspell-pipe" "6.29.1" + "@cspell/cspell-types" "6.29.1" -cspell-io@6.28.0: - version "6.28.0" - resolved "https://registry.npmjs.org/cspell-io/-/cspell-io-6.28.0.tgz#6e0724fd5938679656c65c9480c1869e8b82ee59" - integrity sha512-h/KtXQDX1c7q/0tZvBlYe0MyaqmtJZ1dcL9kInQXrFhLnw3IPXcS3Nwux+FRj7DXJp5uXbM80hEu54z8fDnT6g== +cspell-io@6.29.1: + version "6.29.1" + resolved "https://registry.npmjs.org/cspell-io/-/cspell-io-6.29.1.tgz#5ff699fa742827943216f6a5f56b75a0ced72c2c" + integrity sha512-CpY7syTcvm7voBtjrMKdN/DaTyFl3upfnL36WBcVJaPnrGJmO0TPYXqT75dNFxjpCdWRtcFRE78BzBbikkJ0fA== dependencies: - "@cspell/cspell-service-bus" "6.28.0" + "@cspell/cspell-service-bus" "6.29.1" node-fetch "^2.6.9" -cspell-lib@6.28.0: - version "6.28.0" - resolved "https://registry.npmjs.org/cspell-lib/-/cspell-lib-6.28.0.tgz#8ab13c7815d1e2e3f703bbdd49b51373cbcc844b" - integrity sha512-J24iWuaWU3O4L+4//wS3TA/Dw1GEqzZqeKsufOlpgU+P1+VplPaoIKmKBK44nM7RBPEz+fbyUxhnksLKD1tRmQ== +cspell-lib@6.29.1: + version "6.29.1" + resolved "https://registry.npmjs.org/cspell-lib/-/cspell-lib-6.29.1.tgz#3fdba32564b12d0dac81fb7d64f2b2d759f62e10" + integrity sha512-jov+slC/8UyfCupf7tC26pvJ+TaDOVgx/NvFXZOuJbK5zslNY0zZ8EYNcNRk7ZyvBcT/ebj1kugQYbhZb+jxGg== dependencies: - "@cspell/cspell-bundled-dicts" "6.28.0" - "@cspell/cspell-pipe" "6.28.0" - "@cspell/cspell-types" "6.28.0" - "@cspell/strong-weak-map" "6.28.0" + "@cspell/cspell-bundled-dicts" "6.29.1" + "@cspell/cspell-pipe" "6.29.1" + "@cspell/cspell-types" "6.29.1" + "@cspell/strong-weak-map" "6.29.1" clear-module "^4.1.2" comment-json "^4.2.3" configstore "^5.0.1" cosmiconfig "^8.1.0" - cspell-dictionary "6.28.0" - cspell-glob "6.28.0" - cspell-grammar "6.28.0" - cspell-io "6.28.0" - cspell-trie-lib "6.28.0" + cspell-dictionary "6.29.1" + cspell-glob "6.29.1" + cspell-grammar "6.29.1" + cspell-io "6.29.1" + cspell-trie-lib "6.29.1" fast-equals "^4.0.3" find-up "^5.0.0" gensequence "^5.0.2" @@ -1980,28 +1980,28 @@ cspell-lib@6.28.0: vscode-languageserver-textdocument "^1.0.8" vscode-uri "^3.0.7" -cspell-trie-lib@6.28.0: - version "6.28.0" - resolved "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-6.28.0.tgz#8f07987860c872d08ff7635fc17fbcafaf15c265" - integrity sha512-pF+C60Fdclg5oxXdnyA2biP6WjckaTs/eNMPTxbmQOEAraujZVyGFL3b464dwW9dJ8Qz1FuQc7fhQADelN2LrA== +cspell-trie-lib@6.29.1: + version "6.29.1" + resolved "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-6.29.1.tgz#9e05e8dc127b4c1c52d9c0899ead2a4de551a930" + integrity sha512-CwsJ1igAqYJuxGhp2g0KINlqETU2vqcajMgkSfTmnEy8L6XxgMWyYceuc5Q7B8RoNPeh+EGTjVBo82YgB9pnbg== dependencies: - "@cspell/cspell-pipe" "6.28.0" - "@cspell/cspell-types" "6.28.0" + "@cspell/cspell-pipe" "6.29.1" + "@cspell/cspell-types" "6.29.1" gensequence "^5.0.2" -cspell@^6.28.0: - version "6.28.0" - resolved "https://registry.npmjs.org/cspell/-/cspell-6.28.0.tgz#9cba0cbb439a0ed506c20581fb5dab1f4a779c8d" - integrity sha512-HPw7bO0H6l8vXyUF0Ybp9IucVt15Og8YsOfQ4RIaCLU9uJP4RgwjwHVPnCJiQvhC5s4Zbw1WzX/+J8PP83oIUg== +cspell@^6.29.1: + version "6.29.1" + resolved "https://registry.npmjs.org/cspell/-/cspell-6.29.1.tgz#e61e2ade37fad7060cbf4ad571493b0eb9b7dbb0" + integrity sha512-HBvyPUdrT1B/+SnaRkbuUUJNsssMis30bznfrRRzOc1zKLVNRay8Pd/ZYASp1M0S0T9V1IiE8FGy4t6V4kb+Hw== dependencies: - "@cspell/cspell-pipe" "6.28.0" - "@cspell/dynamic-import" "6.28.0" + "@cspell/cspell-pipe" "6.29.1" + "@cspell/dynamic-import" "6.29.1" chalk "^4.1.2" commander "^10.0.0" - cspell-gitignore "6.28.0" - cspell-glob "6.28.0" - cspell-io "6.28.0" - cspell-lib "6.28.0" + cspell-gitignore "6.29.1" + cspell-glob "6.29.1" + cspell-io "6.29.1" + cspell-lib "6.29.1" fast-glob "^3.2.12" fast-json-stable-stringify "^2.1.0" file-entry-cache "^6.0.1" @@ -2670,10 +2670,10 @@ import-local@^3.0.2: pkg-dir "^4.2.0" resolve-cwd "^3.0.0" -import-meta-resolve@^2.2.1: - version "2.2.1" - resolved "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-2.2.1.tgz#80fdeddbc15d7f3992c37425023ffb4aca7cb583" - integrity sha512-C6lLL7EJPY44kBvA80gq4uMsVFw5x3oSKfuMl1cuZ2RkI5+UJqQXgn+6hlUew0y4ig7Ypt4CObAAIzU53Nfpuw== +import-meta-resolve@^2.2.2: + version "2.2.2" + resolved "https://registry.npmjs.org/import-meta-resolve/-/import-meta-resolve-2.2.2.tgz#75237301e72d1f0fbd74dbc6cca9324b164c2cc9" + integrity sha512-f8KcQ1D80V7RnqVm+/lirO9zkOxjGxhaTC1IPrBGd3MEfNgmNG67tSUO9gTi2F3Blr2Az6g1vocaxzkVnWl9MA== imurmurhash@^0.1.4: version "0.1.4"