@fgv/ts-extras 5.0.1-9 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.js +35 -0
- package/dist/index.js +29 -0
- package/dist/packlets/conversion/converters.js +107 -0
- package/dist/packlets/conversion/index.js +24 -0
- package/dist/packlets/csv/csvFileHelpers.js +55 -0
- package/dist/packlets/csv/csvHelpers.js +37 -0
- package/dist/packlets/csv/index.browser.js +29 -0
- package/dist/packlets/csv/index.js +26 -0
- package/dist/packlets/experimental/extendedArray.js +102 -0
- package/dist/packlets/experimental/formatter.js +67 -0
- package/dist/packlets/experimental/index.js +25 -0
- package/dist/packlets/experimental/rangeOf.js +178 -0
- package/dist/packlets/hash/index.browser.js +24 -0
- package/dist/packlets/hash/index.js +23 -0
- package/dist/packlets/hash/index.node.js +26 -0
- package/dist/packlets/hash/md5Normalizer.browser.js +34 -0
- package/dist/packlets/hash/md5Normalizer.js +37 -0
- package/dist/packlets/record-jar/index.browser.js +29 -0
- package/dist/packlets/record-jar/index.js +26 -0
- package/dist/packlets/record-jar/recordJarFileHelpers.js +60 -0
- package/dist/packlets/record-jar/recordJarHelpers.js +216 -0
- package/dist/packlets/zip-file-tree/index.js +32 -0
- package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js +344 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.browser.d.ts +3 -1
- package/lib/index.browser.js +7 -1
- package/lib/packlets/csv/index.browser.d.ts +3 -0
- package/lib/packlets/csv/index.browser.js +47 -0
- package/lib/packlets/record-jar/index.browser.d.ts +3 -0
- package/lib/packlets/record-jar/index.browser.js +47 -0
- package/package.json +6 -5
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* ZIP-based FileTree implementation for ts-extras.
|
|
24
|
+
*
|
|
25
|
+
* This packlet provides a FileTree accessor implementation that can read from ZIP archives,
|
|
26
|
+
* making it useful for browser environments where files need to be bundled and transferred
|
|
27
|
+
* as a single archive.
|
|
28
|
+
*
|
|
29
|
+
* @packageDocumentation
|
|
30
|
+
*/
|
|
31
|
+
export { ZipFileTreeAccessors, ZipFileItem, ZipDirectoryItem } from './zipFileTreeAccessors';
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 Erik Fortune
|
|
3
|
+
*
|
|
4
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
* in the Software without restriction, including without limitation the rights
|
|
7
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
* furnished to do so, subject to the following conditions:
|
|
10
|
+
*
|
|
11
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
* copies or substantial portions of the Software.
|
|
13
|
+
*
|
|
14
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
* SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
import { unzipSync, unzip } from 'fflate';
|
|
23
|
+
import { succeed, fail, captureResult } from '@fgv/ts-utils';
|
|
24
|
+
/**
|
|
25
|
+
* Implementation of `FileTree.IFileTreeFileItem` for files in a ZIP archive.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export class ZipFileItem {
|
|
29
|
+
/**
|
|
30
|
+
* The content type of the file.
|
|
31
|
+
*/
|
|
32
|
+
get contentType() {
|
|
33
|
+
if (this._contentType === undefined && this._shouldInferContentType) {
|
|
34
|
+
this._contentType = this._accessors.getFileContentType(this.absolutePath).orDefault();
|
|
35
|
+
this._shouldInferContentType = false;
|
|
36
|
+
}
|
|
37
|
+
return this._contentType;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Constructor for ZipFileItem.
|
|
41
|
+
* @param zipFilePath - The path of the file within the ZIP.
|
|
42
|
+
* @param contents - The pre-loaded contents of the file.
|
|
43
|
+
* @param accessors - The ZIP file tree accessors.
|
|
44
|
+
*/
|
|
45
|
+
constructor(zipFilePath, contents, accessors) {
|
|
46
|
+
/**
|
|
47
|
+
* Indicates that this `FileTree.FileTreeItem` is a file.
|
|
48
|
+
*/
|
|
49
|
+
this.type = 'file';
|
|
50
|
+
/**
|
|
51
|
+
* Flag to track if content type should be inferred on first access.
|
|
52
|
+
*/
|
|
53
|
+
this._shouldInferContentType = true;
|
|
54
|
+
this._contents = contents;
|
|
55
|
+
this._accessors = accessors;
|
|
56
|
+
this.absolutePath = '/' + zipFilePath;
|
|
57
|
+
this.name = accessors.getBaseName(zipFilePath);
|
|
58
|
+
this.extension = accessors.getExtension(zipFilePath);
|
|
59
|
+
this.baseName = accessors.getBaseName(zipFilePath, this.extension);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Sets the content type of the file.
|
|
63
|
+
* @param contentType - The content type of the file.
|
|
64
|
+
*/
|
|
65
|
+
setContentType(contentType) {
|
|
66
|
+
this._contentType = contentType;
|
|
67
|
+
this._shouldInferContentType = false;
|
|
68
|
+
}
|
|
69
|
+
getContents(converter) {
|
|
70
|
+
return this.getRawContents()
|
|
71
|
+
.onSuccess((contents) => {
|
|
72
|
+
return captureResult(() => JSON.parse(contents))
|
|
73
|
+
.onSuccess((parsed) => {
|
|
74
|
+
if (converter) {
|
|
75
|
+
return converter.convert(parsed);
|
|
76
|
+
}
|
|
77
|
+
return succeed(parsed);
|
|
78
|
+
})
|
|
79
|
+
.onFailure(() => {
|
|
80
|
+
return fail(`Failed to parse JSON from file: ${this.absolutePath}`);
|
|
81
|
+
});
|
|
82
|
+
})
|
|
83
|
+
.onFailure((error) => {
|
|
84
|
+
return fail(`Failed to get contents from file: ${error}`);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets the raw contents of the file as a string.
|
|
89
|
+
*/
|
|
90
|
+
getRawContents() {
|
|
91
|
+
return succeed(this._contents);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Implementation of `IFileTreeDirectoryItem` for directories in a ZIP archive.
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
export class ZipDirectoryItem {
|
|
99
|
+
/**
|
|
100
|
+
* Constructor for ZipDirectoryItem.
|
|
101
|
+
* @param directoryPath - The path of the directory within the ZIP.
|
|
102
|
+
* @param accessors - The ZIP file tree accessors.
|
|
103
|
+
*/
|
|
104
|
+
constructor(directoryPath, accessors) {
|
|
105
|
+
/**
|
|
106
|
+
* Indicates that this `FileTree.FileTreeItem` is a directory.
|
|
107
|
+
*/
|
|
108
|
+
this.type = 'directory';
|
|
109
|
+
this._accessors = accessors;
|
|
110
|
+
this.absolutePath = '/' + directoryPath.replace(/\/$/, ''); // Normalize path
|
|
111
|
+
this.name = accessors.getBaseName(directoryPath);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Gets the children of the directory.
|
|
115
|
+
*/
|
|
116
|
+
getChildren() {
|
|
117
|
+
return this._accessors.getChildren(this.absolutePath);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* File tree accessors for ZIP archives.
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
export class ZipFileTreeAccessors {
|
|
125
|
+
/**
|
|
126
|
+
* Constructor for ZipFileTreeAccessors.
|
|
127
|
+
* @param files - The unzipped file data from fflate.
|
|
128
|
+
* @param params - Optional initialization parameters.
|
|
129
|
+
*/
|
|
130
|
+
constructor(files, params) {
|
|
131
|
+
var _a;
|
|
132
|
+
/**
|
|
133
|
+
* Cache of all items in the ZIP for efficient lookups.
|
|
134
|
+
*/
|
|
135
|
+
this._itemCache = new Map();
|
|
136
|
+
this._files = files;
|
|
137
|
+
this._prefix = (params === null || params === void 0 ? void 0 : params.prefix) || '';
|
|
138
|
+
this._inferContentType = (_a = params === null || params === void 0 ? void 0 : params.inferContentType) !== null && _a !== void 0 ? _a : ZipFileTreeAccessors.defaultInferContentType;
|
|
139
|
+
this._buildItemCache();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Default function to infer the content type of a file.
|
|
143
|
+
* @param filePath - The path of the file.
|
|
144
|
+
* @param provided - Optional supplied content type.
|
|
145
|
+
* @returns `Success` with the content type of the file if successful, or
|
|
146
|
+
* `Failure` with an error message otherwise.
|
|
147
|
+
* @remarks This default implementation always returns `Success` with `undefined`.
|
|
148
|
+
* @public
|
|
149
|
+
*/
|
|
150
|
+
static defaultInferContentType(__filePath, __provided) {
|
|
151
|
+
return succeed(undefined);
|
|
152
|
+
}
|
|
153
|
+
static fromBuffer(zipBuffer, params) {
|
|
154
|
+
try {
|
|
155
|
+
/* c8 ignore next 1 - defense in depth */
|
|
156
|
+
const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);
|
|
157
|
+
const files = unzipSync(uint8Buffer);
|
|
158
|
+
const normalizedParams = typeof params === 'string' ? { prefix: params } : params;
|
|
159
|
+
return succeed(new ZipFileTreeAccessors(files, normalizedParams));
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
/* c8 ignore next 1 - defensive coding: fflate always throws Error objects in practice */
|
|
163
|
+
return fail(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
static async fromBufferAsync(zipBuffer, params) {
|
|
167
|
+
return new Promise((resolve) => {
|
|
168
|
+
try {
|
|
169
|
+
/* c8 ignore next 1 - defense in depth */
|
|
170
|
+
const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);
|
|
171
|
+
unzip(uint8Buffer, (err, files) => {
|
|
172
|
+
if (err) {
|
|
173
|
+
resolve(fail(`Failed to load ZIP archive: ${err.message}`));
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
const normalizedParams = typeof params === 'string' ? { prefix: params } : params;
|
|
177
|
+
resolve(succeed(new ZipFileTreeAccessors(files, normalizedParams)));
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
/* c8 ignore next 6 - defensive coding: fflate reports errors via callback, not exceptions */
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
resolve(fail(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`));
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Creates a new ZipFileTreeAccessors instance from a File object (browser environment).
|
|
189
|
+
* @param file - The File object containing ZIP data.
|
|
190
|
+
* @param params - Optional initialization parameters.
|
|
191
|
+
* @returns Result containing the ZipFileTreeAccessors instance.
|
|
192
|
+
*/
|
|
193
|
+
static async fromFile(file, params) {
|
|
194
|
+
try {
|
|
195
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
196
|
+
const uint8Buffer = new Uint8Array(arrayBuffer);
|
|
197
|
+
return await ZipFileTreeAccessors.fromBufferAsync(uint8Buffer, params);
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
return fail(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Builds the cache of all items in the ZIP archive.
|
|
205
|
+
*/
|
|
206
|
+
_buildItemCache() {
|
|
207
|
+
const directories = new Set();
|
|
208
|
+
// Process all files and collect directory paths
|
|
209
|
+
for (const [relativePath, fileData] of Object.entries(this._files)) {
|
|
210
|
+
// Skip directories in fflate output (they have null data)
|
|
211
|
+
/* c8 ignore next 5 - handles explicit directory entries from external ZIP tools (fflate doesn't create these) */
|
|
212
|
+
if (fileData === null || fileData === undefined) {
|
|
213
|
+
const dirPath = relativePath.replace(/\/$/, '');
|
|
214
|
+
if (dirPath) {
|
|
215
|
+
directories.add(dirPath);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
// Extract directory paths from file paths
|
|
220
|
+
const pathParts = relativePath.split('/');
|
|
221
|
+
for (let i = 1; i < pathParts.length; i++) {
|
|
222
|
+
const dirPath = pathParts.slice(0, i).join('/');
|
|
223
|
+
if (dirPath) {
|
|
224
|
+
directories.add(dirPath);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// Add the file item with its contents
|
|
228
|
+
const absolutePath = this.resolveAbsolutePath(relativePath);
|
|
229
|
+
const contents = new TextDecoder().decode(fileData);
|
|
230
|
+
const item = new ZipFileItem(relativePath, contents, this);
|
|
231
|
+
this._itemCache.set(absolutePath, item);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// Add directory items to cache
|
|
235
|
+
directories.forEach((dirPath) => {
|
|
236
|
+
const absolutePath = this.resolveAbsolutePath(dirPath);
|
|
237
|
+
const item = new ZipDirectoryItem(dirPath, this);
|
|
238
|
+
this._itemCache.set(absolutePath, item);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Resolves paths to an absolute path.
|
|
243
|
+
*/
|
|
244
|
+
resolveAbsolutePath(...paths) {
|
|
245
|
+
const joinedPath = this.joinPaths(...paths);
|
|
246
|
+
const prefixed = this._prefix ? this.joinPaths(this._prefix, joinedPath) : joinedPath;
|
|
247
|
+
return prefixed.startsWith('/') ? prefixed : '/' + prefixed;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Gets the extension of a path.
|
|
251
|
+
*/
|
|
252
|
+
getExtension(path) {
|
|
253
|
+
const name = this.getBaseName(path);
|
|
254
|
+
const lastDotIndex = name.lastIndexOf('.');
|
|
255
|
+
return lastDotIndex >= 0 ? name.substring(lastDotIndex) : '';
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Gets the base name of a path.
|
|
259
|
+
*/
|
|
260
|
+
getBaseName(path, suffix) {
|
|
261
|
+
const normalizedPath = path.replace(/\/$/, ''); // Remove trailing slash
|
|
262
|
+
const parts = normalizedPath.split('/');
|
|
263
|
+
let baseName = parts[parts.length - 1] || '';
|
|
264
|
+
if (suffix && baseName.endsWith(suffix)) {
|
|
265
|
+
baseName = baseName.substring(0, baseName.length - suffix.length);
|
|
266
|
+
}
|
|
267
|
+
return baseName;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Joins paths together.
|
|
271
|
+
*/
|
|
272
|
+
joinPaths(...paths) {
|
|
273
|
+
return paths
|
|
274
|
+
.filter((p) => p && p.length > 0)
|
|
275
|
+
.map((p) => p.replace(/^\/+|\/+$/g, '')) // Remove leading/trailing slashes
|
|
276
|
+
.join('/')
|
|
277
|
+
.replace(/\/+/g, '/'); // Normalize multiple slashes
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Gets an item from the file tree.
|
|
281
|
+
*/
|
|
282
|
+
getItem(path) {
|
|
283
|
+
const absolutePath = this.resolveAbsolutePath(path);
|
|
284
|
+
const item = this._itemCache.get(absolutePath);
|
|
285
|
+
if (item) {
|
|
286
|
+
return succeed(item);
|
|
287
|
+
}
|
|
288
|
+
return fail(`Item not found: ${absolutePath}`);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Gets the contents of a file in the file tree.
|
|
292
|
+
*/
|
|
293
|
+
getFileContents(path) {
|
|
294
|
+
return this.getItem(path).onSuccess((item) => {
|
|
295
|
+
if (item.type !== 'file') {
|
|
296
|
+
return fail(`Path is not a file: ${path}`);
|
|
297
|
+
}
|
|
298
|
+
return item.getRawContents();
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Gets the content type of a file in the file tree.
|
|
303
|
+
*/
|
|
304
|
+
getFileContentType(path, provided) {
|
|
305
|
+
// If provided contentType is given, use it directly (highest priority)
|
|
306
|
+
if (provided !== undefined) {
|
|
307
|
+
return succeed(provided);
|
|
308
|
+
}
|
|
309
|
+
// For files that exist in the ZIP, we don't store explicit contentType
|
|
310
|
+
// so we always fall back to inference
|
|
311
|
+
return this._inferContentType(path);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Gets the children of a directory in the file tree.
|
|
315
|
+
*/
|
|
316
|
+
getChildren(path) {
|
|
317
|
+
const absolutePath = this.resolveAbsolutePath(path);
|
|
318
|
+
const children = [];
|
|
319
|
+
// Find all items that are direct children of this directory
|
|
320
|
+
for (const [itemPath, item] of this._itemCache) {
|
|
321
|
+
if (this._isDirectChild(absolutePath, itemPath)) {
|
|
322
|
+
children.push(item);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return succeed(children);
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Checks if childPath is a direct child of parentPath.
|
|
329
|
+
*/
|
|
330
|
+
_isDirectChild(parentPath, childPath) {
|
|
331
|
+
// Normalize paths
|
|
332
|
+
const normalizedParent = parentPath.replace(/\/$/, '');
|
|
333
|
+
const normalizedChild = childPath.replace(/\/$/, '');
|
|
334
|
+
// Child must start with parent path
|
|
335
|
+
if (!normalizedChild.startsWith(normalizedParent + '/')) {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
// Get the relative path from parent to child
|
|
339
|
+
const relativePath = normalizedChild.substring(normalizedParent.length + 1);
|
|
340
|
+
// Direct child means no additional slashes in the relative path
|
|
341
|
+
return !relativePath.includes('/');
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
//# sourceMappingURL=zipFileTreeAccessors.js.map
|
package/dist/tsdoc-metadata.json
CHANGED
package/lib/index.browser.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import * as Csv from './packlets/csv/index.browser';
|
|
1
2
|
import * as Experimental from './packlets/experimental';
|
|
2
3
|
import * as Hash from './packlets/hash/index.browser';
|
|
4
|
+
import * as RecordJar from './packlets/record-jar/index.browser';
|
|
3
5
|
import * as ZipFileTree from './packlets/zip-file-tree';
|
|
4
6
|
import { Converters } from './packlets/conversion';
|
|
5
|
-
export { Converters, Experimental, Hash, ZipFileTree };
|
|
7
|
+
export { Converters, Csv, Experimental, Hash, RecordJar, ZipFileTree };
|
|
6
8
|
//# sourceMappingURL=index.browser.d.ts.map
|
package/lib/index.browser.js
CHANGED
|
@@ -54,13 +54,19 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
54
54
|
};
|
|
55
55
|
})();
|
|
56
56
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.ZipFileTree = exports.Hash = exports.Experimental = exports.Converters = void 0;
|
|
57
|
+
exports.ZipFileTree = exports.RecordJar = exports.Hash = exports.Experimental = exports.Csv = exports.Converters = void 0;
|
|
58
58
|
/* c8 ignore start - Browser-specific export used conditionally in package.json */
|
|
59
|
+
// eslint-disable-next-line @rushstack/packlets/mechanics
|
|
60
|
+
const Csv = __importStar(require("./packlets/csv/index.browser"));
|
|
61
|
+
exports.Csv = Csv;
|
|
59
62
|
const Experimental = __importStar(require("./packlets/experimental"));
|
|
60
63
|
exports.Experimental = Experimental;
|
|
61
64
|
// eslint-disable-next-line @rushstack/packlets/mechanics
|
|
62
65
|
const Hash = __importStar(require("./packlets/hash/index.browser"));
|
|
63
66
|
exports.Hash = Hash;
|
|
67
|
+
// eslint-disable-next-line @rushstack/packlets/mechanics
|
|
68
|
+
const RecordJar = __importStar(require("./packlets/record-jar/index.browser"));
|
|
69
|
+
exports.RecordJar = RecordJar;
|
|
64
70
|
const ZipFileTree = __importStar(require("./packlets/zip-file-tree"));
|
|
65
71
|
exports.ZipFileTree = ZipFileTree;
|
|
66
72
|
const conversion_1 = require("./packlets/conversion");
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2020 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
35
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.readCsvFromTree = void 0;
|
|
39
|
+
// Browser-safe CSV exports - excludes Node.js filesystem dependencies
|
|
40
|
+
// Export all browser-safe parsing functionality
|
|
41
|
+
__exportStar(require("./csvHelpers"), exports);
|
|
42
|
+
// Export FileTree-based reading (web-compatible)
|
|
43
|
+
var csvFileHelpers_1 = require("./csvFileHelpers");
|
|
44
|
+
Object.defineProperty(exports, "readCsvFromTree", { enumerable: true, get: function () { return csvFileHelpers_1.readCsvFromTree; } });
|
|
45
|
+
// Exclude:
|
|
46
|
+
// - readCsvFileSync (requires Node.js fs/path)
|
|
47
|
+
//# sourceMappingURL=index.browser.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2023 Erik Fortune
|
|
4
|
+
*
|
|
5
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
* in the Software without restriction, including without limitation the rights
|
|
8
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
* furnished to do so, subject to the following conditions:
|
|
11
|
+
*
|
|
12
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
* copies or substantial portions of the Software.
|
|
14
|
+
*
|
|
15
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
* SOFTWARE.
|
|
22
|
+
*/
|
|
23
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
24
|
+
if (k2 === undefined) k2 = k;
|
|
25
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
26
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
27
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
28
|
+
}
|
|
29
|
+
Object.defineProperty(o, k2, desc);
|
|
30
|
+
}) : (function(o, m, k, k2) {
|
|
31
|
+
if (k2 === undefined) k2 = k;
|
|
32
|
+
o[k2] = m[k];
|
|
33
|
+
}));
|
|
34
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
35
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.readRecordJarFromTree = void 0;
|
|
39
|
+
// Browser-safe RecordJar exports - excludes Node.js filesystem dependencies
|
|
40
|
+
// Export all browser-safe parsing functionality
|
|
41
|
+
__exportStar(require("./recordJarHelpers"), exports);
|
|
42
|
+
// Export FileTree-based reading (web-compatible)
|
|
43
|
+
var recordJarFileHelpers_1 = require("./recordJarFileHelpers");
|
|
44
|
+
Object.defineProperty(exports, "readRecordJarFromTree", { enumerable: true, get: function () { return recordJarFileHelpers_1.readRecordJarFromTree; } });
|
|
45
|
+
// Exclude:
|
|
46
|
+
// - readRecordJarFileSync (requires Node.js fs/path)
|
|
47
|
+
//# sourceMappingURL=index.browser.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fgv/ts-extras",
|
|
3
|
-
"version": "5.0.1
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Assorted Typescript Utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "dist/ts-extras.d.ts",
|
|
@@ -68,18 +68,19 @@
|
|
|
68
68
|
"@types/heft-jest": "1.0.6",
|
|
69
69
|
"@rushstack/heft-jest-plugin": "1.1.3",
|
|
70
70
|
"eslint-plugin-tsdoc": "~0.4.0",
|
|
71
|
-
"@fgv/
|
|
72
|
-
"@fgv/ts-utils": "5.0.1
|
|
71
|
+
"@fgv/heft-dual-rig": "0.1.0",
|
|
72
|
+
"@fgv/ts-utils-jest": "5.0.1",
|
|
73
|
+
"@fgv/ts-utils": "5.0.1"
|
|
73
74
|
},
|
|
74
75
|
"dependencies": {
|
|
75
76
|
"luxon": "^3.7.2",
|
|
76
77
|
"mustache": "^4.2.0",
|
|
77
78
|
"papaparse": "^5.4.1",
|
|
78
79
|
"fflate": "~0.8.2",
|
|
79
|
-
"@fgv/ts-json-base": "5.0.1
|
|
80
|
+
"@fgv/ts-json-base": "5.0.1"
|
|
80
81
|
},
|
|
81
82
|
"peerDependencies": {
|
|
82
|
-
"@fgv/ts-utils": "5.0.1
|
|
83
|
+
"@fgv/ts-utils": "5.0.1"
|
|
83
84
|
},
|
|
84
85
|
"scripts": {
|
|
85
86
|
"build": "heft build --clean",
|