@cspell/cspell-tools 6.31.1 → 7.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.js +4 -6
- package/dist/AppOptions.js +1 -2
- package/dist/FeatureFlags/FeatureFlags.js +4 -11
- package/dist/FeatureFlags/index.d.ts +2 -2
- package/dist/FeatureFlags/index.js +2 -9
- package/dist/FeatureFlags/parseFlags.d.ts +1 -1
- package/dist/FeatureFlags/parseFlags.js +3 -7
- package/dist/app.d.ts +1 -1
- package/dist/app.js +12 -39
- package/dist/build.d.ts +5 -2
- package/dist/build.js +16 -40
- package/dist/compile.d.ts +2 -2
- package/dist/compile.js +12 -16
- package/dist/compiler/CompileOptions.js +1 -2
- package/dist/compiler/Reader.d.ts +1 -1
- package/dist/compiler/Reader.js +8 -12
- package/dist/compiler/SourceReader.d.ts +1 -1
- package/dist/compiler/SourceReader.js +5 -9
- package/dist/compiler/WordsCollection.js +2 -5
- package/dist/compiler/compile.d.ts +6 -2
- package/dist/compiler/compile.js +37 -64
- package/dist/compiler/createCompileRequest.d.ts +2 -2
- package/dist/compiler/createCompileRequest.js +2 -29
- package/dist/compiler/createWordsCollection.d.ts +2 -2
- package/dist/compiler/createWordsCollection.js +12 -21
- package/dist/compiler/fileWriter.d.ts +1 -1
- package/dist/compiler/fileWriter.js +4 -9
- package/dist/compiler/globP.js +4 -11
- package/dist/compiler/index.d.ts +4 -4
- package/dist/compiler/index.js +3 -11
- package/dist/compiler/inlineSettings.js +1 -5
- package/dist/compiler/legacyLineToWords.d.ts +1 -1
- package/dist/compiler/legacyLineToWords.js +5 -10
- package/dist/compiler/logWithTimestamp.d.ts +1 -1
- package/dist/compiler/logWithTimestamp.js +1 -5
- package/dist/compiler/logger.js +2 -7
- package/dist/compiler/readers/ReaderOptions.js +1 -2
- package/dist/compiler/readers/readHunspellFiles.d.ts +1 -1
- package/dist/compiler/readers/readHunspellFiles.js +10 -37
- package/dist/compiler/readers/readTextFile.js +7 -35
- package/dist/compiler/readers/textFileReader.d.ts +1 -1
- package/dist/compiler/readers/textFileReader.js +3 -7
- package/dist/compiler/readers/trieFileReader.d.ts +1 -1
- package/dist/compiler/readers/trieFileReader.js +5 -9
- package/dist/compiler/splitCamelCaseIfAllowed.d.ts +1 -1
- package/dist/compiler/splitCamelCaseIfAllowed.js +7 -34
- package/dist/compiler/streamSourceWordsFromFile.d.ts +1 -1
- package/dist/compiler/streamSourceWordsFromFile.js +3 -7
- package/dist/compiler/text.js +1 -5
- package/dist/compiler/wordListCompiler.d.ts +1 -1
- package/dist/compiler/wordListCompiler.js +17 -45
- package/dist/compiler/wordListParser.d.ts +2 -2
- package/dist/compiler/wordListParser.js +19 -25
- package/dist/compiler/writeTextToFile.js +7 -35
- package/dist/config/config.js +1 -2
- package/dist/config/configUtils.d.ts +1 -1
- package/dist/config/configUtils.js +3 -9
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +2 -9
- package/dist/config/normalizeConfig.js +2 -29
- package/dist/test/TestHelper.d.ts +3 -3
- package/dist/test/TestHelper.js +19 -49
- package/dist/test/console.d.ts +0 -3
- package/dist/test/console.js +14 -13
- package/dist/test/escapeRegEx.js +1 -5
- package/dist/test/normalizeOutput.js +9 -35
- package/package.json +15 -13
package/bin.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { program, CommanderError } from 'commander';
|
|
4
|
+
import { run } from './dist/app.js';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
app.run(program, process.argv).catch((e) => {
|
|
9
|
-
if (!(e instanceof program.CommanderError)) {
|
|
6
|
+
run(program, process.argv).catch((e) => {
|
|
7
|
+
if (!(e instanceof CommanderError)) {
|
|
10
8
|
console.log(e);
|
|
11
9
|
}
|
|
12
10
|
process.exitCode = 1;
|
package/dist/AppOptions.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createFeatureFlags = exports.getSystemFeatureFlags = exports.UnknownFeatureFlagError = exports.FeatureFlags = void 0;
|
|
4
1
|
let systemFeatureFlags;
|
|
5
2
|
/**
|
|
6
3
|
* Feature Flags are used to turn on/off features.
|
|
7
4
|
* These are primarily used before a feature has been fully released.
|
|
8
5
|
*/
|
|
9
|
-
class FeatureFlags {
|
|
6
|
+
export class FeatureFlags {
|
|
10
7
|
constructor(flags = []) {
|
|
11
8
|
this.flagValues = new Map();
|
|
12
9
|
this.flags = new Map(flags.map((f) => [f.name, f]));
|
|
@@ -63,22 +60,18 @@ class FeatureFlags {
|
|
|
63
60
|
return fork;
|
|
64
61
|
}
|
|
65
62
|
}
|
|
66
|
-
|
|
67
|
-
class UnknownFeatureFlagError extends Error {
|
|
63
|
+
export class UnknownFeatureFlagError extends Error {
|
|
68
64
|
constructor(flag) {
|
|
69
65
|
super(`Unknown feature flag: ${flag}`);
|
|
70
66
|
this.flag = flag;
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
|
-
|
|
74
|
-
function getSystemFeatureFlags() {
|
|
69
|
+
export function getSystemFeatureFlags() {
|
|
75
70
|
return systemFeatureFlags || (systemFeatureFlags = createFeatureFlags());
|
|
76
71
|
}
|
|
77
|
-
|
|
78
|
-
function createFeatureFlags() {
|
|
72
|
+
export function createFeatureFlags() {
|
|
79
73
|
return new FeatureFlags();
|
|
80
74
|
}
|
|
81
|
-
exports.createFeatureFlags = createFeatureFlags;
|
|
82
75
|
const boolValues = {
|
|
83
76
|
0: false,
|
|
84
77
|
1: true,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { FeatureFlag, FeatureFlags, getSystemFeatureFlags, UnknownFeatureFlagError } from './FeatureFlags';
|
|
2
|
-
export { parseFlags } from './parseFlags';
|
|
1
|
+
export { FeatureFlag, FeatureFlags, getSystemFeatureFlags, UnknownFeatureFlagError } from './FeatureFlags.js';
|
|
2
|
+
export { parseFlags } from './parseFlags.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.parseFlags = exports.UnknownFeatureFlagError = exports.getSystemFeatureFlags = exports.FeatureFlags = void 0;
|
|
4
|
-
var FeatureFlags_1 = require("./FeatureFlags");
|
|
5
|
-
Object.defineProperty(exports, "FeatureFlags", { enumerable: true, get: function () { return FeatureFlags_1.FeatureFlags; } });
|
|
6
|
-
Object.defineProperty(exports, "getSystemFeatureFlags", { enumerable: true, get: function () { return FeatureFlags_1.getSystemFeatureFlags; } });
|
|
7
|
-
Object.defineProperty(exports, "UnknownFeatureFlagError", { enumerable: true, get: function () { return FeatureFlags_1.UnknownFeatureFlagError; } });
|
|
8
|
-
var parseFlags_1 = require("./parseFlags");
|
|
9
|
-
Object.defineProperty(exports, "parseFlags", { enumerable: true, get: function () { return parseFlags_1.parseFlags; } });
|
|
1
|
+
export { FeatureFlags, getSystemFeatureFlags, UnknownFeatureFlagError } from './FeatureFlags.js';
|
|
2
|
+
export { parseFlags } from './parseFlags.js';
|
|
10
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseFlags = void 0;
|
|
4
|
-
const FeatureFlags_1 = require("./FeatureFlags");
|
|
1
|
+
import { UnknownFeatureFlagError } from './FeatureFlags.js';
|
|
5
2
|
const splitFlag = /[:=]/;
|
|
6
3
|
const leadingEql = /^=/;
|
|
7
|
-
function parseFlags(ff, flags) {
|
|
4
|
+
export function parseFlags(ff, flags) {
|
|
8
5
|
for (const flag of flags) {
|
|
9
6
|
const [name, value] = flag.replace(leadingEql, '').split(splitFlag, 2);
|
|
10
7
|
try {
|
|
11
8
|
ff.setFlag(name, value);
|
|
12
9
|
}
|
|
13
10
|
catch (e) {
|
|
14
|
-
if (e instanceof
|
|
11
|
+
if (e instanceof UnknownFeatureFlagError) {
|
|
15
12
|
console.error(e.message);
|
|
16
13
|
console.error(ff.help());
|
|
17
14
|
}
|
|
@@ -20,5 +17,4 @@ function parseFlags(ff, flags) {
|
|
|
20
17
|
}
|
|
21
18
|
return ff;
|
|
22
19
|
}
|
|
23
|
-
exports.parseFlags = parseFlags;
|
|
24
20
|
//# sourceMappingURL=parseFlags.js.map
|
package/dist/app.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type * as program from 'commander';
|
|
2
|
-
import type { FeatureFlags } from './FeatureFlags';
|
|
2
|
+
import type { FeatureFlags } from './FeatureFlags/index.js';
|
|
3
3
|
export declare function run(program: program.Command, argv: string[], flags?: FeatureFlags): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=app.d.ts.map
|
package/dist/app.js
CHANGED
|
@@ -1,38 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// For large dictionaries, it is necessary to increase the memory limit.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
-
if (mod && mod.__esModule) return mod;
|
|
21
|
-
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
-
__setModuleDefault(result, mod);
|
|
24
|
-
return result;
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.run = void 0;
|
|
28
|
-
const path = __importStar(require("path"));
|
|
29
|
-
const build_1 = require("./build");
|
|
30
|
-
const compile_1 = require("./compile");
|
|
31
|
-
const compiler = __importStar(require("./compiler"));
|
|
32
|
-
const logWithTimestamp_1 = require("./compiler/logWithTimestamp");
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
34
|
-
const npmPackage = require(path.join(__dirname, '..', 'package.json'));
|
|
35
|
-
compiler.setLogger(logWithTimestamp_1.logWithTimestamp);
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import { build } from './build.js';
|
|
4
|
+
import { processCompileAction } from './compile.js';
|
|
5
|
+
import * as compiler from './compiler/index.js';
|
|
6
|
+
import { logWithTimestamp } from './compiler/logWithTimestamp.js';
|
|
7
|
+
const npmPackageRaw = readFileSync(new URL('../package.json', import.meta.url), 'utf8');
|
|
8
|
+
const npmPackage = JSON.parse(npmPackageRaw);
|
|
9
|
+
compiler.setLogger(logWithTimestamp);
|
|
36
10
|
function collect(value, previous) {
|
|
37
11
|
return previous.concat([value]);
|
|
38
12
|
}
|
|
@@ -51,27 +25,26 @@ function addCompileOptions(compileCommand) {
|
|
|
51
25
|
.option('--trie4', 'Use file format trie4', false)
|
|
52
26
|
.option('--trie-base <number>', 'Advanced: Set the trie base number. A value between 10 and 36');
|
|
53
27
|
}
|
|
54
|
-
async function run(program, argv, flags) {
|
|
28
|
+
export async function run(program, argv, flags) {
|
|
55
29
|
program.exitOverride();
|
|
56
30
|
program.version(npmPackage.version);
|
|
57
31
|
addCompileOptions(program.command('compile <src...>').description('Compile words into a cspell dictionary files.'))
|
|
58
32
|
.option('--trie', 'Compile into a trie file.', false)
|
|
59
33
|
.option('--no-sort', 'Do not sort the result')
|
|
60
34
|
.action((src, options) => {
|
|
61
|
-
return
|
|
35
|
+
return processCompileAction(src, options, flags);
|
|
62
36
|
});
|
|
63
37
|
addCompileOptions(program
|
|
64
38
|
.command('compile-trie <src...>')
|
|
65
39
|
.description('Compile words lists or Hunspell dictionary into trie files used by cspell.\nAlias of `compile --trie`')).action((src, options) => {
|
|
66
|
-
return
|
|
40
|
+
return processCompileAction(src, { ...options, trie: true }, flags);
|
|
67
41
|
});
|
|
68
42
|
program
|
|
69
43
|
.command('build [targets]')
|
|
70
44
|
.description('Build the targets defined in the run configuration.')
|
|
71
45
|
.option('-c, --config <path to run configuration>', 'Specify the run configuration file.')
|
|
72
46
|
.option('-r, --root <directory>', 'Specify the run directory')
|
|
73
|
-
.action(
|
|
47
|
+
.action(build);
|
|
74
48
|
await program.parseAsync(argv);
|
|
75
49
|
}
|
|
76
|
-
exports.run = run;
|
|
77
50
|
//# sourceMappingURL=app.js.map
|
package/dist/build.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export interface BuildOptions {
|
|
2
2
|
/** Optional path to config file */
|
|
3
|
-
config?: string;
|
|
4
|
-
|
|
3
|
+
config?: string | undefined;
|
|
4
|
+
/** Used to resolve relative paths in the config. */
|
|
5
|
+
root?: string | undefined;
|
|
6
|
+
/** Current working directory */
|
|
7
|
+
cwd?: string | undefined;
|
|
5
8
|
}
|
|
6
9
|
export declare function build(targets: string[] | undefined, options: BuildOptions): Promise<void>;
|
|
7
10
|
//# sourceMappingURL=build.d.ts.map
|
package/dist/build.js
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.build = void 0;
|
|
27
|
-
const cosmiconfig_1 = require("cosmiconfig");
|
|
28
|
-
const path = __importStar(require("path"));
|
|
29
|
-
const compiler_1 = require("./compiler");
|
|
30
|
-
const config_1 = require("./config");
|
|
1
|
+
import { cosmiconfig } from 'cosmiconfig';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { compile } from './compiler/index.js';
|
|
4
|
+
import { normalizeConfig } from './config/index.js';
|
|
31
5
|
const moduleName = 'cspell-tools';
|
|
32
6
|
const searchPlaces = [
|
|
33
7
|
`${moduleName}.config.json`,
|
|
@@ -35,25 +9,27 @@ const searchPlaces = [
|
|
|
35
9
|
`${moduleName}.config.yml`,
|
|
36
10
|
'package.json',
|
|
37
11
|
];
|
|
38
|
-
async function build(targets, options) {
|
|
12
|
+
export async function build(targets, options) {
|
|
39
13
|
const allowedTargets = new Set(targets || []);
|
|
40
14
|
function filter(target) {
|
|
41
15
|
return !targets || allowedTargets.has(target.name);
|
|
42
16
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
const explorer = (0, cosmiconfig_1.cosmiconfig)(moduleName, {
|
|
17
|
+
const searchDir = path.resolve(options.root || options.cwd || '.');
|
|
18
|
+
const explorer = cosmiconfig(moduleName, {
|
|
47
19
|
searchPlaces,
|
|
48
|
-
stopDir:
|
|
49
|
-
transform:
|
|
20
|
+
stopDir: searchDir,
|
|
21
|
+
transform: normalizeConfig,
|
|
50
22
|
});
|
|
51
|
-
const config = await (options.config ? explorer.load(options.config) : explorer.search(
|
|
23
|
+
const config = await (options.config ? explorer.load(options.config) : explorer.search(searchDir));
|
|
52
24
|
if (!config?.config) {
|
|
53
25
|
console.error('root: %s', options.root);
|
|
54
26
|
throw 'cspell-tools.config not found.';
|
|
55
27
|
}
|
|
56
|
-
|
|
28
|
+
const buildInfo = normalizeRequest(config.config, options.root || path.dirname(config.filepath));
|
|
29
|
+
await compile(buildInfo, { filter, cwd: options.cwd });
|
|
30
|
+
}
|
|
31
|
+
function normalizeRequest(buildInfo, root) {
|
|
32
|
+
const { rootDir = root, targets = [] } = buildInfo;
|
|
33
|
+
return { rootDir, targets };
|
|
57
34
|
}
|
|
58
|
-
exports.build = build;
|
|
59
35
|
//# sourceMappingURL=build.js.map
|
package/dist/compile.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompileCommonAppOptions } from './AppOptions';
|
|
2
|
-
import type { FeatureFlags } from './FeatureFlags';
|
|
1
|
+
import type { CompileCommonAppOptions } from './AppOptions.js';
|
|
2
|
+
import type { FeatureFlags } from './FeatureFlags/index.js';
|
|
3
3
|
export declare function processCompileAction(src: string[], options: CompileCommonAppOptions, featureFlags: FeatureFlags | undefined): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=compile.d.ts.map
|
package/dist/compile.js
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
(
|
|
10
|
-
async function processCompileAction(src, options, featureFlags) {
|
|
11
|
-
const ff = featureFlags || (0, FeatureFlags_1.getSystemFeatureFlags)();
|
|
12
|
-
(0, FeatureFlags_1.parseFlags)(ff, options.experimental);
|
|
1
|
+
import { opConcatMap, pipe } from '@cspell/cspell-pipe/sync';
|
|
2
|
+
import { compile } from './compiler/compile.js';
|
|
3
|
+
import { createCompileRequest } from './compiler/createCompileRequest.js';
|
|
4
|
+
import { globP } from './compiler/globP.js';
|
|
5
|
+
import { getSystemFeatureFlags, parseFlags } from './FeatureFlags/index.js';
|
|
6
|
+
getSystemFeatureFlags().register('compound', 'Enable compound dictionary sources.');
|
|
7
|
+
export async function processCompileAction(src, options, featureFlags) {
|
|
8
|
+
const ff = featureFlags || getSystemFeatureFlags();
|
|
9
|
+
parseFlags(ff, options.experimental);
|
|
13
10
|
return useCompile(src, options);
|
|
14
11
|
}
|
|
15
|
-
exports.processCompileAction = processCompileAction;
|
|
16
12
|
async function useCompile(src, options) {
|
|
17
13
|
console.log('Compile:\n output: %s\n compress: %s\n files:\n %s \n\n', options.output || 'default', options.compress ? 'true' : 'false', src.join('\n '));
|
|
18
|
-
const globResults = await Promise.all(src.map((s) =>
|
|
14
|
+
const globResults = await Promise.all(src.map((s) => globP(s)));
|
|
19
15
|
const sources = [
|
|
20
|
-
...
|
|
16
|
+
...pipe(globResults, opConcatMap((a) => a)),
|
|
21
17
|
];
|
|
22
|
-
return
|
|
18
|
+
return compile(createCompileRequest(sources, options));
|
|
23
19
|
}
|
|
24
20
|
//# sourceMappingURL=compile.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Reader, ReaderOptions } from './readers/ReaderOptions';
|
|
1
|
+
import type { Reader, ReaderOptions } from './readers/ReaderOptions.js';
|
|
2
2
|
export declare const regHunspellFile: RegExp;
|
|
3
3
|
export declare function createReader(filename: string, options: ReaderOptions): Promise<Reader>;
|
|
4
4
|
//# sourceMappingURL=Reader.d.ts.map
|
package/dist/compiler/Reader.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const textFileReader_1 = require("./readers/textFileReader");
|
|
6
|
-
const trieFileReader_1 = require("./readers/trieFileReader");
|
|
7
|
-
exports.regHunspellFile = /\.(dic|aff)$/i;
|
|
1
|
+
import { readHunspellFiles } from './readers/readHunspellFiles.js';
|
|
2
|
+
import { textFileReader } from './readers/textFileReader.js';
|
|
3
|
+
import { trieFileReader } from './readers/trieFileReader.js';
|
|
4
|
+
export const regHunspellFile = /\.(dic|aff)$/i;
|
|
8
5
|
// Readers first match wins
|
|
9
6
|
const readers = [
|
|
10
|
-
{ test: /\.trie\b/, method:
|
|
11
|
-
{ test:
|
|
7
|
+
{ test: /\.trie\b/, method: trieFileReader },
|
|
8
|
+
{ test: regHunspellFile, method: readHunspellFiles },
|
|
12
9
|
];
|
|
13
10
|
function findMatchingReader(filename, options) {
|
|
14
11
|
for (const reader of readers) {
|
|
@@ -16,13 +13,12 @@ function findMatchingReader(filename, options) {
|
|
|
16
13
|
return reader.method(filename, options);
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
return
|
|
16
|
+
return textFileReader(filename);
|
|
20
17
|
}
|
|
21
|
-
async function createReader(filename, options) {
|
|
18
|
+
export async function createReader(filename, options) {
|
|
22
19
|
const baseReader = await findMatchingReader(filename, options);
|
|
23
20
|
return Object.assign(baseReader, {
|
|
24
21
|
[Symbol.iterator]: () => baseReader.lines[Symbol.iterator](),
|
|
25
22
|
});
|
|
26
23
|
}
|
|
27
|
-
exports.createReader = createReader;
|
|
28
24
|
//# sourceMappingURL=Reader.js.map
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const wordListParser_1 = require("./wordListParser");
|
|
6
|
-
async function createSourceReader(filename, options) {
|
|
7
|
-
const reader = await (0, Reader_1.createReader)(filename, options);
|
|
1
|
+
import { createReader } from './Reader.js';
|
|
2
|
+
import { parseFileLines } from './wordListParser.js';
|
|
3
|
+
export async function createSourceReader(filename, options) {
|
|
4
|
+
const reader = await createReader(filename, options);
|
|
8
5
|
if (reader.type !== 'TextFile') {
|
|
9
6
|
return {
|
|
10
7
|
words: reader.lines,
|
|
@@ -15,10 +12,9 @@ async function createSourceReader(filename, options) {
|
|
|
15
12
|
}
|
|
16
13
|
return textFileReader(reader, options);
|
|
17
14
|
}
|
|
18
|
-
exports.createSourceReader = createSourceReader;
|
|
19
15
|
async function textFileReader(reader, options) {
|
|
20
16
|
const { legacy, splitWords: split, allowedSplitWords } = options;
|
|
21
|
-
const words = [...
|
|
17
|
+
const words = [...parseFileLines(reader, { legacy, split, allowedSplitWords })];
|
|
22
18
|
return {
|
|
23
19
|
size: words.length,
|
|
24
20
|
words,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
Object.
|
|
3
|
-
exports.defaultExcludeWordsCollection = exports.defaultAllowedSplitWords = void 0;
|
|
4
|
-
exports.defaultAllowedSplitWords = Object.freeze({ size: 0, has: () => true });
|
|
5
|
-
exports.defaultExcludeWordsCollection = Object.freeze({ size: 0, has: () => false });
|
|
1
|
+
export const defaultAllowedSplitWords = Object.freeze({ size: 0, has: () => true });
|
|
2
|
+
export const defaultExcludeWordsCollection = Object.freeze({ size: 0, has: () => false });
|
|
6
3
|
//# sourceMappingURL=WordsCollection.js.map
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import type { CompileRequest, CompileSourceOptions, Target } from '../config';
|
|
1
|
+
import type { CompileRequest, CompileSourceOptions, Target } from '../config/index.js';
|
|
2
2
|
interface CompileOptions {
|
|
3
3
|
/**
|
|
4
4
|
* Optional filter function to filter targets.
|
|
5
5
|
*/
|
|
6
6
|
filter?: (target: Target) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The current working directory. Defaults to process.cwd()
|
|
9
|
+
*/
|
|
10
|
+
cwd?: string;
|
|
7
11
|
}
|
|
8
12
|
export declare function compile(request: CompileRequest, options?: CompileOptions): Promise<void>;
|
|
9
|
-
export declare function compileTarget(target: Target, options: CompileSourceOptions, rootDir: string): Promise<void>;
|
|
13
|
+
export declare function compileTarget(target: Target, options: CompileSourceOptions, rootDir: string, cwd?: string): Promise<void>;
|
|
10
14
|
export {};
|
|
11
15
|
//# sourceMappingURL=compile.d.ts.map
|