@fgv/ts-extras 5.0.0-3 → 5.0.0-30
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.json +0 -15
- package/dist/ts-extras.d.ts +11 -4
- package/dist/tsdoc-metadata.json +1 -1
- package/eslint.config.js +16 -0
- package/lib/packlets/csv/csvHelpers.js +0 -1
- package/lib/packlets/record-jar/recordJarHelpers.js +0 -1
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts +11 -4
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js +58 -41
- package/package.json +21 -22
- package/CHANGELOG.md +0 -98
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/packlets/conversion/converters.d.ts.map +0 -1
- package/lib/packlets/conversion/converters.js.map +0 -1
- package/lib/packlets/conversion/index.d.ts.map +0 -1
- package/lib/packlets/conversion/index.js.map +0 -1
- package/lib/packlets/csv/csvHelpers.d.ts.map +0 -1
- package/lib/packlets/csv/csvHelpers.js.map +0 -1
- package/lib/packlets/csv/index.d.ts.map +0 -1
- package/lib/packlets/csv/index.js.map +0 -1
- package/lib/packlets/experimental/extendedArray.d.ts.map +0 -1
- package/lib/packlets/experimental/extendedArray.js.map +0 -1
- package/lib/packlets/experimental/formatter.d.ts.map +0 -1
- package/lib/packlets/experimental/formatter.js.map +0 -1
- package/lib/packlets/experimental/index.d.ts.map +0 -1
- package/lib/packlets/experimental/index.js.map +0 -1
- package/lib/packlets/experimental/rangeOf.d.ts.map +0 -1
- package/lib/packlets/experimental/rangeOf.js.map +0 -1
- package/lib/packlets/hash/index.d.ts.map +0 -1
- package/lib/packlets/hash/index.js.map +0 -1
- package/lib/packlets/hash/md5Normalizer.d.ts.map +0 -1
- package/lib/packlets/hash/md5Normalizer.js.map +0 -1
- package/lib/packlets/record-jar/index.d.ts.map +0 -1
- package/lib/packlets/record-jar/index.js.map +0 -1
- package/lib/packlets/record-jar/recordJarHelpers.d.ts.map +0 -1
- package/lib/packlets/record-jar/recordJarHelpers.js.map +0 -1
- package/lib/packlets/zip-file-tree/index.d.ts.map +0 -1
- package/lib/packlets/zip-file-tree/index.js.map +0 -1
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts.map +0 -1
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js.map +0 -1
package/CHANGELOG.json
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-extras",
|
|
3
3
|
"entries": [
|
|
4
|
-
{
|
|
5
|
-
"version": "5.0.0",
|
|
6
|
-
"tag": "@fgv/ts-extras_v5.0.0",
|
|
7
|
-
"date": "Thu, 17 Jul 2025 00:13:24 GMT",
|
|
8
|
-
"comments": {
|
|
9
|
-
"none": [
|
|
10
|
-
{
|
|
11
|
-
"comment": "upgrade dependencies"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"comment": "bump version"
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
4
|
{
|
|
20
5
|
"version": "4.6.0",
|
|
21
6
|
"tag": "@fgv/ts-extras_v4.6.0",
|
package/dist/ts-extras.d.ts
CHANGED
|
@@ -523,9 +523,9 @@ export { ZipFileTree }
|
|
|
523
523
|
*/
|
|
524
524
|
declare class ZipFileTreeAccessors implements FileTree.IFileTreeAccessors {
|
|
525
525
|
/**
|
|
526
|
-
* The
|
|
526
|
+
* The unzipped file data.
|
|
527
527
|
*/
|
|
528
|
-
private readonly
|
|
528
|
+
private readonly _files;
|
|
529
529
|
/**
|
|
530
530
|
* Optional prefix to prepend to paths.
|
|
531
531
|
*/
|
|
@@ -536,17 +536,24 @@ declare class ZipFileTreeAccessors implements FileTree.IFileTreeAccessors {
|
|
|
536
536
|
private readonly _itemCache;
|
|
537
537
|
/**
|
|
538
538
|
* Constructor for ZipFileTreeAccessors.
|
|
539
|
-
* @param
|
|
539
|
+
* @param files - The unzipped file data from fflate.
|
|
540
540
|
* @param prefix - Optional prefix to prepend to paths.
|
|
541
541
|
*/
|
|
542
542
|
private constructor();
|
|
543
543
|
/**
|
|
544
|
-
* Creates a new ZipFileTreeAccessors instance from a ZIP file buffer.
|
|
544
|
+
* Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous).
|
|
545
545
|
* @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.
|
|
546
546
|
* @param prefix - Optional prefix to prepend to paths.
|
|
547
547
|
* @returns Result containing the ZipFileTreeAccessors instance.
|
|
548
548
|
*/
|
|
549
549
|
static fromBuffer(zipBuffer: ArrayBuffer | Uint8Array, prefix?: string): Result<ZipFileTreeAccessors>;
|
|
550
|
+
/**
|
|
551
|
+
* Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous).
|
|
552
|
+
* @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.
|
|
553
|
+
* @param prefix - Optional prefix to prepend to paths.
|
|
554
|
+
* @returns Promise containing Result with the ZipFileTreeAccessors instance.
|
|
555
|
+
*/
|
|
556
|
+
static fromBufferAsync(zipBuffer: ArrayBuffer | Uint8Array, prefix?: string): Promise<Result<ZipFileTreeAccessors>>;
|
|
550
557
|
/**
|
|
551
558
|
* Creates a new ZipFileTreeAccessors instance from a File object (browser environment).
|
|
552
559
|
* @param file - The File object containing ZIP data.
|
package/dist/tsdoc-metadata.json
CHANGED
package/eslint.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// ESLint 9 flat config
|
|
2
|
+
const nodeProfile = require('@rushstack/eslint-config/flat/profile/node');
|
|
3
|
+
const packletsPlugin = require('@rushstack/eslint-config/flat/mixins/packlets');
|
|
4
|
+
const tsdocPlugin = require('@rushstack/eslint-config/flat/mixins/tsdoc');
|
|
5
|
+
|
|
6
|
+
module.exports = [
|
|
7
|
+
...nodeProfile,
|
|
8
|
+
packletsPlugin,
|
|
9
|
+
...tsdocPlugin,
|
|
10
|
+
{
|
|
11
|
+
// Override specific rules if needed
|
|
12
|
+
rules: {
|
|
13
|
+
'@rushstack/packlets/mechanics': 'warn'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
];
|
|
@@ -71,7 +71,6 @@ function readCsvFileSync(srcPath, options) {
|
|
|
71
71
|
const fullPath = path.resolve(srcPath);
|
|
72
72
|
const body = fs.readFileSync(fullPath, 'utf8').toString();
|
|
73
73
|
options = options !== null && options !== void 0 ? options : {};
|
|
74
|
-
// eslint-disable-next-line
|
|
75
74
|
return (0, papaparse_1.parse)(body, Object.assign({ transform: (s) => s.trim(), header: false, dynamicTyping: false, skipEmptyLines: 'greedy' }, options)).data.slice(1);
|
|
76
75
|
});
|
|
77
76
|
}
|
|
@@ -60,7 +60,6 @@ const fs = __importStar(require("fs"));
|
|
|
60
60
|
const path = __importStar(require("path"));
|
|
61
61
|
const ts_utils_1 = require("@fgv/ts-utils");
|
|
62
62
|
class RecordParser {
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
64
63
|
constructor(options) {
|
|
65
64
|
this.records = [];
|
|
66
65
|
this._fields = {};
|
|
@@ -87,9 +87,9 @@ export declare class ZipDirectoryItem implements FileTree.IFileTreeDirectoryItem
|
|
|
87
87
|
*/
|
|
88
88
|
export declare class ZipFileTreeAccessors implements FileTree.IFileTreeAccessors {
|
|
89
89
|
/**
|
|
90
|
-
* The
|
|
90
|
+
* The unzipped file data.
|
|
91
91
|
*/
|
|
92
|
-
private readonly
|
|
92
|
+
private readonly _files;
|
|
93
93
|
/**
|
|
94
94
|
* Optional prefix to prepend to paths.
|
|
95
95
|
*/
|
|
@@ -100,17 +100,24 @@ export declare class ZipFileTreeAccessors implements FileTree.IFileTreeAccessors
|
|
|
100
100
|
private readonly _itemCache;
|
|
101
101
|
/**
|
|
102
102
|
* Constructor for ZipFileTreeAccessors.
|
|
103
|
-
* @param
|
|
103
|
+
* @param files - The unzipped file data from fflate.
|
|
104
104
|
* @param prefix - Optional prefix to prepend to paths.
|
|
105
105
|
*/
|
|
106
106
|
private constructor();
|
|
107
107
|
/**
|
|
108
|
-
* Creates a new ZipFileTreeAccessors instance from a ZIP file buffer.
|
|
108
|
+
* Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous).
|
|
109
109
|
* @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.
|
|
110
110
|
* @param prefix - Optional prefix to prepend to paths.
|
|
111
111
|
* @returns Result containing the ZipFileTreeAccessors instance.
|
|
112
112
|
*/
|
|
113
113
|
static fromBuffer(zipBuffer: ArrayBuffer | Uint8Array, prefix?: string): Result<ZipFileTreeAccessors>;
|
|
114
|
+
/**
|
|
115
|
+
* Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous).
|
|
116
|
+
* @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.
|
|
117
|
+
* @param prefix - Optional prefix to prepend to paths.
|
|
118
|
+
* @returns Promise containing Result with the ZipFileTreeAccessors instance.
|
|
119
|
+
*/
|
|
120
|
+
static fromBufferAsync(zipBuffer: ArrayBuffer | Uint8Array, prefix?: string): Promise<Result<ZipFileTreeAccessors>>;
|
|
114
121
|
/**
|
|
115
122
|
* Creates a new ZipFileTreeAccessors instance from a File object (browser environment).
|
|
116
123
|
* @param file - The File object containing ZIP data.
|
|
@@ -20,12 +20,9 @@
|
|
|
20
20
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
* SOFTWARE.
|
|
22
22
|
*/
|
|
23
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
-
};
|
|
26
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
24
|
exports.ZipFileTreeAccessors = exports.ZipDirectoryItem = exports.ZipFileItem = void 0;
|
|
28
|
-
const
|
|
25
|
+
const fflate_1 = require("fflate");
|
|
29
26
|
const ts_utils_1 = require("@fgv/ts-utils");
|
|
30
27
|
/**
|
|
31
28
|
* Implementation of `FileTree.IFileTreeFileItem` for files in a ZIP archive.
|
|
@@ -56,12 +53,7 @@ class ZipFileItem {
|
|
|
56
53
|
return (0, ts_utils_1.captureResult)(() => {
|
|
57
54
|
const parsed = JSON.parse(contents);
|
|
58
55
|
if (converter) {
|
|
59
|
-
|
|
60
|
-
return converter.convert(parsed);
|
|
61
|
-
} /* c8 ignore next 3 - validator branch functionally tested but coverage tool misses due to interface complexity */
|
|
62
|
-
else {
|
|
63
|
-
return converter.validate(parsed);
|
|
64
|
-
}
|
|
56
|
+
return converter.convert(parsed);
|
|
65
57
|
}
|
|
66
58
|
return (0, ts_utils_1.succeed)(parsed);
|
|
67
59
|
}).onFailure(() => {
|
|
@@ -114,35 +106,62 @@ exports.ZipDirectoryItem = ZipDirectoryItem;
|
|
|
114
106
|
class ZipFileTreeAccessors {
|
|
115
107
|
/**
|
|
116
108
|
* Constructor for ZipFileTreeAccessors.
|
|
117
|
-
* @param
|
|
109
|
+
* @param files - The unzipped file data from fflate.
|
|
118
110
|
* @param prefix - Optional prefix to prepend to paths.
|
|
119
111
|
*/
|
|
120
|
-
constructor(
|
|
112
|
+
constructor(files, prefix) {
|
|
121
113
|
/**
|
|
122
114
|
* Cache of all items in the ZIP for efficient lookups.
|
|
123
115
|
*/
|
|
124
116
|
this._itemCache = new Map();
|
|
125
|
-
this.
|
|
117
|
+
this._files = files;
|
|
126
118
|
this._prefix = prefix || '';
|
|
127
119
|
this._buildItemCache();
|
|
128
120
|
}
|
|
129
121
|
/**
|
|
130
|
-
* Creates a new ZipFileTreeAccessors instance from a ZIP file buffer.
|
|
122
|
+
* Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous).
|
|
131
123
|
* @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.
|
|
132
124
|
* @param prefix - Optional prefix to prepend to paths.
|
|
133
125
|
* @returns Result containing the ZipFileTreeAccessors instance.
|
|
134
126
|
*/
|
|
135
127
|
static fromBuffer(zipBuffer, prefix) {
|
|
136
128
|
try {
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
129
|
+
/* c8 ignore next 1 - defense in depth */
|
|
130
|
+
const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);
|
|
131
|
+
const files = (0, fflate_1.unzipSync)(uint8Buffer);
|
|
132
|
+
return (0, ts_utils_1.succeed)(new ZipFileTreeAccessors(files, prefix));
|
|
140
133
|
}
|
|
141
134
|
catch (error) {
|
|
142
|
-
/* c8 ignore next 1 - defensive coding:
|
|
135
|
+
/* c8 ignore next 1 - defensive coding: fflate always throws Error objects in practice */
|
|
143
136
|
return (0, ts_utils_1.fail)(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`);
|
|
144
137
|
}
|
|
145
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous).
|
|
141
|
+
* @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.
|
|
142
|
+
* @param prefix - Optional prefix to prepend to paths.
|
|
143
|
+
* @returns Promise containing Result with the ZipFileTreeAccessors instance.
|
|
144
|
+
*/
|
|
145
|
+
static async fromBufferAsync(zipBuffer, prefix) {
|
|
146
|
+
return new Promise((resolve) => {
|
|
147
|
+
try {
|
|
148
|
+
/* c8 ignore next 1 - defense in depth */
|
|
149
|
+
const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);
|
|
150
|
+
(0, fflate_1.unzip)(uint8Buffer, (err, files) => {
|
|
151
|
+
if (err) {
|
|
152
|
+
resolve((0, ts_utils_1.fail)(`Failed to load ZIP archive: ${err.message}`));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
resolve((0, ts_utils_1.succeed)(new ZipFileTreeAccessors(files, prefix)));
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
/* c8 ignore next 5 - defensive coding: fflate always throws Error objects in practice */
|
|
161
|
+
resolve((0, ts_utils_1.fail)(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`));
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
146
165
|
/**
|
|
147
166
|
* Creates a new ZipFileTreeAccessors instance from a File object (browser environment).
|
|
148
167
|
* @param file - The File object containing ZIP data.
|
|
@@ -152,7 +171,7 @@ class ZipFileTreeAccessors {
|
|
|
152
171
|
static async fromFile(file, prefix) {
|
|
153
172
|
try {
|
|
154
173
|
const arrayBuffer = await file.arrayBuffer();
|
|
155
|
-
return ZipFileTreeAccessors.
|
|
174
|
+
return await ZipFileTreeAccessors.fromBufferAsync(new Uint8Array(arrayBuffer), prefix);
|
|
156
175
|
}
|
|
157
176
|
catch (error) {
|
|
158
177
|
return (0, ts_utils_1.fail)(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -163,40 +182,38 @@ class ZipFileTreeAccessors {
|
|
|
163
182
|
*/
|
|
164
183
|
_buildItemCache() {
|
|
165
184
|
const directories = new Set();
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const dirPath = pathParts.slice(0, i).join('/');
|
|
185
|
+
// Process all files and collect directory paths
|
|
186
|
+
for (const [relativePath, fileData] of Object.entries(this._files)) {
|
|
187
|
+
// Skip directories in fflate output (they have null data)
|
|
188
|
+
/* c8 ignore next 5 - handles explicit directory entries from external ZIP tools (fflate doesn't create these) */
|
|
189
|
+
if (fileData === null || fileData === undefined) {
|
|
190
|
+
const dirPath = relativePath.replace(/\/$/, '');
|
|
191
|
+
if (dirPath) {
|
|
174
192
|
directories.add(dirPath);
|
|
175
193
|
}
|
|
176
194
|
}
|
|
177
195
|
else {
|
|
178
|
-
//
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
196
|
+
// Extract directory paths from file paths
|
|
197
|
+
const pathParts = relativePath.split('/');
|
|
198
|
+
for (let i = 1; i < pathParts.length; i++) {
|
|
199
|
+
const dirPath = pathParts.slice(0, i).join('/');
|
|
200
|
+
if (dirPath) {
|
|
201
|
+
directories.add(dirPath);
|
|
202
|
+
}
|
|
182
203
|
}
|
|
204
|
+
// Add the file item with its contents
|
|
205
|
+
const absolutePath = this.resolveAbsolutePath(relativePath);
|
|
206
|
+
const contents = new TextDecoder().decode(fileData);
|
|
207
|
+
const item = new ZipFileItem(relativePath, contents, this);
|
|
208
|
+
this._itemCache.set(absolutePath, item);
|
|
183
209
|
}
|
|
184
|
-
}
|
|
210
|
+
}
|
|
185
211
|
// Add directory items to cache
|
|
186
212
|
directories.forEach((dirPath) => {
|
|
187
213
|
const absolutePath = this.resolveAbsolutePath(dirPath);
|
|
188
214
|
const item = new ZipDirectoryItem(dirPath, this);
|
|
189
215
|
this._itemCache.set(absolutePath, item);
|
|
190
216
|
});
|
|
191
|
-
// Add file items to cache
|
|
192
|
-
entries.forEach((entry) => {
|
|
193
|
-
if (!entry.isDirectory) {
|
|
194
|
-
const absolutePath = this.resolveAbsolutePath(entry.entryName);
|
|
195
|
-
const contents = entry.getData().toString('utf8');
|
|
196
|
-
const item = new ZipFileItem(entry.entryName, contents, this);
|
|
197
|
-
this._itemCache.set(absolutePath, item);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
217
|
}
|
|
201
218
|
/**
|
|
202
219
|
* Resolves paths to an absolute path.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-extras",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-30",
|
|
4
4
|
"description": "Assorted Typescript Utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-extras.d.ts",
|
|
@@ -17,46 +17,45 @@
|
|
|
17
17
|
"homepage": "https://github.com/ErikFortune/fgv/tree/main/libraries/ts-extras#ts-utils",
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@jest/expect-utils": "^29.7.0",
|
|
20
|
-
"@microsoft/api-documenter": "^7.26.
|
|
21
|
-
"@microsoft/api-extractor": "^7.
|
|
20
|
+
"@microsoft/api-documenter": "^7.26.31",
|
|
21
|
+
"@microsoft/api-extractor": "^7.52.10",
|
|
22
22
|
"@types/jest": "^29.5.14",
|
|
23
|
-
"@types/luxon": "^3.
|
|
23
|
+
"@types/luxon": "^3.7.1",
|
|
24
24
|
"@types/mustache": "^4.2.5",
|
|
25
25
|
"@types/node": "^20.14.9",
|
|
26
26
|
"@types/papaparse": "^5.3.14",
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
28
|
-
"@typescript-eslint/parser": "^
|
|
29
|
-
"eslint": "^
|
|
27
|
+
"@typescript-eslint/eslint-plugin": "^8.42.0",
|
|
28
|
+
"@typescript-eslint/parser": "^8.42.0",
|
|
29
|
+
"eslint": "^9.35.0",
|
|
30
30
|
"eslint-plugin-import": "^2.32.0",
|
|
31
31
|
"eslint-plugin-node": "^11.1.0",
|
|
32
|
-
"eslint-plugin-promise": "^
|
|
32
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
33
33
|
"jest": "^29.7.0",
|
|
34
34
|
"jest-extended": "^4.0.2",
|
|
35
35
|
"jest-matcher-utils": "^29.7.0",
|
|
36
|
-
"rimraf": "^
|
|
37
|
-
"ts-jest": "^29.4.
|
|
36
|
+
"rimraf": "^6.0.1",
|
|
37
|
+
"ts-jest": "^29.4.1",
|
|
38
38
|
"ts-node": "^10.9.2",
|
|
39
|
-
"typescript": "
|
|
40
|
-
"eslint-plugin-n": "^
|
|
39
|
+
"typescript": "5.8.3",
|
|
40
|
+
"eslint-plugin-n": "^17.21.3",
|
|
41
41
|
"jest-snapshot": "~29.7.0",
|
|
42
|
-
"@rushstack/heft": "
|
|
43
|
-
"@rushstack/heft-node-rig": "
|
|
44
|
-
"@rushstack/eslint-config": "
|
|
42
|
+
"@rushstack/heft": "0.74.4",
|
|
43
|
+
"@rushstack/heft-node-rig": "2.9.5",
|
|
44
|
+
"@rushstack/eslint-config": "4.4.0",
|
|
45
45
|
"@types/heft-jest": "1.0.6",
|
|
46
|
-
"@rushstack/heft-jest-plugin": "
|
|
46
|
+
"@rushstack/heft-jest-plugin": "0.16.13",
|
|
47
47
|
"eslint-plugin-tsdoc": "~0.4.0",
|
|
48
|
-
"@fgv/ts-utils-jest": "5.0.0-
|
|
49
|
-
"@fgv/ts-utils": "5.0.0-
|
|
48
|
+
"@fgv/ts-utils-jest": "5.0.0-30",
|
|
49
|
+
"@fgv/ts-utils": "5.0.0-30"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"luxon": "^3.
|
|
52
|
+
"luxon": "^3.7.2",
|
|
53
53
|
"mustache": "^4.2.0",
|
|
54
54
|
"papaparse": "^5.4.1",
|
|
55
|
-
"
|
|
56
|
-
"adm-zip": "~0.5.16"
|
|
55
|
+
"fflate": "~0.8.2"
|
|
57
56
|
},
|
|
58
57
|
"peerDependencies": {
|
|
59
|
-
"@fgv/ts-utils": "5.0.0-
|
|
58
|
+
"@fgv/ts-utils": "5.0.0-30"
|
|
60
59
|
},
|
|
61
60
|
"scripts": {
|
|
62
61
|
"build": "heft test --clean",
|
package/CHANGELOG.md
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
# Change Log - @fgv/ts-extras
|
|
2
|
-
|
|
3
|
-
This log was last generated on Thu, 17 Jul 2025 00:13:24 GMT and should not be manually modified.
|
|
4
|
-
|
|
5
|
-
## 5.0.0
|
|
6
|
-
Thu, 17 Jul 2025 00:13:24 GMT
|
|
7
|
-
|
|
8
|
-
### Updates
|
|
9
|
-
|
|
10
|
-
- upgrade dependencies
|
|
11
|
-
- bump version
|
|
12
|
-
|
|
13
|
-
## 4.6.0
|
|
14
|
-
Wed, 02 Jul 2025 05:48:16 GMT
|
|
15
|
-
|
|
16
|
-
_Version update only_
|
|
17
|
-
|
|
18
|
-
## 4.5.1
|
|
19
|
-
Wed, 02 Jul 2025 05:47:11 GMT
|
|
20
|
-
|
|
21
|
-
### Updates
|
|
22
|
-
|
|
23
|
-
- update rushstack
|
|
24
|
-
|
|
25
|
-
## 4.5.0
|
|
26
|
-
Tue, 01 Jul 2025 03:26:11 GMT
|
|
27
|
-
|
|
28
|
-
_Version update only_
|
|
29
|
-
|
|
30
|
-
## 4.4.0
|
|
31
|
-
Sat, 01 Feb 2025 17:13:10 GMT
|
|
32
|
-
|
|
33
|
-
_Version update only_
|
|
34
|
-
|
|
35
|
-
## 4.3.0
|
|
36
|
-
Thu, 30 Jan 2025 00:35:17 GMT
|
|
37
|
-
|
|
38
|
-
_Version update only_
|
|
39
|
-
|
|
40
|
-
## 4.2.2
|
|
41
|
-
Thu, 23 Jan 2025 06:19:32 GMT
|
|
42
|
-
|
|
43
|
-
_Version update only_
|
|
44
|
-
|
|
45
|
-
## 4.2.1
|
|
46
|
-
Tue, 21 Jan 2025 04:19:21 GMT
|
|
47
|
-
|
|
48
|
-
_Version update only_
|
|
49
|
-
|
|
50
|
-
## 4.2.0
|
|
51
|
-
Mon, 20 Jan 2025 09:46:53 GMT
|
|
52
|
-
|
|
53
|
-
_Version update only_
|
|
54
|
-
|
|
55
|
-
## 4.1.0
|
|
56
|
-
Thu, 09 Jan 2025 05:33:39 GMT
|
|
57
|
-
|
|
58
|
-
### Updates
|
|
59
|
-
|
|
60
|
-
- update dependencies
|
|
61
|
-
|
|
62
|
-
## 4.0.2
|
|
63
|
-
Tue, 14 May 2024 14:45:53 GMT
|
|
64
|
-
|
|
65
|
-
_Version update only_
|
|
66
|
-
|
|
67
|
-
## 4.0.1
|
|
68
|
-
Tue, 14 May 2024 05:02:20 GMT
|
|
69
|
-
|
|
70
|
-
### Updates
|
|
71
|
-
|
|
72
|
-
- publish
|
|
73
|
-
|
|
74
|
-
## 4.0.0
|
|
75
|
-
Tue, 14 May 2024 03:09:27 GMT
|
|
76
|
-
|
|
77
|
-
### Updates
|
|
78
|
-
|
|
79
|
-
- move templateString, rangeOf and isoDate converters from ts-utils
|
|
80
|
-
- update generated api docs
|
|
81
|
-
|
|
82
|
-
## 3.0.0
|
|
83
|
-
Mon, 22 Jan 2024 07:00:18 GMT
|
|
84
|
-
|
|
85
|
-
### Updates
|
|
86
|
-
|
|
87
|
-
- refactor hash implementation
|
|
88
|
-
- refactor and cleanup
|
|
89
|
-
- Factor extras into their own package
|
|
90
|
-
|
|
91
|
-
## 2.2.0
|
|
92
|
-
Thu, 18 Jan 2024 05:45:04 GMT
|
|
93
|
-
|
|
94
|
-
### Updates
|
|
95
|
-
|
|
96
|
-
- refactor and cleanup
|
|
97
|
-
- Factor extras into their own package
|
|
98
|
-
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,WAAW,MAAM,0BAA0B,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC"}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AAQjB,kBAAG;AAPxB,sEAAwD;AAO9B,oCAAY;AANtC,sDAAwC;AAMA,oBAAI;AAL5C,iEAAmD;AAKL,8BAAS;AAJvD,sEAAwD;AAIC,kCAAW;AAFpE,sDAAmD;AAE1C,2FAFA,uBAAU,OAEA","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Csv from './packlets/csv';\nimport * as Experimental from './packlets/experimental';\nimport * as Hash from './packlets/hash';\nimport * as RecordJar from './packlets/record-jar';\nimport * as ZipFileTree from './packlets/zip-file-tree';\n\nimport { Converters } from './packlets/conversion';\n\nexport { Converters, Csv, Experimental, Hash, RecordJar, ZipFileTree };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"converters.d.ts","sourceRoot":"","sources":["../../../src/packlets/conversion/converters.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAc,MAAM,EAAgC,MAAM,eAAe,CAAC;AAGxG,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,iBAAiB,EAAE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ereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Conversion, Converter, Converters, Result, captureResult, fail, succeed } from '@fgv/ts-utils';\nimport { DateTime } from 'luxon';\nimport Mustache from 'mustache';\nimport { ExtendedArray, RangeOf, RangeOfProperties } from '../experimental';\n\n/**\n * Helper function to create a `StringConverter` which converts\n * `unknown` to `string`, applying template conversions supplied at construction time or at\n * runtime as context.\n * @remarks\n * Template conversions are applied using `mustache` syntax.\n * @param defaultContext - Optional default context to use for template values.\n * @returns A new `Converter` returning `string`.\n * @public\n */\nexport function templateString(defaultContext?: unknown): Conversion.StringConverter<string, unknown> {\n return new Conversion.StringConverter<string, unknown>(\n defaultContext,\n undefined,\n (from: unknown, __self: Converter<string, unknown>, context?: unknown) => {\n if (typeof from !== 'string') {\n return fail(`Not a string: ${JSON.stringify(from)}`);\n }\n return captureResult(() => Mustache.render(from, context));\n }\n );\n}\n\n/**\n * A `Converter` which converts an iso formatted string, a number or a `Date` object to\n * a `Date` object.\n * @public\n */\nexport const isoDate: Converter<Date, unknown> = new Conversion.BaseConverter<Date>((from: unknown) => {\n if (typeof from === 'string') {\n const dt = DateTime.fromISO(from);\n if (dt.isValid) {\n return succeed(dt.toJSDate());\n }\n return fail(`Invalid date: ${dt.invalidExplanation}`);\n } else if (typeof from === 'number') {\n return succeed(new Date(from));\n } else if (from instanceof Date) {\n return succeed(from);\n }\n return fail(`Cannot convert ${JSON.stringify(from)} to Date`);\n});\n\n/**\n * A helper function to create a `Converter` which converts `unknown` to {@link Experimental.ExtendedArray | ExtendedArray<T>}.\n * @remarks\n * If `onError` is `'failOnError'` (default), then the entire conversion fails if any element cannot\n * be converted. If `onError` is `'ignoreErrors'`, then failing elements are silently ignored.\n * @param converter - `Converter` used to convert each item in the array\n * @param ignoreErrors - Specifies treatment of unconvertible elements\n * @beta\n */\nexport function extendedArrayOf<T, TC = undefined>(\n label: string,\n converter: Converter<T, TC>,\n onError: Conversion.OnError = 'failOnError'\n): Converter<ExtendedArray<T>, TC> {\n return Converters.arrayOf(converter, onError).map((items: T[]) => {\n return captureResult(() => new ExtendedArray(label, ...items));\n });\n}\n\n/**\n * A helper wrapper to construct a `Converter` which converts to an arbitrary strongly-typed\n * range of some comparable type.\n * @param converter - `Converter` used to convert `min` and `max` extent of the range.\n * @param constructor - Static constructor to instantiate the object.\n * @public\n */\nexport function rangeTypeOf<T, RT extends RangeOf<T>, TC = unknown>(\n converter: Converter<T, TC>,\n constructor: (init: RangeOfProperties<T>) => Result<RT>\n): Converter<RT, TC> {\n return new Conversion.BaseConverter((from: unknown, __self, context?: TC) => {\n const result = Converters.object(\n {\n min: converter,\n max: converter\n },\n { optionalFields: ['min', 'max'] }\n ).convert(from, context);\n if (result.isSuccess()) {\n return constructor({ min: result.value.min, max: result.value.max });\n }\n return fail(result.message);\n });\n}\n\n/**\n * A helper wrapper to construct a `Converter` which converts to {@link Experimental.RangeOf | RangeOf<T>}\n * where `<T>` is some comparable type.\n * @param converter - `Converter` used to convert `min` and `max` extent of the range.\n * @public\n */\nexport function rangeOf<T, TC = unknown>(converter: Converter<T, TC>): Converter<RangeOf<T>, TC> {\n return rangeTypeOf<T, RangeOf<T>, TC>(converter, RangeOf.createRange);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/conversion/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/conversion/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yDAA2C;AAElC,gCAAU","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Converters from './converters';\n\nexport { Converters };\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"csvHelpers.d.ts","sourceRoot":"","sources":["../../../src/packlets/csv/csvHelpers.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAKtD;;;GAGG;AAEH,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CActF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"csvHelpers.js","sourceRoot":"","sources":["../../../src/packlets/csv/csvHelpers.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBH,0CAcC;AAnCD,4CAAsD;AACtD,uCAAyB;AACzB,yCAAkC;AAClC,2CAA6B;AAW7B;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,OAAe,EAAE,OAAoB;IACnE,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC1D,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;QACxB,2BAA2B;QAC3B,OAAO,IAAA,iBAAK,EAAC,IAAI,kBACf,SAAS,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,EAClC,MAAM,EAAE,KAAK,EACb,aAAa,EAAE,KAAK,EACpB,cAAc,EAAE,QAAQ,IACrB,OAAO,EACV,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult } from '@fgv/ts-utils';\nimport * as fs from 'fs';\nimport { parse } from 'papaparse';\nimport * as path from 'path';\n\n/**\n * Options for {@link Csv.readCsvFileSync | readCsvFileSync}\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface CsvOptions {\n delimiter?: string;\n}\n\n/**\n * Reads a CSV file from a supplied path.\n * @param srcPath - Source path from which the file is read.\n * @param options - optional parameters to control the processing\n * @returns The contents of the file.\n * @beta\n */\nexport function readCsvFileSync(srcPath: string, options?: CsvOptions): Result<unknown> {\n return captureResult(() => {\n const fullPath = path.resolve(srcPath);\n const body = fs.readFileSync(fullPath, 'utf8').toString();\n options = options ?? {};\n // eslint-disable-next-line\n return parse(body, {\n transform: (s: string) => s.trim(),\n header: false,\n dynamicTyping: false,\n skipEmptyLines: 'greedy',\n ...options\n }).data.slice(1);\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/csv/index.ts"],"names":[],"mappings":"AAsBA,cAAc,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/csv/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,+CAA6B","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './csvHelpers';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extendedArray.d.ts","sourceRoot":"","sources":["../../../src/packlets/experimental/extendedArray.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEtD;;;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to any person obtaining a copy\r\n * of this software and associated documentation files (the \"Software\"), to deal\r\n * in the Software without restriction, including without limitation the rights\r\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n * copies of the Software, and to permit persons to whom the Software is\r\n * furnished to do so, subject to the following conditions:\r\n *\r\n * The above copyright notice and this permission notice shall be included in all\r\n * copies or substantial portions of the Software.\r\n *\r\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n * SOFTWARE.\r\n */\r\n\r\nimport { Result, fail, succeed } from '@fgv/ts-utils';\r\n\r\n/**\r\n * An experimental array template which extend built-in `Array` to include a handful\r\n * of predicates which return `Result<T>`.\r\n * @beta\r\n */\r\nexport class ExtendedArray<T> extends Array<T> {\r\n public readonly itemDescription: string;\r\n\r\n /**\r\n * Constructs an {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * @param itemDescription - Brief description of the type of each item in this array.\r\n * @param items - The initial contents of the array.\r\n */\r\n public constructor(itemDescription: string, ...items: T[]) {\r\n super(...items);\r\n this.itemDescription = itemDescription;\r\n }\r\n\r\n /**\r\n * Type guard to determine if some arbitrary array is an\r\n * {@link Experimental.ExtendedArray}\r\n * @param a - The `Array` to be tested.\r\n * @returns Returns `true` if `a` is an {@link Experimental.ExtendedArray | ExtendedArray},\r\n * `false` otherwise.\r\n */\r\n public static isExtendedArray<T>(a?: T[]): a is ExtendedArray<T> {\r\n return a instanceof ExtendedArray;\r\n }\r\n\r\n /**\r\n * Determines if this array contains exactly one element which matches\r\n * a supplied predicate.\r\n * @param predicate - The predicate function to be applied.\r\n * @returns Returns `Success<T>` with the single matching\r\n * result if exactly one item matches `predicate`. Returns `Failure<T>`\r\n * with an error message if there are no matches or more than one match.\r\n */\r\n public single(predicate?: (item: T) => boolean): Result<T> {\r\n const match = predicate ? this.filter(predicate) : this;\r\n if (match.length === 1) {\r\n return succeed(match[0]);\r\n }\r\n if (match.length === 0) {\r\n return fail(`${this.itemDescription} not found`);\r\n }\r\n return fail(`${this.itemDescription} matches ${match.length} items`);\r\n }\r\n\r\n /**\r\n * Returns the first element of an {@link Experimental.ExtendedArray | ExtendedArray}. Fails with an\r\n * error message if the array is empty.\r\n * @param failMessage - Optional message to be displayed in the event of failure.\r\n * @returns Returns `Success<T>` with the value of the first element\r\n * in the array, or `Failure<T>` with an error message if the array is empty.\r\n */\r\n public first(failMessage?: string): Result<T> {\r\n if (this.length > 0) {\r\n return succeed(this[0]);\r\n }\r\n return fail(failMessage ?? `${this.itemDescription} not found`);\r\n }\r\n\r\n /**\r\n * Returns an array containing all elements of an {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * Fails with an error message if the array is empty.\r\n * @param failMessage - Optional message to be displayed in the event of failure.\r\n * @returns Returns `Success<T>` with a new (non-extended) `Array`\r\n * containing the elements of this array, or `Failure<T>` with an error message\r\n * if the array is empty.\r\n */\r\n public atLeastOne(failMessage?: string): Result<T[]> {\r\n if (this.length > 0) {\r\n return succeed(Array.from(this));\r\n }\r\n return fail(failMessage ?? `${this.itemDescription} not found`);\r\n }\r\n\r\n /**\r\n * Gets a new (non-extended) `Array` containing all of the elements from this\r\n * {@link Experimental.ExtendedArray | ExtendedArray}.\r\n * @returns A new (non-extended) `Array<T>`.\r\n */\r\n public all(): T[] {\r\n return Array.from(this);\r\n }\r\n}\r\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"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Content":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult, mapResults, succeed } from '@fgv/ts-utils';\nimport Mustache from 'mustache';\n\nMustache.escape = (s: string) => s;\n\n/**\n * Destination format for some formatted string.\n * @beta\n */\nexport type FormatTargets = 'text' | 'markdown' | 'embed';\n\n/**\n * Interface for an object that can be formatted.\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface Formattable {\n /**\n * Formats an object using the supplied mustache template.\n * @param format - A mustache template used to format the object.\n * @returns `Success<string>` with the resulting string, or `Failure<string>`\n * with an error message if an error occurs.\n */\n format(format: string): Result<string>;\n}\n\n/**\n * Base class which adds common formatting.\n * @beta\n */\nexport class FormattableBase {\n /**\n * Helper enables derived classes to add named details to a formatted presentation.\n * @param details - An array of detail description strings.\n * @param label - Label to use for the new detail.\n * @param value - Value to use for the new detail.\n * @internal\n */\n protected static _tryAddDetail(details: string[], label: string, value: string | undefined): void {\n if (value !== undefined) {\n const padded = ` ${label}:`.padEnd(20, ' ');\n details.push(`${padded} ${value}`);\n }\n }\n\n /**\n * {@inheritdoc Experimental.Formattable.format}\n */\n public format(template: string): Result<string> {\n return captureResult(() => Mustache.render(template, this));\n }\n}\n\n/**\n * Type definition for a formatting function, which takes a `string` and an\n * item and returns `Result<string>`.\n * @beta\n */\nexport type Formatter<T> = (format: string, item: T) => Result<string>;\n\n/**\n * A collection of {@link Experimental.Formatter | formatters} indexed by target name, to enable\n * different format methods per output target.\n * @beta\n */\nexport type FormattersByExtendedTarget<TFT extends FormatTargets, T> = Record<TFT, Formatter<T>>;\n/**\n * A collection of {@link Experimental.Formatter | formatters} indexed by the\n * {@link Experimental.FormatTargets | default supported target formats}.\n * @beta\n */\nexport type FormattersByTarget<T> = FormattersByExtendedTarget<FormatTargets, T>;\n\n/**\n * Formats a list of items using the supplied template and formatter, one result\n * per output line.\n * @param format - A mustache template used to format each item.\n * @param items - The items to be formatted.\n * @param itemFormatter - The {@link Experimental.Formatter | Formatter<T>} used to format each item.\n * @returns The resulting string.\n * @beta\n */\nexport function formatList<T>(format: string, items: T[], itemFormatter: Formatter<T>): Result<string> {\n return mapResults(\n items.map((item) => {\n return itemFormatter(format, item);\n })\n ).onSuccess((results: string[]) => {\n const filtered = results.filter((s) => s !== '');\n return succeed(filtered.join('\\n'));\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/experimental/index.ts"],"names":[],"mappings":"AAsBA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/experimental/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kDAAgC;AAChC,8CAA4B;AAC5B,4CAA0B","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './extendedArray';\nexport * from './formatter';\nexport * from './rangeOf';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rangeOf.d.ts","sourceRoot":"","sources":["../../../src/packlets/experimental/rangeOf.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAGtD;;;GAGG;AAEH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;CAClB;AAED;;;;;GAKG;AAEH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,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2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Result, captureResult } from '@fgv/ts-utils';\nimport Mustache from 'mustache';\n\n/**\n * Represents a generic range of some comparable type `<T>`.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface RangeOfProperties<T> {\n readonly min?: T;\n readonly max?: T;\n}\n\n/**\n * Format strings (in mustache format) to\n * use for both open-ended and complete\n * {@link Experimental.RangeOf | RangeOf<T>}.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface RangeOfFormats {\n minOnly: string;\n maxOnly: string;\n minMax: string;\n}\n\n/**\n * Default {@link Experimental.RangeOfFormats | formats} to use for both\n * open-ended and complete {@link Experimental.RangeOf | RangeOf<T>}.\n * @public\n */\nexport const DEFAULT_RANGEOF_FORMATS: RangeOfFormats = {\n minOnly: '{{min}}-',\n maxOnly: '-{{max}}',\n minMax: '{{min}}-{{max}}'\n};\n\n/**\n * Simple implementation of a possibly open-ended range of some comparable\n * type `<T>` with test and formatting.\n * @public\n */\nexport class RangeOf<T> implements RangeOfProperties<T> {\n /**\n * Minimum extent of the range.\n */\n public readonly min?: T;\n /**\n * Maximum extent of the range.\n */\n public readonly max?: T;\n\n /**\n * Creates a new {@link Experimental.RangeOf | RangeOf<T>}.\n * @param min - Optional minimum extent of the range.\n * @param max - Optional maximum extent of the range.\n */\n public constructor(min?: T, max?: T) {\n if (min !== undefined && max !== undefined && this._compare(min, max) === 'greater') {\n throw new Error(`Inverted range - ${JSON.stringify(min)} must be <= ${JSON.stringify(max)}.`);\n }\n this.min = min;\n this.max = max;\n }\n\n /**\n * Static constructor for a {@link Experimental.RangeOf | RangeOf<T>}.\n * @param init - {@link Experimental.RangeOfProperties | Range initializer}.\n * @returns A new {@link Experimental.RangeOf | RangeOf<T>}.\n */\n public static createRange<T>(init?: RangeOfProperties<T>): Result<RangeOf<T>> {\n return captureResult(() => new RangeOf<T>(init?.min, init?.max));\n }\n\n /**\n * Gets a formatted description of a {@link Experimental.RangeOfProperties | RangeOfProperties<T>} given an\n * optional set of formats and 'empty' value to use.\n * @param range - The {@link Experimental.RangeOfProperties | RangeOfProperties<T>} to be formatted.\n * @param formats - Optional {@link Experimental.RangeOfFormats | formats} to use. Default is\n * {@link Experimental.DEFAULT_RANGEOF_FORMATS | DEFAULT_RANGEOF_FORMATS}.\n * @param emptyValue - Value which represents unbounded minimum or maximum for this range. Default is `undefined`.\n * @returns A string representation of the range.\n */\n public static propertiesToString<T>(\n range: RangeOfProperties<T>,\n formats?: RangeOfFormats,\n emptyValue?: T\n ): string | undefined {\n formats = formats ?? DEFAULT_RANGEOF_FORMATS;\n if (range.min !== undefined && range.min !== emptyValue) {\n if (range.max !== undefined && range.max !== emptyValue) {\n return Mustache.render(formats.minMax, range);\n } else {\n return Mustache.render(formats.minOnly, range);\n }\n } else if (range.max !== undefined && range.max !== emptyValue) {\n return Mustache.render(formats.maxOnly, range);\n }\n return undefined;\n }\n\n /**\n * Default comparison uses javascript built-in comparison.\n * @param t1 - First value to be compared.\n * @param t2 - Second value to be compared.\n * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger\n * and `'equal'` if `t1` and `t2` are equal.\n * @internal\n */\n protected static _defaultCompare<T>(t1: T, t2: T): 'less' | 'equal' | 'greater' {\n if (t1 < t2) {\n return 'less';\n } else if (t1 > t2) {\n return 'greater';\n }\n return 'equal';\n }\n\n /**\n * Checks if a supplied value is within this range.\n * @param t - The value to be tested.\n * @returns `'included'` if `t` falls within the range, `'less'` if `t` falls\n * below the minimum extent of the range and `'greater'` if `t` is above the\n * maximum extent.\n */\n public check(t: T): 'less' | 'included' | 'greater' {\n if (this.min !== undefined && this._compare(t, this.min) === 'less') {\n return 'less';\n }\n if (this.max !== undefined && this._compare(t, this.max) !== 'less') {\n return 'greater';\n }\n return 'included';\n }\n\n /**\n * Determines if a supplied value is within this range.\n * @param t - The value to be tested.\n * @returns Returns `true` if `t` falls within the range, `false` otherwise.\n */\n public includes(t: T): boolean {\n return this.check(t) === 'included';\n }\n\n /**\n * Finds the transition value that would bring a supplied value `t` into\n * range.\n * @param t - The value to be tested.\n * @returns The minimum extent of the range if `t` is below the range or\n * the maximum extent of the range if `t` is above the range. Returns\n * `undefined` if `t` already falls within the range.\n */\n public findTransition(t: T): T | undefined {\n switch (this.check(t)) {\n case 'less':\n return this.min;\n case 'included':\n return this.max;\n }\n return undefined;\n }\n\n /**\n * Formats the minimum and maximum values of this range.\n * @param format - A format function used to format the values.\n * @returns A {@link Experimental.RangeOfProperties | RangeOfProperties<string>} containing the\n * formatted representation of the {@link Experimental.RangeOf.min | minimum} and\n * {@link Experimental.RangeOf.max | maximum}\n * extent of the range, or `undefined` for an extent that is not present.\n */\n public toFormattedProperties(format: (value: T) => string | undefined): RangeOfProperties<string> {\n return {\n min: this.min !== undefined ? format(this.min) : undefined,\n max: this.max !== undefined ? format(this.max) : undefined\n };\n }\n\n /**\n * Formats this range using the supplied format function.\n * @param format - Format function used to format minimum and maximum extent values.\n * @param formats - The {@link Experimental.RangeOfFormats | format strings} used to format the range\n * (default {@link Experimental.DEFAULT_RANGEOF_FORMATS}).\n * @returns Returns a formatted representation of this range.\n */\n public format(format: (value: T) => string | undefined, formats?: RangeOfFormats): string | undefined {\n return RangeOf.propertiesToString(this.toFormattedProperties(format), formats);\n }\n\n /**\n * Inner compare method can be overridden by a derived class.\n * @param t1 - First value to compare.\n * @param t2 - Second value to compare.\n * @returns `'less'` if `t1` is less than `t2`, `'greater'` if `t1` is larger\n * and `'equal'` if `t1` and `t2` are equal.\n * @internal\n */\n protected _compare(t1: T, t2: T): 'less' | 'equal' | 'greater' {\n return RangeOf._defaultCompare(t1, t2);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/index.ts"],"names":[],"mappings":"AAsBA,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/hash/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,kDAAgC","sourcesContent":["/*\n * Copyright (c) 2020 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './md5Normalizer';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"md5Normalizer.d.ts","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;;;GAIG;AACH,qBAAa,aAAc,SAAQ,IAAI,CAAC,iBAAiB;;WAKzC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM;CAG/C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"md5Normalizer.js","sourceRoot":"","sources":["../../../src/packlets/hash/md5Normalizer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAqC;AACrC,+CAAiC;AACjC;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAI,CAAC,iBAAiB;IACvD;QACE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,OAAO,CAAC,KAAe;QACnC,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChF,CAAC;CACF;AARD,sCAQC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { Hash } from '@fgv/ts-utils';\nimport * as crypto from 'crypto';\n/**\n * A hashing normalizer which computes object\n * hash using the MD5 algorithm.\n * @public\n */\nexport class Md5Normalizer extends Hash.HashingNormalizer {\n public constructor() {\n super(Md5Normalizer.md5Hash);\n }\n\n public static md5Hash(parts: string[]): string {\n return crypto.createHash('md5').update(parts.join('|'), 'utf8').digest('hex');\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/record-jar/index.ts"],"names":[],"mappings":"AAsBA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/record-jar/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;AAEH,qDAAmC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport * from './recordJarHelpers';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recordJarHelpers.d.ts","sourceRoot":"","sources":["../../../src/packlets/record-jar/recordJarHelpers.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,MAAM,EAAyC,MAAM,eAAe,CAAC;AAO9E;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;AAEzF;;;GAGG;AAEH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC;IACjD,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CACzC;AAoMD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EA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EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CACnC,OAAe,EACf,OAAgC;IAEhC,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;QACrB,OAAO,mBAAmB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/*\n * Copyright (c) 2022 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as fs from 'fs';\nimport * as path from 'path';\n\nimport { Result, captureResult, fail, isKeyOf, succeed } from '@fgv/ts-utils';\n\ninterface IRecordBody {\n body: string;\n isContinuation: boolean;\n}\n\n/**\n * Represents a single record in a JAR file\n * @public\n */\nexport type JarRecord = Record<string, string | string[]>;\n\n/**\n * @public\n */\nexport type JarFieldPicker<T extends JarRecord = JarRecord> = (record: T) => (keyof T)[];\n\n/**\n * Options for a JAR record parser.\n * @public\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport interface JarRecordParserOptions {\n readonly arrayFields?: string[] | JarFieldPicker;\n readonly fixedContinuationSize?: number;\n}\n\nclass RecordParser {\n public readonly records: JarRecord[] = [];\n public readonly options: JarRecordParserOptions;\n\n protected _fields: JarRecord = {};\n protected _name: string | undefined = undefined;\n protected _body: IRecordBody | undefined = undefined;\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n private constructor(options?: JarRecordParserOptions) {\n this.options = options ?? {};\n }\n\n public static parse(lines: string[], options?: JarRecordParserOptions): Result<JarRecord[]> {\n return new RecordParser(options)._parse(lines);\n }\n\n protected static _parseRecordBody(body: string): Result<IRecordBody> {\n const isContinuation = body.endsWith('\\\\');\n if (isContinuation) {\n body = body.slice(0, body.length - 1);\n }\n if (this._hasEscapes(body)) {\n const result = this._replaceEscapes(body);\n if (result.isFailure()) {\n return fail(result.message);\n }\n body = result.value;\n }\n return succeed({ body, isContinuation });\n }\n\n protected static _hasEscapes(from: string): boolean {\n return from.includes('\\\\') || from.includes('&');\n }\n\n protected static _replaceEscapes(body: string): Result<string> {\n const invalid: string[] = [];\n const escaped = body.replace(/(\\\\.)|(&#x[a-fA-F0-9]{2,6};)/g, (match) => {\n switch (match) {\n case '\\\\\\\\':\n return '\\\\';\n case '\\\\&':\n return '&';\n case '\\\\r':\n return '\\r';\n case '\\\\n':\n return '\\n';\n case '\\\\t':\n return '\\t';\n }\n if (match.startsWith('&')) {\n const hexCode = `0x${match.slice(3, match.length - 1)}`;\n const charCode = Number.parseInt(hexCode, 16);\n return String.fromCharCode(charCode);\n }\n invalid.push(match);\n return '\\\\';\n });\n if (invalid.length > 0) {\n return fail(`unrecognized escape \"${invalid.join(', ')}\" in record-jar body`);\n }\n return succeed(escaped);\n }\n\n protected static _applyOptions(record: JarRecord, options: JarRecordParserOptions): JarRecord {\n if (options.arrayFields) {\n record = { ...record }; // don't edit incoming values\n const arrayFields = Array.isArray(options.arrayFields)\n ? options.arrayFields\n : options.arrayFields(record);\n\n for (const field of arrayFields) {\n if (isKeyOf(field, record) && typeof record[field] === 'string') {\n const current = record[field] as string;\n record[field] = [current];\n }\n }\n }\n return record;\n }\n\n protected _parse(lines: string[]): Result<JarRecord[]> {\n for (let n = 0; n < lines.length; n++) {\n const line = lines[n];\n if (line.startsWith('%%') && !this._body?.isContinuation) {\n const result = this._writePendingRecord();\n if (result.isFailure()) {\n return fail(`${n}: ${result.message}`);\n }\n } else if (/^\\s*$/.test(line)) {\n // ignore blank lines but cancel continuation\n if (this._body) {\n this._body.isContinuation = false;\n }\n continue;\n } else if (this._body?.isContinuation || /^\\s+/.test(line)) {\n // explicit continuation on previous line or implicit starts with whitespace\n if (this._body === undefined) {\n return fail(`${n}: continuation (\"${line}\") without prior value.`);\n }\n const result = this._parseContinuation(line);\n if (result.isFailure()) {\n return fail(`${n}: ${result.message}`);\n }\n this._body = result.value;\n } else {\n const result = this._parseField(line);\n if (result.isFailure()) {\n return fail(`${n}: ${result.message}`);\n }\n }\n }\n\n const result = this._writePendingRecord();\n if (result.isFailure()) {\n return fail(`${lines.length}: ${result.message}`);\n }\n return succeed(this.records);\n }\n\n protected _parseField(line: string): Result<boolean> {\n const separatorIndex = line.indexOf(':');\n if (separatorIndex < 1) {\n return fail(`malformed line (\"${line}\") in record-jar.`);\n }\n const parts = [line.slice(0, separatorIndex), line.slice(separatorIndex + 1)];\n\n return this._writePendingField().onSuccess(() => {\n this._name = parts[0].trimEnd();\n return RecordParser._parseRecordBody(parts[1].trim()).onSuccess((body) => {\n this._body = body;\n return succeed(true);\n });\n });\n }\n\n protected _parseContinuation(line: string): Result<IRecordBody> {\n let trimmed = line.trim();\n if (!this._body!.isContinuation) {\n /* c8 ignore next */\n const fixedSize = this.options?.fixedContinuationSize ?? 0;\n if (fixedSize > 0) {\n if (trimmed.length < line.length - fixedSize) {\n // oops, took too much\n trimmed = line.slice(fixedSize);\n }\n }\n }\n return RecordParser._parseRecordBody(trimmed).onSuccess((newBody) => {\n return succeed({\n body: `${this._body!.body}${newBody.body}`,\n isContinuation: newBody.isContinuation\n });\n });\n }\n\n protected _havePendingRecord(): boolean {\n return Object.keys(this._fields).length > 0;\n }\n\n protected _writePendingRecord(): Result<JarRecord | undefined> {\n return this._writePendingField().onSuccess(() => {\n let record = this._havePendingRecord() ? this._fields : undefined;\n if (record !== undefined) {\n record = RecordParser._applyOptions(record, this.options);\n this.records.push(record);\n this._fields = {};\n }\n return succeed(undefined);\n });\n }\n\n protected _writePendingField(): Result<boolean> {\n if (this._name !== undefined) {\n if (this._body!.body.length < 1) {\n return fail('empty body value not allowed');\n }\n if (!isKeyOf(this._name, this._fields)) {\n this._fields[this._name] = this._body!.body;\n } else if (typeof this._fields[this._name] === 'string') {\n const current = this._fields[this._name] as string;\n this._fields[this._name] = [current, this._body!.body];\n } else {\n const current = this._fields[this._name] as string[];\n current.push(this._body!.body);\n }\n this._name = undefined;\n this._body = undefined;\n }\n return succeed(true);\n }\n}\n\n/**\n * Reads a record-jar from an array of strings, each of which represents one\n * line in the source file.\n * @param lines - the array of strings to be parsed\n * @param options - Optional parser configuration\n * @returns a corresponding array of `Record<string, string>`\n * @public\n */\nexport function parseRecordJarLines(lines: string[], options?: JarRecordParserOptions): Result<JarRecord[]> {\n return RecordParser.parse(lines, options);\n}\n\n/**\n * Reads a record-jar file from a supplied path.\n * @param srcPath - Source path from which the file is read.\n * @param options - Optional parser configuration\n * @returns The contents of the file as an array of `Record<string, string>`\n * @see https://datatracker.ietf.org/doc/html/draft-phillips-record-jar-01\n * @public\n */\nexport function readRecordJarFileSync(\n srcPath: string,\n options?: JarRecordParserOptions\n): Result<JarRecord[]> {\n return captureResult(() => {\n const fullPath = path.resolve(srcPath);\n return fs.readFileSync(fullPath, 'utf8').toString().split(/\\r?\\n/);\n }).onSuccess((lines) => {\n return parseRecordJarLines(lines, options);\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/index.ts"],"names":[],"mappings":"AAsBA;;;;;;;;GAQG;AAEH,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH;;;;;;;;GAQG;AAEH,+DAA6F;AAApF,4HAAA,oBAAoB,OAAA;AAAE,mHAAA,WAAW,OAAA;AAAE,wHAAA,gBAAgB,OAAA","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n/**\n * ZIP-based FileTree implementation for ts-extras.\n *\n * This packlet provides a FileTree accessor implementation that can read from ZIP archives,\n * making it useful for browser environments where files need to be bundled and transferred\n * as a single archive.\n *\n * @packageDocumentation\n */\n\nexport { ZipFileTreeAccessors, ZipFileItem, ZipDirectoryItem } from './zipFileTreeAccessors';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zipFileTreeAccessors.d.ts","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/zipFileTreeAccessors.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,MAAM,EAAgC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAErG;;;GAGG;AACH,qBAAa,WAAY,YAAW,QAAQ,CAAC,iBAAiB;IAC5D;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAU;IAEtC;;OAEG;IACH,SAAgB,YAAY,EAAE,MAAM,CAAC;IAErC;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,SAAgB,SAAS,EAAE,MAAM,CAAC;IAElC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAElD;;;;;OAKG;gBACgB,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,oBAAoB;IASzF;;OAEG;IACI,WAAW,IAAI,MAAM,CAAC,OAAO,CAAC;IAC9B,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAuBxE;;OAEG;IACI,cAAc,IAAI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C,UAAU,CAAC,gBAAgB,GAAG,GAAG,CAAC,EAAE,CAAC;YACxD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,6CAA6C;QAC7C,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE5E,gEAAgE;QAChE,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;CACF;AAnND,oDAmNC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport AdmZip from 'adm-zip';\nimport { Result, succeed, fail, captureResult, Converter, Validator, FileTree } from '@fgv/ts-utils';\n\n/**\n * Implementation of `FileTree.IFileTreeFileItem` for files in a ZIP archive.\n * @public\n */\nexport class ZipFileItem implements FileTree.IFileTreeFileItem {\n /**\n * Indicates that this `FileTree.FileTreeItem` is a file.\n */\n public readonly type: 'file' = 'file';\n\n /**\n * The absolute path of the file within the ZIP archive.\n */\n public readonly absolutePath: string;\n\n /**\n * The name of the file\n */\n public readonly name: string;\n\n /**\n * The base name of the file (without extension)\n */\n public readonly baseName: string;\n\n /**\n * The extension of the file\n */\n public readonly extension: string;\n\n /**\n * The pre-loaded contents of the file.\n */\n private readonly _contents: string;\n\n /**\n * The ZIP file tree accessors that created this item.\n */\n private readonly _accessors: ZipFileTreeAccessors;\n\n /**\n * Constructor for ZipFileItem.\n * @param zipFilePath - The path of the file within the ZIP.\n * @param contents - The pre-loaded contents of the file.\n * @param accessors - The ZIP file tree accessors.\n */\n public constructor(zipFilePath: string, contents: string, accessors: ZipFileTreeAccessors) {\n this._contents = contents;\n this._accessors = accessors;\n this.absolutePath = '/' + zipFilePath;\n this.name = accessors.getBaseName(zipFilePath);\n this.extension = accessors.getExtension(zipFilePath);\n this.baseName = accessors.getBaseName(zipFilePath, this.extension);\n }\n\n /**\n * Gets the contents of the file as parsed JSON.\n */\n public getContents(): Result<unknown>;\n public getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;\n public getContents<T>(converter?: Validator<T> | Converter<T>): Result<T | unknown> {\n return this.getRawContents()\n .onSuccess((contents) => {\n return captureResult(() => {\n const parsed = JSON.parse(contents);\n if (converter) {\n if ('convert' in converter) {\n return converter.convert(parsed);\n } /* c8 ignore next 3 - validator branch functionally tested but coverage tool misses due to interface complexity */ else {\n return (converter as Validator<T>).validate(parsed);\n }\n }\n return succeed(parsed);\n }).onFailure(() => {\n return fail(`Failed to parse JSON from file: ${this.absolutePath}`);\n });\n })\n .onFailure((error) => {\n return fail(`Failed to get contents from file: ${error}`);\n });\n }\n\n /**\n * Gets the raw contents of the file as a string.\n */\n public getRawContents(): Result<string> {\n return succeed(this._contents);\n }\n}\n\n/**\n * Implementation of `IFileTreeDirectoryItem` for directories in a ZIP archive.\n * @public\n */\nexport class ZipDirectoryItem implements FileTree.IFileTreeDirectoryItem {\n /**\n * Indicates that this `FileTree.FileTreeItem` is a directory.\n */\n public readonly type: 'directory' = 'directory';\n\n /**\n * The absolute path of the directory within the ZIP archive.\n */\n public readonly absolutePath: string;\n\n /**\n * The name of the directory\n */\n public readonly name: string;\n\n /**\n * The ZIP file tree accessors that created this item.\n */\n private readonly _accessors: ZipFileTreeAccessors;\n\n /**\n * Constructor for ZipDirectoryItem.\n * @param directoryPath - The path of the directory within the ZIP.\n * @param accessors - The ZIP file tree accessors.\n */\n public constructor(directoryPath: string, accessors: ZipFileTreeAccessors) {\n this._accessors = accessors;\n this.absolutePath = '/' + directoryPath.replace(/\\/$/, ''); // Normalize path\n this.name = accessors.getBaseName(directoryPath);\n }\n\n /**\n * Gets the children of the directory.\n */\n public getChildren(): Result<ReadonlyArray<FileTree.FileTreeItem>> {\n return this._accessors.getChildren(this.absolutePath);\n }\n}\n\n/**\n * File tree accessors for ZIP archives.\n * @public\n */\nexport class ZipFileTreeAccessors implements FileTree.IFileTreeAccessors {\n /**\n * The AdmZip instance containing the archive.\n */\n private readonly _zip: AdmZip;\n\n /**\n * Optional prefix to prepend to paths.\n */\n private readonly _prefix: string;\n\n /**\n * Cache of all items in the ZIP for efficient lookups.\n */\n private readonly _itemCache: Map<string, FileTree.FileTreeItem> = new Map();\n\n /**\n * Constructor for ZipFileTreeAccessors.\n * @param zip - The AdmZip instance.\n * @param prefix - Optional prefix to prepend to paths.\n */\n private constructor(zip: AdmZip, prefix?: string) {\n this._zip = zip;\n this._prefix = prefix || '';\n this._buildItemCache();\n }\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer.\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param prefix - Optional prefix to prepend to paths.\n * @returns Result containing the ZipFileTreeAccessors instance.\n */\n public static fromBuffer(\n zipBuffer: ArrayBuffer | Uint8Array,\n prefix?: string\n ): Result<ZipFileTreeAccessors> {\n try {\n const buffer = Buffer.from(zipBuffer);\n const zip = new AdmZip(buffer);\n return succeed(new ZipFileTreeAccessors(zip, prefix));\n } catch (error) {\n /* c8 ignore next 1 - defensive coding: AdmZip always throws Error objects in practice */\n return fail(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a File object (browser environment).\n * @param file - The File object containing ZIP data.\n * @param prefix - Optional prefix to prepend to paths.\n * @returns Result containing the ZipFileTreeAccessors instance.\n */\n public static async fromFile(file: File, prefix?: string): Promise<Result<ZipFileTreeAccessors>> {\n try {\n const arrayBuffer = await file.arrayBuffer();\n return ZipFileTreeAccessors.fromBuffer(new Uint8Array(arrayBuffer), prefix);\n } catch (error) {\n return fail(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Builds the cache of all items in the ZIP archive.\n */\n private _buildItemCache(): void {\n const directories = new Set<string>();\n const entries = this._zip.getEntries();\n\n // First pass: collect all directories from file paths\n entries.forEach((entry) => {\n if (!entry.isDirectory) {\n // Extract directory path from file path\n const pathParts = entry.entryName.split('/');\n for (let i = 1; i < pathParts.length; i++) {\n const dirPath = pathParts.slice(0, i).join('/');\n directories.add(dirPath);\n }\n } else {\n // Also add explicit directories\n const dirPath = entry.entryName.replace(/\\/$/, ''); // Remove trailing slash\n if (dirPath) {\n directories.add(dirPath);\n }\n }\n });\n\n // Add directory items to cache\n directories.forEach((dirPath) => {\n const absolutePath = this.resolveAbsolutePath(dirPath);\n const item = new ZipDirectoryItem(dirPath, this);\n this._itemCache.set(absolutePath, item);\n });\n\n // Add file items to cache\n entries.forEach((entry) => {\n if (!entry.isDirectory) {\n const absolutePath = this.resolveAbsolutePath(entry.entryName);\n const contents = entry.getData().toString('utf8');\n const item = new ZipFileItem(entry.entryName, contents, this);\n this._itemCache.set(absolutePath, item);\n }\n });\n }\n\n /**\n * Resolves paths to an absolute path.\n */\n public resolveAbsolutePath(...paths: string[]): string {\n const joinedPath = this.joinPaths(...paths);\n const prefixed = this._prefix ? this.joinPaths(this._prefix, joinedPath) : joinedPath;\n return prefixed.startsWith('/') ? prefixed : '/' + prefixed;\n }\n\n /**\n * Gets the extension of a path.\n */\n public getExtension(path: string): string {\n const name = this.getBaseName(path);\n const lastDotIndex = name.lastIndexOf('.');\n return lastDotIndex >= 0 ? name.substring(lastDotIndex) : '';\n }\n\n /**\n * Gets the base name of a path.\n */\n public getBaseName(path: string, suffix?: string): string {\n const normalizedPath = path.replace(/\\/$/, ''); // Remove trailing slash\n const parts = normalizedPath.split('/');\n let baseName = parts[parts.length - 1] || '';\n\n if (suffix && baseName.endsWith(suffix)) {\n baseName = baseName.substring(0, baseName.length - suffix.length);\n }\n\n return baseName;\n }\n\n /**\n * Joins paths together.\n */\n public joinPaths(...paths: string[]): string {\n return paths\n .filter((p) => p && p.length > 0)\n .map((p) => p.replace(/^\\/+|\\/+$/g, '')) // Remove leading/trailing slashes\n .join('/')\n .replace(/\\/+/g, '/'); // Normalize multiple slashes\n }\n\n /**\n * Gets an item from the file tree.\n */\n public getItem(path: string): Result<FileTree.FileTreeItem> {\n const absolutePath = this.resolveAbsolutePath(path);\n const item = this._itemCache.get(absolutePath);\n\n if (item) {\n return succeed(item);\n }\n\n return fail(`Item not found: ${absolutePath}`);\n }\n\n /**\n * Gets the contents of a file in the file tree.\n */\n public getFileContents(path: string): Result<string> {\n return this.getItem(path).onSuccess((item) => {\n if (item.type !== 'file') {\n return fail(`Path is not a file: ${path}`);\n }\n return item.getRawContents();\n });\n }\n\n /**\n * Gets the children of a directory in the file tree.\n */\n public getChildren(path: string): Result<ReadonlyArray<FileTree.FileTreeItem>> {\n const absolutePath = this.resolveAbsolutePath(path);\n const children: FileTree.FileTreeItem[] = [];\n\n // Find all items that are direct children of this directory\n for (const [itemPath, item] of this._itemCache) {\n if (this._isDirectChild(absolutePath, itemPath)) {\n children.push(item);\n }\n }\n\n return succeed(children);\n }\n\n /**\n * Checks if childPath is a direct child of parentPath.\n */\n private _isDirectChild(parentPath: string, childPath: string): boolean {\n // Normalize paths\n const normalizedParent = parentPath.replace(/\\/$/, '');\n const normalizedChild = childPath.replace(/\\/$/, '');\n\n // Child must start with parent path\n if (!normalizedChild.startsWith(normalizedParent + '/')) {\n return false;\n }\n\n // Get the relative path from parent to child\n const relativePath = normalizedChild.substring(normalizedParent.length + 1);\n\n // Direct child means no additional slashes in the relative path\n return !relativePath.includes('/');\n }\n}\n"]}
|