@fgv/ts-res 5.0.0-16 → 5.0.0-17
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/ts-res.d.ts +461 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +3 -1
- package/lib/packlets/zip-archive/convert.d.ts +52 -0
- package/lib/packlets/zip-archive/convert.js +104 -0
- package/lib/packlets/zip-archive/index.d.ts +23 -0
- package/lib/packlets/zip-archive/index.js +95 -0
- package/lib/packlets/zip-archive/json.d.ts +64 -0
- package/lib/packlets/zip-archive/json.js +24 -0
- package/lib/packlets/zip-archive/types.d.ts +98 -0
- package/lib/packlets/zip-archive/types.js +39 -0
- package/lib/packlets/zip-archive/zipArchiveCreator.d.ts +35 -0
- package/lib/packlets/zip-archive/zipArchiveCreator.js +194 -0
- package/lib/packlets/zip-archive/zipArchiveFormat.d.ts +70 -0
- package/lib/packlets/zip-archive/zipArchiveFormat.js +184 -0
- package/lib/packlets/zip-archive/zipArchiveLoader.d.ts +70 -0
- package/lib/packlets/zip-archive/zipArchiveLoader.js +289 -0
- package/lib/test/unit/zip-archive/convert.test.d.ts +2 -0
- package/lib/test/unit/zip-archive/json.test.d.ts +2 -0
- package/lib/test/unit/zip-archive/zipArchiveCreator.test.d.ts +2 -0
- package/lib/test/unit/zip-archive/zipArchiveFormat.test.d.ts +2 -0
- package/lib/test/unit/zip-archive/zipArchiveIdempotency.test.d.ts +2 -0
- package/lib/test/unit/zip-archive/zipArchiveLoader.test.d.ts +2 -0
- package/package.json +8 -7
- package/src/index.ts +3 -1
- package/src/packlets/zip-archive/convert.ts +121 -0
- package/src/packlets/zip-archive/index.ts +76 -0
- package/src/packlets/zip-archive/json.ts +91 -0
- package/src/packlets/zip-archive/types.ts +140 -0
- package/src/packlets/zip-archive/zipArchiveCreator.ts +229 -0
- package/src/packlets/zip-archive/zipArchiveFormat.ts +158 -0
- package/src/packlets/zip-archive/zipArchiveLoader.ts +374 -0
package/dist/ts-res.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { ResultMap } from '@fgv/ts-utils';
|
|
|
14
14
|
import { ValidatingCollector } from '@fgv/ts-utils';
|
|
15
15
|
import { ValidatingConvertingCollector } from '@fgv/ts-utils';
|
|
16
16
|
import { ValidatingResultMap } from '@fgv/ts-utils';
|
|
17
|
+
import { Validator } from '@fgv/ts-utils';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* An abstract decision represents a class of decisions with candidates
|
|
@@ -2099,6 +2100,20 @@ declare namespace Convert_11 {
|
|
|
2099
2100
|
}
|
|
2100
2101
|
}
|
|
2101
2102
|
|
|
2103
|
+
declare namespace Convert_12 {
|
|
2104
|
+
export {
|
|
2105
|
+
zipArchiveInputType,
|
|
2106
|
+
zipArchiveConfigType,
|
|
2107
|
+
zipArchiveInputInfo,
|
|
2108
|
+
zipArchiveConfigInfo,
|
|
2109
|
+
zipArchiveManifest,
|
|
2110
|
+
mimeType,
|
|
2111
|
+
importedFile,
|
|
2112
|
+
importedDirectory,
|
|
2113
|
+
systemConfiguration_2 as systemConfiguration
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2102
2117
|
declare namespace Convert_2 {
|
|
2103
2118
|
export {
|
|
2104
2119
|
languageQualifierTypeConfig,
|
|
@@ -2221,6 +2236,17 @@ declare function createQualifierTypeFromSystemConfig(typeConfig: Config_2.ISyste
|
|
|
2221
2236
|
*/
|
|
2222
2237
|
declare function createResourceTypeFromConfig(config: IResourceTypeConfig): Result<ResourceType>;
|
|
2223
2238
|
|
|
2239
|
+
/**
|
|
2240
|
+
* Create a ZIP archive manifest object
|
|
2241
|
+
* @param inputType - Type of input (file or directory)
|
|
2242
|
+
* @param originalPath - Original file/directory path
|
|
2243
|
+
* @param archivePath - Path within the archive
|
|
2244
|
+
* @param configPath - Optional configuration file path
|
|
2245
|
+
* @returns ZIP archive manifest
|
|
2246
|
+
* @public
|
|
2247
|
+
*/
|
|
2248
|
+
declare function createZipArchiveManifest(inputType: 'file' | 'directory', originalPath: string, archivePath: string, configPath?: string): Json_2.IZipArchiveManifest;
|
|
2249
|
+
|
|
2224
2250
|
/**
|
|
2225
2251
|
* Simple collectible implementation of {@link Decisions.IDecision | IDecision}.
|
|
2226
2252
|
* @public
|
|
@@ -2533,6 +2559,22 @@ declare class FsItemImporter implements IImporter {
|
|
|
2533
2559
|
*/
|
|
2534
2560
|
declare type FsItemResultDetail = 'failed' | 'skipped' | 'succeeded';
|
|
2535
2561
|
|
|
2562
|
+
/**
|
|
2563
|
+
* Generate a timestamp-based filename for ZIP archives
|
|
2564
|
+
* @param customName - Optional custom name prefix
|
|
2565
|
+
* @returns Generated filename
|
|
2566
|
+
* @public
|
|
2567
|
+
*/
|
|
2568
|
+
declare function generateZipArchiveFilename(customName?: string): string;
|
|
2569
|
+
|
|
2570
|
+
/**
|
|
2571
|
+
* Extract directory name from a file path
|
|
2572
|
+
* @param path - File path
|
|
2573
|
+
* @returns Directory name
|
|
2574
|
+
* @public
|
|
2575
|
+
*/
|
|
2576
|
+
declare function getDirectoryName(path: string): string;
|
|
2577
|
+
|
|
2536
2578
|
/**
|
|
2537
2579
|
* Gets the name for a resource ID.
|
|
2538
2580
|
* @param id - The resource ID to get the name for.
|
|
@@ -3612,6 +3654,46 @@ declare interface IImportContext {
|
|
|
3612
3654
|
readonly conditions?: ReadonlyArray<IConditionDecl>;
|
|
3613
3655
|
}
|
|
3614
3656
|
|
|
3657
|
+
/**
|
|
3658
|
+
* JSON representation of an imported directory structure
|
|
3659
|
+
* @public
|
|
3660
|
+
*/
|
|
3661
|
+
declare interface IImportedDirectory {
|
|
3662
|
+
/** Directory name */
|
|
3663
|
+
name: string;
|
|
3664
|
+
/** Files in this directory */
|
|
3665
|
+
files: IImportedFile[];
|
|
3666
|
+
/** Subdirectories */
|
|
3667
|
+
subdirectories: IImportedDirectory[];
|
|
3668
|
+
}
|
|
3669
|
+
|
|
3670
|
+
/**
|
|
3671
|
+
* Imported directory structure
|
|
3672
|
+
* @public
|
|
3673
|
+
*/
|
|
3674
|
+
declare type IImportedDirectory_2 = Json_2.IImportedDirectory;
|
|
3675
|
+
|
|
3676
|
+
/**
|
|
3677
|
+
* JSON representation of an imported file
|
|
3678
|
+
* @public
|
|
3679
|
+
*/
|
|
3680
|
+
declare interface IImportedFile {
|
|
3681
|
+
/** File name */
|
|
3682
|
+
name: string;
|
|
3683
|
+
/** Full path within archive */
|
|
3684
|
+
path: string;
|
|
3685
|
+
/** File content as string */
|
|
3686
|
+
content: string;
|
|
3687
|
+
/** MIME type */
|
|
3688
|
+
type: string;
|
|
3689
|
+
}
|
|
3690
|
+
|
|
3691
|
+
/**
|
|
3692
|
+
* Imported file representation
|
|
3693
|
+
* @public
|
|
3694
|
+
*/
|
|
3695
|
+
declare type IImportedFile_2 = Json_2.IImportedFile;
|
|
3696
|
+
|
|
3615
3697
|
/**
|
|
3616
3698
|
* Generic interface for an importer than accepts a typed
|
|
3617
3699
|
* {@link Import.IImportable | importable} item, extracts any resources
|
|
@@ -4068,6 +4150,19 @@ declare class ImportContext implements IValidatedImportContext {
|
|
|
4068
4150
|
static forContainerImport(container?: ResourceJson.Normalized.IContainerContextDecl, importer?: ImportContext): Result<ImportContext | undefined>;
|
|
4069
4151
|
}
|
|
4070
4152
|
|
|
4153
|
+
/**
|
|
4154
|
+
* Converter for imported directory structure (recursive)
|
|
4155
|
+
* Note: Uses Converter pattern because Validators don't support recursion with self parameter
|
|
4156
|
+
* @public
|
|
4157
|
+
*/
|
|
4158
|
+
declare const importedDirectory: Converter<Json_2.IImportedDirectory>;
|
|
4159
|
+
|
|
4160
|
+
/**
|
|
4161
|
+
* Converter for imported file
|
|
4162
|
+
* @public
|
|
4163
|
+
*/
|
|
4164
|
+
declare const importedFile: Converter<Json_2.IImportedFile>;
|
|
4165
|
+
|
|
4071
4166
|
/**
|
|
4072
4167
|
* `Converter` for a normalized {@link ResourceJson.Normalized.IImporterResourceCandidateDecl | importer resource candidate declaration}.
|
|
4073
4168
|
* @public
|
|
@@ -5402,6 +5497,14 @@ declare interface ISystemTerritoryQualifierTypeConfig extends IQualifierTypeConf
|
|
|
5402
5497
|
systemType: 'territory';
|
|
5403
5498
|
}
|
|
5404
5499
|
|
|
5500
|
+
/**
|
|
5501
|
+
* Validate ZIP file extension
|
|
5502
|
+
* @param filename - Filename to validate
|
|
5503
|
+
* @returns True if filename has .zip extension
|
|
5504
|
+
* @public
|
|
5505
|
+
*/
|
|
5506
|
+
declare function isZipFile(filename: string): boolean;
|
|
5507
|
+
|
|
5405
5508
|
/**
|
|
5406
5509
|
* Configuration for {@link QualifierTypes.TerritoryQualifierType | territory qualifier type} configuration.
|
|
5407
5510
|
* @public
|
|
@@ -5575,6 +5678,111 @@ declare interface IValidatingSimpleContextQualifierProviderCreateParams {
|
|
|
5575
5678
|
qualifierValues?: Record<string, string>;
|
|
5576
5679
|
}
|
|
5577
5680
|
|
|
5681
|
+
/**
|
|
5682
|
+
* JSON representation of ZIP archive config information
|
|
5683
|
+
* @public
|
|
5684
|
+
*/
|
|
5685
|
+
declare interface IZipArchiveConfigInfo {
|
|
5686
|
+
/** Type of config (always 'file') */
|
|
5687
|
+
type: 'file';
|
|
5688
|
+
/** Original config file path */
|
|
5689
|
+
originalPath: string;
|
|
5690
|
+
/** Path within the archive (e.g., "config.json") */
|
|
5691
|
+
archivePath: string;
|
|
5692
|
+
}
|
|
5693
|
+
|
|
5694
|
+
/**
|
|
5695
|
+
* Options for creating a ZIP archive buffer from a file tree
|
|
5696
|
+
* @public
|
|
5697
|
+
*/
|
|
5698
|
+
declare interface IZipArchiveFileTreeOptions {
|
|
5699
|
+
/** Input file or directory */
|
|
5700
|
+
inputItem?: FileTree.FileTreeItem;
|
|
5701
|
+
/** Optional configuration file */
|
|
5702
|
+
configItem?: FileTree.IFileTreeFileItem;
|
|
5703
|
+
}
|
|
5704
|
+
|
|
5705
|
+
/**
|
|
5706
|
+
* JSON representation of ZIP archive input information
|
|
5707
|
+
* @public
|
|
5708
|
+
*/
|
|
5709
|
+
declare interface IZipArchiveInputInfo {
|
|
5710
|
+
/** Type of input (file or directory) */
|
|
5711
|
+
type: 'file' | 'directory';
|
|
5712
|
+
/** Original file/directory path */
|
|
5713
|
+
originalPath: string;
|
|
5714
|
+
/** Path within the archive (e.g., "input/mydir") */
|
|
5715
|
+
archivePath: string;
|
|
5716
|
+
}
|
|
5717
|
+
|
|
5718
|
+
/**
|
|
5719
|
+
* Options for loading a ZIP archive
|
|
5720
|
+
* @public
|
|
5721
|
+
*/
|
|
5722
|
+
declare interface IZipArchiveLoadOptions {
|
|
5723
|
+
/** Validate manifest strictly */
|
|
5724
|
+
strictManifestValidation?: boolean;
|
|
5725
|
+
}
|
|
5726
|
+
|
|
5727
|
+
/**
|
|
5728
|
+
* Result of ZIP archive loading
|
|
5729
|
+
* @public
|
|
5730
|
+
*/
|
|
5731
|
+
declare interface IZipArchiveLoadResult {
|
|
5732
|
+
/** Parsed archive manifest */
|
|
5733
|
+
manifest: IZipArchiveManifest_2 | undefined;
|
|
5734
|
+
/** Loaded configuration */
|
|
5735
|
+
config: Model.ISystemConfiguration | undefined;
|
|
5736
|
+
/** All files extracted from the archive */
|
|
5737
|
+
files: IImportedFile_2[];
|
|
5738
|
+
/** Directory structure if available */
|
|
5739
|
+
directory: IImportedDirectory_2 | undefined;
|
|
5740
|
+
}
|
|
5741
|
+
|
|
5742
|
+
/**
|
|
5743
|
+
* JSON representation of a ZIP archive manifest
|
|
5744
|
+
* Compatible with existing tools from ts-res-browser-cli
|
|
5745
|
+
* @public
|
|
5746
|
+
*/
|
|
5747
|
+
declare interface IZipArchiveManifest {
|
|
5748
|
+
/** Archive creation timestamp */
|
|
5749
|
+
timestamp: string;
|
|
5750
|
+
/** Optional input source information */
|
|
5751
|
+
input?: IZipArchiveInputInfo;
|
|
5752
|
+
/** Optional configuration file information */
|
|
5753
|
+
config?: IZipArchiveConfigInfo;
|
|
5754
|
+
}
|
|
5755
|
+
|
|
5756
|
+
/**
|
|
5757
|
+
* Standardized ZIP archive manifest format (compatible with existing tools)
|
|
5758
|
+
* @public
|
|
5759
|
+
*/
|
|
5760
|
+
declare type IZipArchiveManifest_2 = Json_2.IZipArchiveManifest;
|
|
5761
|
+
|
|
5762
|
+
/**
|
|
5763
|
+
* Options for creating a ZIP archive buffer
|
|
5764
|
+
* @public
|
|
5765
|
+
*/
|
|
5766
|
+
declare interface IZipArchivePathOptions {
|
|
5767
|
+
/** File or directory path to include in the archive */
|
|
5768
|
+
inputPath?: string;
|
|
5769
|
+
/** Optional configuration file path */
|
|
5770
|
+
configPath?: string;
|
|
5771
|
+
}
|
|
5772
|
+
|
|
5773
|
+
/**
|
|
5774
|
+
* Result of ZIP archive buffer creation
|
|
5775
|
+
* @public
|
|
5776
|
+
*/
|
|
5777
|
+
declare interface IZipArchiveResult {
|
|
5778
|
+
/** Raw ZIP data buffer */
|
|
5779
|
+
zipBuffer: Uint8Array;
|
|
5780
|
+
/** Archive manifest with metadata */
|
|
5781
|
+
manifest: IZipArchiveManifest_2;
|
|
5782
|
+
/** Total ZIP size in bytes */
|
|
5783
|
+
size: number;
|
|
5784
|
+
}
|
|
5785
|
+
|
|
5578
5786
|
/**
|
|
5579
5787
|
* Joins a list of {@link ResourceId | resource ID} or {@link ResourceName | resource name} with
|
|
5580
5788
|
* to create a new {@link ResourceId | resource ID}. Returns `undefined` if no names are defined.
|
|
@@ -5622,6 +5830,16 @@ declare namespace Json {
|
|
|
5622
5830
|
}
|
|
5623
5831
|
}
|
|
5624
5832
|
|
|
5833
|
+
declare namespace Json_2 {
|
|
5834
|
+
export {
|
|
5835
|
+
IZipArchiveInputInfo,
|
|
5836
|
+
IZipArchiveConfigInfo,
|
|
5837
|
+
IZipArchiveManifest,
|
|
5838
|
+
IImportedFile,
|
|
5839
|
+
IImportedDirectory
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
|
|
5625
5843
|
/**
|
|
5626
5844
|
* {@link Import.Importers.IImporter | Importer} implementation which imports resources from a JSON object.
|
|
5627
5845
|
* @public
|
|
@@ -6090,6 +6308,12 @@ declare function mergeLooseCandidate(candidate: Normalized.IImporterResourceCand
|
|
|
6090
6308
|
*/
|
|
6091
6309
|
declare function mergeLooseResource(resource: Normalized.IImporterResourceDecl, baseName?: string, baseConditions?: ReadonlyArray<Json.ILooseConditionDecl>): Result<Normalized.ILooseResourceDecl>;
|
|
6092
6310
|
|
|
6311
|
+
/**
|
|
6312
|
+
* Validator for MIME type strings
|
|
6313
|
+
* @public
|
|
6314
|
+
*/
|
|
6315
|
+
declare const mimeType: Validator<string>;
|
|
6316
|
+
|
|
6093
6317
|
/**
|
|
6094
6318
|
* Minimum valid priority for a condition.
|
|
6095
6319
|
* @public
|
|
@@ -6193,6 +6417,14 @@ declare namespace Normalized {
|
|
|
6193
6417
|
}
|
|
6194
6418
|
}
|
|
6195
6419
|
|
|
6420
|
+
/**
|
|
6421
|
+
* Normalize path separators for cross-platform compatibility
|
|
6422
|
+
* @param path - Path to normalize
|
|
6423
|
+
* @returns Normalized path
|
|
6424
|
+
* @public
|
|
6425
|
+
*/
|
|
6426
|
+
declare function normalizePath(path: string): string;
|
|
6427
|
+
|
|
6196
6428
|
/**
|
|
6197
6429
|
* Overall cache metrics across all cache types.
|
|
6198
6430
|
* @public
|
|
@@ -6247,6 +6479,22 @@ declare function parseQualifierDefaultValuesTokenParts(token: string): Result<IQ
|
|
|
6247
6479
|
*/
|
|
6248
6480
|
declare function parseQualifierDefaultValueTokenParts(token: string): Result<IQualifierDefaultValueTokenParts>;
|
|
6249
6481
|
|
|
6482
|
+
/**
|
|
6483
|
+
* Parse and validate configuration JSON
|
|
6484
|
+
* @param configData - JSON string containing configuration
|
|
6485
|
+
* @returns Result containing validated configuration
|
|
6486
|
+
* @public
|
|
6487
|
+
*/
|
|
6488
|
+
declare function parseZipArchiveConfiguration(configData: string): Result<Model.ISystemConfiguration>;
|
|
6489
|
+
|
|
6490
|
+
/**
|
|
6491
|
+
* Parse and validate a ZIP archive manifest
|
|
6492
|
+
* @param manifestData - JSON string containing manifest data
|
|
6493
|
+
* @returns Result containing validated manifest
|
|
6494
|
+
* @public
|
|
6495
|
+
*/
|
|
6496
|
+
declare function parseZipArchiveManifest(manifestData: string): Result<Json_2.IZipArchiveManifest>;
|
|
6497
|
+
|
|
6250
6498
|
/**
|
|
6251
6499
|
* {@link Import.Importers.IImporter | Importer} implementation which imports resources from a `FileTree`
|
|
6252
6500
|
* given a path.
|
|
@@ -8400,6 +8648,14 @@ declare namespace Runtime {
|
|
|
8400
8648
|
}
|
|
8401
8649
|
export { Runtime }
|
|
8402
8650
|
|
|
8651
|
+
/**
|
|
8652
|
+
* Create a safe filename by removing invalid characters
|
|
8653
|
+
* @param filename - Original filename
|
|
8654
|
+
* @returns Sanitized filename
|
|
8655
|
+
* @public
|
|
8656
|
+
*/
|
|
8657
|
+
declare function sanitizeFilename(filename: string): string;
|
|
8658
|
+
|
|
8403
8659
|
/**
|
|
8404
8660
|
* @internal
|
|
8405
8661
|
*/
|
|
@@ -8577,6 +8833,13 @@ declare class SystemConfiguration {
|
|
|
8577
8833
|
*/
|
|
8578
8834
|
declare const systemConfiguration: ObjectConverter<ISystemConfiguration, unknown>;
|
|
8579
8835
|
|
|
8836
|
+
/**
|
|
8837
|
+
* Validator for system configuration (delegates to config packlet)
|
|
8838
|
+
* This validates that the parsed JSON conforms to the system configuration schema
|
|
8839
|
+
* @public
|
|
8840
|
+
*/
|
|
8841
|
+
declare const systemConfiguration_2: Validator<Model.ISystemConfiguration>;
|
|
8842
|
+
|
|
8580
8843
|
/**
|
|
8581
8844
|
* A `Converter` for {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | SystemLanguageQualifierTypeConfig} objects.
|
|
8582
8845
|
* @returns A `Converter` for {@link QualifierTypes.Config.ISystemLanguageQualifierTypeConfig | SystemLanguageQualifierTypeConfig} objects.
|
|
@@ -9057,6 +9320,14 @@ declare const validatedContextQualifierValueDecl: Converter<IValidatedContextQua
|
|
|
9057
9320
|
*/
|
|
9058
9321
|
declare const validatedQualifierDecl: Converter<IValidatedQualifierDecl, IQualifierDeclConvertContext>;
|
|
9059
9322
|
|
|
9323
|
+
/**
|
|
9324
|
+
* Validate a ZIP archive manifest object
|
|
9325
|
+
* @param manifest - Object to validate as manifest
|
|
9326
|
+
* @returns Result containing validated manifest
|
|
9327
|
+
* @public
|
|
9328
|
+
*/
|
|
9329
|
+
declare function validateZipArchiveManifest(manifest: unknown): Result<Json_2.IZipArchiveManifest>;
|
|
9330
|
+
|
|
9060
9331
|
/**
|
|
9061
9332
|
* A {@link Runtime.SimpleContextQualifierProvider | SimpleContextQualifierProvider} with a
|
|
9062
9333
|
* {@link Runtime.Context.ContextQualifierProviderValidator | validator} property that enables
|
|
@@ -9085,4 +9356,194 @@ declare class ValidatingSimpleContextQualifierProvider extends SimpleContextQual
|
|
|
9085
9356
|
static create(params: IValidatingSimpleContextQualifierProviderCreateParams): Result<ValidatingSimpleContextQualifierProvider>;
|
|
9086
9357
|
}
|
|
9087
9358
|
|
|
9359
|
+
declare namespace ZipArchive {
|
|
9360
|
+
export {
|
|
9361
|
+
Json_2 as Json,
|
|
9362
|
+
Convert_12 as Convert,
|
|
9363
|
+
ZipArchiveCreator,
|
|
9364
|
+
ZipArchiveLoader,
|
|
9365
|
+
IZipArchivePathOptions,
|
|
9366
|
+
IZipArchiveFileTreeOptions,
|
|
9367
|
+
ZipArchiveOptions,
|
|
9368
|
+
IZipArchiveResult,
|
|
9369
|
+
IZipArchiveManifest_2 as IZipArchiveManifest,
|
|
9370
|
+
IZipArchiveLoadOptions,
|
|
9371
|
+
IZipArchiveLoadResult,
|
|
9372
|
+
IImportedFile_2 as IImportedFile,
|
|
9373
|
+
IImportedDirectory_2 as IImportedDirectory,
|
|
9374
|
+
ZipArchiveProgressCallback,
|
|
9375
|
+
createZipArchiveManifest,
|
|
9376
|
+
parseZipArchiveManifest,
|
|
9377
|
+
validateZipArchiveManifest,
|
|
9378
|
+
parseZipArchiveConfiguration,
|
|
9379
|
+
generateZipArchiveFilename,
|
|
9380
|
+
normalizePath,
|
|
9381
|
+
getDirectoryName,
|
|
9382
|
+
sanitizeFilename,
|
|
9383
|
+
isZipFile,
|
|
9384
|
+
ZipArchiveConstants
|
|
9385
|
+
}
|
|
9386
|
+
}
|
|
9387
|
+
export { ZipArchive }
|
|
9388
|
+
|
|
9389
|
+
/**
|
|
9390
|
+
* Validator for ZIP archive config information
|
|
9391
|
+
* @public
|
|
9392
|
+
*/
|
|
9393
|
+
declare const zipArchiveConfigInfo: Validator<Json_2.IZipArchiveConfigInfo>;
|
|
9394
|
+
|
|
9395
|
+
/**
|
|
9396
|
+
* Validator for ZIP archive config type
|
|
9397
|
+
* @public
|
|
9398
|
+
*/
|
|
9399
|
+
declare const zipArchiveConfigType: Validator<'file'>;
|
|
9400
|
+
|
|
9401
|
+
/**
|
|
9402
|
+
* Constants for ZIP archive structure
|
|
9403
|
+
* @public
|
|
9404
|
+
*/
|
|
9405
|
+
declare const ZipArchiveConstants: {
|
|
9406
|
+
/** Manifest file name */
|
|
9407
|
+
readonly MANIFEST_FILE: "manifest.json";
|
|
9408
|
+
/** Configuration file name */
|
|
9409
|
+
readonly CONFIG_FILE: "config.json";
|
|
9410
|
+
/** Input files directory */
|
|
9411
|
+
readonly INPUT_DIR: "input";
|
|
9412
|
+
/** Configuration files directory */
|
|
9413
|
+
readonly CONFIG_DIR: "config";
|
|
9414
|
+
};
|
|
9415
|
+
|
|
9416
|
+
/**
|
|
9417
|
+
* ZIP archive creator using fflate for universal compatibility
|
|
9418
|
+
* @public
|
|
9419
|
+
*/
|
|
9420
|
+
declare class ZipArchiveCreator {
|
|
9421
|
+
/**
|
|
9422
|
+
* Create a ZIP archive buffer from a supplied buffer
|
|
9423
|
+
* @param options - Input paths and configuration
|
|
9424
|
+
* @param onProgress - Optional progress callback
|
|
9425
|
+
* @returns Result containing ZIP buffer and manifest
|
|
9426
|
+
*/
|
|
9427
|
+
createFromBuffer(options: ZipArchiveOptions, onProgress?: ZipArchiveProgressCallback): Promise<Result<IZipArchiveResult>>;
|
|
9428
|
+
/**
|
|
9429
|
+
* Add a single FileTree item to the ZIP archive
|
|
9430
|
+
* @param files - ZIP files collection
|
|
9431
|
+
* @param fileItem - FileTree file item to add
|
|
9432
|
+
* @param archivePath - Path within the archive
|
|
9433
|
+
* @returns Result indicating success or failure
|
|
9434
|
+
*/
|
|
9435
|
+
private _addFileTreeItemToZip;
|
|
9436
|
+
/**
|
|
9437
|
+
* Add a directory recursively to the ZIP archive using FileTree
|
|
9438
|
+
* @param files - ZIP files collection
|
|
9439
|
+
* @param directoryItem - FileTree directory item to add
|
|
9440
|
+
* @param archivePrefix - Prefix path within the archive
|
|
9441
|
+
* @param onProgress - Optional progress callback
|
|
9442
|
+
* @returns Result indicating success or failure
|
|
9443
|
+
*/
|
|
9444
|
+
private _addDirectoryTreeToZip;
|
|
9445
|
+
private _getInputFileTreeItem;
|
|
9446
|
+
private _getConfigFileTreeItem;
|
|
9447
|
+
}
|
|
9448
|
+
|
|
9449
|
+
/**
|
|
9450
|
+
* Validator for ZIP archive input information
|
|
9451
|
+
* @public
|
|
9452
|
+
*/
|
|
9453
|
+
declare const zipArchiveInputInfo: Validator<Json_2.IZipArchiveInputInfo>;
|
|
9454
|
+
|
|
9455
|
+
/**
|
|
9456
|
+
* Validator for ZIP archive input type
|
|
9457
|
+
* @public
|
|
9458
|
+
*/
|
|
9459
|
+
declare const zipArchiveInputType: Validator<'file' | 'directory'>;
|
|
9460
|
+
|
|
9461
|
+
/**
|
|
9462
|
+
* ZIP archive loader extending ts-extras foundation
|
|
9463
|
+
* @public
|
|
9464
|
+
*/
|
|
9465
|
+
declare class ZipArchiveLoader {
|
|
9466
|
+
/**
|
|
9467
|
+
* Load ZIP archive from File object (Browser)
|
|
9468
|
+
* @param file - File object from file input
|
|
9469
|
+
* @param options - Loading options
|
|
9470
|
+
* @param onProgress - Optional progress callback
|
|
9471
|
+
* @returns Result containing loaded archive data
|
|
9472
|
+
*/
|
|
9473
|
+
loadFromFile(file: File, options?: IZipArchiveLoadOptions, onProgress?: ZipArchiveProgressCallback): Promise<Result<IZipArchiveLoadResult>>;
|
|
9474
|
+
/**
|
|
9475
|
+
* Load ZIP archive from ArrayBuffer (Universal)
|
|
9476
|
+
* @param buffer - ZIP data buffer
|
|
9477
|
+
* @param options - Loading options
|
|
9478
|
+
* @param onProgress - Optional progress callback
|
|
9479
|
+
* @returns Result containing loaded archive data
|
|
9480
|
+
*/
|
|
9481
|
+
loadFromBuffer(buffer: ArrayBuffer, options?: IZipArchiveLoadOptions, onProgress?: ZipArchiveProgressCallback): Promise<Result<IZipArchiveLoadResult>>;
|
|
9482
|
+
/**
|
|
9483
|
+
* Load manifest from ZIP using ZipFileTreeAccessors
|
|
9484
|
+
* @param zipAccessors - ZIP file tree accessors
|
|
9485
|
+
* @returns Result containing parsed manifest
|
|
9486
|
+
*/
|
|
9487
|
+
private _loadManifestFromAccessors;
|
|
9488
|
+
/**
|
|
9489
|
+
* Load configuration from ZIP using ZipFileTreeAccessors
|
|
9490
|
+
* @param zipAccessors - ZIP file tree accessors
|
|
9491
|
+
* @param manifest - Parsed manifest (may be undefined)
|
|
9492
|
+
* @param options - Loading options
|
|
9493
|
+
* @returns Result containing parsed configuration
|
|
9494
|
+
*/
|
|
9495
|
+
private _loadConfigurationFromAccessors;
|
|
9496
|
+
/**
|
|
9497
|
+
* Extract files and directory structure from ZIP
|
|
9498
|
+
* @param zipAccessors - ZIP file tree accessors
|
|
9499
|
+
* @param onProgress - Optional progress callback
|
|
9500
|
+
* @returns Result containing files and directory structure
|
|
9501
|
+
*/
|
|
9502
|
+
private _extractFilesFromAccessors;
|
|
9503
|
+
/**
|
|
9504
|
+
* Recursively process file tree items
|
|
9505
|
+
* @param zipAccessors - ZIP file tree accessors
|
|
9506
|
+
* @param currentPath - Current directory path
|
|
9507
|
+
* @param items - Items to process
|
|
9508
|
+
* @param files - Files collection
|
|
9509
|
+
* @param directories - Directories collection
|
|
9510
|
+
* @param onProgress - Optional progress callback
|
|
9511
|
+
* @param processed - Processing counter
|
|
9512
|
+
*/
|
|
9513
|
+
private _processFileTreeItems;
|
|
9514
|
+
/**
|
|
9515
|
+
* Build directory structure from files
|
|
9516
|
+
* @param files - Extracted files
|
|
9517
|
+
* @param directories - Directories map
|
|
9518
|
+
* @returns Root directory structure or null
|
|
9519
|
+
*/
|
|
9520
|
+
private _buildDirectoryStructure;
|
|
9521
|
+
/**
|
|
9522
|
+
* Get file MIME type based on extension
|
|
9523
|
+
* @param filename - Filename
|
|
9524
|
+
* @returns MIME type
|
|
9525
|
+
*/
|
|
9526
|
+
private _getFileType;
|
|
9527
|
+
}
|
|
9528
|
+
|
|
9529
|
+
/**
|
|
9530
|
+
* Validator for ZIP archive manifest
|
|
9531
|
+
* Compatible with existing tools from ts-res-browser-cli
|
|
9532
|
+
* @public
|
|
9533
|
+
*/
|
|
9534
|
+
declare const zipArchiveManifest: Validator<Json_2.IZipArchiveManifest>;
|
|
9535
|
+
|
|
9536
|
+
/**
|
|
9537
|
+
* Options for creating a ZIP archive buffer
|
|
9538
|
+
* @public
|
|
9539
|
+
*/
|
|
9540
|
+
declare type ZipArchiveOptions = IZipArchivePathOptions | IZipArchiveFileTreeOptions;
|
|
9541
|
+
|
|
9542
|
+
/**
|
|
9543
|
+
* Progress callback for ZIP operations
|
|
9544
|
+
* @public
|
|
9545
|
+
*/
|
|
9546
|
+
declare type ZipArchiveProgressCallback = (stage: 'reading-file' | 'parsing-zip' | 'loading-manifest' | 'loading-config' | 'extracting-files' | 'processing-resources' | 'creating-zip', progress: number, // 0-100
|
|
9547
|
+
details: string) => void;
|
|
9548
|
+
|
|
9088
9549
|
export { }
|
package/lib/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import * as Resources from './packlets/resources';
|
|
|
10
10
|
import * as ResourceTypes from './packlets/resource-types';
|
|
11
11
|
import * as Import from './packlets/import';
|
|
12
12
|
import * as Runtime from './packlets/runtime';
|
|
13
|
+
import * as ZipArchive from './packlets/zip-archive';
|
|
13
14
|
export * from './packlets/common';
|
|
14
15
|
import { Condition, ConditionSet } from './packlets/conditions';
|
|
15
16
|
import { Decision } from './packlets/decisions';
|
|
@@ -19,5 +20,5 @@ import { ResourceType } from './packlets/resource-types';
|
|
|
19
20
|
import { Resource, ResourceCandidate, ResourceManagerBuilder } from './packlets/resources';
|
|
20
21
|
import { IResourceManager, ResourceResolver } from './packlets/runtime';
|
|
21
22
|
import { BundleBuilder, BundleLoader } from './packlets/bundle';
|
|
22
|
-
export { Bundle, BundleBuilder, BundleLoader, Condition, Conditions, ConditionSet, Config, Context, Decision, Decisions, Import, IResourceManager, Qualifier, QualifierType, QualifierTypes, Qualifiers, Resource, ResourceCandidate, ResourceJson, ResourceResolver, ResourceManagerBuilder, ResourceType, ResourceTypes, Resources, Runtime };
|
|
23
|
+
export { Bundle, BundleBuilder, BundleLoader, Condition, Conditions, ConditionSet, Config, Context, Decision, Decisions, Import, IResourceManager, Qualifier, QualifierType, QualifierTypes, Qualifiers, Resource, ResourceCandidate, ResourceJson, ResourceResolver, ResourceManagerBuilder, ResourceType, ResourceTypes, Resources, Runtime, ZipArchive };
|
|
23
24
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -57,7 +57,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
57
57
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
58
58
|
};
|
|
59
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
-
exports.Runtime = exports.Resources = exports.ResourceTypes = exports.ResourceType = exports.ResourceManagerBuilder = exports.ResourceResolver = exports.ResourceJson = exports.ResourceCandidate = exports.Resource = exports.Qualifiers = exports.QualifierTypes = exports.QualifierType = exports.Qualifier = exports.Import = exports.Decisions = exports.Decision = exports.Context = exports.Config = exports.ConditionSet = exports.Conditions = exports.Condition = exports.BundleLoader = exports.BundleBuilder = exports.Bundle = void 0;
|
|
60
|
+
exports.ZipArchive = exports.Runtime = exports.Resources = exports.ResourceTypes = exports.ResourceType = exports.ResourceManagerBuilder = exports.ResourceResolver = exports.ResourceJson = exports.ResourceCandidate = exports.Resource = exports.Qualifiers = exports.QualifierTypes = exports.QualifierType = exports.Qualifier = exports.Import = exports.Decisions = exports.Decision = exports.Context = exports.Config = exports.ConditionSet = exports.Conditions = exports.Condition = exports.BundleLoader = exports.BundleBuilder = exports.Bundle = void 0;
|
|
61
61
|
const Bundle = __importStar(require("./packlets/bundle"));
|
|
62
62
|
exports.Bundle = Bundle;
|
|
63
63
|
const QualifierTypes = __importStar(require("./packlets/qualifier-types"));
|
|
@@ -82,6 +82,8 @@ const Import = __importStar(require("./packlets/import"));
|
|
|
82
82
|
exports.Import = Import;
|
|
83
83
|
const Runtime = __importStar(require("./packlets/runtime"));
|
|
84
84
|
exports.Runtime = Runtime;
|
|
85
|
+
const ZipArchive = __importStar(require("./packlets/zip-archive"));
|
|
86
|
+
exports.ZipArchive = ZipArchive;
|
|
85
87
|
__exportStar(require("./packlets/common"), exports);
|
|
86
88
|
const conditions_1 = require("./packlets/conditions");
|
|
87
89
|
Object.defineProperty(exports, "Condition", { enumerable: true, get: function () { return conditions_1.Condition; } });
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Validator, Converter } from '@fgv/ts-utils';
|
|
2
|
+
import * as Json from './json';
|
|
3
|
+
import { Model as ConfigModel } from '../config';
|
|
4
|
+
/**
|
|
5
|
+
* Validator for ZIP archive input type
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare const zipArchiveInputType: Validator<'file' | 'directory'>;
|
|
9
|
+
/**
|
|
10
|
+
* Validator for ZIP archive config type
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const zipArchiveConfigType: Validator<'file'>;
|
|
14
|
+
/**
|
|
15
|
+
* Validator for ZIP archive input information
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export declare const zipArchiveInputInfo: Validator<Json.IZipArchiveInputInfo>;
|
|
19
|
+
/**
|
|
20
|
+
* Validator for ZIP archive config information
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare const zipArchiveConfigInfo: Validator<Json.IZipArchiveConfigInfo>;
|
|
24
|
+
/**
|
|
25
|
+
* Validator for ZIP archive manifest
|
|
26
|
+
* Compatible with existing tools from ts-res-browser-cli
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare const zipArchiveManifest: Validator<Json.IZipArchiveManifest>;
|
|
30
|
+
/**
|
|
31
|
+
* Validator for MIME type strings
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare const mimeType: Validator<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Converter for imported file
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare const importedFile: Converter<Json.IImportedFile>;
|
|
40
|
+
/**
|
|
41
|
+
* Converter for imported directory structure (recursive)
|
|
42
|
+
* Note: Uses Converter pattern because Validators don't support recursion with self parameter
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export declare const importedDirectory: Converter<Json.IImportedDirectory>;
|
|
46
|
+
/**
|
|
47
|
+
* Validator for system configuration (delegates to config packlet)
|
|
48
|
+
* This validates that the parsed JSON conforms to the system configuration schema
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export declare const systemConfiguration: Validator<ConfigModel.ISystemConfiguration>;
|
|
52
|
+
//# sourceMappingURL=convert.d.ts.map
|