@fgv/ts-extras 5.1.0-45 → 5.1.0-47

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.
Files changed (141) hide show
  1. package/README.md +90 -0
  2. package/dist/index.browser.js +3 -1
  3. package/dist/index.browser.js.map +1 -1
  4. package/dist/index.js +2 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/packlets/ai-assist/index.js +1 -1
  7. package/dist/packlets/ai-assist/index.js.map +1 -1
  8. package/dist/packlets/ai-assist/jsonResponse.js +270 -7
  9. package/dist/packlets/ai-assist/jsonResponse.js.map +1 -1
  10. package/dist/packlets/ai-assist/model.js +14 -0
  11. package/dist/packlets/ai-assist/model.js.map +1 -1
  12. package/dist/packlets/ai-assist/registry.js +57 -14
  13. package/dist/packlets/ai-assist/registry.js.map +1 -1
  14. package/dist/packlets/safer-fetch/addressClassification.js +438 -0
  15. package/dist/packlets/safer-fetch/addressClassification.js.map +1 -0
  16. package/dist/packlets/safer-fetch/addressPolicy.js +119 -0
  17. package/dist/packlets/safer-fetch/addressPolicy.js.map +1 -0
  18. package/dist/packlets/safer-fetch/contentType.js +120 -0
  19. package/dist/packlets/safer-fetch/contentType.js.map +1 -0
  20. package/dist/packlets/safer-fetch/deadline.js +254 -0
  21. package/dist/packlets/safer-fetch/deadline.js.map +1 -0
  22. package/dist/packlets/safer-fetch/defaults.js +131 -0
  23. package/dist/packlets/safer-fetch/defaults.js.map +1 -0
  24. package/dist/packlets/safer-fetch/failureReason.js +21 -0
  25. package/dist/packlets/safer-fetch/failureReason.js.map +1 -0
  26. package/dist/packlets/safer-fetch/guards.js +148 -0
  27. package/dist/packlets/safer-fetch/guards.js.map +1 -0
  28. package/dist/packlets/safer-fetch/index.browser.js +58 -0
  29. package/dist/packlets/safer-fetch/index.browser.js.map +1 -0
  30. package/dist/packlets/safer-fetch/index.js +52 -0
  31. package/dist/packlets/safer-fetch/index.js.map +1 -0
  32. package/dist/packlets/safer-fetch/model.js +21 -0
  33. package/dist/packlets/safer-fetch/model.js.map +1 -0
  34. package/dist/packlets/safer-fetch/nodeAddressGuard.js +191 -0
  35. package/dist/packlets/safer-fetch/nodeAddressGuard.js.map +1 -0
  36. package/dist/packlets/safer-fetch/redirect.js +93 -0
  37. package/dist/packlets/safer-fetch/redirect.js.map +1 -0
  38. package/dist/packlets/safer-fetch/retry.js +188 -0
  39. package/dist/packlets/safer-fetch/retry.js.map +1 -0
  40. package/dist/packlets/safer-fetch/saferFetch.js +755 -0
  41. package/dist/packlets/safer-fetch/saferFetch.js.map +1 -0
  42. package/dist/packlets/safer-fetch/transport.js +50 -0
  43. package/dist/packlets/safer-fetch/transport.js.map +1 -0
  44. package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js +65 -7
  45. package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -1
  46. package/dist/packlets/zip-file-tree/zipFileTreeWriter.js +16 -1
  47. package/dist/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -1
  48. package/dist/ts-extras.d.ts +1590 -13
  49. package/lib/index.browser.d.ts +2 -1
  50. package/lib/index.browser.d.ts.map +1 -1
  51. package/lib/index.browser.js +4 -1
  52. package/lib/index.browser.js.map +1 -1
  53. package/lib/index.d.ts +2 -1
  54. package/lib/index.d.ts.map +1 -1
  55. package/lib/index.js +3 -1
  56. package/lib/index.js.map +1 -1
  57. package/lib/packlets/ai-assist/index.d.ts +1 -1
  58. package/lib/packlets/ai-assist/index.d.ts.map +1 -1
  59. package/lib/packlets/ai-assist/index.js +3 -2
  60. package/lib/packlets/ai-assist/index.js.map +1 -1
  61. package/lib/packlets/ai-assist/jsonResponse.d.ts +96 -0
  62. package/lib/packlets/ai-assist/jsonResponse.d.ts.map +1 -1
  63. package/lib/packlets/ai-assist/jsonResponse.js +271 -7
  64. package/lib/packlets/ai-assist/jsonResponse.js.map +1 -1
  65. package/lib/packlets/ai-assist/model.d.ts +43 -0
  66. package/lib/packlets/ai-assist/model.d.ts.map +1 -1
  67. package/lib/packlets/ai-assist/model.js +14 -0
  68. package/lib/packlets/ai-assist/model.js.map +1 -1
  69. package/lib/packlets/ai-assist/registry.d.ts +26 -6
  70. package/lib/packlets/ai-assist/registry.d.ts.map +1 -1
  71. package/lib/packlets/ai-assist/registry.js +57 -14
  72. package/lib/packlets/ai-assist/registry.js.map +1 -1
  73. package/lib/packlets/safer-fetch/addressClassification.d.ts +144 -0
  74. package/lib/packlets/safer-fetch/addressClassification.d.ts.map +1 -0
  75. package/lib/packlets/safer-fetch/addressClassification.js +441 -0
  76. package/lib/packlets/safer-fetch/addressClassification.js.map +1 -0
  77. package/lib/packlets/safer-fetch/addressPolicy.d.ts +113 -0
  78. package/lib/packlets/safer-fetch/addressPolicy.d.ts.map +1 -0
  79. package/lib/packlets/safer-fetch/addressPolicy.js +123 -0
  80. package/lib/packlets/safer-fetch/addressPolicy.js.map +1 -0
  81. package/lib/packlets/safer-fetch/contentType.d.ts +51 -0
  82. package/lib/packlets/safer-fetch/contentType.d.ts.map +1 -0
  83. package/lib/packlets/safer-fetch/contentType.js +127 -0
  84. package/lib/packlets/safer-fetch/contentType.js.map +1 -0
  85. package/lib/packlets/safer-fetch/deadline.d.ts +138 -0
  86. package/lib/packlets/safer-fetch/deadline.d.ts.map +1 -0
  87. package/lib/packlets/safer-fetch/deadline.js +258 -0
  88. package/lib/packlets/safer-fetch/deadline.js.map +1 -0
  89. package/lib/packlets/safer-fetch/defaults.d.ts +108 -0
  90. package/lib/packlets/safer-fetch/defaults.d.ts.map +1 -0
  91. package/lib/packlets/safer-fetch/defaults.js +134 -0
  92. package/lib/packlets/safer-fetch/defaults.js.map +1 -0
  93. package/lib/packlets/safer-fetch/failureReason.d.ts +148 -0
  94. package/lib/packlets/safer-fetch/failureReason.d.ts.map +1 -0
  95. package/lib/packlets/safer-fetch/failureReason.js +22 -0
  96. package/lib/packlets/safer-fetch/failureReason.js.map +1 -0
  97. package/lib/packlets/safer-fetch/guards.d.ts +62 -0
  98. package/lib/packlets/safer-fetch/guards.d.ts.map +1 -0
  99. package/lib/packlets/safer-fetch/guards.js +153 -0
  100. package/lib/packlets/safer-fetch/guards.js.map +1 -0
  101. package/lib/packlets/safer-fetch/index.browser.d.ts +33 -0
  102. package/lib/packlets/safer-fetch/index.browser.d.ts.map +1 -0
  103. package/lib/packlets/safer-fetch/index.browser.js +82 -0
  104. package/lib/packlets/safer-fetch/index.browser.js.map +1 -0
  105. package/lib/packlets/safer-fetch/index.d.ts +27 -0
  106. package/lib/packlets/safer-fetch/index.d.ts.map +1 -0
  107. package/lib/packlets/safer-fetch/index.js +78 -0
  108. package/lib/packlets/safer-fetch/index.js.map +1 -0
  109. package/lib/packlets/safer-fetch/model.d.ts +373 -0
  110. package/lib/packlets/safer-fetch/model.d.ts.map +1 -0
  111. package/lib/packlets/safer-fetch/model.js +22 -0
  112. package/lib/packlets/safer-fetch/model.js.map +1 -0
  113. package/lib/packlets/safer-fetch/nodeAddressGuard.d.ts +129 -0
  114. package/lib/packlets/safer-fetch/nodeAddressGuard.d.ts.map +1 -0
  115. package/lib/packlets/safer-fetch/nodeAddressGuard.js +196 -0
  116. package/lib/packlets/safer-fetch/nodeAddressGuard.js.map +1 -0
  117. package/lib/packlets/safer-fetch/redirect.d.ts +62 -0
  118. package/lib/packlets/safer-fetch/redirect.d.ts.map +1 -0
  119. package/lib/packlets/safer-fetch/redirect.js +98 -0
  120. package/lib/packlets/safer-fetch/redirect.js.map +1 -0
  121. package/lib/packlets/safer-fetch/retry.d.ts +162 -0
  122. package/lib/packlets/safer-fetch/retry.d.ts.map +1 -0
  123. package/lib/packlets/safer-fetch/retry.js +197 -0
  124. package/lib/packlets/safer-fetch/retry.js.map +1 -0
  125. package/lib/packlets/safer-fetch/saferFetch.d.ts +108 -0
  126. package/lib/packlets/safer-fetch/saferFetch.d.ts.map +1 -0
  127. package/lib/packlets/safer-fetch/saferFetch.js +760 -0
  128. package/lib/packlets/safer-fetch/saferFetch.js.map +1 -0
  129. package/lib/packlets/safer-fetch/transport.d.ts +18 -0
  130. package/lib/packlets/safer-fetch/transport.d.ts.map +1 -0
  131. package/lib/packlets/safer-fetch/transport.js +53 -0
  132. package/lib/packlets/safer-fetch/transport.js.map +1 -0
  133. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts +54 -6
  134. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts.map +1 -1
  135. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js +65 -7
  136. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -1
  137. package/lib/packlets/zip-file-tree/zipFileTreeWriter.d.ts +26 -1
  138. package/lib/packlets/zip-file-tree/zipFileTreeWriter.d.ts.map +1 -1
  139. package/lib/packlets/zip-file-tree/zipFileTreeWriter.js +17 -1
  140. package/lib/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -1
  141. package/package.json +17 -7
