cspell-lib 8.9.0 → 8.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import type { Uri } from '../util/Uri.js';
2
2
  import type { Document } from './Document.js';
3
3
  export declare function isBinaryDoc(document: Document): boolean;
4
- export declare function isBinaryFile(filename: Uri | URL | string, languageId?: string | string[]): boolean;
4
+ export declare function isBinaryFile(filename: Uri | URL | string, languageId?: string | string[], text?: string): boolean;
5
5
  //# sourceMappingURL=isBinaryDoc.d.ts.map
@@ -1,10 +1,10 @@
1
- import { isGenerated, isGeneratedFile } from '../LanguageIds.js';
1
+ import { getLanguagesForBasename, isGenerated } from '../LanguageIds.js';
2
2
  import { basename, toUri } from '../util/Uri.js';
3
3
  import { normalizeLanguageIds } from './normalizeLanguageIds.js';
4
4
  export function isBinaryDoc(document) {
5
- return isBinaryFile(toUri(document.uri), document.languageId);
5
+ return isBinaryFile(toUri(document.uri), document.languageId, document.text);
6
6
  }
7
- export function isBinaryFile(filename, languageId) {
7
+ export function isBinaryFile(filename, languageId, text) {
8
8
  const filenameUri = toUri(filename);
9
9
  if (languageId) {
10
10
  const ids = normalizeLanguageIds(languageId);
@@ -12,6 +12,10 @@ export function isBinaryFile(filename, languageId) {
12
12
  return isGenerated(ids);
13
13
  }
14
14
  const file = basename(filenameUri);
15
- return isGeneratedFile(file);
15
+ const ids = getLanguagesForBasename(file);
16
+ if (ids.length)
17
+ return isGenerated(ids);
18
+ // Unknown file type, check the content.
19
+ return text?.slice(0, 1024).includes('\u0000') || false;
16
20
  }
17
21
  //# sourceMappingURL=isBinaryDoc.js.map
@@ -216,7 +216,7 @@ export const languageExtensionDefinitions = [
216
216
  },
217
217
  {
218
218
  id: 'video',
219
- extensions: ['.mov', '.mpg'],
219
+ extensions: ['.mov', '.mpg', '.mpeg', '.mp4', '.avi', '.wmv', '.mkv', '.flv'],
220
220
  format: 'Binary',
221
221
  },
222
222
  {
@@ -39,6 +39,17 @@ export async function spellCheckDocument(document, options, settings) {
39
39
  try {
40
40
  const timer = createPerfTimer('loadFile');
41
41
  const doc = await resolveDocument(document).finally(() => timer.end());
42
+ if (isBinaryDoc(doc)) {
43
+ return {
44
+ document,
45
+ options,
46
+ settingsUsed: settings,
47
+ localConfigFilepath: undefined,
48
+ issues: [],
49
+ checked: false,
50
+ errors: undefined,
51
+ };
52
+ }
42
53
  const result = await spellCheckFullDocument(doc, options, settings);
43
54
  const perf = result.perf || {};
44
55
  perf.loadTimeMs = timer.elapsed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell-lib",
3
- "version": "8.9.0",
3
+ "version": "8.9.1",
4
4
  "description": "A library of useful functions used across various cspell tools.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -59,21 +59,21 @@
59
59
  },
60
60
  "homepage": "https://github.com/streetsidesoftware/cspell#readme",
61
61
  "dependencies": {
62
- "@cspell/cspell-bundled-dicts": "8.9.0",
63
- "@cspell/cspell-pipe": "8.9.0",
64
- "@cspell/cspell-resolver": "8.9.0",
65
- "@cspell/cspell-types": "8.9.0",
66
- "@cspell/dynamic-import": "8.9.0",
67
- "@cspell/strong-weak-map": "8.9.0",
68
- "@cspell/url": "8.9.0",
62
+ "@cspell/cspell-bundled-dicts": "8.9.1",
63
+ "@cspell/cspell-pipe": "8.9.1",
64
+ "@cspell/cspell-resolver": "8.9.1",
65
+ "@cspell/cspell-types": "8.9.1",
66
+ "@cspell/dynamic-import": "8.9.1",
67
+ "@cspell/strong-weak-map": "8.9.1",
68
+ "@cspell/url": "8.9.1",
69
69
  "clear-module": "^4.1.2",
70
70
  "comment-json": "^4.2.3",
71
- "cspell-config-lib": "8.9.0",
72
- "cspell-dictionary": "8.9.0",
73
- "cspell-glob": "8.9.0",
74
- "cspell-grammar": "8.9.0",
75
- "cspell-io": "8.9.0",
76
- "cspell-trie-lib": "8.9.0",
71
+ "cspell-config-lib": "8.9.1",
72
+ "cspell-dictionary": "8.9.1",
73
+ "cspell-glob": "8.9.1",
74
+ "cspell-grammar": "8.9.1",
75
+ "cspell-io": "8.9.1",
76
+ "cspell-trie-lib": "8.9.1",
77
77
  "env-paths": "^3.0.0",
78
78
  "fast-equals": "^5.0.1",
79
79
  "gensequence": "^7.0.0",
@@ -101,5 +101,5 @@
101
101
  "leaked-handles": "^5.2.0",
102
102
  "lorem-ipsum": "^2.0.8"
103
103
  },
104
- "gitHead": "33c513cf848a61fb1ebcea1b9c67505a31447411"
104
+ "gitHead": "f532c77cca4bfae380293c586f02f377354c850b"
105
105
  }