@breadstone-tools/localizator-core 0.0.70 → 0.0.72
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/CHANGELOG.md +27 -0
- package/Resources/Models/TypeScriptResourceInfo.d.ts.map +1 -1
- package/Resources/Models/TypeScriptResourceInfo.js +6 -0
- package/Resources/Models/TypeScriptResourceInfo.js.map +1 -1
- package/Resources/Readers/Adapter/JsonResourceReaderAdapter.js +15 -15
- package/Resources/Readers/Adapter/JsonResourceReaderAdapter.js.map +1 -1
- package/Resources/Readers/Adapter/ResxResourceReaderAdapter.js +15 -15
- package/Resources/Readers/Adapter/ResxResourceReaderAdapter.js.map +1 -1
- package/Resources/ResourceFactory.js +7 -7
- package/Resources/ResourceFactory.js.map +1 -1
- package/Resources/Sorting/ResourceSorter.js +1 -1
- package/Resources/Sorting/ResourceSorter.js.map +1 -1
- package/Services/LocalizationProcessor.js +3 -3
- package/Services/LocalizationProcessor.js.map +1 -1
- package/package.json +2 -2
- package/Resources/Scanners/Adapter/Interfaces/IResourceReaderAdapter.d.ts +0 -26
- package/Resources/Scanners/Adapter/Interfaces/IResourceReaderAdapter.d.ts.map +0 -1
- package/Resources/Scanners/Adapter/Interfaces/IResourceReaderAdapter.js +0 -4
- package/Resources/Scanners/Adapter/Interfaces/IResourceReaderAdapter.js.map +0 -1
- package/Resources/Scanners/Adapter/Interfaces/IScannerAdapter.d.ts +0 -17
- package/Resources/Scanners/Adapter/Interfaces/IScannerAdapter.d.ts.map +0 -1
- package/Resources/Scanners/Adapter/Interfaces/IScannerAdapter.js +0 -4
- package/Resources/Scanners/Adapter/Interfaces/IScannerAdapter.js.map +0 -1
- package/Resources/Scanners/Adapter/JsonResourceReaderAdapter.d.ts +0 -44
- package/Resources/Scanners/Adapter/JsonResourceReaderAdapter.d.ts.map +0 -1
- package/Resources/Scanners/Adapter/JsonResourceReaderAdapter.js +0 -120
- package/Resources/Scanners/Adapter/JsonResourceReaderAdapter.js.map +0 -1
- package/Resources/Scanners/Adapter/JsonScannerAdapter.d.ts +0 -32
- package/Resources/Scanners/Adapter/JsonScannerAdapter.d.ts.map +0 -1
- package/Resources/Scanners/Adapter/JsonScannerAdapter.js +0 -80
- package/Resources/Scanners/Adapter/JsonScannerAdapter.js.map +0 -1
- package/Resources/Scanners/Adapter/ResxResourceReaderAdapter.d.ts +0 -44
- package/Resources/Scanners/Adapter/ResxResourceReaderAdapter.d.ts.map +0 -1
- package/Resources/Scanners/Adapter/ResxResourceReaderAdapter.js +0 -120
- package/Resources/Scanners/Adapter/ResxResourceReaderAdapter.js.map +0 -1
- package/Resources/Scanners/Adapter/ResxScannerAdapter.d.ts +0 -32
- package/Resources/Scanners/Adapter/ResxScannerAdapter.d.ts.map +0 -1
- package/Resources/Scanners/Adapter/ResxScannerAdapter.js +0 -80
- package/Resources/Scanners/Adapter/ResxScannerAdapter.js.map +0 -1
- package/Resources/Scanners/ResourceReader.d.ts +0 -41
- package/Resources/Scanners/ResourceReader.d.ts.map +0 -1
- package/Resources/Scanners/ResourceReader.js +0 -77
- package/Resources/Scanners/ResourceReader.js.map +0 -1
- package/Resources/Scanners/ResourceScanner.d.ts +0 -41
- package/Resources/Scanners/ResourceScanner.d.ts.map +0 -1
- package/Resources/Scanners/ResourceScanner.js +0 -77
- package/Resources/Scanners/ResourceScanner.js.map +0 -1
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// #region Imports
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.JsonResourceReaderAdapter = void 0;
|
|
5
|
-
const utilities_1 = require("@breadstone-infrastructure/utilities");
|
|
6
|
-
const JsonResourceInfo_1 = require("../../Models/JsonResourceInfo");
|
|
7
|
-
const ResourceType_1 = require("../../Models/Interfaces/ResourceType");
|
|
8
|
-
// #endregion
|
|
9
|
-
/**
|
|
10
|
-
* A resource reader adapter that scans directories for JSON files.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
class JsonResourceReaderAdapter {
|
|
15
|
-
// #region Fields
|
|
16
|
-
_fileSystem;
|
|
17
|
-
_logger;
|
|
18
|
-
_glob;
|
|
19
|
-
// #endregion
|
|
20
|
-
// #region Ctor
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new instance of the `JsonResourceReaderAdapter` class.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
constructor(fileSystem, logger) {
|
|
27
|
-
this._fileSystem = fileSystem;
|
|
28
|
-
this._logger = logger;
|
|
29
|
-
this._glob = '**/*.json';
|
|
30
|
-
}
|
|
31
|
-
// #endregion
|
|
32
|
-
// #region Methods
|
|
33
|
-
/**
|
|
34
|
-
* Scans the specified directory for .json files.
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
* @param path - The directory to scan.
|
|
38
|
-
* @returns The resource information.
|
|
39
|
-
*/
|
|
40
|
-
scanDirectory(path) {
|
|
41
|
-
this.invalidateDirectory(path);
|
|
42
|
-
const globPath = utilities_1.Path.combine(path, this._glob);
|
|
43
|
-
this._logger.info(` Scanning ${(0, utilities_1.gray)(globPath)}`);
|
|
44
|
-
const scans = this._fileSystem.glob(globPath).map((file) => {
|
|
45
|
-
this._logger.info(` Scanning ${(0, utilities_1.gray)(utilities_1.Path.getFileName(file))}`);
|
|
46
|
-
const json = this._fileSystem.readAllJson(file);
|
|
47
|
-
this._logger.log(` Found ${(0, utilities_1.bold)(Object.keys(json).toString())} keys in language ${(0, utilities_1.bold)(this._fileSystem.getLocale(file))}`);
|
|
48
|
-
return {
|
|
49
|
-
file: file,
|
|
50
|
-
content: () => json
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
return scans.map((scan) => new JsonResourceInfo_1.JsonResourceInfo({
|
|
54
|
-
type: ResourceType_1.ResourceType.Json,
|
|
55
|
-
content: scan.content,
|
|
56
|
-
locale: this._fileSystem.getLocale(scan.file),
|
|
57
|
-
name: this._fileSystem.getFileName(scan.file),
|
|
58
|
-
path: scan.file
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Scans a specific file for resource information.
|
|
63
|
-
*
|
|
64
|
-
* @public
|
|
65
|
-
* @param path - The path to the file to scan.
|
|
66
|
-
* @returns The resource information or null if the file is not a valid resource.
|
|
67
|
-
*/
|
|
68
|
-
scanFile(path) {
|
|
69
|
-
this.invalidateFile(path);
|
|
70
|
-
const json = this._fileSystem.readAllJson(path);
|
|
71
|
-
if (Object.keys(json).length === 0) {
|
|
72
|
-
this._logger.warn(`The file ${(0, utilities_1.gray)(path)} does not contain any valid JSON data.`);
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
this._logger.info(` Found ${(0, utilities_1.bold)(Object.keys(json).length.toString())} keys in language ${(0, utilities_1.bold)(this._fileSystem.getLocale(path))}`);
|
|
76
|
-
return new JsonResourceInfo_1.JsonResourceInfo({
|
|
77
|
-
type: ResourceType_1.ResourceType.Json,
|
|
78
|
-
content: () => json,
|
|
79
|
-
locale: this._fileSystem.getLocale(path),
|
|
80
|
-
name: this._fileSystem.getFileName(path),
|
|
81
|
-
path: path
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* @private
|
|
86
|
-
*/
|
|
87
|
-
invalidateDirectory(path) {
|
|
88
|
-
if (this._fileSystem.isFileOrDirectory(path) !== 'directory') {
|
|
89
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} is not a valid directory.`);
|
|
90
|
-
}
|
|
91
|
-
if (!this._fileSystem.exists(path)) {
|
|
92
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not exist.`);
|
|
93
|
-
}
|
|
94
|
-
if (this._fileSystem.glob(path).length === 0) {
|
|
95
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} is empty or does not contain any files.`);
|
|
96
|
-
}
|
|
97
|
-
if (this._glob.endsWith(this._glob)) {
|
|
98
|
-
throw new Error(`The path should not end with ${(0, utilities_1.gray)(this._glob)}.`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* @private
|
|
103
|
-
*/
|
|
104
|
-
invalidateFile(path) {
|
|
105
|
-
if (this._fileSystem.isFileOrDirectory(path) !== 'file') {
|
|
106
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} is not a valid file.`);
|
|
107
|
-
}
|
|
108
|
-
if (!this._fileSystem.exists(path)) {
|
|
109
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not exist.`);
|
|
110
|
-
}
|
|
111
|
-
if (!this._fileSystem.glob(path).length) {
|
|
112
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not contain any files.`);
|
|
113
|
-
}
|
|
114
|
-
if (!path.endsWith('.json')) {
|
|
115
|
-
throw new Error('The path should end with .json.');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
exports.JsonResourceReaderAdapter = JsonResourceReaderAdapter;
|
|
120
|
-
//# sourceMappingURL=JsonResourceReaderAdapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JsonResourceReaderAdapter.js","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/JsonResourceReaderAdapter.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;AAIlB,oEAAwG;AACxG,oEAAiE;AACjE,uEAAoE;AAEpE,aAAa;AAEb;;;;GAIG;AACH,MAAa,yBAAyB;IAElC,iBAAiB;IAEA,WAAW,CAAc;IACzB,OAAO,CAAU;IACjB,KAAK,CAAS;IAE/B,aAAa;IAEb,eAAe;IAEf;;;;OAIG;IACH,YAAmB,UAAuB,EAAE,MAAe;QACvD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;IAC7B,CAAC;IAED,aAAa;IAEb,kB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CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACvD,CAAC;IACL,CAAC;CAIJ;AAvID,8DAuIC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { IScannerAdapter } from './Interfaces/IResourceReaderAdapter';
|
|
2
|
-
import type { IJsonResourceInfo } from '../../Models/Interfaces/IJsonResourceInfo';
|
|
3
|
-
import { type IFileSystem, type ILogger } from '@breadstone-infrastructure/utilities';
|
|
4
|
-
/**
|
|
5
|
-
* The `JsonScannerAdapter` class is responsible for scanning .json files.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export declare class JsonScannerAdapter implements IScannerAdapter {
|
|
10
|
-
private readonly _fileSystem;
|
|
11
|
-
private readonly _logger;
|
|
12
|
-
private readonly _glob;
|
|
13
|
-
/**
|
|
14
|
-
* Constructs a new instance of the `ResourceScanner` class.
|
|
15
|
-
*
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
constructor(fileSystem: IFileSystem, logger: ILogger);
|
|
19
|
-
/**
|
|
20
|
-
* Scans the specified path for .json files.
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
* @param path - The path to scan.
|
|
24
|
-
* @returns The resource information.
|
|
25
|
-
*/
|
|
26
|
-
scan(path: string): Array<IJsonResourceInfo>;
|
|
27
|
-
/**
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
private invalidatePath;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=JsonScannerAdapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JsonScannerAdapter.d.ts","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/JsonScannerAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAMxG;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IAItD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAM/B;;;;OAIG;gBACgB,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO;IAU3D;;;;;;OAMG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,iBAAiB,CAAC;IA6BnD;;OAEG;IACH,OAAO,CAAC,cAAc;CAoBzB"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// #region Imports
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.JsonScannerAdapter = void 0;
|
|
5
|
-
const utilities_1 = require("@breadstone-infrastructure/utilities");
|
|
6
|
-
const JsonResourceInfo_1 = require("../../Models/JsonResourceInfo");
|
|
7
|
-
const ResourceType_1 = require("../../Models/Interfaces/ResourceType");
|
|
8
|
-
// #endregion
|
|
9
|
-
/**
|
|
10
|
-
* The `JsonScannerAdapter` class is responsible for scanning .json files.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
class JsonScannerAdapter {
|
|
15
|
-
// #region Fields
|
|
16
|
-
_fileSystem;
|
|
17
|
-
_logger;
|
|
18
|
-
_glob;
|
|
19
|
-
// #endregion
|
|
20
|
-
// #region Ctor
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new instance of the `ResourceScanner` class.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
constructor(fileSystem, logger) {
|
|
27
|
-
this._fileSystem = fileSystem;
|
|
28
|
-
this._logger = logger;
|
|
29
|
-
this._glob = '**/*.json';
|
|
30
|
-
}
|
|
31
|
-
// #endregion
|
|
32
|
-
// #region Methods
|
|
33
|
-
/**
|
|
34
|
-
* Scans the specified path for .json files.
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
* @param path - The path to scan.
|
|
38
|
-
* @returns The resource information.
|
|
39
|
-
*/
|
|
40
|
-
scan(path) {
|
|
41
|
-
this.invalidatePath(path);
|
|
42
|
-
const globPath = utilities_1.Path.combine(path, this._glob);
|
|
43
|
-
this._logger.info(` Scanning ${(0, utilities_1.gray)(globPath)}`);
|
|
44
|
-
const scans = this._fileSystem.glob(globPath).map((file) => {
|
|
45
|
-
this._logger.info(` Scanning ${(0, utilities_1.gray)(utilities_1.Path.getFileName(file))}`);
|
|
46
|
-
const json = this._fileSystem.readAllJson(file);
|
|
47
|
-
this._logger.log(` Found ${(0, utilities_1.bold)(Object.keys(json).toString())} keys in language ${(0, utilities_1.bold)(this._fileSystem.getLocale(file))}`);
|
|
48
|
-
return {
|
|
49
|
-
file: file,
|
|
50
|
-
content: () => json
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
return scans.map((scan) => new JsonResourceInfo_1.JsonResourceInfo({
|
|
54
|
-
type: ResourceType_1.ResourceType.Json,
|
|
55
|
-
content: scan.content,
|
|
56
|
-
locale: this._fileSystem.getLocale(scan.file),
|
|
57
|
-
name: this._fileSystem.getFileName(scan.file),
|
|
58
|
-
path: scan.file
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @private
|
|
63
|
-
*/
|
|
64
|
-
invalidatePath(path) {
|
|
65
|
-
if (this._fileSystem.isFileOrDirectory(path) !== 'directory') {
|
|
66
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} is not a valid directory.`);
|
|
67
|
-
}
|
|
68
|
-
if (!this._fileSystem.exists(path)) {
|
|
69
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not exist.`);
|
|
70
|
-
}
|
|
71
|
-
if (this._fileSystem.glob(path).length === 0) {
|
|
72
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} is empty or does not contain any files.`);
|
|
73
|
-
}
|
|
74
|
-
if (this._glob.endsWith(this._glob)) {
|
|
75
|
-
throw new Error(`The glob pattern ${(0, utilities_1.gray)(this._glob)} should not end with .json.`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.JsonScannerAdapter = JsonScannerAdapter;
|
|
80
|
-
//# sourceMappingURL=JsonScannerAdapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JsonScannerAdapter.js","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/JsonScannerAdapter.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;AAIlB,oEAAwG;AACxG,oEAAiE;AACjE,uEAAoE;AAEpE,aAAa;AAEb;;;;GAIG;AACH,MAAa,kBAAkB;IAE3B,iBAAiB;IAEA,WAAW,CAAc;IACzB,OAAO,CAAU;IACjB,KAAK,CAAS;IAE/B,aAAa;IAEb,eAAe;IAEf;;;;OAIG;IACH,YAAmB,UAAuB,EAAE,MAAe;QACvD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC;IAC7B,CAAC;IAED,aAAa;IAEb,kBAAkB;IAElB;;;;;;OAMG;IACI,IAAI,CAAC,IAAY;QACpB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE1B,MAAM,QAAQ,GAAG,gBAAI,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAEhD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,IAAA,gBAAI,EAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAElD,MAAM,KAAK,GAAG,IAAI,CAAC,WAA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ACxE,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,gBAAI,EAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,gBAAI,EAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;QACtF,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAA,gBAAI,EAAC,IAAI,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACvF,CAAC;IACL,CAAC;CAIJ;AAtFD,gDAsFC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { IResourceReaderAdapter } from './Interfaces/IResourceReaderAdapter';
|
|
2
|
-
import type { IResxResourceInfo } from '../../Models/Interfaces/IResxResourceInfo';
|
|
3
|
-
import { type IFileSystem, type ILogger } from '@breadstone-infrastructure/utilities';
|
|
4
|
-
/**
|
|
5
|
-
* A resource reader adapter that scans directories for RESX files.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export declare class ResxResourceReaderAdapter implements IResourceReaderAdapter {
|
|
10
|
-
private readonly _fileSystem;
|
|
11
|
-
private readonly _logger;
|
|
12
|
-
private readonly _glob;
|
|
13
|
-
/**
|
|
14
|
-
* Constructs a new instance of the `ResxResourceReaderAdapter` class.
|
|
15
|
-
*
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
constructor(fileSystem: IFileSystem, logger: ILogger);
|
|
19
|
-
/**
|
|
20
|
-
* Scans the specified directory for .resx files.
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
* @param path - The directory to scan.
|
|
24
|
-
* @returns The resource information.
|
|
25
|
-
*/
|
|
26
|
-
scanDirectory(path: string): Array<IResxResourceInfo>;
|
|
27
|
-
/**
|
|
28
|
-
* Scans a specific file for resource information.
|
|
29
|
-
*
|
|
30
|
-
* @public
|
|
31
|
-
* @param path - The path to the file to scan.
|
|
32
|
-
* @returns The resource information or null if the file is not a valid resource.
|
|
33
|
-
*/
|
|
34
|
-
scanFile(path: string): IResxResourceInfo | null;
|
|
35
|
-
/**
|
|
36
|
-
* @private
|
|
37
|
-
*/
|
|
38
|
-
private invalidateDirectory;
|
|
39
|
-
/**
|
|
40
|
-
* @private
|
|
41
|
-
*/
|
|
42
|
-
private invalidateFile;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=ResxResourceReaderAdapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResxResourceReaderAdapter.d.ts","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/ResxResourceReaderAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAMxG;;;;GAIG;AACH,qBAAa,yBAA0B,YAAW,sBAAsB;IAIpE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAM/B;;;;OAIG;gBACgB,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO;IAU3D;;;;;;OAMG;IACI,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,iBAAiB,CAAC;IA6B5D;;;;;;OAMG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;IAqBvD;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;OAEG;IACH,OAAO,CAAC,cAAc;CAoBzB"}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// #region Imports
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ResxResourceReaderAdapter = void 0;
|
|
5
|
-
const utilities_1 = require("@breadstone-infrastructure/utilities");
|
|
6
|
-
const ResxResourceInfo_1 = require("../../Models/ResxResourceInfo");
|
|
7
|
-
const ResourceType_1 = require("../../Models/Interfaces/ResourceType");
|
|
8
|
-
// #endregion
|
|
9
|
-
/**
|
|
10
|
-
* A resource reader adapter that scans directories for RESX files.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
class ResxResourceReaderAdapter {
|
|
15
|
-
// #region Fields
|
|
16
|
-
_fileSystem;
|
|
17
|
-
_logger;
|
|
18
|
-
_glob;
|
|
19
|
-
// #endregion
|
|
20
|
-
// #region Ctor
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new instance of the `ResxResourceReaderAdapter` class.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
constructor(fileSystem, logger) {
|
|
27
|
-
this._fileSystem = fileSystem;
|
|
28
|
-
this._logger = logger;
|
|
29
|
-
this._glob = '**/*.resx';
|
|
30
|
-
}
|
|
31
|
-
// #endregion
|
|
32
|
-
// #region Methods
|
|
33
|
-
/**
|
|
34
|
-
* Scans the specified directory for .resx files.
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
* @param path - The directory to scan.
|
|
38
|
-
* @returns The resource information.
|
|
39
|
-
*/
|
|
40
|
-
scanDirectory(path) {
|
|
41
|
-
this.invalidateDirectory(path);
|
|
42
|
-
const globPath = utilities_1.Path.combine(path, this._glob);
|
|
43
|
-
this._logger.log(` Scanning ${(0, utilities_1.gray)(globPath)}`);
|
|
44
|
-
const scans = this._fileSystem.glob(globPath).map((file) => {
|
|
45
|
-
this._logger.log(` Scanning ${(0, utilities_1.gray)(utilities_1.Path.getFileName(file))}`);
|
|
46
|
-
const resx = this._fileSystem.readAllResx(file);
|
|
47
|
-
this._logger.log(` Found ${(0, utilities_1.bold)(resx.length.toString())} keys in language ${(0, utilities_1.bold)(this._fileSystem.getLocale(file))}`);
|
|
48
|
-
return {
|
|
49
|
-
file: file,
|
|
50
|
-
content: () => resx
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
return scans.map((scan) => new ResxResourceInfo_1.ResxResourceInfo({
|
|
54
|
-
type: ResourceType_1.ResourceType.Resx,
|
|
55
|
-
content: scan.content,
|
|
56
|
-
locale: this._fileSystem.getLocale(scan.file),
|
|
57
|
-
name: this._fileSystem.getFileName(scan.file),
|
|
58
|
-
path: scan.file
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Scans a specific file for resource information.
|
|
63
|
-
*
|
|
64
|
-
* @public
|
|
65
|
-
* @param path - The path to the file to scan.
|
|
66
|
-
* @returns The resource information or null if the file is not a valid resource.
|
|
67
|
-
*/
|
|
68
|
-
scanFile(path) {
|
|
69
|
-
this.invalidateFile(path);
|
|
70
|
-
const resx = this._fileSystem.readAllResx(path);
|
|
71
|
-
if (resx.length === 0) {
|
|
72
|
-
this._logger.warn(`The file ${(0, utilities_1.gray)(path)} does not contain any resources.`);
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
this._logger.log(` Found ${(0, utilities_1.bold)(resx.length.toString())} keys in language ${(0, utilities_1.bold)(this._fileSystem.getLocale(path))}`);
|
|
76
|
-
return new ResxResourceInfo_1.ResxResourceInfo({
|
|
77
|
-
type: ResourceType_1.ResourceType.Resx,
|
|
78
|
-
content: () => resx,
|
|
79
|
-
locale: this._fileSystem.getLocale(path),
|
|
80
|
-
name: this._fileSystem.getFileName(path),
|
|
81
|
-
path: path
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* @private
|
|
86
|
-
*/
|
|
87
|
-
invalidateDirectory(path) {
|
|
88
|
-
if (this._fileSystem.isFileOrDirectory(path) !== 'directory') {
|
|
89
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} is not a valid directory.`);
|
|
90
|
-
}
|
|
91
|
-
if (!this._fileSystem.exists(path)) {
|
|
92
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not exist.`);
|
|
93
|
-
}
|
|
94
|
-
if (this._fileSystem.glob(path).length === 0) {
|
|
95
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} is empty or does not contain any files.`);
|
|
96
|
-
}
|
|
97
|
-
if (this._glob.endsWith(this._glob)) {
|
|
98
|
-
throw new Error(`The path should not end with ${(0, utilities_1.gray)(this._glob)}.`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* @private
|
|
103
|
-
*/
|
|
104
|
-
invalidateFile(path) {
|
|
105
|
-
if (this._fileSystem.isFileOrDirectory(path) !== 'file') {
|
|
106
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} is not a valid file.`);
|
|
107
|
-
}
|
|
108
|
-
if (!this._fileSystem.exists(path)) {
|
|
109
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not exist.`);
|
|
110
|
-
}
|
|
111
|
-
if (!this._fileSystem.glob(path).length) {
|
|
112
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not contain any files.`);
|
|
113
|
-
}
|
|
114
|
-
if (!path.endsWith('.resx')) {
|
|
115
|
-
throw new Error('The path should end with .resx.');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
exports.ResxResourceReaderAdapter = ResxResourceReaderAdapter;
|
|
120
|
-
//# sourceMappingURL=ResxResourceReaderAdapter.js.map
|
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I,KAAK,CAAC,YAAY,IAAA,gBAAI,EAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,gBAAI,EAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,gBAAI,EAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QAC1E,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACvD,CAAC;IACL,CAAC;CAIJ;AAvID,8DAuIC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { IScannerAdapter } from './Interfaces/IResourceReaderAdapter';
|
|
2
|
-
import type { IResxResourceInfo } from '../../Models/Interfaces/IResxResourceInfo';
|
|
3
|
-
import { type IFileSystem, type ILogger } from '@breadstone-infrastructure/utilities';
|
|
4
|
-
/**
|
|
5
|
-
* The `ResxScannerAdapter` class is responsible for scanning .resx files.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export declare class ResxScannerAdapter implements IScannerAdapter {
|
|
10
|
-
private readonly _fileSystem;
|
|
11
|
-
private readonly _logger;
|
|
12
|
-
private readonly _glob;
|
|
13
|
-
/**
|
|
14
|
-
* Constructs a new instance of the `ResxScannerAdapter` class.
|
|
15
|
-
*
|
|
16
|
-
* @public
|
|
17
|
-
*/
|
|
18
|
-
constructor(fileSystem: IFileSystem, logger: ILogger);
|
|
19
|
-
/**
|
|
20
|
-
* Scans the specified path for .resx files.
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
* @param path - The path to scan.
|
|
24
|
-
* @returns The resource information.
|
|
25
|
-
*/
|
|
26
|
-
scan(path: string): Array<IResxResourceInfo>;
|
|
27
|
-
/**
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
private invalidatePath;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=ResxScannerAdapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResxScannerAdapter.d.ts","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/ResxScannerAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAoB,KAAK,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAMxG;;;;GAIG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IAItD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAM/B;;;;OAIG;gBACgB,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO;IAU3D;;;;;;OAMG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,iBAAiB,CAAC;IA6BnD;;OAEG;IACH,OAAO,CAAC,cAAc;CAoBzB"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// #region Imports
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ResxScannerAdapter = void 0;
|
|
5
|
-
const utilities_1 = require("@breadstone-infrastructure/utilities");
|
|
6
|
-
const ResxResourceInfo_1 = require("../../Models/ResxResourceInfo");
|
|
7
|
-
const ResourceType_1 = require("../../Models/Interfaces/ResourceType");
|
|
8
|
-
// #endregion
|
|
9
|
-
/**
|
|
10
|
-
* The `ResxScannerAdapter` class is responsible for scanning .resx files.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
class ResxScannerAdapter {
|
|
15
|
-
// #region Fields
|
|
16
|
-
_fileSystem;
|
|
17
|
-
_logger;
|
|
18
|
-
_glob;
|
|
19
|
-
// #endregion
|
|
20
|
-
// #region Ctor
|
|
21
|
-
/**
|
|
22
|
-
* Constructs a new instance of the `ResxScannerAdapter` class.
|
|
23
|
-
*
|
|
24
|
-
* @public
|
|
25
|
-
*/
|
|
26
|
-
constructor(fileSystem, logger) {
|
|
27
|
-
this._fileSystem = fileSystem;
|
|
28
|
-
this._logger = logger;
|
|
29
|
-
this._glob = '**/*.resx';
|
|
30
|
-
}
|
|
31
|
-
// #endregion
|
|
32
|
-
// #region Methods
|
|
33
|
-
/**
|
|
34
|
-
* Scans the specified path for .resx files.
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
* @param path - The path to scan.
|
|
38
|
-
* @returns The resource information.
|
|
39
|
-
*/
|
|
40
|
-
scan(path) {
|
|
41
|
-
this.invalidatePath(path);
|
|
42
|
-
const globPath = utilities_1.Path.combine(path, this._glob);
|
|
43
|
-
this._logger.log(` Scanning ${(0, utilities_1.gray)(globPath)}`);
|
|
44
|
-
const scans = this._fileSystem.glob(globPath).map((file) => {
|
|
45
|
-
this._logger.log(` Scanning ${(0, utilities_1.gray)(utilities_1.Path.getFileName(file))}`);
|
|
46
|
-
const resx = this._fileSystem.readAllResx(file);
|
|
47
|
-
this._logger.log(` Found ${(0, utilities_1.bold)(resx.length.toString())} keys in language ${(0, utilities_1.bold)(this._fileSystem.getLocale(file))}`);
|
|
48
|
-
return {
|
|
49
|
-
file: file,
|
|
50
|
-
content: () => resx
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
return scans.map((scan) => new ResxResourceInfo_1.ResxResourceInfo({
|
|
54
|
-
type: ResourceType_1.ResourceType.Resx,
|
|
55
|
-
content: scan.content,
|
|
56
|
-
locale: this._fileSystem.getLocale(scan.file),
|
|
57
|
-
name: this._fileSystem.getFileName(scan.file),
|
|
58
|
-
path: scan.file
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* @private
|
|
63
|
-
*/
|
|
64
|
-
invalidatePath(path) {
|
|
65
|
-
if (this._fileSystem.isFileOrDirectory(path) !== 'directory') {
|
|
66
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} is not a valid directory.`);
|
|
67
|
-
}
|
|
68
|
-
if (!this._fileSystem.exists(path)) {
|
|
69
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} does not exist.`);
|
|
70
|
-
}
|
|
71
|
-
if (this._fileSystem.glob(path).length === 0) {
|
|
72
|
-
throw new Error(`The path ${(0, utilities_1.gray)(path)} is empty or does not contain any files.`);
|
|
73
|
-
}
|
|
74
|
-
if (this._glob.endsWith(this._glob)) {
|
|
75
|
-
throw new Error(`The glob pattern ${(0, utilities_1.gray)(this._glob)} should not end with .resx.`);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.ResxScannerAdapter = ResxScannerAdapter;
|
|
80
|
-
//# sourceMappingURL=ResxScannerAdapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResxScannerAdapter.js","sourceRoot":"","sources":["../../../../src/Resources/Scanners/Adapter/ResxScannerAdapter.ts"],"names":[],"mappings":";AAAA,kBAAkB;;;AAIlB,oEAAwG;AACxG,oEAAiE;AACjE,uEAAoE;AAEpE,aAAa;AAEb;;;;GAIG;AACH,MAAa,kBAAkB;IAE3B,iBAAiB;IAEA,WAAW,CAAc;IACzB,OAAO,CAAU;IACjB,KAAK,CAAS;IAE/B,aAAa;IAEb,eAAe;IAEf;;;;OAIG;IACH,YAAmB,UAAuB,EAAE,MAAe;QAC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O,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YAC7C,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;YAC7C,IAAI,EAAE,IAAI,CAAC,IAAI;SAClB,CAAC,CAAC,CAAC;IACR,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,IAAY;QAC/B,IAAI,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,WAAW,EAAE,CAAC;YAC3D,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,gBAAI,EAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,gBAAI,EAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC9D,CAAC;QAED,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,YAAY,IAAA,gBAAI,EAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;QACtF,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAA,gBAAI,EAAC,IAAI,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACvF,CAAC;IACL,CAAC;CAIJ;AAtFD,gDAsFC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { IResourceInfo } from '../Models/Interfaces/IResourceInfo';
|
|
2
|
-
import { ResourceMode } from '../ResourceMode';
|
|
3
|
-
import { type IFileSystem, type ILogger } from '@breadstone-infrastructure/utilities';
|
|
4
|
-
/**
|
|
5
|
-
* The `ResourceReader` class is responsible for processing resources.
|
|
6
|
-
* It can be resolves json or resx files.
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export declare class ResourceReader {
|
|
11
|
-
private readonly _fileSystem;
|
|
12
|
-
private readonly _logger;
|
|
13
|
-
private readonly _adapters;
|
|
14
|
-
/**
|
|
15
|
-
* Creates a new instance of `ResourceReader`.
|
|
16
|
-
*
|
|
17
|
-
* @public
|
|
18
|
-
* @param logger - The logger interface.
|
|
19
|
-
* @param fileSystem - The file system interface.
|
|
20
|
-
*/
|
|
21
|
-
constructor(logger: ILogger, fileSystem: IFileSystem);
|
|
22
|
-
/**
|
|
23
|
-
* Scans a directory for resources of the given type.
|
|
24
|
-
*
|
|
25
|
-
* @public
|
|
26
|
-
* @param path - The path to scan.
|
|
27
|
-
* @param type - The type of resource to scan for.
|
|
28
|
-
* @returns An array of resource information found in the directory.
|
|
29
|
-
*/
|
|
30
|
-
scanDirectory(path: string, type: ResourceMode): Array<IResourceInfo>;
|
|
31
|
-
/**
|
|
32
|
-
* Scans a specific file for resources of the given type.
|
|
33
|
-
*
|
|
34
|
-
* @public
|
|
35
|
-
* @param path - The path to the file to scan.
|
|
36
|
-
* @param type - The type of resource to scan for.
|
|
37
|
-
* @returns The resource information or null if the file is not a valid resource.
|
|
38
|
-
*/
|
|
39
|
-
scanFile(path: string, type: ResourceMode): IResourceInfo | null;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=ResourceReader.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceReader.d.ts","sourceRoot":"","sources":["../../../src/Resources/Scanners/ResourceReader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAQ,KAAK,WAAW,EAAE,KAAK,OAAO,EAAsB,MAAM,sCAAsC,CAAC;AAIhH;;;;;GAKG;AACH,qBAAa,cAAc;IAIvB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4C;IAMtE;;;;;;OAMG;gBACgB,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW;IAY3D;;;;;;;OAOG;IACI,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,KAAK,CAAC,aAAa,CAAC;IAgB5E;;;;;;;OAOG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,aAAa,GAAG,IAAI;CAkB1E"}
|