@zip.js/zip.js 2.8.7 → 2.8.9

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/index.d.ts CHANGED
@@ -635,7 +635,14 @@ export class SplitDataWriter implements Initializable, WritableWriter {
635
635
  /**
636
636
  * Represents a {@link Writer} instance used to retrieve the written data as a `Uint8Array` instance.
637
637
  */
638
- export class Uint8ArrayWriter extends Writer<Uint8Array<ArrayBuffer>> {}
638
+ export class Uint8ArrayWriter extends Writer<Uint8Array<ArrayBuffer>> {
639
+ /**
640
+ * Creates the {@link Uint8ArrayWriter} instance
641
+ *
642
+ * @param defaultBufferSize The initial size of the internal buffer (default: 256KB).
643
+ */
644
+ constructor(defaultBufferSize?: number);
645
+ }
639
646
 
640
647
  /**
641
648
  * Represents an instance used to create an unzipped stream.
@@ -979,14 +986,78 @@ export interface EntryMetaData {
979
986
  * `true` if `internalFileAttributes` and `externalFileAttributes` are compatible with MS-DOS format.
980
987
  */
981
988
  msDosCompatible: boolean;
989
+ /**
990
+ * Note (MS-DOS / Unix attributes):
991
+ *
992
+ * - The single source of truth for on-disk metadata is the 32-bit `externalFileAttributes` value stored in
993
+ * the ZIP headers. The upper 16 bits are commonly used for Unix `st_mode` (type/permissions/special bits)
994
+ * and the low 8 bits for MS-DOS attribute flags.
995
+ *
996
+ * - Writer vs Reader:
997
+ * - The writer composes `externalFileAttributes` from the provided options (`externalFileAttributes`,
998
+ * `unixMode`/special flags, `msdosAttributesRaw`/`msdosAttributes`).
999
+ * - The reader decodes the stored `externalFileAttributes` and exposes convenience fields such as
1000
+ * `msdosAttributesRaw`, `msdosAttributes`, `unixExternalUpper`, and `unixMode`.
1001
+ *
1002
+ * - Practical rule: treat `externalFileAttributes` as authoritative; other fields are conveniences derived
1003
+ * from it. If you need a specific on-disk value, set `externalFileAttributes` explicitly.
1004
+ */
1005
+ /**
1006
+ * The MS-DOS attributes low byte (raw).
1007
+ * This is the low 8 bits of {@link EntryMetaData#externalFileAttributes} when present.
1008
+ */
1009
+ msdosAttributesRaw?: number;
1010
+ /**
1011
+ * The MS-DOS attribute flags exposed as booleans.
1012
+ */
1013
+ msdosAttributes?: {
1014
+ readOnly: boolean;
1015
+ hidden: boolean;
1016
+ system: boolean;
1017
+ directory: boolean;
1018
+ archive: boolean;
1019
+ };
1020
+ /**
1021
+ * Unix owner id when available.
1022
+ */
1023
+ uid?: number;
1024
+ /**
1025
+ * Unix group id when available.
1026
+ */
1027
+ gid?: number;
1028
+ /**
1029
+ * Unix mode (st_mode) when available.
1030
+ */
1031
+ unixMode?: number;
1032
+ /**
1033
+ * `true` if the setuid bit is set on the entry.
1034
+ */
1035
+ setuid?: boolean;
1036
+ /**
1037
+ * `true` if the setgid bit is set on the entry.
1038
+ */
1039
+ setgid?: boolean;
1040
+ /**
1041
+ * `true` if the sticky bit is set on the entry.
1042
+ */
1043
+ sticky?: boolean;
982
1044
  /**
983
1045
  * The internal file attributes (raw).
984
1046
  */
985
1047
  internalFileAttributes: number;
986
1048
  /**
987
- * The external file attributes (raw).
1049
+ * The 32-bit `externalFileAttributes` field is the authoritative on-disk metadata for each entry.
1050
+ * - Upper 16 bits: Unix mode/type (e.g., permissions, file type)
1051
+ * - Low 8 bits: MS-DOS file attributes (e.g., directory, read-only)
1052
+ *
1053
+ * When writing, all provided options are merged into this field. When reading, convenience fields are decoded from it.
1054
+ * For most use cases, prefer the high-level options and fields; only advanced users need to manipulate the raw value directly.
988
1055
  */
989
1056
  externalFileAttributes: number;
1057
+ /**
1058
+ * The upper 16-bit portion of {@link EntryMetaData#externalFileAttributes} when it represents Unix mode bits.
1059
+ */
1060
+ unixExternalUpper?: number;
990
1061
  /**
991
1062
  * The number of the disk where the entry data starts.
992
1063
  */
@@ -1471,12 +1542,57 @@ export interface ZipWriterConstructorOptions {
1471
1542
  * @defaultValue 0
1472
1543
  */
1473
1544
  externalFileAttributes?: number;
1545
+ /**
1546
+ * The Unix owner id to write in the Unix extra field or as part of the external attributes.
1547
+ */
1548
+ uid?: number;
1549
+ /**
1550
+ * The Unix group id to write in the Unix extra field or as part of the external attributes.
1551
+ */
1552
+ gid?: number;
1553
+ /**
1554
+ * The Unix mode (st_mode bits) to use when writing external attributes.
1555
+ */
1556
+ unixMode?: number;
1557
+ /**
1558
+ * `true` to set the setuid bit when writing the Unix mode.
1559
+ */
1560
+ setuid?: boolean;
1561
+ /**
1562
+ * `true` to set the setgid bit when writing the Unix mode.
1563
+ */
1564
+ setgid?: boolean;
1565
+ /**
1566
+ * `true` to set the sticky bit when writing the Unix mode.
1567
+ */
1568
+ sticky?: boolean;
1569
+ /**
1570
+ * Which Unix extra field format to write when creating entries that include Unix metadata.
1571
+ * - "infozip": use Info-ZIP New Unix extra field
1572
+ * - "unix": use the traditional Unix extra field format
1573
+ */
1574
+ unixExtraFieldType?: "infozip" | "unix";
1474
1575
  /**
1475
1576
  * The internal file attribute.
1476
1577
  *
1477
1578
  * @defaultValue 0
1478
1579
  */
1479
1580
  internalFileAttributes?: number;
1581
+ /**
1582
+ * When provided, the low 8-bit MS-DOS attributes to write into external file attributes.
1583
+ * Must be an integer between 0 and 255.
1584
+ */
1585
+ msdosAttributesRaw?: number;
1586
+ /**
1587
+ * When provided, MS-DOS attribute flags (boolean object) to write into external file attributes low byte.
1588
+ */
1589
+ msdosAttributes?: {
1590
+ readOnly?: boolean;
1591
+ hidden?: boolean;
1592
+ system?: boolean;
1593
+ directory?: boolean;
1594
+ archive?: boolean;
1595
+ };
1480
1596
  /**
1481
1597
  * `false` to never write disk numbers in zip64 data.
1482
1598
  *