@@ -1 +1 @@
1
- {"version":3,"file":"zipFileTreeAccessors.js","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/zipFileTreeAccessors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,mCAAoD;AACpD,4CAA2F;AAG3F;;;;;GAKG;AACH,MAAa,WAAW;IA0BtB;;OAEG;IACH,IAAW,WAAW;QACpB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,IAAI,IAAI,CAAC,uBAAuB,EAAE,CAAC;YACpE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,SAAS,EAAE,CAAC;YACtF,IAAI,CAAC,uBAAuB,GAAG,KAAK,CAAC;QACvC,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAsBD;;;;;OAKG;IACH,YAAmB,WAAmB,EAAE,QAAgB,EAAE,SAAoC;QA9D9F;;WAEG;QACa,SAAI,GAAW,MAAM,CAAC;QAgDtC;;WAEG;QACK,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ACrC,CAAC;CACF;AA3TD,oDA2TC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { unzipSync, unzip, Unzipped } from 'fflate';\nimport { Result, succeed, fail, captureResult, Converter, Validator } from '@fgv/ts-utils';\nimport { FileTree, JsonValue } from '@fgv/ts-json-base';\n\n/**\n * Implementation of `FileTree.IFileTreeFileItem` for files in a ZIP archive.\n * ZIP files are read-only, so this item does not support mutation.\n * Use {@link FileTree.isMutableFileItem | isMutableFileItem} to check before attempting mutations.\n * @public\n */\nexport class ZipFileItem<TCT extends string = string> implements FileTree.IFileTreeFileItem<TCT> {\n /**\n * Indicates that this `FileTree.FileTreeItem` is a file.\n */\n public readonly type: 'file' = 'file';\n\n /**\n * The absolute path of the file within the ZIP archive.\n */\n public readonly absolutePath: string;\n\n /**\n * The name of the file\n */\n public readonly name: string;\n\n /**\n * The base name of the file (without extension)\n */\n public readonly baseName: string;\n\n /**\n * The extension of the file\n */\n public readonly extension: string;\n\n /**\n * The content type of the file.\n */\n public get contentType(): TCT | undefined {\n if (this._contentType === undefined && this._shouldInferContentType) {\n this._contentType = this._accessors.getFileContentType(this.absolutePath).orDefault();\n this._shouldInferContentType = false;\n }\n return this._contentType;\n }\n\n /**\n * The pre-loaded contents of the file.\n */\n private readonly _contents: string;\n\n /**\n * The ZIP file tree accessors that created this item.\n */\n private readonly _accessors: ZipFileTreeAccessors<TCT>;\n\n /**\n * Mutable content type of the file.\n */\n private _contentType: TCT | undefined;\n\n /**\n * Flag to track if content type should be inferred on first access.\n */\n private _shouldInferContentType: boolean = true;\n\n /**\n * Constructor for ZipFileItem.\n * @param zipFilePath - The path of the file within the ZIP.\n * @param contents - The pre-loaded contents of the file.\n * @param accessors - The ZIP file tree accessors.\n */\n public constructor(zipFilePath: string, contents: string, accessors: ZipFileTreeAccessors<TCT>) {\n this._contents = contents;\n this._accessors = accessors;\n this.absolutePath = '/' + zipFilePath;\n this.name = accessors.getBaseName(zipFilePath);\n this.extension = accessors.getExtension(zipFilePath);\n this.baseName = accessors.getBaseName(zipFilePath, this.extension);\n }\n\n /**\n * Sets the content type of the file.\n * @param contentType - The content type of the file.\n */\n public setContentType(contentType: TCT | undefined): void {\n this._contentType = contentType;\n this._shouldInferContentType = false;\n }\n\n /**\n * Gets the contents of the file as parsed JSON.\n */\n public getContents(): Result<JsonValue>;\n public getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;\n public getContents<T>(converter?: Validator<T> | Converter<T>): Result<T | JsonValue> {\n return this.getRawContents()\n .onSuccess((contents) => {\n return captureResult(() => JSON.parse(contents))\n .onSuccess((parsed) => {\n if (converter) {\n return converter.convert(parsed) as Result<T | JsonValue>;\n }\n return succeed(parsed as JsonValue);\n })\n .onFailure(() => {\n return fail(`Failed to parse JSON from file: ${this.absolutePath}`);\n });\n })\n .onFailure((error) => {\n return fail(`Failed to get contents from file: ${error}`);\n });\n }\n\n /**\n * Gets the raw contents of the file as a string.\n */\n public getRawContents(): Result<string> {\n return succeed(this._contents);\n }\n}\n\n/**\n * Implementation of `IFileTreeDirectoryItem` for directories in a ZIP archive.\n * @public\n */\nexport class ZipDirectoryItem<TCT extends string = string> implements FileTree.IFileTreeDirectoryItem<TCT> {\n /**\n * Indicates that this `FileTree.FileTreeItem` is a directory.\n */\n public readonly type: 'directory' = 'directory';\n\n /**\n * The absolute path of the directory within the ZIP archive.\n */\n public readonly absolutePath: string;\n\n /**\n * The name of the directory\n */\n public readonly name: string;\n\n /**\n * The ZIP file tree accessors that created this item.\n */\n private readonly _accessors: ZipFileTreeAccessors<TCT>;\n\n /**\n * Constructor for ZipDirectoryItem.\n * @param directoryPath - The path of the directory within the ZIP.\n * @param accessors - The ZIP file tree accessors.\n */\n public constructor(directoryPath: string, accessors: ZipFileTreeAccessors<TCT>) {\n this._accessors = accessors;\n this.absolutePath = '/' + directoryPath.replace(/\\/$/, ''); // Normalize path\n this.name = accessors.getBaseName(directoryPath);\n }\n\n /**\n * Gets the children of the directory.\n */\n public getChildren(): Result<ReadonlyArray<FileTree.FileTreeItem<TCT>>> {\n return this._accessors.getChildren(this.absolutePath);\n }\n}\n\n/**\n * Read-only file tree accessors for ZIP archives.\n * ZIP archives are read-only by design — use {@link FileTree.isMutableAccessors | isMutableAccessors}\n * to check before attempting mutations.\n * @public\n */\nexport class ZipFileTreeAccessors<TCT extends string = string> implements FileTree.IFileTreeAccessors<TCT> {\n /**\n * The unzipped file data.\n */\n private readonly _files: Unzipped;\n\n /**\n * Optional prefix to prepend to paths.\n */\n private readonly _prefix: string;\n\n /**\n * Content type inference function.\n */\n private readonly _inferContentType: FileTree.ContentTypeFactory<TCT>;\n\n /**\n * Cache of all items in the ZIP for efficient lookups.\n */\n private readonly _itemCache: Map<string, FileTree.FileTreeItem<TCT>> = new Map();\n\n /**\n * Constructor for ZipFileTreeAccessors.\n * @param files - The unzipped file data from fflate.\n * @param params - Optional initialization parameters.\n */\n private constructor(files: Unzipped, params?: FileTree.IFileTreeInitParams<TCT>) {\n this._files = files;\n this._prefix = params?.prefix || '';\n this._inferContentType = params?.inferContentType ?? ZipFileTreeAccessors.defaultInferContentType;\n this._buildItemCache();\n }\n\n /**\n * Default function to infer the content type of a file.\n * @param __filePath - The path of the file.\n * @param __provided - Optional supplied content type.\n * @returns `Success` with the content type of the file if successful, or\n * `Failure` with an error message otherwise.\n * @remarks This default implementation always returns `Success` with `undefined`.\n * @public\n */\n public static defaultInferContentType<TCT extends string = string>(\n __filePath: string,\n __provided?: string\n ): Result<TCT | undefined> {\n return succeed(undefined);\n }\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param prefix - Optional prefix to prepend to paths.\n * @returns Result containing the ZipFileTreeAccessors instance.\n */\n public static fromBuffer<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n prefix?: string\n ): Result<ZipFileTreeAccessors<TCT>>;\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param params - Optional initialization parameters.\n * @returns Result containing the ZipFileTreeAccessors instance.\n */\n public static fromBuffer<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT>\n ): Result<ZipFileTreeAccessors<TCT>>;\n\n public static fromBuffer<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT> | string\n ): Result<ZipFileTreeAccessors<TCT>> {\n try {\n /* c8 ignore next 1 - defense in depth */\n const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);\n const files = unzipSync(uint8Buffer);\n const normalizedParams = typeof params === 'string' ? { prefix: params } : params;\n return succeed(new ZipFileTreeAccessors<TCT>(files, normalizedParams));\n } catch (error) {\n /* c8 ignore next 1 - defensive coding: fflate always throws Error objects in practice */\n return fail(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param prefix - Optional prefix to prepend to paths.\n * @returns Promise containing Result with the ZipFileTreeAccessors instance.\n */\n public static async fromBufferAsync<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n prefix?: string\n ): Promise<Result<ZipFileTreeAccessors<TCT>>>;\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param params - Optional initialization parameters.\n * @returns Promise containing Result with the ZipFileTreeAccessors instance.\n */\n public static async fromBufferAsync<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT>\n ): Promise<Result<ZipFileTreeAccessors<TCT>>>;\n\n public static async fromBufferAsync<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT> | string\n ): Promise<Result<ZipFileTreeAccessors<TCT>>> {\n return new Promise((resolve) => {\n try {\n /* c8 ignore next 1 - defense in depth */\n const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);\n unzip(uint8Buffer, (err, files) => {\n if (err) {\n resolve(fail(`Failed to load ZIP archive: ${err.message}`));\n } else {\n const normalizedParams = typeof params === 'string' ? { prefix: params } : params;\n resolve(succeed(new ZipFileTreeAccessors<TCT>(files, normalizedParams)));\n }\n });\n /* c8 ignore next 5 - defensive coding: fflate reports errors via callback, not exceptions */\n } catch (error) {\n resolve(\n fail(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`)\n );\n }\n });\n }\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a File object (browser environment).\n * @param file - The File object containing ZIP data.\n * @param params - Optional initialization parameters.\n * @returns Result containing the ZipFileTreeAccessors instance.\n */\n public static async fromFile<TCT extends string = string>(\n file: File,\n params?: FileTree.IFileTreeInitParams<TCT>\n ): Promise<Result<ZipFileTreeAccessors<TCT>>> {\n try {\n const arrayBuffer = await file.arrayBuffer();\n const uint8Buffer = new Uint8Array(arrayBuffer);\n\n return await ZipFileTreeAccessors.fromBufferAsync<TCT>(uint8Buffer, params);\n } catch (error) {\n return fail(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Builds the cache of all items in the ZIP archive.\n */\n private _buildItemCache(): void {\n const directories = new Set<string>();\n\n // Process all files and collect directory paths\n for (const [relativePath, fileData] of Object.entries(this._files)) {\n // Skip directories in fflate output (they have null data)\n /* c8 ignore next 5 - handles explicit directory entries from external ZIP tools (fflate doesn't create these) */\n if (fileData === null || fileData === undefined) {\n const dirPath = relativePath.replace(/\\/$/, '');\n if (dirPath) {\n directories.add(dirPath);\n }\n } else {\n // Extract directory paths from file paths\n const pathParts = relativePath.split('/');\n for (let i = 1; i < pathParts.length; i++) {\n const dirPath = pathParts.slice(0, i).join('/');\n if (dirPath) {\n directories.add(dirPath);\n }\n }\n\n // Add the file item with its contents\n const absolutePath = this.resolveAbsolutePath(relativePath);\n const contents = new TextDecoder().decode(fileData);\n const item = new ZipFileItem<TCT>(relativePath, contents, this);\n this._itemCache.set(absolutePath, item);\n }\n }\n\n // Add directory items to cache\n directories.forEach((dirPath) => {\n const absolutePath = this.resolveAbsolutePath(dirPath);\n const item = new ZipDirectoryItem<TCT>(dirPath, this);\n this._itemCache.set(absolutePath, item);\n });\n }\n\n /**\n * Resolves paths to an absolute path.\n */\n public resolveAbsolutePath(...paths: string[]): string {\n const joinedPath = this.joinPaths(...paths);\n const prefixed = this._prefix ? this.joinPaths(this._prefix, joinedPath) : joinedPath;\n return prefixed.startsWith('/') ? prefixed : '/' + prefixed;\n }\n\n /**\n * Gets the extension of a path.\n */\n public getExtension(path: string): string {\n const name = this.getBaseName(path);\n const lastDotIndex = name.lastIndexOf('.');\n return lastDotIndex >= 0 ? name.substring(lastDotIndex) : '';\n }\n\n /**\n * Gets the base name of a path.\n */\n public getBaseName(path: string, suffix?: string): string {\n const normalizedPath = path.replace(/\\/$/, ''); // Remove trailing slash\n const parts = normalizedPath.split('/');\n let baseName = parts[parts.length - 1] || '';\n\n if (suffix && baseName.endsWith(suffix)) {\n baseName = baseName.substring(0, baseName.length - suffix.length);\n }\n\n return baseName;\n }\n\n /**\n * Joins paths together.\n */\n public joinPaths(...paths: string[]): string {\n return paths\n .filter((p) => p && p.length > 0)\n .map((p) => p.replace(/^\\/+|\\/+$/g, '')) // Remove leading/trailing slashes\n .join('/')\n .replace(/\\/+/g, '/'); // Normalize multiple slashes\n }\n\n /**\n * Gets an item from the file tree.\n */\n public getItem(path: string): Result<FileTree.FileTreeItem<TCT>> {\n const absolutePath = this.resolveAbsolutePath(path);\n const item = this._itemCache.get(absolutePath);\n\n if (item) {\n return succeed(item);\n }\n\n return fail(`Item not found: ${absolutePath}`);\n }\n\n /**\n * Gets the contents of a file in the file tree.\n */\n public getFileContents(path: string): Result<string> {\n return this.getItem(path).onSuccess((item) => {\n if (item.type !== 'file') {\n return fail(`Path is not a file: ${path}`);\n }\n return item.getRawContents();\n });\n }\n\n /**\n * Gets the content type of a file in the file tree.\n */\n public getFileContentType(path: string, provided?: string): Result<TCT | undefined> {\n // If provided contentType is given, use it directly (highest priority)\n if (provided !== undefined) {\n return succeed(provided as TCT);\n }\n\n // For files that exist in the ZIP, we don't store explicit contentType\n // so we always fall back to inference\n return this._inferContentType(path);\n }\n\n /**\n * Gets the children of a directory in the file tree.\n */\n public getChildren(path: string): Result<ReadonlyArray<FileTree.FileTreeItem<TCT>>> {\n const absolutePath = this.resolveAbsolutePath(path);\n const children: FileTree.FileTreeItem<TCT>[] = [];\n\n // Find all items that are direct children of this directory\n for (const [itemPath, item] of this._itemCache) {\n if (this._isDirectChild(absolutePath, itemPath)) {\n children.push(item);\n }\n }\n\n return succeed(children);\n }\n\n /**\n * Checks if childPath is a direct child of parentPath.\n */\n private _isDirectChild(parentPath: string, childPath: string): boolean {\n // Normalize paths\n const normalizedParent = parentPath.replace(/\\/$/, '');\n const normalizedChild = childPath.replace(/\\/$/, '');\n\n // Child must start with parent path\n if (!normalizedChild.startsWith(normalizedParent + '/')) {\n return false;\n }\n\n // Get the relative path from parent to child\n const relativePath = normalizedChild.substring(normalizedParent.length + 1);\n\n // Direct child means no additional slashes in the relative path\n return !relativePath.includes('/');\n }\n}\n"]}
1
+ {"version":3,"file":"zipFileTreeAccessors.js","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/zipFileTreeAccessors.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;AAEH,mCAAoD;AACpD,4CAA2F;AAG3F;;;;;;;;;;;GAWG;AACH,MAAa,WAAW;IA0BtB;;OAEG;IACH,IAAW,WAAW;QACpB,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,IAAI,IAAI,CAAC,uBAAuB,EAAE,CAAC;YACpE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,SAAS,EAAE,CAAC;YACtF,IAAI,CAAC,uBAAuB,GAAG,KAAK,CAAC;QACvC,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IA2BD;;;;;;;OAOG;IACH,YACE,WAAmB,EACnB,QAA6B,EAC7B,SAAoC;QAxEtC;;WAEG;QACa,SAAI,GAAW,MAAM,CAAC;QAqDtC;;WAEG;QACK,4BAAuB,GAAY,IAAI,CAAC;QAe9C,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;YAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnD,CAAC;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C,QAAQ,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACK,cAAc,CAAC,UAAkB,EAAE,SAAiB;QAC1D,kBAAkB;QAClB,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACvD,MAAM,eAAe,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAErD,oCAAoC;QACpC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,gBAAgB,GAAG,GAAG,CAAC,EAAE,CAAC;YACxD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,6CAA6C;QAC7C,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE5E,gEAAgE;QAChE,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;CACF;AAnVD,oDAmVC","sourcesContent":["/*\n * Copyright (c) 2025 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { unzipSync, unzip, Unzipped } from 'fflate';\nimport { Result, succeed, fail, captureResult, Converter, Validator } from '@fgv/ts-utils';\nimport { FileTree, JsonValue } from '@fgv/ts-json-base';\n\n/**\n * Implementation of `FileTree.IFileTreeFileItem` for files in a ZIP archive.\n * ZIP files are read-only, so this item does not support mutation.\n * Use {@link FileTree.isMutableFileItem | isMutableFileItem} to check before attempting mutations.\n *\n * @remarks\n * ZIP entries are byte-native, so this item also implements the read half of the\n * optional binary capability (`FileTree.IBinaryFileTreeFileItem`) — use\n * `FileTree.isBinaryFileItem` to narrow and `getRawBytes()` to read the entry's\n * undecoded bytes.\n * @public\n */\nexport class ZipFileItem<TCT extends string = string> implements FileTree.IBinaryFileTreeFileItem<TCT> {\n /**\n * Indicates that this `FileTree.FileTreeItem` is a file.\n */\n public readonly type: 'file' = 'file';\n\n /**\n * The absolute path of the file within the ZIP archive.\n */\n public readonly absolutePath: string;\n\n /**\n * The name of the file\n */\n public readonly name: string;\n\n /**\n * The base name of the file (without extension)\n */\n public readonly baseName: string;\n\n /**\n * The extension of the file\n */\n public readonly extension: string;\n\n /**\n * The content type of the file.\n */\n public get contentType(): TCT | undefined {\n if (this._contentType === undefined && this._shouldInferContentType) {\n this._contentType = this._accessors.getFileContentType(this.absolutePath).orDefault();\n this._shouldInferContentType = false;\n }\n return this._contentType;\n }\n\n /**\n * The pre-loaded raw bytes of the ZIP entry.\n */\n private readonly _bytes: Uint8Array;\n\n /**\n * Text form of the entry, decoded lazily from the raw bytes on first text read.\n */\n private _contents: string | undefined;\n\n /**\n * The ZIP file tree accessors that created this item.\n */\n private readonly _accessors: ZipFileTreeAccessors<TCT>;\n\n /**\n * Mutable content type of the file.\n */\n private _contentType: TCT | undefined;\n\n /**\n * Flag to track if content type should be inferred on first access.\n */\n private _shouldInferContentType: boolean = true;\n\n /**\n * Constructor for ZipFileItem.\n * @param zipFilePath - The path of the file within the ZIP.\n * @param contents - The pre-loaded contents of the entry, either as raw bytes or as\n * already-decoded text. Text is encoded as UTF-8 for the byte accessor and is also\n * retained verbatim, so supplying text never round-trips through a decode.\n * @param accessors - The ZIP file tree accessors.\n */\n public constructor(\n zipFilePath: string,\n contents: string | Uint8Array,\n accessors: ZipFileTreeAccessors<TCT>\n ) {\n if (typeof contents === 'string') {\n this._contents = contents;\n this._bytes = new TextEncoder().encode(contents);\n } else {\n this._bytes = contents;\n }\n this._accessors = accessors;\n this.absolutePath = '/' + zipFilePath;\n this.name = accessors.getBaseName(zipFilePath);\n this.extension = accessors.getExtension(zipFilePath);\n this.baseName = accessors.getBaseName(zipFilePath, this.extension);\n }\n\n /**\n * Sets the content type of the file.\n * @param contentType - The content type of the file.\n */\n public setContentType(contentType: TCT | undefined): void {\n this._contentType = contentType;\n this._shouldInferContentType = false;\n }\n\n /**\n * Gets the contents of the file as parsed JSON.\n */\n public getContents(): Result<JsonValue>;\n public getContents<T>(converter: Validator<T> | Converter<T>): Result<T>;\n public getContents<T>(converter?: Validator<T> | Converter<T>): Result<T | JsonValue> {\n return this.getRawContents()\n .onSuccess((contents) => {\n return captureResult(() => JSON.parse(contents))\n .onSuccess((parsed) => {\n if (converter) {\n return converter.convert(parsed) as Result<T | JsonValue>;\n }\n return succeed(parsed as JsonValue);\n })\n .onFailure(() => {\n return fail(`Failed to parse JSON from file: ${this.absolutePath}`);\n });\n })\n .onFailure((error) => {\n return fail(`Failed to get contents from file: ${error}`);\n });\n }\n\n /**\n * Gets the raw contents of the file as a string.\n *\n * @remarks\n * The entry's bytes are decoded as UTF-8 with the lenient WHATWG default, so\n * malformed input is silently replaced with U+FFFD. Use `getRawBytes()` for the\n * undecoded bytes — and `new TextDecoder('utf-8', { fatal: true }).decode(bytes)`\n * for a decode that fails loudly instead.\n */\n public getRawContents(): Result<string> {\n if (this._contents === undefined) {\n this._contents = new TextDecoder().decode(this._bytes);\n }\n return succeed(this._contents);\n }\n\n /**\n * Gets the raw bytes of the ZIP entry, with no text decoding applied.\n *\n * @remarks\n * The returned array is the item's internal buffer and must not be modified.\n */\n public getRawBytes(): Result<Uint8Array> {\n return succeed(this._bytes);\n }\n}\n\n/**\n * Implementation of `IFileTreeDirectoryItem` for directories in a ZIP archive.\n * @public\n */\nexport class ZipDirectoryItem<TCT extends string = string> implements FileTree.IFileTreeDirectoryItem<TCT> {\n /**\n * Indicates that this `FileTree.FileTreeItem` is a directory.\n */\n public readonly type: 'directory' = 'directory';\n\n /**\n * The absolute path of the directory within the ZIP archive.\n */\n public readonly absolutePath: string;\n\n /**\n * The name of the directory\n */\n public readonly name: string;\n\n /**\n * The ZIP file tree accessors that created this item.\n */\n private readonly _accessors: ZipFileTreeAccessors<TCT>;\n\n /**\n * Constructor for ZipDirectoryItem.\n * @param directoryPath - The path of the directory within the ZIP.\n * @param accessors - The ZIP file tree accessors.\n */\n public constructor(directoryPath: string, accessors: ZipFileTreeAccessors<TCT>) {\n this._accessors = accessors;\n this.absolutePath = '/' + directoryPath.replace(/\\/$/, ''); // Normalize path\n this.name = accessors.getBaseName(directoryPath);\n }\n\n /**\n * Gets the children of the directory.\n */\n public getChildren(): Result<ReadonlyArray<FileTree.FileTreeItem<TCT>>> {\n return this._accessors.getChildren(this.absolutePath);\n }\n}\n\n/**\n * Read-only file tree accessors for ZIP archives.\n * ZIP archives are read-only by design — use {@link FileTree.isMutableAccessors | isMutableAccessors}\n * to check before attempting mutations.\n *\n * @remarks\n * ZIP entries are byte-native, so these accessors also implement the read half of the\n * optional binary capability (`FileTree.IBinaryFileTreeAccessors`) — use\n * `FileTree.isBinaryAccessors` to narrow and `getFileBytes()` to read an entry's\n * undecoded bytes.\n * @public\n */\nexport class ZipFileTreeAccessors<TCT extends string = string>\n implements FileTree.IBinaryFileTreeAccessors<TCT>\n{\n /**\n * The unzipped file data.\n */\n private readonly _files: Unzipped;\n\n /**\n * Optional prefix to prepend to paths.\n */\n private readonly _prefix: string;\n\n /**\n * Content type inference function.\n */\n private readonly _inferContentType: FileTree.ContentTypeFactory<TCT>;\n\n /**\n * Cache of all items in the ZIP for efficient lookups.\n */\n private readonly _itemCache: Map<string, FileTree.FileTreeItem<TCT>> = new Map();\n\n /**\n * Constructor for ZipFileTreeAccessors.\n * @param files - The unzipped file data from fflate.\n * @param params - Optional initialization parameters.\n */\n private constructor(files: Unzipped, params?: FileTree.IFileTreeInitParams<TCT>) {\n this._files = files;\n this._prefix = params?.prefix || '';\n this._inferContentType = params?.inferContentType ?? ZipFileTreeAccessors.defaultInferContentType;\n this._buildItemCache();\n }\n\n /**\n * Default function to infer the content type of a file.\n * @param __filePath - The path of the file.\n * @param __provided - Optional supplied content type.\n * @returns `Success` with the content type of the file if successful, or\n * `Failure` with an error message otherwise.\n * @remarks This default implementation always returns `Success` with `undefined`.\n * @public\n */\n public static defaultInferContentType<TCT extends string = string>(\n __filePath: string,\n __provided?: string\n ): Result<TCT | undefined> {\n return succeed(undefined);\n }\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param prefix - Optional prefix to prepend to paths.\n * @returns Result containing the ZipFileTreeAccessors instance.\n */\n public static fromBuffer<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n prefix?: string\n ): Result<ZipFileTreeAccessors<TCT>>;\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (synchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param params - Optional initialization parameters.\n * @returns Result containing the ZipFileTreeAccessors instance.\n */\n public static fromBuffer<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT>\n ): Result<ZipFileTreeAccessors<TCT>>;\n\n public static fromBuffer<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT> | string\n ): Result<ZipFileTreeAccessors<TCT>> {\n try {\n /* c8 ignore next 1 - defense in depth */\n const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);\n const files = unzipSync(uint8Buffer);\n const normalizedParams = typeof params === 'string' ? { prefix: params } : params;\n return succeed(new ZipFileTreeAccessors<TCT>(files, normalizedParams));\n } catch (error) {\n /* c8 ignore next 1 - defensive coding: fflate always throws Error objects in practice */\n return fail(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param prefix - Optional prefix to prepend to paths.\n * @returns Promise containing Result with the ZipFileTreeAccessors instance.\n */\n public static async fromBufferAsync<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n prefix?: string\n ): Promise<Result<ZipFileTreeAccessors<TCT>>>;\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a ZIP file buffer (asynchronous).\n * @param zipBuffer - The ZIP file as an ArrayBuffer or Uint8Array.\n * @param params - Optional initialization parameters.\n * @returns Promise containing Result with the ZipFileTreeAccessors instance.\n */\n public static async fromBufferAsync<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT>\n ): Promise<Result<ZipFileTreeAccessors<TCT>>>;\n\n public static async fromBufferAsync<TCT extends string = string>(\n zipBuffer: ArrayBuffer | Uint8Array,\n params?: FileTree.IFileTreeInitParams<TCT> | string\n ): Promise<Result<ZipFileTreeAccessors<TCT>>> {\n return new Promise((resolve) => {\n try {\n /* c8 ignore next 1 - defense in depth */\n const uint8Buffer = zipBuffer instanceof Uint8Array ? zipBuffer : new Uint8Array(zipBuffer);\n unzip(uint8Buffer, (err, files) => {\n if (err) {\n resolve(fail(`Failed to load ZIP archive: ${err.message}`));\n } else {\n const normalizedParams = typeof params === 'string' ? { prefix: params } : params;\n resolve(succeed(new ZipFileTreeAccessors<TCT>(files, normalizedParams)));\n }\n });\n /* c8 ignore next 5 - defensive coding: fflate reports errors via callback, not exceptions */\n } catch (error) {\n resolve(\n fail(`Failed to load ZIP archive: ${error instanceof Error ? error.message : String(error)}`)\n );\n }\n });\n }\n\n /**\n * Creates a new ZipFileTreeAccessors instance from a File object (browser environment).\n * @param file - The File object containing ZIP data.\n * @param params - Optional initialization parameters.\n * @returns Result containing the ZipFileTreeAccessors instance.\n */\n public static async fromFile<TCT extends string = string>(\n file: File,\n params?: FileTree.IFileTreeInitParams<TCT>\n ): Promise<Result<ZipFileTreeAccessors<TCT>>> {\n try {\n const arrayBuffer = await file.arrayBuffer();\n const uint8Buffer = new Uint8Array(arrayBuffer);\n\n return await ZipFileTreeAccessors.fromBufferAsync<TCT>(uint8Buffer, params);\n } catch (error) {\n return fail(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`);\n }\n }\n\n /**\n * Builds the cache of all items in the ZIP archive.\n */\n private _buildItemCache(): void {\n const directories = new Set<string>();\n\n // Process all files and collect directory paths\n for (const [relativePath, fileData] of Object.entries(this._files)) {\n // Skip directories in fflate output (they have null data)\n /* c8 ignore next 5 - handles explicit directory entries from external ZIP tools (fflate doesn't create these) */\n if (fileData === null || fileData === undefined) {\n const dirPath = relativePath.replace(/\\/$/, '');\n if (dirPath) {\n directories.add(dirPath);\n }\n } else {\n // Extract directory paths from file paths\n const pathParts = relativePath.split('/');\n for (let i = 1; i < pathParts.length; i++) {\n const dirPath = pathParts.slice(0, i).join('/');\n if (dirPath) {\n directories.add(dirPath);\n }\n }\n\n // Add the file item with its raw bytes; text is decoded lazily on demand.\n const absolutePath = this.resolveAbsolutePath(relativePath);\n const item = new ZipFileItem<TCT>(relativePath, fileData, this);\n this._itemCache.set(absolutePath, item);\n }\n }\n\n // Add directory items to cache\n directories.forEach((dirPath) => {\n const absolutePath = this.resolveAbsolutePath(dirPath);\n const item = new ZipDirectoryItem<TCT>(dirPath, this);\n this._itemCache.set(absolutePath, item);\n });\n }\n\n /**\n * Resolves paths to an absolute path.\n */\n public resolveAbsolutePath(...paths: string[]): string {\n const joinedPath = this.joinPaths(...paths);\n const prefixed = this._prefix ? this.joinPaths(this._prefix, joinedPath) : joinedPath;\n return prefixed.startsWith('/') ? prefixed : '/' + prefixed;\n }\n\n /**\n * Gets the extension of a path.\n */\n public getExtension(path: string): string {\n const name = this.getBaseName(path);\n const lastDotIndex = name.lastIndexOf('.');\n return lastDotIndex >= 0 ? name.substring(lastDotIndex) : '';\n }\n\n /**\n * Gets the base name of a path.\n */\n public getBaseName(path: string, suffix?: string): string {\n const normalizedPath = path.replace(/\\/$/, ''); // Remove trailing slash\n const parts = normalizedPath.split('/');\n let baseName = parts[parts.length - 1] || '';\n\n if (suffix && baseName.endsWith(suffix)) {\n baseName = baseName.substring(0, baseName.length - suffix.length);\n }\n\n return baseName;\n }\n\n /**\n * Joins paths together.\n */\n public joinPaths(...paths: string[]): string {\n return paths\n .filter((p) => p && p.length > 0)\n .map((p) => p.replace(/^\\/+|\\/+$/g, '')) // Remove leading/trailing slashes\n .join('/')\n .replace(/\\/+/g, '/'); // Normalize multiple slashes\n }\n\n /**\n * Gets an item from the file tree.\n */\n public getItem(path: string): Result<FileTree.FileTreeItem<TCT>> {\n const absolutePath = this.resolveAbsolutePath(path);\n const item = this._itemCache.get(absolutePath);\n\n if (item) {\n return succeed(item);\n }\n\n return fail(`Item not found: ${absolutePath}`);\n }\n\n /**\n * Gets the contents of a file in the file tree.\n *\n * @remarks\n * The entry's bytes are decoded as UTF-8 with the lenient WHATWG default. Use\n * `getFileBytes()` for the undecoded bytes.\n */\n public getFileContents(path: string): Result<string> {\n return this._getFileItem(path).onSuccess((item) => item.getRawContents());\n }\n\n /**\n * Gets the raw bytes of a ZIP entry, with no text decoding applied.\n *\n * @remarks\n * The returned array is the archive's internal buffer and must not be modified.\n */\n public getFileBytes(path: string): Result<Uint8Array> {\n return this._getFileItem(path).onSuccess((item) => item.getRawBytes());\n }\n\n /**\n * Resolves a path to the ZIP file item it names.\n * @param path - Path of the entry to look up.\n * @returns `Success` with the item, or `Failure` if it is missing or is a directory.\n */\n private _getFileItem(path: string): Result<ZipFileItem<TCT>> {\n return this.getItem(path).onSuccess((item) => {\n if (!(item instanceof ZipFileItem)) {\n return fail(`Path is not a file: ${path}`);\n }\n return succeed(item);\n });\n }\n\n /**\n * Gets the content type of a file in the file tree.\n */\n public getFileContentType(path: string, provided?: string): Result<TCT | undefined> {\n // If provided contentType is given, use it directly (highest priority)\n if (provided !== undefined) {\n return succeed(provided as TCT);\n }\n\n // For files that exist in the ZIP, we don't store explicit contentType\n // so we always fall back to inference\n return this._inferContentType(path);\n }\n\n /**\n * Gets the children of a directory in the file tree.\n */\n public getChildren(path: string): Result<ReadonlyArray<FileTree.FileTreeItem<TCT>>> {\n const absolutePath = this.resolveAbsolutePath(path);\n const children: FileTree.FileTreeItem<TCT>[] = [];\n\n // Find all items that are direct children of this directory\n for (const [itemPath, item] of this._itemCache) {\n if (this._isDirectChild(absolutePath, itemPath)) {\n children.push(item);\n }\n }\n\n return succeed(children);\n }\n\n /**\n * Checks if childPath is a direct child of parentPath.\n */\n private _isDirectChild(parentPath: string, childPath: string): boolean {\n // Normalize paths\n const normalizedParent = parentPath.replace(/\\/$/, '');\n const normalizedChild = childPath.replace(/\\/$/, '');\n\n // Child must start with parent path\n if (!normalizedChild.startsWith(normalizedParent + '/')) {\n return false;\n }\n\n // Get the relative path from parent to child\n const relativePath = normalizedChild.substring(normalizedParent.length + 1);\n\n // Direct child means no additional slashes in the relative path\n return !relativePath.includes('/');\n }\n}\n"]}
@@ -1,12 +1,24 @@
1
1
  import { Result } from '@fgv/ts-utils';
