diff --git a/.github/actions/setup-for-scripts/action.yml b/.github/actions/setup-for-scripts/action.yml index 3c28fe320c5d90..013c6a8b6b07d8 100644 --- a/.github/actions/setup-for-scripts/action.yml +++ b/.github/actions/setup-for-scripts/action.yml @@ -7,7 +7,7 @@ runs: - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: node-version: '24' - - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 with: run_install: | - args: [--filter, ., --filter, '{./scripts}...'] diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6ca70cd2174aa6..6e81bb65694808 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -39,7 +39,7 @@ jobs: with: node-version: '24' - - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 - id: matrix run: | @@ -79,7 +79,7 @@ jobs: printf "Aborting: symlinks found:\n%s" "$symlinks"; exit 1 fi - - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 - name: Get pnpm cache info id: pnpm-cache @@ -139,7 +139,7 @@ jobs: id: suggestions-dir run: echo "path=$(node ./scripts/get-suggestions-dir.js)" >> "$GITHUB_OUTPUT" - - uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: path: ${{ steps.suggestions-dir.outputs.path }} merge-multiple: true diff --git a/.github/workflows/pnpm-cache.yml b/.github/workflows/pnpm-cache.yml index 260d9077c95ad9..f91d14c88d6927 100644 --- a/.github/workflows/pnpm-cache.yml +++ b/.github/workflows/pnpm-cache.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: node-version: '24' - - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 + - uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v4.4.0 - name: Get pnpm cache info id: pnpm-cache diff --git a/types/adm-zip/adm-zip-tests.ts b/types/adm-zip/adm-zip-tests.ts index 4fcaade52b52c6..4410196098039e 100644 --- a/types/adm-zip/adm-zip-tests.ts +++ b/types/adm-zip/adm-zip-tests.ts @@ -98,3 +98,5 @@ zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", false, true); function isAdmZipEntry(obj: any): obj is AdmZip.IZipEntry { return obj !== null && typeof obj === "object" && typeof obj["entryName"] === "string"; } + +zip.toBuffer(); // $ExpectType Buffer diff --git a/types/adm-zip/index.d.ts b/types/adm-zip/index.d.ts index 2dc1b9d73dbf5f..91959aa75d306c 100644 --- a/types/adm-zip/index.d.ts +++ b/types/adm-zip/index.d.ts @@ -226,7 +226,7 @@ declare class AdmZip { /** * Returns the content of the entire zip file. */ - toBuffer(): Buffer; + toBuffer(): Buffer; /** * Asynchronously returns the content of the entire zip file. * @param onSuccess called with the content of the zip file, once it has been generated. @@ -235,7 +235,7 @@ declare class AdmZip { * @param onItemEnd called after an entry is compressed. */ toBuffer( - onSuccess: (buffer: Buffer) => void, + onSuccess: (buffer: Buffer) => void, onFail?: (...args: any[]) => void, onItemStart?: (name: string) => void, onItemEnd?: (name: string) => void, @@ -243,7 +243,7 @@ declare class AdmZip { /** * Asynchronously convert the promise to a Buffer */ - toBufferPromise(): Promise; + toBufferPromise(): Promise>; } declare namespace AdmZip { diff --git a/types/adm-zip/package.json b/types/adm-zip/package.json index c5ac88d9b77935..25fc78cd9578a6 100644 --- a/types/adm-zip/package.json +++ b/types/adm-zip/package.json @@ -5,6 +5,12 @@ "projects": [ "https://github.com/cthackers/adm-zip" ], + "types": "index", + "typesVersions": { + "<=5.6": { + "*": ["ts5.6/*"] + } + }, "dependencies": { "@types/node": "*" }, diff --git a/types/adm-zip/ts5.6/adm-zip-tests.ts b/types/adm-zip/ts5.6/adm-zip-tests.ts new file mode 100644 index 00000000000000..69bc863f2a061f --- /dev/null +++ b/types/adm-zip/ts5.6/adm-zip-tests.ts @@ -0,0 +1,102 @@ +import AdmZip = require("adm-zip"); +import util = require("adm-zip/util"); +const { Constants } = util; + +// reading archives +// reading archive causes error +try { + const zip = new AdmZip("./my_file.zip"); +} catch (e: unknown) { + const error = e as Error; + switch (error.message) { + case util.Errors.INVALID_FORMAT: + // handle specific error + throw new Error("Invalid zip format"); + default: + // handle other errors + throw error; + } +} +// reading archive successfully +const zip = new AdmZip("./my_file.zip"); +if (!zip.test()) { + throw new Error("invalid zip?"); +} +const zipEntries: AdmZip.IZipEntry[] = zip.getEntries(); // an array of ZipEntry records + +zipEntries.forEach(zipEntry => { + console.log(zipEntry.toString()); // outputs zip entries information + if (zipEntry.entryName === "my_file.txt" && zipEntry.header.size < 1000) { + console.log(zipEntry.getData().toString("utf8")); + zipEntry.getDataAsync((data, err) => console.log(err ? "Error: " + err : data.toString("utf8"))); + } +}); +// outputs the content of some_folder/my_file.txt +console.log(zip.readAsText("some_folder/my_file.txt")); +// same async +zip.readAsTextAsync("my_file.txt", (data, err) => console.log(err ? "Error: " + err : data)); +// extracts the specified file to the specified location +zip.extractEntryTo(/*entry name*/ "some_folder/my_file.txt", /*target path*/ "/home/me/tempfolder", /*overwrite*/ true); +// extracts everything +zip.extractAllTo(/*target path*/ "/home/me/zipcontent/", /*overwrite*/ true); +// extracts everything and calls callback -> async extracction +zip.extractAllToAsync( + /*target path*/ "/home/me/zipcontent/", + /*overwrite*/ true, + /*keepOriginalPermission*/ false, + /*callback*/ (error?: Error) => {}, +); + +// creating archives +new AdmZip(); +// creating archives with options +new AdmZip(undefined, { method: Constants.DEFLATED }); + +// add file directly +const addedEntry = zip.addFile("test.txt", new Buffer("inner content of the file"), "entry comment goes here"); +console.log("added", addedEntry.name); +processZipEntry(addedEntry); +// add local file +zip.addLocalFile("/home/me/some_picture.png"); +// get everything as a buffer +const willSendthis = zip.toBuffer(); + +zip.toBuffer( + buffer => console.log(buffer.length), + () => {}, + name => console.log(name), + name => console.log(name), +); +// or write everything to disk +zip.writeZip(/*target file name*/ "/home/me/files.zip"); + +function processZipEntry(zipEntry: AdmZip.IZipEntry) { + console.log("comment", zipEntry.comment); +} + +// tests taken from examples at https://github.com/cthackers/adm-zip/wiki/ADM-ZIP +import Zip = require("adm-zip"); +// loads and parses existing zip file local_file.zip +new Zip("local_file.zip"); +// creates new in memory zip +new Zip(); +// loads and parses existing zip file local_file.zip +new Zip("local_file.zip"); +// get all entries and iterate them +zip.getEntries().forEach(entry => { + const entryName = entry.entryName; + const decompressedData = zip.readFile(entry); // decompressed buffer of the entry + console.log(zip.readAsText(entry)); // outputs the decompressed content of the entry +}); + +// will extract the file myfile.txt from the archive to /home/user/folder/subfolder/myfile.txt +zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", true, true); + +// will extract the file myfile.txt from the archive to /home/user/myfile.txt +zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", false, true); + +function isAdmZipEntry(obj: any): obj is AdmZip.IZipEntry { + return obj !== null && typeof obj === "object" && typeof obj["entryName"] === "string"; +} + +zip.toBuffer(); // $ExpectType Buffer diff --git a/types/adm-zip/ts5.6/index.d.ts b/types/adm-zip/ts5.6/index.d.ts new file mode 100644 index 00000000000000..b195652c767a97 --- /dev/null +++ b/types/adm-zip/ts5.6/index.d.ts @@ -0,0 +1,368 @@ +/// + +import * as FS from "fs"; +import { Constants } from "../util"; + +declare class AdmZip { + /** + * @param fileNameOrRawData If provided, reads an existing archive. Otherwise creates a new, empty archive. + * @param options Options when initializing the ZIP file + */ + constructor(fileNameOrRawData?: string | Buffer, options?: Partial); + /** + * Extracts the given entry from the archive and returns the content as a Buffer object + * @param entry ZipEntry object or String with the full path of the entry + * @param pass Password used for decrypting the file + * @return Buffer or Null in case of error + */ + readFile(entry: string | AdmZip.IZipEntry, pass?: string | Buffer): Buffer | null; + /** + * Asynchronous `readFile`. + * @param entry The full path of the entry or a `IZipEntry` object. + * @param callback Called with a `Buffer` or `null` in case of error. + */ + readFileAsync(entry: string | AdmZip.IZipEntry, callback: (data: Buffer | null, err: string) => void): void; + /** + * Extracts the given entry from the archive and returns the content as + * plain text in the given encoding. + * @param entry The full path of the entry or a `IZipEntry` object. + * @param encoding If no encoding is specified `"utf8"` is used. + */ + readAsText(fileName: string | AdmZip.IZipEntry, encoding?: string): string; + /** + * Asynchronous `readAsText`. + * @param entry The full path of the entry or a `IZipEntry` object. + * @param callback Called with the resulting string. + * @param encoding If no encoding is specified `"utf8"` is used. + */ + readAsTextAsync( + fileName: string | AdmZip.IZipEntry, + callback: (data: string, err: string) => void, + encoding?: string, + ): void; + /** + * Remove the entry from the file or the entry and all its nested directories + * and files if the given entry is a directory. + * @param entry The full path of the entry or a `IZipEntry` object. + */ + deleteFile(entry: string | AdmZip.IZipEntry): void; + /** + * Adds a comment to the zip. The zip must be rewritten after + * adding the comment. + * @param comment Content of the comment. + */ + addZipComment(comment: string): void; + /** + * @return The zip comment. + */ + getZipComment(): string; + /** + * Adds a comment to a specified file or `IZipEntry`. The zip must be rewritten after + * adding the comment. + * The comment cannot exceed 65535 characters in length. + * @param entry The full path of the entry or a `IZipEntry` object. + * @param comment The comment to add to the entry. + */ + addZipEntryComment(entry: string | AdmZip.IZipEntry, comment: string): void; + /** + * Returns the comment of the specified entry. + * @param entry The full path of the entry or a `IZipEntry` object. + * @return The comment of the specified entry. + */ + getZipEntryComment(entry: string | AdmZip.IZipEntry): string; + /** + * Updates the content of an existing entry inside the archive. The zip + * must be rewritten after updating the content. + * @param entry The full path of the entry or a `IZipEntry` object. + * @param content The entry's new contents. + */ + updateFile(entry: string | AdmZip.IZipEntry, content: Buffer): void; + /** + * Adds a file from the disk to the archive. + * @param localPath Path to a file on disk. + * @param zipPath Path to a directory in the archive. Defaults to the empty + * string. + * @param zipName Name for the file. + * @param comment Comment to be attached to the file + */ + addLocalFile(localPath: string, zipPath?: string, zipName?: string, comment?: string): void; + /** + * Adds a local directory and all its nested files and directories to the + * archive. + * @param localPath Path to a folder on disk. + * @param zipPath Path to a folder in the archive. Default: `""`. + * @param filter RegExp or Function if files match will be included. + */ + addLocalFolder(localPath: string, zipPath?: string, filter?: RegExp | ((filename: string) => boolean)): void; + /** + * Asynchronous addLocalFile + * @param localPath + * @param callback + * @param zipPath optional path inside zip + * @param filter optional RegExp or Function if files match will + * be included. + */ + addLocalFolderAsync( + localPath: string, + callback: (success?: boolean, err?: string) => void, + zipPath?: string, + filter?: RegExp | ((filename: string) => boolean), + ): void; + /** + * @param localPath - path where files will be extracted + * @param props - optional properties + * @param props.zipPath - optional path inside zip + * @param props.filter - RegExp or Function if files match will be included. + */ + addLocalFolderPromise( + localPath: string, + props: { zipPath?: string; filter?: RegExp | ((filename: string) => boolean) }, + ): Promise; + /** + * Allows you to create a entry (file or directory) in the zip file. + * If you want to create a directory the `entryName` must end in `"/"` and a `null` + * buffer should be provided. + * @param entryName Entry path. + * @param content Content to add to the entry; must be a 0-length buffer + * for a directory. + * @param comment Comment to add to the entry. + * @param attr Attribute to add to the entry. + * @return The entry corresponding to one which was just added. + */ + addFile(entryName: string, content: Buffer, comment?: string, attr?: number): AdmZip.IZipEntry; + /** + * Returns an array of `IZipEntry` objects representing the files and folders + * inside the archive. + */ + getEntries(): AdmZip.IZipEntry[]; + /** + * Returns a `IZipEntry` object representing the file or folder specified by `name`. + * @param name Name of the file or folder to retrieve. + * @return The entry corresponding to the `name`. + */ + getEntry(name: string): AdmZip.IZipEntry | null; + /** + * Returns the number of entries in the ZIP + * @return The amount of entries in the ZIP + */ + getEntryCount(): number; + /** + * Loop through each entry in the ZIP + * @param callback The callback that receives each individual entry + */ + forEach(callback: (entry: AdmZip.IZipEntry) => void): void; + /** + * Extracts the given entry to the given `targetPath`. + * If the entry is a directory inside the archive, the entire directory and + * its subdirectories will be extracted. + * @param entry The full path of the entry or a `IZipEntry` object. + * @param targetPath Target folder where to write the file. + * @param maintainEntryPath If maintainEntryPath is `true` and the entry is + * inside a folder, the entry folder will be created in `targetPath` as + * well. Default: `true`. + * @param overwrite If the file already exists at the target path, the file + * will be overwriten if this is `true`. Default: `false`. + * @param keepOriginalPermission The file will be set as the permission from + * the entry if this is true. Default: `false`. + * @param outFileName String If set will override the filename of the + * extracted file (Only works if the entry is a file) + * @return Boolean + */ + extractEntryTo( + entryPath: string | AdmZip.IZipEntry, + targetPath: string, + maintainEntryPath?: boolean, + overwrite?: boolean, + keepOriginalPermission?: boolean, + outFileName?: string, + ): boolean; + /** + * Test the archive + * @param password The password for the archive + */ + test(password?: string | Buffer): boolean; + /** + * Extracts the entire archive to the given location. + * @param targetPath Target location. + * @param overwrite If the file already exists at the target path, the file + * will be overwriten if this is `true`. Default: `false`. + * @param keepOriginalPermission The file will be set as the permission from + * the entry if this is true. Default: `false`. + * @param password The password for the archive + */ + extractAllTo( + targetPath: string, + overwrite?: boolean, + keepOriginalPermission?: boolean, + password?: string | Buffer, + ): void; + /** + * Extracts the entire archive to the given location. + * @param targetPath Target location. + * @param overwrite If the file already exists at the target path, the file + * will be overwriten if this is `true`. Default: `false`. + * @param keepOriginalPermission The file will be set as the permission from + * the entry if this is true. Default: `false`. + * @param callback The callback function will be called after extraction. + */ + extractAllToAsync( + targetPath: string, + overwrite?: boolean, + keepOriginalPermission?: boolean, + callback?: (error?: Error) => void, + ): void; + /** + * Writes the newly created zip file to disk at the specified location or + * if a zip was opened and no `targetFileName` is provided, it will + * overwrite the opened zip. + */ + writeZip(targetFileName?: string, callback?: (error: Error | null) => void): void; + /** + * Writes the newly created zip file to disk at the specified location or + * if a zip was opened and no `targetFileName` is provided, it will + * overwrite the opened zip. + */ + writeZipPromise(targetFileName?: string, props?: { overwrite?: boolean; perm?: number }): Promise; + /** + * Returns the content of the entire zip file. + */ + toBuffer(): Buffer; + /** + * Asynchronously returns the content of the entire zip file. + * @param onSuccess called with the content of the zip file, once it has been generated. + * @param onFail unused. + * @param onItemStart called before an entry is compressed. + * @param onItemEnd called after an entry is compressed. + */ + toBuffer( + onSuccess: (buffer: Buffer) => void, + onFail?: (...args: any[]) => void, + onItemStart?: (name: string) => void, + onItemEnd?: (name: string) => void, + ): void; + /** + * Asynchronously convert the promise to a Buffer + */ + toBufferPromise(): Promise; +} + +declare namespace AdmZip { + /** + * The `IZipEntry` is more than a structure representing the entry inside the + * zip file. Beside the normal attributes and headers a entry can have, the + * class contains a reference to the part of the file where the compressed + * data resides and decompresses it when requested. It also compresses the + * data and creates the headers required to write in the zip file. + */ + // disable warning about the I-prefix in interface name to prevent breaking stuff for users without a major bump + // eslint-disable-next-line @typescript-eslint/naming-convention + interface IZipEntry { + /** + * Represents the full name and path of the file + */ + entryName: string; + readonly rawEntryName: Buffer; + /** + * Extra data associated with this entry. + */ + extra: Buffer; + /** + * Entry comment. + */ + comment: string; + readonly name: string; + /** + * Read-Only property that indicates the type of the entry. + */ + readonly isDirectory: boolean; + /** + * Get the header associated with this ZipEntry. + */ + readonly header: EntryHeader; + attr: number; + /** + * Retrieve the compressed data for this entry. Note that this may trigger + * compression if any properties were modified. + */ + getCompressedData(): Buffer; + /** + * Asynchronously retrieve the compressed data for this entry. Note that + * this may trigger compression if any properties were modified. + */ + getCompressedDataAsync(callback: (data: Buffer) => void): void; + /** + * Set the (uncompressed) data to be associated with this entry. + */ + setData(value: string | Buffer): void; + /** + * Get the decompressed data associated with this entry. + */ + getData(): Buffer; + /** + * Asynchronously get the decompressed data associated with this entry. + */ + getDataAsync(callback: (data: Buffer, err: string) => void): void; + /** + * Returns the CEN Entry Header to be written to the output zip file, plus + * the extra data and the entry comment. + */ + packHeader(): Buffer; + /** + * Returns a nicely formatted string with the most important properties of + * the ZipEntry. + */ + toString(): string; + } + + interface EntryHeader { + made: number; + version: number; + flags: number; + method: number; + time: Date; + crc: number; + compressedSize: number; + size: number; + fileNameLength: number; + extraLength: number; + commentLength: number; + diskNumStart: number; + inAttr: number; + attr: number; + offset: number; + readonly encripted: boolean; + readonly entryHeaderSize: number; + readonly realDataOffset: number; + readonly dataHeader: DataHeader; + loadDataHeaderFromBinary(data: Buffer): void; + loadFromBinary(data: Buffer): void; + dataHeaderToBinary(): Buffer; + entryHeaderToBinary(): Buffer; + toString(): string; + } + + interface DataHeader { + version: number; + flags: number; + method: number; + time: number; + crc: number; + compressedSize: number; + size: number; + fnameLen: number; + extraLen: number; + } + + interface InitOptions { + /* If true it disables files sorting */ + noSort: boolean; + /* Read entries during load (initial loading may be slower) */ + readEntries: boolean; + /* Read method */ + method: (typeof Constants)[keyof typeof Constants] | number; + /* file system */ + fs: null | typeof FS; + } +} + +export = AdmZip; diff --git a/types/adm-zip/ts5.6/tsconfig.json b/types/adm-zip/ts5.6/tsconfig.json new file mode 100644 index 00000000000000..d656e939e24d99 --- /dev/null +++ b/types/adm-zip/ts5.6/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "node16", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "adm-zip-tests.ts" + ] +} diff --git a/types/adm-zip/ts5.6/util.d.ts b/types/adm-zip/ts5.6/util.d.ts new file mode 100644 index 00000000000000..1691f3830a97c6 --- /dev/null +++ b/types/adm-zip/ts5.6/util.d.ts @@ -0,0 +1,178 @@ +export const Constants: { + /* The local file header */ + LOCHDR: 30; // LOC header size + LOCSIG: 0x04034b50; // "PK\003\004" + LOCVER: 4; // version needed to extract + LOCFLG: 6; // general purpose bit flag + LOCHOW: 8; // compression method + LOCTIM: 10; // modification time (2 bytes time, 2 bytes date) + LOCCRC: 14; // uncompressed file crc-32 value + LOCSIZ: 18; // compressed size + LOCLEN: 22; // uncompressed size + LOCNAM: 26; // filename length + LOCEXT: 28; // extra field length + + /* The Data descriptor */ + EXTSIG: 0x08074b50; // "PK\007\008" + EXTHDR: 16; // EXT header size + EXTCRC: 4; // uncompressed file crc-32 value + EXTSIZ: 8; // compressed size + EXTLEN: 12; // uncompressed size + + /* The central directory file header */ + CENHDR: 46; // CEN header size + CENSIG: 0x02014b50; // "PK\001\002" + CENVEM: 4; // version made by + CENVER: 6; // version needed to extract + CENFLG: 8; // encrypt, decrypt flags + CENHOW: 10; // compression method + CENTIM: 12; // modification time (2 bytes time, 2 bytes date) + CENCRC: 16; // uncompressed file crc-32 value + CENSIZ: 20; // compressed size + CENLEN: 24; // uncompressed size + CENNAM: 28; // filename length + CENEXT: 30; // extra field length + CENCOM: 32; // file comment length + CENDSK: 34; // volume number start + CENATT: 36; // internal file attributes + CENATX: 38; // external file attributes (host system dependent) + CENOFF: 42; // LOC header offset + + /* The entries in the end of central directory */ + ENDHDR: 22; // END header size + ENDSIG: 0x06054b50; // "PK\005\006" + ENDSUB: 8; // number of entries on this disk + ENDTOT: 10; // total number of entries + ENDSIZ: 12; // central directory size in bytes + ENDOFF: 16; // offset of first CEN header + ENDCOM: 20; // zip file comment length + + END64HDR: 20; // zip64 END header size + END64SIG: 0x07064b50; // zip64 Locator signature, "PK\006\007" + END64START: 4; // number of the disk with the start of the zip64 + END64OFF: 8; // relative offset of the zip64 end of central directory + END64NUMDISKS: 16; // total number of disks + + ZIP64SIG: 0x06064b50; // zip64 signature, "PK\006\006" + ZIP64HDR: 56; // zip64 record minimum size + ZIP64LEAD: 12; // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE + ZIP64SIZE: 4; // zip64 size of the central directory record + ZIP64VEM: 12; // zip64 version made by + ZIP64VER: 14; // zip64 version needed to extract + ZIP64DSK: 16; // zip64 number of this disk + ZIP64DSKDIR: 20; // number of the disk with the start of the record directory + ZIP64SUB: 24; // number of entries on this disk + ZIP64TOT: 32; // total number of entries + ZIP64SIZB: 40; // zip64 central directory size in bytes + ZIP64OFF: 48; // offset of start of central directory with respect to the starting disk number + ZIP64EXTRA: 56; // extensible data sector + + /* Compression methods */ + STORED: 0; // no compression + SHRUNK: 1; // shrunk + REDUCED1: 2; // reduced with compression factor 1 + REDUCED2: 3; // reduced with compression factor 2 + REDUCED3: 4; // reduced with compression factor 3 + REDUCED4: 5; // reduced with compression factor 4 + IMPLODED: 6; // imploded + // 7 reserved for Tokenizing compression algorithm + DEFLATED: 8; // deflated + ENHANCED_DEFLATED: 9; // enhanced deflated + PKWARE: 10; // PKWare DCL imploded + // 11 reserved by PKWARE + BZIP2: 12; // compressed using BZIP2 + // 13 reserved by PKWARE + LZMA: 14; // LZMA + // 15-17 reserved by PKWARE + IBM_TERSE: 18; // compressed using IBM TERSE + IBM_LZ77: 19; // IBM LZ77 z + AES_ENCRYPT: 99; // WinZIP AES encryption method + + /* General purpose bit flag */ + // values can obtained with expression 2**bitnr + FLG_ENC: 1; // Bit 0: encrypted file + FLG_COMP1: 2; // Bit 1, compression option + FLG_COMP2: 4; // Bit 2, compression option + FLG_DESC: 8; // Bit 3, data descriptor + FLG_ENH: 16; // Bit 4, enhanced deflating + FLG_PATCH: 32; // Bit 5, indicates that the file is compressed patched data. + FLG_STR: 64; // Bit 6, strong encryption (patented) + // Bits 7-10: Currently unused. + FLG_EFS: 2048; // Bit 11: Language encoding flag (EFS) + // Bit 12: Reserved by PKWARE for enhanced compression. + // Bit 13: encrypted the Central Directory (patented). + // Bits 14-15: Reserved by PKWARE. + FLG_MSK: 4096; // mask header values + + /* Load type */ + FILE: 2; + BUFFER: 1; + NONE: 0; + + /* 4.5 Extensible data fields */ + EF_ID: 0; + EF_SIZE: 2; + + /* Header IDs */ + ID_ZIP64: 0x0001; + ID_AVINFO: 0x0007; + ID_PFS: 0x0008; + ID_OS2: 0x0009; + ID_NTFS: 0x000a; + ID_OPENVMS: 0x000c; + ID_UNIX: 0x000d; + ID_FORK: 0x000e; + ID_PATCH: 0x000f; + ID_X509_PKCS7: 0x0014; + ID_X509_CERTID_F: 0x0015; + ID_X509_CERTID_C: 0x0016; + ID_STRONGENC: 0x0017; + ID_RECORD_MGT: 0x0018; + ID_X509_PKCS7_RL: 0x0019; + ID_IBM1: 0x0065; + ID_IBM2: 0x0066; + ID_POSZIP: 0x4690; + + EF_ZIP64_OR_32: 0xffffffff; + EF_ZIP64_OR_16: 0xffff; + EF_ZIP64_SUNCOMP: 0; + EF_ZIP64_SCOMP: 8; + EF_ZIP64_RHO: 16; + EF_ZIP64_DSN: 24; +}; + +export const Errors: { + /* Header error messages */ + INVALID_LOC: "Invalid LOC header (bad signature)"; + INVALID_CEN: "Invalid CEN header (bad signature)"; + INVALID_END: "Invalid END header (bad signature)"; + + /* ZipEntry error messages */ + NO_DATA: "Nothing to decompress"; + BAD_CRC: "CRC32 checksum failed"; + FILE_IN_THE_WAY: "There is a file in the way: %s"; + UNKNOWN_METHOD: "Invalid/unsupported compression method"; + + /* Inflater error messages */ + AVAIL_DATA: "inflate::Available inflate data did not terminate"; + INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block"; + TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes"; + INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths"; + INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length"; + INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete"; + INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths"; + INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths"; + INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement"; + INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)"; + + /* ADM-ZIP error messages */ + CANT_EXTRACT_FILE: "Could not extract the file"; + CANT_OVERRIDE: "Target file already exists"; + NO_ZIP: "No zip file was loaded"; + NO_ENTRY: "Entry doesn't exist"; + DIRECTORY_CONTENT_ERROR: "A directory cannot have content"; + FILE_NOT_FOUND: "File not found: %s"; + NOT_IMPLEMENTED: "Not implemented"; + INVALID_FILENAME: "Invalid filename"; + INVALID_FORMAT: "Invalid or unsupported zip format. No END header found"; +}; diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 2125fd396f3cf7..ea0e941baae5c4 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -4074,14 +4074,17 @@ declare namespace chrome { id: string; /** * Implements the WebCrypto's SubtleCrypto interface. The cryptographic operations, including key generation, are hardware-backed. - * Only non-extractable keys can be generated. The supported key types are RSASSA-PKCS1-V1_5 and RSA-OAEP (on Chrome versions 134+) with `modulusLength` up to 2048 and ECDSA with `namedCurve` P-256. Each RSASSA-PKCS1-V1_5 and ECDSA key can be used for signing data at most once, unless the extension is allowlisted through the KeyPermissions policy, in which case the key can be used indefinitely. RSA-OAEP keys are supported since Chrome version 134 and can be used by extensions allowlisted through that same policy to unwrap other keys. + * + * Only non-extractable keys can be generated. The supported key types are RSASSA-PKCS1-V1_5 with `modulusLength` up to 2048 and ECDSA with `namedCurve` P-256. Each key can be used for signing data at most once, unless the extension is allowlisted by the KeyPermissions policy, in which case the key can be used indefinitely. + * * Keys generated on a specific `Token` cannot be used with any other Tokens, nor can they be used with `window.crypto.subtle`. Equally, `Key` objects created with `window.crypto.subtle` cannot be used with this interface. */ subtleCrypto: SubtleCrypto; /** - * Implements the WebCrypto's SubtleCrypto interface. The cryptographic operations, including key generation, are software-backed. - * Protection of the keys, and thus implementation of the non-extractable property, is done in software, so the keys are less protected than hardware-backed keys. - * Only non-extractable keys can be generated. The supported key types are RSASSA-PKCS1-V1_5 and RSA-OAEP (on Chrome versions 134+) with `modulusLength` up to 2048. Each RSASSA-PKCS1-V1_5 key can be used for signing data at most once, unless the extension is allowlisted through the KeyPermissions policy, in which case the key can be used indefinitely. RSA-OAEP keys are supported since Chrome version 134 and can be used by extensions allowlisted through that same policy to unwrap other keys. + * Implements the WebCrypto's SubtleCrypto interface. The cryptographic operations, including key generation, are software-backed. Protection of the keys, and thus implementation of the non-extractable property, is done in software, so the keys are less protected than hardware-backed keys. + * + * Only non-extractable keys can be generated. The only supported key type is RSASSA-PKCS1-V1_5 with `modulusLength` up to 2048. up to 2048. Each key can be used for signing data at most once, unless the extension is allowlisted through the KeyPermissions policy, in which case the key can be used indefinitely. + * * Keys generated on a specific `Token` cannot be used with any other Tokens, nor can they be used with `window.crypto.subtle`. Equally, `Key` objects created with `window.crypto.subtle` cannot be used with this interface. * @since Chrome 97 */ @@ -9690,7 +9693,7 @@ declare namespace chrome { /** Sent after onSuspend to indicate that the app won't be unloaded after all. */ export const onSuspendCanceled: events.Event<() => void>; - /** Fired when a message is sent from either an extension process (by {@link runtime.sendMessage}) or a content script (by {@link tabs.sendMessage}). */ + /** Fired when a message is sent from either {@link runtime.sendMessage} or {@link tabs.sendMessage}. */ export const onMessage: events.Event< (message: any, sender: MessageSender, sendResponse: (response?: any) => void) => void >; @@ -11056,7 +11059,7 @@ declare namespace chrome { sessionId?: string | undefined; /** * The ID of the Split View that the tab belongs to. - * @since Chrome 145 + * @since Chrome 140 */ splitViewId?: number | undefined; /** @@ -11132,7 +11135,7 @@ declare namespace chrome { /** * An ID that represents the absence of a split tab. - * @since Chrome 145 + * @since Chrome 140 */ export const SPLIT_VIEW_ID_NONE: -1; @@ -11579,7 +11582,7 @@ declare namespace chrome { export function duplicate(tabId: number, callback: (tab?: Tab) => void): void; /** - * Sends a single message to the content script(s) in the specified tab, with an optional callback to run when a response is sent back. The {@link runtime.onMessage} event is fired in each content script running in the specified tab for the current extension. + * Sends a single message to the content script(s) in the specified tab. The {@link runtime.onMessage} event is fired in each content script running in the specified tab for the current extension. * * Can return its result via Promise in Manifest V3 or later since Chrome 99. */ diff --git a/types/knockout.mapping/package.json b/types/knockout.mapping/package.json index c4971384227519..18f05b080fff29 100644 --- a/types/knockout.mapping/package.json +++ b/types/knockout.mapping/package.json @@ -19,10 +19,6 @@ { "name": "Mathias Lorenzen", "githubUsername": "ffMathy" - }, - { - "name": "Leonardo Lombardi", - "githubUsername": "ltlombardi" } ] } diff --git a/types/knockout/package.json b/types/knockout/package.json index 01ca8c751a822a..868b853c90f781 100644 --- a/types/knockout/package.json +++ b/types/knockout/package.json @@ -33,10 +33,6 @@ "name": "Mathias Lorenzen", "githubUsername": "ffMathy" }, - { - "name": "Leonardo Lombardi", - "githubUsername": "ltlombardi" - }, { "name": "Retsam", "githubUsername": "Retsam" diff --git a/types/murmurhash-js/package.json b/types/murmurhash-js/package.json index dbd194279043dd..f5437e49b43cef 100644 --- a/types/murmurhash-js/package.json +++ b/types/murmurhash-js/package.json @@ -8,10 +8,5 @@ "devDependencies": { "@types/murmurhash-js": "workspace:." }, - "owners": [ - { - "name": "Chi Vinh Le", - "githubUsername": "cvle" - } - ] + "owners": [] } diff --git a/types/readmore-js/package.json b/types/readmore-js/package.json index 7f1ce2a9e278c3..5c525ad632e622 100644 --- a/types/readmore-js/package.json +++ b/types/readmore-js/package.json @@ -8,10 +8,5 @@ "devDependencies": { "@types/readmore-js": "workspace:." }, - "owners": [ - { - "name": "AntonDemarczyk", - "githubUsername": "AntonDemarczyk" - } - ] + "owners": [] } diff --git a/types/telegram-web-app/index.d.ts b/types/telegram-web-app/index.d.ts index 1fea6315017529..1b142fb36cbf63 100644 --- a/types/telegram-web-app/index.d.ts +++ b/types/telegram-web-app/index.d.ts @@ -935,46 +935,73 @@ export interface BackButton { * Web App in the Telegram interface. */ export interface BottomButton { - /** Current button text. Set to CONTINUE by default. */ + /** + * **Bot API 9.5+** + * + * Unique identifier of the custom emoji shown + * before the text of the button. + */ + iconCustomEmojiId: string; + /** + * Current button text. Set to _Continue_ for the main button and + * _Cancel_ for the secondary button by default. + */ text: string; - /** Current button color. Set to themeParams.button_color by default. */ + /** + * Current button color. Set to _themeParams.button_color_ for the main button + * and _themeParams.bottom_bar_bg_color_ for the secondary button by default. + */ color: string; /** - * Current button text color. Set to themeParams.button_text_color by - * default. + * Current button text color. Set to + * _themeParams.button_text_color_ for the main button and + * _themeParams.button_color_ for the secondary button by default. */ textColor: string; - /** Shows whether the button is visible. Set to false by default. */ + /** Shows whether the button is visible. Set to _false_ by default. */ isVisible: boolean; - /** Shows whether the button is active. Set to true by default. */ + /** Shows whether the button is active. Set to _true_ by default. */ isActive: boolean; - /** Shows whether the button has a shine effect. Set to false by default. */ + /** + * **Bot API 7.10+** + * + * Shows whether the button has a shine effect. Set to _false_ by default. + */ hasShineEffect: boolean; /** + * **Bot API 7.10+** + * * Position of the secondary button. Not defined for the main button. - * It applies only if both the main and secondary buttons are visible. Set to left by default. + * It applies only if both the main and secondary buttons are visible. + * Set to _left_ by default. + * * Supported values: - * - left, displayed to the left of the main button, - * - right, displayed to the right of the main button, - * - top, displayed above the main button, - * - bottom, displayed below the main button. + * - _left_, displayed to the left of the main button, + * - _right_, displayed to the right of the main button, + * - _top_, displayed above the main button, + * - _bottom_, displayed below the main button. */ position?: "left" | "right" | "top" | "bottom"; - /** Readonly. Shows whether the button is displaying a loading indicator. */ + /** _Readonly._ Shows whether the button is displaying a loading indicator. */ isProgressVisible: boolean; /** A method to set the button text. */ setText(text: string): BottomButton; /** - * A method that sets the button press event handler. An alias for - * Telegram.WebApp.onEvent('mainButtonClicked', callback) + * A method that sets the button's press event handler. + * An alias for `Telegram.WebApp.onEvent('mainButtonClicked', callback)` */ onClick(callback: () => void): BottomButton; - /** A method that deletes a previously set handler */ + /** + * A method that removes the button's press event handler. + * An alias for `Telegram.WebApp.offEvent('mainButtonClicked', callback)` + */ offClick(callback: () => void): BottomButton; /** - * A method to make the button visible. Note that opening the Web App from - * the attachment menu hides the main button until the user interacts with - * the Web App interface. + * A method to make the button visible. + * + * _Note that opening the Web App from + * the {@link https://core.telegram.org/bots/webapps#launching-mini-apps-from-the-attachment-menu | attachment menu} + * hides the main button until the user interacts with the Web App interface._ */ show(): BottomButton; /** A method to hide the button. */ @@ -987,7 +1014,7 @@ export interface BottomButton { * A method to show a loading indicator on the button. It is recommended to * display loading progress if the action tied to the button may take a long * time. By default, the button is disabled while the action is in progress. - * If the parameter leaveActive=true is passed, the button remains enabled. + * If the parameter `leaveActive=true` is passed, the button remains enabled. */ showProgress(leaveActive?: boolean): BottomButton; /** A method to hide the loading indicator. */ @@ -995,23 +1022,36 @@ export interface BottomButton { /** * A method to set the button parameters. The params parameter is an object * containing one or several fields that need to be changed: + * - icon_custom_emoji_id - `Bot API 9.5+` button icon emoji id; * - text - button text; * - color - button color; * - text_color - button text color; + * - has_shine_effect - `Bot API 7.10+` enable shine effect; + * - position - position of the secondary button; * - is_active - enable the button; * - is_visible - show the button. */ - setParams(params: MainButtonParams): BottomButton; + setParams(params: BottomButtonParams): BottomButton; } -export interface MainButtonParams { +export interface BottomButtonParams { + /** + * **Bot API 9.5+** + * + * button icon emoji id + */ + icon_custom_emoji_id?: string; /** button text */ text?: string; /** button color */ color?: Color; /** button text color */ text_color?: Color; - /** enable shine effect */ + /** + * **Bot API 7.10+** + * + * enable shine effect + */ has_shine_effect?: boolean; /** position of the secondary button */ position?: "left" | "right" | "top" | "bottom"; diff --git a/types/telegram-web-app/package.json b/types/telegram-web-app/package.json index 61b68b9a953f99..ec080c1d7488e8 100644 --- a/types/telegram-web-app/package.json +++ b/types/telegram-web-app/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/telegram-web-app", - "version": "9.1.9999", + "version": "9.5.9999", "nonNpm": "conflict", "nonNpmDescription": "telegram-web-app", "projects": ["https://telegram.org/js/telegram-web-app.js"], diff --git a/types/telegram-web-app/telegram-web-app-tests.ts b/types/telegram-web-app/telegram-web-app-tests.ts index b490fbe5e40b3a..529ad9326a227f 100644 --- a/types/telegram-web-app/telegram-web-app-tests.ts +++ b/types/telegram-web-app/telegram-web-app-tests.ts @@ -126,3 +126,15 @@ app.isActive; // $ExpectType boolean app.isFullscreen; // $ExpectType boolean app.isOrientationLocked; // $ExpectType boolean + +app.MainButton.iconCustomEmojiId; // $ExpectType string + +app.MainButton.setParams({ + icon_custom_emoji_id: "", // $ExpectType string +}); + +app.SecondaryButton.iconCustomEmojiId; // $ExpectType string + +app.SecondaryButton.setParams({ + icon_custom_emoji_id: "", // $ExpectType string +}); diff --git a/types/text-metrics/package.json b/types/text-metrics/package.json index 8bf230f9946bca..016532715190d5 100644 --- a/types/text-metrics/package.json +++ b/types/text-metrics/package.json @@ -9,10 +9,6 @@ "@types/text-metrics": "workspace:." }, "owners": [ - { - "name": "Wunmi Sogunle", - "githubUsername": "theresasogunle" - }, { "name": "Jose Fort", "githubUsername": "modus-jose" diff --git a/types/warning/package.json b/types/warning/package.json index d2036e2cf9d502..14be90e275b0fe 100644 --- a/types/warning/package.json +++ b/types/warning/package.json @@ -8,10 +8,5 @@ "devDependencies": { "@types/warning": "workspace:." }, - "owners": [ - { - "name": "Chi Vinh Le", - "githubUsername": "cvle" - } - ] + "owners": [] }