@fgv/ts-web-extras 5.1.0-2 → 5.1.0-21
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/packlets/crypto-utils/browserCryptoProvider.js +208 -18
- package/dist/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
- package/dist/packlets/file-tree/fileApiTreeAccessors.js +1 -1
- package/dist/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
- package/dist/packlets/file-tree/httpTreeAccessors.js +72 -42
- package/dist/packlets/file-tree/httpTreeAccessors.js.map +1 -1
- package/dist/ts-web-extras.d.ts +59 -7
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts +52 -5
- package/lib/packlets/crypto-utils/browserCryptoProvider.d.ts.map +1 -1
- package/lib/packlets/crypto-utils/browserCryptoProvider.js +207 -17
- package/lib/packlets/crypto-utils/browserCryptoProvider.js.map +1 -1
- package/lib/packlets/file-tree/fileApiTreeAccessors.d.ts +1 -1
- package/lib/packlets/file-tree/fileApiTreeAccessors.js +1 -1
- package/lib/packlets/file-tree/fileApiTreeAccessors.js.map +1 -1
- package/lib/packlets/file-tree/httpTreeAccessors.d.ts +6 -0
- package/lib/packlets/file-tree/httpTreeAccessors.d.ts.map +1 -1
- package/lib/packlets/file-tree/httpTreeAccessors.js +72 -42
- package/lib/packlets/file-tree/httpTreeAccessors.js.map +1 -1
- package/package.json +27 -26
- package/.rush/temp/chunked-rush-logs/ts-web-extras.build.chunks.jsonl +0 -75
- package/.rush/temp/chunked-rush-logs/ts-web-extras.test.chunks.jsonl +0 -75
- package/.rush/temp/operation/build/all.log +0 -75
- package/.rush/temp/operation/build/error.log +0 -18
- package/.rush/temp/operation/build/log-chunks.jsonl +0 -75
- package/.rush/temp/operation/build/state.json +0 -3
- package/.rush/temp/operation/test/all.log +0 -75
- package/.rush/temp/operation/test/error.log +0 -18
- package/.rush/temp/operation/test/log-chunks.jsonl +0 -75
- package/.rush/temp/operation/test/state.json +0 -3
- package/.rush/temp/shrinkwrap-deps.json +0 -635
- package/CHANGELOG.md +0 -23
- package/config/api-extractor.json +0 -343
- package/config/jest.config.json +0 -19
- package/config/rig.json +0 -16
- package/config/typedoc.json +0 -6
- package/dist/test/mocks/idb-keyval.js +0 -6
- package/dist/test/mocks/idb-keyval.js.map +0 -1
- package/dist/test/setupTests.js +0 -74
- package/dist/test/setupTests.js.map +0 -1
- package/dist/test/unit/browserHashProvider.test.js +0 -140
- package/dist/test/unit/browserHashProvider.test.js.map +0 -1
- package/dist/test/unit/directoryHandleStore.test.js +0 -190
- package/dist/test/unit/directoryHandleStore.test.js.map +0 -1
- package/dist/test/unit/fileApiTreeAccessors.test.js +0 -1188
- package/dist/test/unit/fileApiTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/fileApiTypes.test.js +0 -472
- package/dist/test/unit/fileApiTypes.test.js.map +0 -1
- package/dist/test/unit/fileSystemAccessTreeAccessors.test.js +0 -622
- package/dist/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/fileTreeHelpers.test.js +0 -590
- package/dist/test/unit/fileTreeHelpers.test.js.map +0 -1
- package/dist/test/unit/httpTreeAccessors.test.js +0 -1229
- package/dist/test/unit/httpTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/localStorageTreeAccessors.test.js +0 -812
- package/dist/test/unit/localStorageTreeAccessors.test.js.map +0 -1
- package/dist/test/unit/urlParams.test.js +0 -393
- package/dist/test/unit/urlParams.test.js.map +0 -1
- package/dist/test/utils/fileSystemAccessMocks.js +0 -271
- package/dist/test/utils/fileSystemAccessMocks.js.map +0 -1
- package/dist/test/utils/testHelpers.js +0 -124
- package/dist/test/utils/testHelpers.js.map +0 -1
- package/docs/@fgv/namespaces/CryptoUtils/README.md +0 -18
- package/docs/@fgv/namespaces/CryptoUtils/classes/BrowserCryptoProvider.md +0 -203
- package/docs/@fgv/namespaces/CryptoUtils/classes/BrowserHashProvider.md +0 -63
- package/docs/@fgv/namespaces/CryptoUtils/functions/createBrowserCryptoProvider.md +0 -18
- package/docs/@fgv/namespaces/FileTreeHelpers/README.md +0 -19
- package/docs/@fgv/namespaces/FileTreeHelpers/functions/extractFileListMetadata.md +0 -23
- package/docs/@fgv/namespaces/FileTreeHelpers/functions/extractFileMetadata.md +0 -23
- package/docs/@fgv/namespaces/FileTreeHelpers/functions/fromDirectoryUpload.md +0 -33
- package/docs/@fgv/namespaces/FileTreeHelpers/functions/fromFileList.md +0 -33
- package/docs/@fgv/namespaces/FileTreeHelpers/functions/getOriginalFile.md +0 -25
- package/docs/@fgv/namespaces/FileTreeHelpers/variables/defaultFileApiTreeInitParams.md +0 -11
- package/docs/README.md +0 -78
- package/docs/classes/DirectoryHandleStore.md +0 -116
- package/docs/classes/FileApiTreeAccessors.md +0 -286
- package/docs/classes/FileSystemAccessTreeAccessors.md +0 -557
- package/docs/classes/HttpTreeAccessors.md +0 -508
- package/docs/classes/LocalStorageTreeAccessors.md +0 -520
- package/docs/functions/exportAsJson.md +0 -23
- package/docs/functions/exportUsingFileSystemAPI.md +0 -26
- package/docs/functions/extractDirectoryPath.md +0 -23
- package/docs/functions/isDirectoryHandle.md +0 -23
- package/docs/functions/isFileHandle.md +0 -23
- package/docs/functions/isFilePath.md +0 -21
- package/docs/functions/parseContextFilter.md +0 -22
- package/docs/functions/parseQualifierDefaults.md +0 -22
- package/docs/functions/parseResourceTypes.md +0 -22
- package/docs/functions/parseUrlParameters.md +0 -15
- package/docs/functions/safeShowDirectoryPicker.md +0 -24
- package/docs/functions/safeShowOpenFilePicker.md +0 -24
- package/docs/functions/safeShowSaveFilePicker.md +0 -24
- package/docs/functions/supportsFileSystemAccess.md +0 -23
- package/docs/interfaces/FilePickerAcceptType.md +0 -16
- package/docs/interfaces/FileSystemCreateWritableOptions.md +0 -15
- package/docs/interfaces/FileSystemDirectoryHandle.md +0 -187
- package/docs/interfaces/FileSystemFileHandle.md +0 -106
- package/docs/interfaces/FileSystemGetDirectoryOptions.md +0 -15
- package/docs/interfaces/FileSystemGetFileOptions.md +0 -15
- package/docs/interfaces/FileSystemHandle.md +0 -69
- package/docs/interfaces/FileSystemHandlePermissionDescriptor.md +0 -15
- package/docs/interfaces/FileSystemRemoveOptions.md +0 -15
- package/docs/interfaces/FileSystemWritableFileStream.md +0 -127
- package/docs/interfaces/IDirectoryHandleTreeInitializer.md +0 -17
- package/docs/interfaces/IFileHandleTreeInitializer.md +0 -16
- package/docs/interfaces/IFileListTreeInitializer.md +0 -15
- package/docs/interfaces/IFileMetadata.md +0 -19
- package/docs/interfaces/IFileSystemAccessTreeParams.md +0 -30
- package/docs/interfaces/IFsAccessApis.md +0 -57
- package/docs/interfaces/IHttpTreeParams.md +0 -32
- package/docs/interfaces/ILocalStorageTreeParams.md +0 -30
- package/docs/interfaces/IUrlConfigOptions.md +0 -27
- package/docs/interfaces/ShowDirectoryPickerOptions.md +0 -17
- package/docs/interfaces/ShowOpenFilePickerOptions.md +0 -19
- package/docs/interfaces/ShowSaveFilePickerOptions.md +0 -19
- package/docs/type-aliases/TreeInitializer.md +0 -11
- package/docs/type-aliases/WellKnownDirectory.md +0 -11
- package/docs/type-aliases/WindowWithFsAccess.md +0 -11
- package/docs/variables/DEFAULT_DIRECTORY_HANDLE_DB.md +0 -11
- package/docs/variables/DEFAULT_DIRECTORY_HANDLE_STORE.md +0 -11
- package/etc/ts-web-extras.api.md +0 -433
- package/lib/test/mocks/idb-keyval.d.ts +0 -6
- package/lib/test/mocks/idb-keyval.d.ts.map +0 -1
- package/lib/test/mocks/idb-keyval.js +0 -9
- package/lib/test/mocks/idb-keyval.js.map +0 -1
- package/lib/test/setupTests.d.ts +0 -2
- package/lib/test/setupTests.d.ts.map +0 -1
- package/lib/test/setupTests.js +0 -76
- package/lib/test/setupTests.js.map +0 -1
- package/lib/test/unit/browserHashProvider.test.d.ts +0 -2
- package/lib/test/unit/browserHashProvider.test.d.ts.map +0 -1
- package/lib/test/unit/browserHashProvider.test.js +0 -142
- package/lib/test/unit/browserHashProvider.test.js.map +0 -1
- package/lib/test/unit/directoryHandleStore.test.d.ts +0 -2
- package/lib/test/unit/directoryHandleStore.test.d.ts.map +0 -1
- package/lib/test/unit/directoryHandleStore.test.js +0 -192
- package/lib/test/unit/directoryHandleStore.test.js.map +0 -1
- package/lib/test/unit/fileApiTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/fileApiTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/fileApiTreeAccessors.test.js +0 -1190
- package/lib/test/unit/fileApiTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/fileApiTypes.test.d.ts +0 -2
- package/lib/test/unit/fileApiTypes.test.d.ts.map +0 -1
- package/lib/test/unit/fileApiTypes.test.js +0 -474
- package/lib/test/unit/fileApiTypes.test.js.map +0 -1
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.js +0 -624
- package/lib/test/unit/fileSystemAccessTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/fileTreeHelpers.test.d.ts +0 -2
- package/lib/test/unit/fileTreeHelpers.test.d.ts.map +0 -1
- package/lib/test/unit/fileTreeHelpers.test.js +0 -592
- package/lib/test/unit/fileTreeHelpers.test.js.map +0 -1
- package/lib/test/unit/httpTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/httpTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/httpTreeAccessors.test.js +0 -1231
- package/lib/test/unit/httpTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/localStorageTreeAccessors.test.d.ts +0 -2
- package/lib/test/unit/localStorageTreeAccessors.test.d.ts.map +0 -1
- package/lib/test/unit/localStorageTreeAccessors.test.js +0 -814
- package/lib/test/unit/localStorageTreeAccessors.test.js.map +0 -1
- package/lib/test/unit/urlParams.test.d.ts +0 -2
- package/lib/test/unit/urlParams.test.d.ts.map +0 -1
- package/lib/test/unit/urlParams.test.js +0 -395
- package/lib/test/unit/urlParams.test.js.map +0 -1
- package/lib/test/utils/fileSystemAccessMocks.d.ts +0 -53
- package/lib/test/utils/fileSystemAccessMocks.d.ts.map +0 -1
- package/lib/test/utils/fileSystemAccessMocks.js +0 -277
- package/lib/test/utils/fileSystemAccessMocks.js.map +0 -1
- package/lib/test/utils/testHelpers.d.ts +0 -51
- package/lib/test/utils/testHelpers.d.ts.map +0 -1
- package/lib/test/utils/testHelpers.js +0 -133
- package/lib/test/utils/testHelpers.js.map +0 -1
- package/rush-logs/ts-web-extras.build.cache.log +0 -0
- package/rush-logs/ts-web-extras.build.error.log +0 -18
- package/rush-logs/ts-web-extras.build.log +0 -75
- package/rush-logs/ts-web-extras.test.cache.log +0 -1
- package/rush-logs/ts-web-extras.test.error.log +0 -18
- package/rush-logs/ts-web-extras.test.log +0 -75
- package/src/index.browser.ts +0 -24
- package/src/index.ts +0 -47
- package/src/packlets/crypto-utils/browserCryptoProvider.ts +0 -311
- package/src/packlets/crypto-utils/browserHashProvider.ts +0 -73
- package/src/packlets/crypto-utils/index.ts +0 -29
- package/src/packlets/file-api-types/index.ts +0 -366
- package/src/packlets/file-tree/directoryHandleStore.ts +0 -136
- package/src/packlets/file-tree/fileApiTreeAccessors.ts +0 -528
- package/src/packlets/file-tree/fileSystemAccessTreeAccessors.ts +0 -519
- package/src/packlets/file-tree/httpTreeAccessors.ts +0 -448
- package/src/packlets/file-tree/index.ts +0 -32
- package/src/packlets/file-tree/localStorageTreeAccessors.ts +0 -430
- package/src/packlets/helpers/fileTreeHelpers.ts +0 -107
- package/src/packlets/helpers/index.ts +0 -28
- package/src/packlets/url-utils/index.ts +0 -28
- package/src/packlets/url-utils/urlParams.ts +0 -245
- package/src/test/mocks/idb-keyval.ts +0 -5
- package/src/test/setupTests.ts +0 -87
- package/src/test/unit/browserHashProvider.test.ts +0 -155
- package/src/test/unit/browserHashProvider.test.ts.bak +0 -376
- package/src/test/unit/directoryHandleStore.test.ts +0 -251
- package/src/test/unit/fileApiTreeAccessors.test.ts +0 -1387
- package/src/test/unit/fileApiTypes.test.ts +0 -587
- package/src/test/unit/fileSystemAccessTreeAccessors.test.ts +0 -885
- package/src/test/unit/fileTreeHelpers.test.ts +0 -694
- package/src/test/unit/httpTreeAccessors.test.ts +0 -1571
- package/src/test/unit/localStorageTreeAccessors.test.ts +0 -1014
- package/src/test/unit/urlParams.test.ts +0 -464
- package/src/test/utils/fileSystemAccessMocks.ts +0 -353
- package/src/test/utils/testHelpers.ts +0 -155
- package/temp/build/typescript/ts_8nwakTlr.json +0 -1
- package/temp/coverage/base.css +0 -224
- package/temp/coverage/block-navigation.js +0 -87
- package/temp/coverage/crypto/browserHashProvider.ts.html +0 -304
- package/temp/coverage/crypto/index.html +0 -116
- package/temp/coverage/crypto-utils/browserCryptoProvider.ts.html +0 -1018
- package/temp/coverage/crypto-utils/browserHashProvider.ts.html +0 -304
- package/temp/coverage/crypto-utils/index.html +0 -131
- package/temp/coverage/favicon.png +0 -0
- package/temp/coverage/file-tree/directoryHandleStore.ts.html +0 -493
- package/temp/coverage/file-tree/fileApiTreeAccessors.ts.html +0 -1669
- package/temp/coverage/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
- package/temp/coverage/file-tree/httpTreeAccessors.ts.html +0 -1429
- package/temp/coverage/file-tree/index.html +0 -176
- package/temp/coverage/file-tree/localStorageTreeAccessors.ts.html +0 -1375
- package/temp/coverage/helpers/fileTreeHelpers.ts.html +0 -406
- package/temp/coverage/helpers/index.html +0 -116
- package/temp/coverage/index.html +0 -161
- package/temp/coverage/lcov-report/base.css +0 -224
- package/temp/coverage/lcov-report/block-navigation.js +0 -87
- package/temp/coverage/lcov-report/crypto/browserHashProvider.ts.html +0 -304
- package/temp/coverage/lcov-report/crypto/index.html +0 -116
- package/temp/coverage/lcov-report/crypto-utils/browserCryptoProvider.ts.html +0 -1018
- package/temp/coverage/lcov-report/crypto-utils/browserHashProvider.ts.html +0 -304
- package/temp/coverage/lcov-report/crypto-utils/index.html +0 -131
- package/temp/coverage/lcov-report/favicon.png +0 -0
- package/temp/coverage/lcov-report/file-tree/directoryHandleStore.ts.html +0 -493
- package/temp/coverage/lcov-report/file-tree/fileApiTreeAccessors.ts.html +0 -1669
- package/temp/coverage/lcov-report/file-tree/fileSystemAccessTreeAccessors.ts.html +0 -1642
- package/temp/coverage/lcov-report/file-tree/httpTreeAccessors.ts.html +0 -1429
- package/temp/coverage/lcov-report/file-tree/index.html +0 -176
- package/temp/coverage/lcov-report/file-tree/localStorageTreeAccessors.ts.html +0 -1375
- package/temp/coverage/lcov-report/helpers/fileTreeHelpers.ts.html +0 -406
- package/temp/coverage/lcov-report/helpers/index.html +0 -116
- package/temp/coverage/lcov-report/index.html +0 -161
- package/temp/coverage/lcov-report/prettify.css +0 -1
- package/temp/coverage/lcov-report/prettify.js +0 -2
- package/temp/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/temp/coverage/lcov-report/sorter.js +0 -210
- package/temp/coverage/lcov-report/url-utils/index.html +0 -116
- package/temp/coverage/lcov-report/url-utils/urlParams.ts.html +0 -820
- package/temp/coverage/lcov.info +0 -3597
- package/temp/coverage/prettify.css +0 -1
- package/temp/coverage/prettify.js +0 -2
- package/temp/coverage/sort-arrow-sprite.png +0 -0
- package/temp/coverage/sorter.js +0 -210
- package/temp/coverage/url-utils/index.html +0 -116
- package/temp/coverage/url-utils/urlParams.ts.html +0 -820
- package/temp/test/jest/haste-map-b931e4e63102f86c5bd4949f7dced44f-9d713eb41149188b4e5c0ae3d86d0a57-2ad8e16b24e391b8cdbe50b55c137169 +0 -0
- package/temp/test/jest/jest-transform-cache-b931e4e63102f86c5bd4949f7dced44f-79ef2876fae7ca75eedb2aa53dc48338/b5/package_b5f57afc9ec2c011239b1608ee5bdfa5 +0 -53
- package/temp/test/jest/perf-cache-b931e4e63102f86c5bd4949f7dced44f-da39a3ee5e6b4b0d3255bfef95601890 +0 -1
- package/temp/ts-web-extras.api.json +0 -8850
- package/temp/ts-web-extras.api.md +0 -433
- package/tsconfig.json +0 -7
|
@@ -1,528 +0,0 @@
|
|
|
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
|
-
// File System Access API types are imported via the file-api-types module
|
|
24
|
-
import { Result, succeed, fail } from '@fgv/ts-utils';
|
|
25
|
-
import { FileTree } from '@fgv/ts-json-base';
|
|
26
|
-
import {
|
|
27
|
-
isFileHandle,
|
|
28
|
-
isDirectoryHandle,
|
|
29
|
-
FileSystemFileHandle,
|
|
30
|
-
FileSystemDirectoryHandle
|
|
31
|
-
} from '../file-api-types';
|
|
32
|
-
import { FileSystemAccessTreeAccessors, IFileSystemAccessTreeParams } from './fileSystemAccessTreeAccessors';
|
|
33
|
-
import { HttpTreeAccessors, IHttpTreeParams } from './httpTreeAccessors';
|
|
34
|
-
import { LocalStorageTreeAccessors, ILocalStorageTreeParams } from './localStorageTreeAccessors';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Interface for File objects that may have the webkitRelativePath property.
|
|
38
|
-
* This property is added by browsers when using directory upload (webkitdirectory).
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
interface IFileWithWebkitPath {
|
|
42
|
-
readonly webkitRelativePath?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Helper function to safely get webkitRelativePath from a File object.
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
49
|
-
function getFileRelativePath(file: File): string {
|
|
50
|
-
return (file as unknown as IFileWithWebkitPath).webkitRelativePath || file.name;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Tree initializer for FileList objects (from File API).
|
|
55
|
-
* @public
|
|
56
|
-
*/
|
|
57
|
-
export interface IFileListTreeInitializer {
|
|
58
|
-
readonly fileList: FileList;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Tree initializer for File System Access API file handles.
|
|
63
|
-
* @public
|
|
64
|
-
*/
|
|
65
|
-
export interface IFileHandleTreeInitializer {
|
|
66
|
-
readonly prefix?: string;
|
|
67
|
-
readonly fileHandles: FileSystemFileHandle[];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Tree initializer for File System Access API directory handles.
|
|
72
|
-
* @public
|
|
73
|
-
*/
|
|
74
|
-
export interface IDirectoryHandleTreeInitializer {
|
|
75
|
-
readonly prefix?: string;
|
|
76
|
-
readonly dirHandles: FileSystemDirectoryHandle[];
|
|
77
|
-
readonly nonRecursive?: boolean; // Default: false (recursive by default)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Union type for all supported tree initializers.
|
|
82
|
-
* @public
|
|
83
|
-
*/
|
|
84
|
-
export type TreeInitializer =
|
|
85
|
-
| IFileListTreeInitializer
|
|
86
|
-
| IFileHandleTreeInitializer
|
|
87
|
-
| IDirectoryHandleTreeInitializer;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Interface for file metadata.
|
|
91
|
-
* @public
|
|
92
|
-
*/
|
|
93
|
-
export interface IFileMetadata {
|
|
94
|
-
path: string;
|
|
95
|
-
name: string;
|
|
96
|
-
size: number;
|
|
97
|
-
type: string;
|
|
98
|
-
lastModified: number;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Helper class to create FileTree instances from various file sources.
|
|
103
|
-
* Supports File API (FileList) and File System Access API handles.
|
|
104
|
-
* @public
|
|
105
|
-
*/
|
|
106
|
-
export class FileApiTreeAccessors<TCT extends string = string> {
|
|
107
|
-
/**
|
|
108
|
-
* Create a persistent FileTree from a File System Access API directory handle.
|
|
109
|
-
* Changes to files can be synced back to disk.
|
|
110
|
-
*
|
|
111
|
-
* @param dirHandle - FileSystemDirectoryHandle to load files from
|
|
112
|
-
* @param params - Optional parameters including autoSync and permission settings
|
|
113
|
-
* @returns Promise resolving to a FileTree with persistence capability
|
|
114
|
-
*
|
|
115
|
-
* @remarks
|
|
116
|
-
* - Only works in browsers supporting File System Access API (Chrome, Edge, Opera)
|
|
117
|
-
* - Requires 'readwrite' permission on the directory handle
|
|
118
|
-
* - Falls back to read-only mode if permissions unavailable (unless requireWritePermission is true)
|
|
119
|
-
*
|
|
120
|
-
* @public
|
|
121
|
-
*/
|
|
122
|
-
public static async createPersistent<TCT extends string = string>(
|
|
123
|
-
dirHandle: FileSystemDirectoryHandle,
|
|
124
|
-
params?: IFileSystemAccessTreeParams<TCT>
|
|
125
|
-
): Promise<Result<FileTree.FileTree<TCT>>> {
|
|
126
|
-
const accessorsResult = await FileSystemAccessTreeAccessors.fromDirectoryHandle<TCT>(dirHandle, params);
|
|
127
|
-
if (accessorsResult.isFailure()) {
|
|
128
|
-
return fail(accessorsResult.message);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return FileTree.FileTree.create<TCT>(accessorsResult.value);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Create a persistent FileTree from an HTTP storage service.
|
|
136
|
-
*
|
|
137
|
-
* @param params - Configuration including API base URL, namespace, and optional autoSync
|
|
138
|
-
* @returns Promise resolving to a FileTree with persistence capability
|
|
139
|
-
* @public
|
|
140
|
-
*/
|
|
141
|
-
public static async createFromHttp<TCT extends string = string>(
|
|
142
|
-
params: IHttpTreeParams<TCT>
|
|
143
|
-
): Promise<Result<FileTree.FileTree<TCT>>> {
|
|
144
|
-
const accessorsResult = await HttpTreeAccessors.fromHttp<TCT>(params);
|
|
145
|
-
if (accessorsResult.isFailure()) {
|
|
146
|
-
return fail(accessorsResult.message);
|
|
147
|
-
}
|
|
148
|
-
return FileTree.FileTree.create<TCT>(accessorsResult.value);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Create a persistent FileTree from a single File System Access API file handle.
|
|
153
|
-
* The tree contains exactly one file at `/<filename>`.
|
|
154
|
-
* Changes can be synced back to the original file via `syncToDisk()`.
|
|
155
|
-
*
|
|
156
|
-
* @param fileHandle - FileSystemFileHandle to load
|
|
157
|
-
* @param params - Optional parameters including autoSync and permission settings
|
|
158
|
-
* @returns Promise resolving to a FileTree with persistence capability
|
|
159
|
-
* @public
|
|
160
|
-
*/
|
|
161
|
-
public static async createPersistentFromFile<TCT extends string = string>(
|
|
162
|
-
fileHandle: FileSystemFileHandle,
|
|
163
|
-
params?: IFileSystemAccessTreeParams<TCT>
|
|
164
|
-
): Promise<Result<FileTree.FileTree<TCT>>> {
|
|
165
|
-
const accessorsResult = await FileSystemAccessTreeAccessors.fromFileHandle<TCT>(fileHandle, params);
|
|
166
|
-
if (accessorsResult.isFailure()) {
|
|
167
|
-
return fail(accessorsResult.message);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return FileTree.FileTree.create<TCT>(accessorsResult.value);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Create a persistent FileTree from browser localStorage.
|
|
175
|
-
* Changes to files can be synced back to localStorage.
|
|
176
|
-
*
|
|
177
|
-
* @param params - Configuration including path-to-key mappings and optional autoSync
|
|
178
|
-
* @returns Result containing a FileTree with persistence capability
|
|
179
|
-
*
|
|
180
|
-
* @remarks
|
|
181
|
-
* - Works in all browsers with localStorage support
|
|
182
|
-
* - Maps directory paths to localStorage keys
|
|
183
|
-
* - Each key stores multiple collections as JSON
|
|
184
|
-
* - Files are automatically discovered from storage
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```typescript
|
|
188
|
-
* const tree = FileApiTreeAccessors.createFromLocalStorage({
|
|
189
|
-
* pathToKeyMap: {
|
|
190
|
-
* '/data/ingredients': 'myapp:ingredients:v1',
|
|
191
|
-
* '/data/fillings': 'myapp:fillings:v1'
|
|
192
|
-
* },
|
|
193
|
-
* mutable: true,
|
|
194
|
-
* autoSync: false
|
|
195
|
-
* });
|
|
196
|
-
* ```
|
|
197
|
-
*
|
|
198
|
-
* @public
|
|
199
|
-
*/
|
|
200
|
-
public static createFromLocalStorage<TCT extends string = string>(
|
|
201
|
-
params: ILocalStorageTreeParams<TCT>
|
|
202
|
-
): Result<FileTree.FileTree<TCT>> {
|
|
203
|
-
const accessorsResult = LocalStorageTreeAccessors.fromStorage<TCT>(params);
|
|
204
|
-
/* c8 ignore next 3 - coverage intermittently missed in full suite */
|
|
205
|
-
if (accessorsResult.isFailure()) {
|
|
206
|
-
return fail(accessorsResult.message);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return FileTree.FileTree.create<TCT>(accessorsResult.value);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Create FileTree from various file sources using TreeInitializer array.
|
|
214
|
-
* @param initializers - Array of TreeInitializer objects specifying file sources
|
|
215
|
-
* @param params - Optional `IFileTreeInitParams` for the file tree.
|
|
216
|
-
* @returns Promise resolving to a FileTree with all content pre-loaded
|
|
217
|
-
*/
|
|
218
|
-
public static async create<TCT extends string = string>(
|
|
219
|
-
initializers: TreeInitializer[],
|
|
220
|
-
params?: FileTree.IFileTreeInitParams<TCT>
|
|
221
|
-
): Promise<Result<FileTree.FileTree<TCT>>> {
|
|
222
|
-
try {
|
|
223
|
-
const allFiles: FileTree.IInMemoryFile<TCT>[] = [];
|
|
224
|
-
|
|
225
|
-
for (const initializer of initializers) {
|
|
226
|
-
const filesResult = await this._processInitializer<TCT>(initializer, params);
|
|
227
|
-
if (filesResult.isFailure()) {
|
|
228
|
-
return fail(filesResult.message);
|
|
229
|
-
}
|
|
230
|
-
allFiles.push(...filesResult.value);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
return FileTree.inMemory<TCT>(allFiles, params);
|
|
234
|
-
/* c8 ignore next 5 - defense in depth */
|
|
235
|
-
} catch (error) {
|
|
236
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
237
|
-
return fail(`Failed to process initializers: ${message}`);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Create FileTree from FileList (e.g., from input[type="file"]).
|
|
243
|
-
* @param fileList - FileList from a file input element
|
|
244
|
-
* @param params - Optional `IFileTreeInitParams` for the file tree.
|
|
245
|
-
* @returns Promise resolving to a FileTree with all content pre-loaded
|
|
246
|
-
*/
|
|
247
|
-
public static async fromFileList<TCT extends string = string>(
|
|
248
|
-
fileList: FileList,
|
|
249
|
-
params?: FileTree.IFileTreeInitParams<TCT>
|
|
250
|
-
): Promise<Result<FileTree.FileTree<TCT>>> {
|
|
251
|
-
const files: FileTree.IInMemoryFile<TCT>[] = [];
|
|
252
|
-
|
|
253
|
-
for (let i = 0; i < fileList.length; i++) {
|
|
254
|
-
const file = fileList[i];
|
|
255
|
-
const path = this._normalizePath(params?.prefix || '', file.name);
|
|
256
|
-
|
|
257
|
-
try {
|
|
258
|
-
const contents = await file.text();
|
|
259
|
-
const contentType = params?.inferContentType?.(path, file.type).orDefault();
|
|
260
|
-
files.push({
|
|
261
|
-
path,
|
|
262
|
-
contents,
|
|
263
|
-
contentType
|
|
264
|
-
});
|
|
265
|
-
} catch (error) {
|
|
266
|
-
/* c8 ignore next 1 - defense in depth */
|
|
267
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
268
|
-
return fail(`Failed to read file ${file.name}: ${message}`);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return FileTree.inMemory<TCT>(files, params);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Create FileTree from directory upload with webkitRelativePath.
|
|
277
|
-
* @param fileList - FileList from a directory upload (input with webkitdirectory)
|
|
278
|
-
* @param params - Optional `IFileTreeInitParams` for the file tree.
|
|
279
|
-
* @returns Promise resolving to a FileTree with all content pre-loaded
|
|
280
|
-
*/
|
|
281
|
-
public static async fromDirectoryUpload<TCT extends string = string>(
|
|
282
|
-
fileList: FileList,
|
|
283
|
-
params?: FileTree.IFileTreeInitParams<TCT>
|
|
284
|
-
): Promise<Result<FileTree.FileTree<TCT>>> {
|
|
285
|
-
const files: FileTree.IInMemoryFile<TCT>[] = [];
|
|
286
|
-
|
|
287
|
-
for (let i = 0; i < fileList.length; i++) {
|
|
288
|
-
const file = fileList[i];
|
|
289
|
-
const relativePath = getFileRelativePath(file);
|
|
290
|
-
const path = this._normalizePath(params?.prefix || '', relativePath);
|
|
291
|
-
|
|
292
|
-
try {
|
|
293
|
-
const contents = await file.text();
|
|
294
|
-
const contentType = params?.inferContentType?.(path, file.type).orDefault();
|
|
295
|
-
files.push({
|
|
296
|
-
path,
|
|
297
|
-
contents,
|
|
298
|
-
contentType
|
|
299
|
-
});
|
|
300
|
-
} catch (error) {
|
|
301
|
-
/* c8 ignore next 1 - defense in depth */
|
|
302
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
303
|
-
return fail(`Failed to read file ${relativePath}: ${message}`);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
return FileTree.inMemory<TCT>(files, params);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Get the File object for a specific path from the original FileList.
|
|
312
|
-
* This is useful for accessing the original File API object for operations
|
|
313
|
-
* like getting file metadata, MIME type, etc.
|
|
314
|
-
* @param fileList - The original FileList
|
|
315
|
-
* @param targetPath - The path to find
|
|
316
|
-
* @returns Result containing the File object if found
|
|
317
|
-
*/
|
|
318
|
-
public static getOriginalFile(fileList: FileList, targetPath: string): Result<File> {
|
|
319
|
-
for (const file of Array.from(fileList)) {
|
|
320
|
-
const filePath = getFileRelativePath(file);
|
|
321
|
-
if (filePath === targetPath) {
|
|
322
|
-
return succeed(file);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
return fail(`File not found: ${targetPath}`);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Extract file metadata from a File.
|
|
330
|
-
* @param fileList - The File to extract metadata from
|
|
331
|
-
* @returns The {@link IFileMetadata | file metadata}
|
|
332
|
-
*/
|
|
333
|
-
public static extractFileMetadata(file: File): IFileMetadata {
|
|
334
|
-
return {
|
|
335
|
-
path: getFileRelativePath(file),
|
|
336
|
-
name: file.name,
|
|
337
|
-
size: file.size,
|
|
338
|
-
type: file.type,
|
|
339
|
-
lastModified: file.lastModified
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Process a single TreeInitializer and return the resulting files.
|
|
345
|
-
* @param initializer - The TreeInitializer to process
|
|
346
|
-
* @param params - Optional `IFileTreeInitParams` for the file tree.
|
|
347
|
-
* @returns Promise resolving to an array of `IInMemoryFile` objects
|
|
348
|
-
* @internal
|
|
349
|
-
*/
|
|
350
|
-
private static async _processInitializer<TCT extends string = string>(
|
|
351
|
-
initializer: TreeInitializer,
|
|
352
|
-
params?: FileTree.IFileTreeInitParams<TCT>
|
|
353
|
-
): Promise<Result<FileTree.IInMemoryFile<TCT>[]>> {
|
|
354
|
-
if ('fileList' in initializer) {
|
|
355
|
-
return this._processFileList<TCT>(initializer.fileList, params);
|
|
356
|
-
} else if ('fileHandles' in initializer) {
|
|
357
|
-
return this._processFileHandles<TCT>(initializer.fileHandles, params);
|
|
358
|
-
} else if ('dirHandles' in initializer) {
|
|
359
|
-
return this._processDirectoryHandles<TCT>(
|
|
360
|
-
initializer.dirHandles,
|
|
361
|
-
initializer.prefix ?? params?.prefix,
|
|
362
|
-
!initializer.nonRecursive,
|
|
363
|
-
params
|
|
364
|
-
);
|
|
365
|
-
} else {
|
|
366
|
-
return fail('Unknown initializer type');
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Process a FileList and return IInMemoryFile array.
|
|
372
|
-
* @param fileList - The FileList to process
|
|
373
|
-
* @param params - Optional `IFileTreeInitParams` for the file tree.
|
|
374
|
-
* @returns Promise resolving to an array of `IInMemoryFile` objects
|
|
375
|
-
* @internal
|
|
376
|
-
*/
|
|
377
|
-
private static async _processFileList<TCT extends string = string>(
|
|
378
|
-
fileList: FileList,
|
|
379
|
-
params?: FileTree.IFileTreeInitParams<TCT>
|
|
380
|
-
): Promise<Result<FileTree.IInMemoryFile<TCT>[]>> {
|
|
381
|
-
const files: FileTree.IInMemoryFile<TCT>[] = [];
|
|
382
|
-
|
|
383
|
-
for (let i = 0; i < fileList.length; i++) {
|
|
384
|
-
const file = fileList[i];
|
|
385
|
-
const metadata = this.extractFileMetadata(file);
|
|
386
|
-
const relativePath = metadata.path;
|
|
387
|
-
const path = relativePath.startsWith('/') ? relativePath : `/${relativePath}`;
|
|
388
|
-
|
|
389
|
-
try {
|
|
390
|
-
const contents = await file.text();
|
|
391
|
-
const contentType = params?.inferContentType?.(path, metadata.type).orDefault();
|
|
392
|
-
files.push({
|
|
393
|
-
path,
|
|
394
|
-
contents,
|
|
395
|
-
contentType
|
|
396
|
-
});
|
|
397
|
-
} catch (error) {
|
|
398
|
-
/* c8 ignore next 1 - defense in depth */
|
|
399
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
400
|
-
return fail(`Failed to read file ${relativePath}: ${message}`);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
return succeed(files);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Process FileSystemFileHandles and return IInMemoryFile array.
|
|
409
|
-
* @internal
|
|
410
|
-
*/
|
|
411
|
-
private static async _processFileHandles<TCT extends string = string>(
|
|
412
|
-
handles: FileSystemFileHandle[],
|
|
413
|
-
params?: FileTree.IFileTreeInitParams<TCT>
|
|
414
|
-
): Promise<Result<FileTree.IInMemoryFile<TCT>[]>> {
|
|
415
|
-
const files: FileTree.IInMemoryFile<TCT>[] = [];
|
|
416
|
-
|
|
417
|
-
for (const handle of handles) {
|
|
418
|
-
try {
|
|
419
|
-
const file = await handle.getFile();
|
|
420
|
-
const contents = await file.text();
|
|
421
|
-
const metadata = this.extractFileMetadata(file);
|
|
422
|
-
/* c8 ignore next 1 - defense in depth */
|
|
423
|
-
const path = this._normalizePath(params?.prefix ?? '', handle.name);
|
|
424
|
-
const contentType = params?.inferContentType?.(path, metadata.type).orDefault();
|
|
425
|
-
|
|
426
|
-
files.push({
|
|
427
|
-
path,
|
|
428
|
-
contents,
|
|
429
|
-
contentType
|
|
430
|
-
});
|
|
431
|
-
} catch (error) {
|
|
432
|
-
/* c8 ignore next 1 - defense in depth */
|
|
433
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
434
|
-
return fail(`Failed to read file handle ${handle.name}: ${message}`);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
return succeed(files);
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* Process FileSystemDirectoryHandles and return IInMemoryFile array.
|
|
443
|
-
* @param handles - The FileSystemDirectoryHandle[] to process
|
|
444
|
-
* @param prefix - The prefix to use for the file paths
|
|
445
|
-
* @param recursive - Whether to process the directory recursively
|
|
446
|
-
* @param params - Optional `IFileTreeInitParams` for the file tree.
|
|
447
|
-
* @returns Promise resolving to an array of `IInMemoryFile` objects
|
|
448
|
-
* @internal
|
|
449
|
-
*/
|
|
450
|
-
private static async _processDirectoryHandles<TCT extends string = string>(
|
|
451
|
-
handles: FileSystemDirectoryHandle[],
|
|
452
|
-
prefix?: string,
|
|
453
|
-
recursive: boolean = true,
|
|
454
|
-
params?: FileTree.IFileTreeInitParams<TCT>
|
|
455
|
-
): Promise<Result<FileTree.IInMemoryFile<TCT>[]>> {
|
|
456
|
-
const allFiles: FileTree.IInMemoryFile<TCT>[] = [];
|
|
457
|
-
prefix = prefix ?? params?.prefix;
|
|
458
|
-
|
|
459
|
-
for (const handle of handles) {
|
|
460
|
-
const dirPrefix = this._normalizePath(prefix ?? '', handle.name);
|
|
461
|
-
const filesResult = await this._processDirectoryHandle<TCT>(handle, dirPrefix, recursive, params);
|
|
462
|
-
if (filesResult.isFailure()) {
|
|
463
|
-
return filesResult;
|
|
464
|
-
}
|
|
465
|
-
allFiles.push(...filesResult.value);
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
return succeed(allFiles);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* Process a single FileSystemDirectoryHandle recursively.
|
|
473
|
-
* @param handle - The FileSystemDirectoryHandle to process
|
|
474
|
-
* @param basePath - The base path to use for the file paths
|
|
475
|
-
* @param recursive - Whether to process the directory recursively
|
|
476
|
-
* @param params - Optional `IFileTreeInitParams` for the file tree.
|
|
477
|
-
* @returns Promise resolving to an array of `IInMemoryFile` objects
|
|
478
|
-
* @internal
|
|
479
|
-
*/
|
|
480
|
-
private static async _processDirectoryHandle<TCT extends string = string>(
|
|
481
|
-
handle: FileSystemDirectoryHandle,
|
|
482
|
-
basePath: string,
|
|
483
|
-
recursive: boolean,
|
|
484
|
-
params?: FileTree.IFileTreeInitParams<TCT>
|
|
485
|
-
): Promise<Result<FileTree.IInMemoryFile<TCT>[]>> {
|
|
486
|
-
const files: FileTree.IInMemoryFile<TCT>[] = [];
|
|
487
|
-
|
|
488
|
-
try {
|
|
489
|
-
for await (const entry of handle.values()) {
|
|
490
|
-
if (isFileHandle(entry)) {
|
|
491
|
-
const file = await entry.getFile();
|
|
492
|
-
const contents = await file.text();
|
|
493
|
-
const path = this._normalizePath(basePath, entry.name);
|
|
494
|
-
const contentType = params?.inferContentType?.(path).orDefault();
|
|
495
|
-
|
|
496
|
-
files.push({
|
|
497
|
-
path,
|
|
498
|
-
contents,
|
|
499
|
-
contentType
|
|
500
|
-
});
|
|
501
|
-
} else if (isDirectoryHandle(entry) && recursive) {
|
|
502
|
-
const subDirPath = this._normalizePath(basePath, entry.name);
|
|
503
|
-
const subdirResult = await this._processDirectoryHandle<TCT>(entry, subDirPath, recursive, params);
|
|
504
|
-
if (subdirResult.isFailure()) {
|
|
505
|
-
return subdirResult;
|
|
506
|
-
}
|
|
507
|
-
files.push(...subdirResult.value);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
return succeed(files);
|
|
512
|
-
} catch (error) {
|
|
513
|
-
/* c8 ignore next 1 - defense in depth */
|
|
514
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
515
|
-
return fail(`Failed to process directory ${handle.name}: ${message}`);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
private static _normalizePath(prefix: string, path: string): string {
|
|
520
|
-
// Remove leading slash from prefix if it exists to avoid double slashes
|
|
521
|
-
const cleanPrefix = prefix ? prefix.replace(/^\/+/, '') : '';
|
|
522
|
-
const combined = cleanPrefix ? `${cleanPrefix}/${path}` : path;
|
|
523
|
-
// Normalize multiple slashes and ensure it starts with / for FileTree compatibility
|
|
524
|
-
const normalized = combined.replace(/\/+/g, '/').replace(/\/$/, '');
|
|
525
|
-
/* c8 ignore next 1 - tested but coverage intermittently missed */
|
|
526
|
-
return normalized.startsWith('/') ? normalized : `/${normalized}`;
|
|
527
|
-
}
|
|
528
|
-
}
|