2
2
  /**
3
- * Simple interface for a file to be added to a zip file.
3
+ * Simple interface for a text file to be added to a zip file.
4
4
  * @public
5
5
  */
6
6
  export interface IZipTextFile {
7
7
  readonly path: string;
8
8
  readonly contents: string;
9
9
  }
10
+ /**
11
+ * Interface for a file to be added to a zip file, whose contents are either text or
12
+ * raw bytes.
13
+ *
14
+ * @remarks
15
+ * String contents are encoded as UTF-8; `Uint8Array` contents are stored verbatim.
16
+ * @public
17
+ */
18
+ export interface IZipFile {
19
+ readonly path: string;
20
+ readonly contents: string | Uint8Array;
21
+ }
10
22
  /**
11
23
  * Supported compression levels for zip files.
12
24
  * @public
@@ -21,7 +33,20 @@ export interface ICreateZipOptions {
21
33
  }
22
34
  /**
23
35
  * Creates a zip file from an array of text files.
36
+ *
37
+ * @remarks
38
+ * Contents are encoded as UTF-8. Use `createZipFromFiles` to write entries whose
39
+ * contents are raw bytes.
24
40
  * @public
25
41
  */
26
42
  export declare function createZipFromTextFiles(files: ReadonlyArray<IZipTextFile>, options?: ICreateZipOptions): Result<Uint8Array>;
43
+ /**
44
+ * Creates a zip file from an array of files whose contents are either text or raw bytes.
45
+ *
46
+ * @remarks
47
+ * String contents are encoded as UTF-8; `Uint8Array` contents are stored verbatim, so
48
+ * arbitrary binary payloads round-trip through the archive unchanged.
49
+ * @public
50
+ */
51
+ export declare function createZipFromFiles(files: ReadonlyArray<IZipFile>, options?: ICreateZipOptions): Result<Uint8Array>;
27
52
  //# sourceMappingURL=zipFileTreeWriter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zipFileTreeWriter.d.ts","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/zipFileTreeWriter.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,MAAM,EAAiB,MAAM,eAAe,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,iBA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+22,35 @@
22
22
  */
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.createZipFromTextFiles = createZipFromTextFiles;
25
+ exports.createZipFromFiles = createZipFromFiles;
25
26
  const fflate_1 = require("fflate");
26
27
  const ts_utils_1 = require("@fgv/ts-utils");
27
28
  /**
28
29
  * Creates a zip file from an array of text files.
30
+ *
31
+ * @remarks
32
+ * Contents are encoded as UTF-8. Use `createZipFromFiles` to write entries whose
33
+ * contents are raw bytes.
29
34
  * @public
30
35
  */
31
36
  function createZipFromTextFiles(files, options) {
37
+ return createZipFromFiles(files, options);
38
+ }
39
+ /**
40
+ * Creates a zip file from an array of files whose contents are either text or raw bytes.
41
+ *
42
+ * @remarks
43
+ * String contents are encoded as UTF-8; `Uint8Array` contents are stored verbatim, so
44
+ * arbitrary binary payloads round-trip through the archive unchanged.
45
+ * @public
46
+ */
47
+ function createZipFromFiles(files, options) {
32
48
  return (0, ts_utils_1.captureResult)(() => {
33
49
  var _a;
34
50
  const out = {};
35
51
  for (const f of files) {
36
52
  const normalizedPath = f.path.replace(/^\/+/, '');
37
- out[normalizedPath] = (0, fflate_1.strToU8)(f.contents);
53
+ out[normalizedPath] = typeof f.contents === 'string' ? (0, fflate_1.strToU8)(f.contents) : f.contents;
38
54
  }
39
55
  return (0, fflate_1.zipSync)(out, { level: (_a = options === null || options === void 0 ? void 0 : options.level) !== null && _a !== void 0 ? _a : 6 });
40
56
  /* c8 ignore next - defensive: zipSync only throws on internal library errors */
@@ -1 +1 @@
1
- {"version":3,"file":"zipFileTreeWriter.js","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/zipFileTreeWriter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAgCH,wDAaC;AA3CD,mCAA0C;AAC1C,4CAAsD;AAyBtD;;;GAGG;AACH,SAAgB,sBAAsB,CACpC,KAAkC,EAClC,OAA2B;IAE3B,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;;QACxB,MAAM,GAAG,GAA+B,EAAE,CAAC;QAC3C,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAClD,GAAG,CAAC,cAAc,CAAC,GAAG,IAAA,gBAAO,EAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,IAAA,gBAAO,EAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,mCAAI,CAAC,EAAE,CAAC,CAAC;QACpD,gFAAgF;IAClF,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/*\n * Copyright (c) 2026 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { zipSync, strToU8 } from 'fflate';\nimport { Result, captureResult } from '@fgv/ts-utils';\n\n/**\n * Simple interface for a file to be added to a zip file.\n * @public\n */\nexport interface IZipTextFile {\n readonly path: string;\n readonly contents: string;\n}\n\n/**\n * Supported compression levels for zip files.\n * @public\n */\nexport type ZipCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;\n\n/**\n * Options for creating a zip file from text files.\n * @public\n */\nexport interface ICreateZipOptions {\n readonly level?: ZipCompressionLevel;\n}\n\n/**\n * Creates a zip file from an array of text files.\n * @public\n */\nexport function createZipFromTextFiles(\n files: ReadonlyArray<IZipTextFile>,\n options?: ICreateZipOptions\n): Result<Uint8Array> {\n return captureResult(() => {\n const out: Record<string, Uint8Array> = {};\n for (const f of files) {\n const normalizedPath = f.path.replace(/^\\/+/, '');\n out[normalizedPath] = strToU8(f.contents);\n }\n return zipSync(out, { level: options?.level ?? 6 });\n /* c8 ignore next - defensive: zipSync only throws on internal library errors */\n }).withErrorFormat((e) => `Failed to create zip: ${e}`);\n}\n"]}
1
+ {"version":3,"file":"zipFileTreeWriter.js","sourceRoot":"","sources":["../../../src/packlets/zip-file-tree/zipFileTreeWriter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;AAiDH,wDAKC;AAUD,gDAaC;AA3ED,mCAA0C;AAC1C,4CAAsD;AAsCtD;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CACpC,KAAkC,EAClC,OAA2B;IAE3B,OAAO,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAChC,KAA8B,EAC9B,OAA2B;IAE3B,OAAO,IAAA,wBAAa,EAAC,GAAG,EAAE;;QACxB,MAAM,GAAG,GAA+B,EAAE,CAAC;QAC3C,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAClD,GAAG,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAA,gBAAO,EAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC1F,CAAC;QACD,OAAO,IAAA,gBAAO,EAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,mCAAI,CAAC,EAAE,CAAC,CAAC;QACpD,gFAAgF;IAClF,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,yBAAyB,CAAC,EAAE,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["/*\n * Copyright (c) 2026 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport { zipSync, strToU8 } from 'fflate';\nimport { Result, captureResult } from '@fgv/ts-utils';\n\n/**\n * Simple interface for a text file to be added to a zip file.\n * @public\n */\nexport interface IZipTextFile {\n readonly path: string;\n readonly contents: string;\n}\n\n/**\n * Interface for a file to be added to a zip file, whose contents are either text or\n * raw bytes.\n *\n * @remarks\n * String contents are encoded as UTF-8; `Uint8Array` contents are stored verbatim.\n * @public\n */\nexport interface IZipFile {\n readonly path: string;\n readonly contents: string | Uint8Array;\n}\n\n/**\n * Supported compression levels for zip files.\n * @public\n */\nexport type ZipCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;\n\n/**\n * Options for creating a zip file from text files.\n * @public\n */\nexport interface ICreateZipOptions {\n readonly level?: ZipCompressionLevel;\n}\n\n/**\n * Creates a zip file from an array of text files.\n *\n * @remarks\n * Contents are encoded as UTF-8. Use `createZipFromFiles` to write entries whose\n * contents are raw bytes.\n * @public\n */\nexport function createZipFromTextFiles(\n files: ReadonlyArray<IZipTextFile>,\n options?: ICreateZipOptions\n): Result<Uint8Array> {\n return createZipFromFiles(files, options);\n}\n\n/**\n * Creates a zip file from an array of files whose contents are either text or raw bytes.\n *\n * @remarks\n * String contents are encoded as UTF-8; `Uint8Array` contents are stored verbatim, so\n * arbitrary binary payloads round-trip through the archive unchanged.\n * @public\n */\nexport function createZipFromFiles(\n files: ReadonlyArray<IZipFile>,\n options?: ICreateZipOptions\n): Result<Uint8Array> {\n return captureResult(() => {\n const out: Record<string, Uint8Array> = {};\n for (const f of files) {\n const normalizedPath = f.path.replace(/^\\/+/, '');\n out[normalizedPath] = typeof f.contents === 'string' ? strToU8(f.contents) : f.contents;\n }\n return zipSync(out, { level: options?.level ?? 6 });\n /* c8 ignore next - defensive: zipSync only throws on internal library errors */\n }).withErrorFormat((e) => `Failed to create zip: ${e}`);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fgv/ts-extras",
3
- "version": "5.1.0-45",
3
+ "version": "5.1.0-47",
4
4
  "description": "Assorted Typescript Utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "dist/ts-extras.d.ts",
@@ -36,6 +36,16 @@
36
36
  "require": "./lib/packlets/crypto-utils/keystore/index.browser.js"
37
37
  }
38
38
  },
39
+ "./safer-fetch": {
40
+ "node": {
41
+ "import": "./lib/packlets/safer-fetch/index.js",
42
+ "require": "./lib/packlets/safer-fetch/index.js"
43
+ },
44
+ "default": {
45
+ "import": "./lib/packlets/safer-fetch/index.browser.js",
46
+ "require": "./lib/packlets/safer-fetch/index.browser.js"
47
+ }
48
+ },
39
49
  "./hash": {
40
50
  "node": {
41
51
  "import": "./lib/packlets/hash/index.node.js",
@@ -90,10 +100,10 @@
90
100
  "@types/js-yaml": "~4.0.9",
91
101
  "typedoc": "~0.28.16",
92
102
  "typedoc-plugin-markdown": "~4.9.0",
93
- "@fgv/heft-dual-rig": "5.1.0-45",
94
- "@fgv/typedoc-compact-theme": "5.1.0-45",
95
- "@fgv/ts-utils": "5.1.0-45",
96
- "@fgv/ts-utils-jest": "5.1.0-45"
103
+ "@fgv/typedoc-compact-theme": "5.1.0-47",
104
+ "@fgv/ts-utils-jest": "5.1.0-47",
105
+ "@fgv/ts-utils": "5.1.0-47",
106
+ "@fgv/heft-dual-rig": "5.1.0-47"
97
107
  },
98
108
  "dependencies": {
99
109
  "@types/luxon": "^3.7.1",
@@ -102,10 +112,10 @@
102
112
  "papaparse": "^5.4.1",
103
113
  "fflate": "~0.8.2",
104
114
  "js-yaml": "~4.1.1",
105
- "@fgv/ts-json-base": "5.1.0-45"
115
+ "@fgv/ts-json-base": "5.1.0-47"
106
116
  },
107
117
  "peerDependencies": {
108
- "@fgv/ts-utils": "5.1.0-45"
118
+ "@fgv/ts-utils": "5.1.0-47"
109
119
  },
110
120
  "repository": {
111
121
  "type": "git",