[
  {
    "path": ".eslintrc.json",
    "content": "{\n  \"$schema\": \"https://json.schemastore.org/eslintrc.json\",\n  \"env\": {\n    \"es2021\": true,\n    \"node\": true\n  },\n  \"extends\": [\"eslint:recommended\", \"plugin:@typescript-eslint/recommended\"],\n  \"parserOptions\": {\n    \"ecmaVersion\": \"latest\",\n    \"sourceType\": \"module\"\n  },\n  \"rules\": {\n    \"no-console\": \"error\",\n    \"@typescript-eslint/semi\": \"off\",\n    \"@typescript-eslint/no-explicit-any\": \"off\"\n  },\n  \"ignorePatterns\": [\"cmdline\", \"dist\"]\n}\n"
  },
  {
    "path": ".gitignore",
    "content": "# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\nlerna-debug.log*\n.pnpm-debug.log*\n\n# Diagnostic reports (https://nodejs.org/api/report.html)\nreport.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n*.lcov\n\n# nyc test coverage\n.nyc_output\n\n# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# Bower dependency directory (https://bower.io/)\nbower_components\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (https://nodejs.org/api/addons.html)\nbuild/Release\n\n# Dependency directories\nnode_modules/\njspm_packages/\n\n# Snowpack dependency directory (https://snowpack.dev/)\nweb_modules/\n\n# TypeScript cache\n*.tsbuildinfo\n\n# Optional npm cache directory\n.npm\n\n# Optional eslint cache\n.eslintcache\n\n# Optional stylelint cache\n.stylelintcache\n\n# Microbundle cache\n.rpt2_cache/\n.rts2_cache_cjs/\n.rts2_cache_es/\n.rts2_cache_umd/\n\n# Optional REPL history\n.node_repl_history\n\n# Output of 'npm pack'\n*.tgz\n\n# Yarn Integrity file\n.yarn-integrity\n\n# dotenv environment variable files\npackages/szip/.env\n.env.development.local\n.env.test.local\n.env.production.local\n.env.local\n\n# parcel-bundler cache (https://parceljs.org/)\n.cache\n.parcel-cache\n\n# Next.js build output\n.next\nout\n\n# Nuxt.js build / generate output\n.nuxt\ndist\n\n# Gatsby files\n.cache/\n# Comment in the public line in if your project uses Gatsby and not Next.js\n# https://nextjs.org/blog/next-9-1#public-directory-support\n# public\n\n# vuepress build output\n.vuepress/dist\n\n# vuepress v2.x temp and cache directory\n.temp\n.cache\n\n# Docusaurus cache and generated files\n.docusaurus\n\n# Serverless directories\n.serverless/\n\n# FuseBox cache\n.fusebox/\n\n# DynamoDB Local files\n.dynamodb/\n\n# TernJS port file\n.tern-port\n\n# Stores VSCode versions used for testing VSCode extensions\n.vscode-test\n\n# yarn v2\n.yarn/cache\n.yarn/unplugged\n.yarn/build-state.yml\n.yarn/install-state.gz\n.pnp.*\n\n.idea\n"
  },
  {
    "path": ".mocharc.json",
    "content": "{\n  \"$schema\": \"https://json.schemastore.org/mocharc.json\",\n  \"require\": [\"tsx\", \"dotenv/config\", \"chai/register-expect\"],\n  \"timeout\": 10000\n}\n"
  },
  {
    "path": ".prettierignore",
    "content": ".DS_Store\nnode_modules\n/build\n/.svelte-kit\n/package\npackages/szip/.env\n.env.*\n!.env.example\n\n# Ignore files for PNPM, NPM and YARN\npnpm-lock.yaml\npackage-lock.json\nyarn.lock\n.changeset/\n.prettierrc\npackage.json\n.vercel\n.contentlayer\ndist\ncmdline\n\nvite.config.js.timestamp-*\nvite.config.ts.timestamp-*\n"
  },
  {
    "path": ".prettierrc",
    "content": "{\n  \"useTabs\": false,\n  \"singleQuote\": true,\n  \"trailingComma\": \"none\",\n  \"printWidth\": 100,\n  \"overrides\": [\n    {\n      \"files\": \"*.md\",\n      \"options\": {\n        \"parser\": \"markdown\",\n        \"printWidth\": 79\n      }\n    }\n  ]\n}"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# node-archive\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"node-archive\",\n  \"version\": \"0.0.0-canary.5\",\n  \"main\": \"dist/index.js\",\n  \"module\": \"dist/index.mjs\",\n  \"types\": \"dist/index.d.ts\",\n  \"files\": [\n    \"dist/**\",\n    \"!dist/bin\"\n  ],\n  \"exports\": {\n    \".\": {\n      \"import\": {\n        \"types\": \"./dist/index.d.mts\",\n        \"default\": \"./dist/index.mjs\"\n      },\n      \"require\": {\n        \"types\": \"./dist/index.d.ts\",\n        \"default\": \"./dist/index.js\"\n      }\n    }\n  },\n  \"scripts\": {\n    \"dev\": \"tsup --watch\",\n    \"build\": \"tsup\",\n    \"test\": \"mocha \\\"**/*.test.ts\\\"\",\n    \"type-check\": \"tsc --noEmit\",\n    \"lint\": \"eslint \\\"src/**/*.ts\\\"\",\n    \"lint:fix\": \"npm run lint -- --fix\",\n    \"format:check\": \"prettier --check \\\"**/*.{ts,tsx,json,md}\\\"\",\n    \"format\": \"prettier --write .\",\n    \"bin:download\": \"node dist/scripts/install.mjs\",\n    \"prepublishOnly\": \"pnpm build && pnpm run format:check && pnpm run type-check && pnpm run bin:download && pnpm test\",\n    \"preinstall\": \"pnpm run bin:download\"\n  },\n  \"packageManager\": \"pnpm@8.15.0\",\n  \"dependencies\": {\n    \"execa\": \"^8.0.1\"\n  },\n  \"devDependencies\": {\n    \"@types/chai\": \"^4.3.12\",\n    \"@types/debug\": \"^4.1.12\",\n    \"@types/mocha\": \"^10.0.6\",\n    \"@types/node\": \"^20.11.26\",\n    \"@typescript-eslint/eslint-plugin\": \"^7.2.0\",\n    \"chai\": \"^5.1.0\",\n    \"debug\": \"^4.3.4\",\n    \"dotenv\": \"^16.4.5\",\n    \"eslint\": \"^8.57.0\",\n    \"mocha\": \"^10.3.0\",\n    \"prettier\": \"^3.2.5\",\n    \"szip\": \"workspace:^\",\n    \"tsup\": \"^8.0.2\",\n    \"tsx\": \"^4.7.1\",\n    \"typescript\": \"^5.4.2\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/shahradelahi/node-archive.git\"\n  },\n  \"author\": \"Shahrad Elahi <shahrad@litehex.com> (https://github.com/shahradelahi)\",\n  \"license\": \"GPL-3.0\",\n  \"bugs\": {\n    \"url\": \"https://github.com/shahradelahi/node-archive/issues\"\n  },\n  \"homepage\": \"https://github.com/shahradelahi/node-archive#readme\"\n}\n"
  },
  {
    "path": "packages/szip/index.ts",
    "content": "import * as Add from '@szip/cmd/add';\nimport * as Compress from '@szip/cmd/compress';\nimport * as Delete from '@szip/cmd/delete';\nimport * as Encrypt from '@szip/cmd/encrypt';\nimport * as List from '@szip/cmd/list';\nimport * as Update from '@szip/cmd/update';\n\nexport { Add, Compress, Delete, Encrypt, List, Update };\n\nconst SZip = {\n  ...Add,\n  ...Compress,\n  ...Delete,\n  ...Encrypt,\n  ...List,\n  ...Update\n};\n\n// ------------------------------\n\n// @todo: export SZip option types\n\nexport type { ArchiveType, Archive7z, ArchiveZip, ArchiveTar } from '@szip/parser';\nexport type { SZipCompressResult } from '@szip/parser';\n\n// ------------------------------\n\nexport { SZipError } from '@szip/error';\n\n// ------------------------------\n\nexport type * from '@szip/types';\n\n// ------------------------------\n\nexport { SZip };\nexport default SZip;\n"
  },
  {
    "path": "packages/szip/package.json",
    "content": "{\n  \"name\": \"szip\",\n  \"version\": \"0.0.0\",\n  \"main\": \"index.ts\",\n  \"types\": \"index.ts\",\n  \"scripts\": {\n    \"tests\": \"mocha \\\"**/*.test.ts\\\"\"\n  },\n  \"dependencies\": {},\n  \"devDependencies\": {}\n}\n"
  },
  {
    "path": "packages/szip/src/bin.ts",
    "content": "import { fsAccessSync } from '@/utils/fs-access';\nimport { getDirname } from '@/utils/get-dirname';\nimport { debug } from '@szip/debugger';\nimport { SZipError } from '@szip/error';\nimport { join, resolve } from 'node:path';\n\nexport const BIN_PATH = process?.env?.SZIP_BIN_PATH ?? resolveBinPath();\n\ndebug('Binary Path:', BIN_PATH);\n\nfunction resolveBinPath() {\n  // This path is for dev and its pointing to the dist folder and root of the project\n  const develPath = resolve(join('dist', 'bin', '7zz'));\n  if (fsAccessSync(develPath)) {\n    return develPath;\n  }\n\n  // This path is for dist version and its pointing to bin directory at the dist folder\n  const distLevel = resolve(join(getDirname(), 'bin', '7zz'));\n  if (fsAccessSync(distLevel)) {\n    return distLevel;\n  }\n\n  // We are not going to use $(which 7z) result because it can be different from the one we are using\n  throw new SZipError('p7z binary not found');\n}\n"
  },
  {
    "path": "packages/szip/src/cmd/add.ts",
    "content": "import type { ContentLike, WritableStream } from '@/types';\nimport { BIN_PATH } from '@szip/bin';\nimport { debug } from '@szip/debugger';\nimport { SZipError } from '@szip/error';\nimport { auditArgsWithStdout, handleExecaResult } from '@szip/helpers';\nimport { ArchiveInfo, ArchiveOperation, ArchiveResult } from '@szip/parser';\nimport { parseArchiveResult } from '@szip/parser/parse-archive-result';\nimport { addPattern, isRecurse } from '@szip/utils/pattern';\nimport { safeExec } from '@szip/utils/safe-exec';\nimport { PathLike } from 'node:fs';\nimport { ArchiveType, SafeReturn } from 'szip';\n\ntype SZipAddOptions = {\n  // -bb (Set output log level)\n  logLevel?: string;\n  // -i (Include)\n  include?: string[];\n  // -m (Method)\n  method?: string;\n  // -p (Set Password)\n  password?: string;\n  // -r (Recurse)\n  recurse?: boolean;\n  // -sdel (Delete files after including to archive)\n  deleteAfter?: boolean;\n  // -sfx (create SFX)\n  sfx?: boolean;\n  // -si (use StdIn)\n  stdin?: ContentLike;\n  // -so (use StdOut)\n  stdout?: WritableStream;\n  // -sni (Store NT security information)\n  storeNTSecurityInformation?: boolean;\n  // -sns (Store NTFS alternate Streams)\n  storeNTFSAlternateStreams?: boolean;\n  // -ssw (Compress shared files)\n  compressSharedFiles?: boolean;\n  // -spf (Use fully qualified file paths)\n  fullyQualifiedPaths?: boolean;\n  // -spm (Require path separator mark for directory path)\n  requirePathSeparator?: boolean;\n  // -stl (Set archive timestamp from the most recently modified file)\n  setArchiveTimestamp?: boolean;\n  // -stx (Exclude archive type)\n  excludeArchiveType?: boolean;\n  // -t (Type of archive)\n  type?: string;\n  // -u (Update)\n  update?: boolean;\n  // -v (Volumes)\n  volumes?: string;\n  // -w (Working Dir)\n  cwd?: string;\n  // -x (Exclude)\n  exclude?: string[];\n};\n\nexport async function add<\n  Operation extends ArchiveOperation = 'create' | 'update',\n  Type extends ArchiveType = any\n>(\n  filename: PathLike,\n  patterns: string[],\n  options: SZipAddOptions & { raw?: false }\n): Promise<SafeReturn<ArchiveResult<Operation, Type>, SZipError>>;\n\nexport async function add(\n  filename: PathLike,\n  patterns: string[],\n  options: SZipAddOptions & { stdout?: WritableStream; raw?: never }\n): Promise<SafeReturn<boolean, SZipError>>;\n\nexport async function add(\n  filename: PathLike,\n  patterns: string[],\n  options: SZipAddOptions & { raw: true }\n): Promise<SafeReturn<string, SZipError>>;\n\n/**\n * Add files to an archive.\n *\n * @param filename\n * @param patterns\n * @param options\n */\nexport async function add<Type extends ArchiveType = ArchiveType>(\n  filename: PathLike,\n  patterns: string[],\n  options: SZipAddOptions & { raw?: boolean }\n): Promise<SafeReturn<ArchiveInfo<Type> | string | boolean, SZipError>> {\n  let args = ['a'];\n\n  const audited = await auditArgsWithStdout(filename, args, {\n    ...options,\n    ignoreOverwrite: options.update\n  });\n  if (audited.error) {\n    return audited;\n  }\n\n  if (audited.data) {\n    args = audited.data;\n  }\n\n  if (options.type) {\n    args.push('-t' + options.type); // Type of archive: zip, tar, etc.\n  }\n\n  if (options.password) {\n    args.push(`-p${options.password}`);\n\n    // On 7z format add -mhe switch\n    if (options.type === '7z') {\n      args.push('-mhe');\n    }\n  }\n\n  // Add patterns\n  Array.from(patterns || [])\n    .filter((p) => p && p.trim() !== '')\n    .forEach((p) => args.push(p.trim()));\n\n  if (options.include) {\n    options.include.forEach((include) => {\n      args.push(addPattern('i', include, options.recurse ?? isRecurse(include)));\n    });\n  }\n\n  if (options.exclude) {\n    options.exclude.forEach((exclude) => {\n      args.push(addPattern('x', exclude, options.recurse ?? isRecurse(exclude)));\n    });\n  }\n\n  if (options.volumes) {\n    args.push('-v' + options.volumes);\n  }\n\n  if (options.deleteAfter) {\n    args.push('-sdel');\n  }\n\n  if (options.method) {\n    args.push('-m' + options.method);\n  }\n\n  if (options.sfx) {\n    args.push('-sfx');\n  }\n\n  if (options.fullyQualifiedPaths) {\n    args.push('-spf');\n  }\n\n  if (options.requirePathSeparator) {\n    args.push('-spm');\n  }\n\n  if (options.storeNTSecurityInformation) {\n    args.push('-sni');\n  }\n\n  if (options.storeNTFSAlternateStreams) {\n    args.push('-sns');\n  }\n\n  if (options.compressSharedFiles) {\n    args.push('-ssw');\n  }\n\n  if (options.setArchiveTimestamp) {\n    args.push('-stl');\n  }\n\n  if (options.excludeArchiveType) {\n    args.push('-stx');\n  }\n\n  // Examples:\n  //\n  // $ 7z a archive1.zip subdir\\\n  // adds all files and subfolders from folder subdir to archive archive1.zip. The filenames\n  // in archive will contain subdir\\ prefix.\n  //\n  // $ 7z a archive.7z Folder1\\ -xr!*.png\n  // adds to the archive.7z all files from Folder1 and its subfolders, except *.png files.\n  //\n  // $ 7z a -tzip archive.zip *.txt -x!temp.*\n  // adds to the archive.zip all *.txt files, except temp.* files.\n\n  const { data, error } = await safeExec(BIN_PATH, args, {\n    cwd: options?.cwd\n  });\n\n  if (error) {\n    return { error: SZipError.fromExecaError(error) };\n  }\n\n  debug('add', data.command);\n\n  // @ts-expect-error - It does not recognize the `operation` and `type` properties\n  return handleExecaResult(data, {\n    raw: options.raw || false,\n    stdout: options.stdout,\n    parser: parseArchiveResult\n  });\n}\n"
  },
  {
    "path": "packages/szip/src/cmd/compress.ts",
    "content": "import type { ContentLike, WritableStream } from '@/types';\nimport { BIN_PATH } from '@szip/bin';\nimport { debug } from '@szip/debugger';\nimport { SZipError } from '@szip/error';\nimport { auditArgsWithStdout, handleExecaResult } from '@szip/helpers';\nimport { SZipCompressResult } from '@szip/parser';\nimport { parseCompressMessage } from '@szip/parser/parse-compress-message';\nimport { safeExec } from '@szip/utils/safe-exec';\nimport { PathLike } from 'node:fs';\nimport { SafeReturn } from 'szip';\n\ntype SZipCompressOptions = {\n  // -m (Method)\n  method?: string;\n  // -p (Set Password)\n  password?: string;\n  // -t (Type of archive)\n  type: string;\n  // -so (write data to stdout)\n  stdout?: WritableStream;\n  // -w (Working Dir)\n  cwd?: string;\n  // force: Force to recreate archive\n  force?: boolean;\n};\n\nexport async function compress(\n  filename: PathLike | undefined,\n  content: ContentLike,\n  options: Omit<SZipCompressOptions, 'stdout'> & { stdout: WritableStream; raw?: never }\n): Promise<SafeReturn<boolean, SZipError>>;\n\nexport async function compress(\n  filename: PathLike,\n  content: ContentLike,\n  options: SZipCompressOptions & { raw?: false }\n): Promise<SafeReturn<SZipCompressResult, SZipError>>;\n\nexport async function compress(\n  filename: PathLike,\n  content: ContentLike,\n  options: SZipCompressOptions & { raw: true }\n): Promise<SafeReturn<string, SZipError>>;\n\n/**\n * Compress an archive or any given content.\n *\n * @param filename\n * @param content\n * @param options\n */\nexport async function compress(\n  filename: PathLike | undefined,\n  content: ContentLike,\n  options: SZipCompressOptions & { raw?: boolean }\n): Promise<SafeReturn<SZipCompressResult | string | boolean, SZipError>> {\n  let args = ['a', '-si'];\n\n  const audited = await auditArgsWithStdout(filename, args, options);\n  if (audited.error) {\n    return audited;\n  }\n\n  if (audited.data) {\n    args = audited.data;\n  }\n\n  if (options.type) {\n    args.push('-t' + options.type);\n  }\n\n  if (options.method) {\n    args.push('-m' + options.method);\n  }\n\n  if (options.password) {\n    args.push('-p' + options.password);\n  }\n\n  const { data, error } = await safeExec(BIN_PATH, args, {\n    input: content,\n    stdio: options.stdout ? ['pipe', options.stdout, 'inherit'] : undefined,\n    cwd: options?.cwd\n  });\n\n  if (error) {\n    return { error: SZipError.fromExecaError(error) };\n  }\n\n  debug('compress', data.command);\n\n  return handleExecaResult(data, {\n    raw: options.raw || false,\n    stdout: options.stdout,\n    parser: parseCompressMessage\n  });\n}\n"
  },
  {
    "path": "packages/szip/src/cmd/delete.ts",
    "content": "import { normalizePathLike } from '@/utils/normalize';\nimport { BIN_PATH } from '@szip/bin';\nimport { debug } from '@szip/debugger';\nimport { handleExecaResult } from '@szip/helpers';\nimport { ArchiveInfo, ArchiveResult, ArchiveType } from '@szip/parser';\nimport { parseArchiveResult } from '@szip/parser/parse-archive-result';\nimport { addPattern, isWildcard } from '@szip/utils/pattern';\nimport { safeExec } from '@szip/utils/safe-exec';\nimport { PathLike } from 'node:fs';\nimport { SafeReturn, SZipError } from 'szip';\n\ntype SZipDeleteOptions = {\n  // -bb (Set output log level)\n  logLevel?: string;\n  // -i (Include)\n  include?: string[];\n  // -x (Exclude)\n  exclude?: string[];\n  // -m (Method)\n  method?: string;\n  // -w (Working Dir)\n  cwd?: string;\n  // -p (Set Password)\n  password?: string;\n  // -r (Recurse)\n  recurse?: boolean;\n  // -sns (Store NTFS alternate Streams)\n  storeNTFSAlternateStreams?: boolean;\n  // -u (Update)\n  update?: boolean;\n};\n\nexport async function del(\n  filepath: PathLike,\n  patterns: string[],\n  options?: SZipDeleteOptions & { raw: true }\n): Promise<SafeReturn<string, SZipError>>;\n\nexport async function del<Type extends ArchiveType = any>(\n  filepath: PathLike,\n  patterns: string[],\n  options?: SZipDeleteOptions & { raw?: boolean }\n): Promise<SafeReturn<ArchiveResult<'delete', Type>, SZipError>>;\n\n/**\n * Deletes files from archive.\n *\n * @param filepath\n * @param patterns\n * @param options\n */\nexport async function del<Type extends ArchiveType = ArchiveType>(\n  filepath: PathLike,\n  patterns: string[],\n  options?: SZipDeleteOptions & { raw?: boolean }\n): Promise<SafeReturn<ArchiveInfo<Type> | string, SZipError>> {\n  const normalizedPath = normalizePathLike(filepath);\n  const args = ['d', normalizedPath];\n\n  if (options?.logLevel) {\n    args.push(`-bb${options.logLevel}`);\n  }\n\n  if (options?.password) {\n    args.push(`-p${options.password}`);\n  }\n\n  if (options?.recurse) {\n    args.push('-r');\n  }\n\n  if (options?.storeNTFSAlternateStreams) {\n    args.push('-sns');\n  }\n\n  if (options?.update) {\n    args.push('-u');\n  }\n\n  // Add patterns\n  Array.from(patterns || [])\n    .filter((p) => p && p.trim() !== '')\n    .forEach((p) => args.push(p.trim()));\n\n  if (options?.include) {\n    options.include.forEach((include) => {\n      args.push(addPattern('i', include, options.recurse ?? isWildcard(include)));\n    });\n  }\n\n  if (options?.exclude) {\n    options.exclude.forEach((exclude) => {\n      args.push(addPattern('x', exclude, options.recurse ?? isWildcard(exclude)));\n    });\n  }\n\n  // Examples:\n  //\n  // 7z d archive.zip *.bak -r\n  // deletes *.bak files from archive archive.zip.\n\n  const { data, error } = await safeExec(BIN_PATH, args, {\n    cwd: options?.cwd\n  });\n\n  if (error) {\n    return { error: SZipError.fromExecaError(error) };\n  }\n\n  debug('delete', data.command);\n\n  // @ts-expect-error - It does not recognize the `type` property\n  return handleExecaResult(data, {\n    raw: options?.raw || false,\n    parser: parseArchiveResult\n  });\n}\n"
  },
  {
    "path": "packages/szip/src/cmd/encrypt.ts",
    "content": "import { ContentLike } from '@/types';\nimport { normalizePathLike } from '@/utils/normalize';\nimport { BIN_PATH } from '@szip/bin';\nimport { debug } from '@szip/debugger';\nimport { handleExecaResult } from '@szip/helpers';\nimport { safeExec } from '@szip/utils/safe-exec';\nimport { PathLike } from 'node:fs';\nimport { basename } from 'node:path';\nimport { SafeReturn, SZipError } from 'szip';\n\ntype SZipEncryptOptions = {\n  // -t (Type of archive)\n  type?: string;\n  // -p (Set Password)\n  password: string;\n  // -w (Working Dir)\n  cwd?: string;\n  // force overwrite\n  force?: boolean;\n};\n\nexport async function encrypt(\n  output: PathLike,\n  content: ContentLike,\n  options: SZipEncryptOptions & { raw: true }\n): Promise<SafeReturn<string, SZipError>>;\n\nexport async function encrypt(\n  output: PathLike,\n  content: ContentLike,\n  options: SZipEncryptOptions & { raw?: false }\n): Promise<SafeReturn<boolean, SZipError>>;\n\n/**\n * Encrypt an archive\n *\n * @param output\n * @param content\n * @param options\n */\nexport async function encrypt(\n  output: PathLike,\n  content: ContentLike,\n  options: SZipEncryptOptions & { raw?: boolean }\n): Promise<SafeReturn<string | boolean, SZipError>> {\n  const normalizedPath = normalizePathLike(output);\n  const args = ['a', '-si', normalizedPath];\n\n  if (!options.password) {\n    throw new Error('Password is required');\n  }\n\n  if (options.type) {\n    args.push(`-t${options.type}`);\n  }\n\n  args.push(`-p${options.password}`);\n\n  const filename = basename(normalizedPath);\n\n  if (filename.endsWith('.7z')) {\n    args.push('-mhe=on');\n  }\n\n  const { data, error } = await safeExec(BIN_PATH, args, {\n    input: content,\n    cwd: options?.cwd\n  });\n\n  if (error) {\n    return { error: SZipError.fromExecaError(error) };\n  }\n\n  debug('encrypt', data.command);\n\n  return handleExecaResult(data, {\n    raw: options.raw || false,\n    parser: () => true\n  });\n}\n"
  },
  {
    "path": "packages/szip/src/cmd/extract.ts",
    "content": "import type { ContentLike, WritableStream } from '@/types';\nimport { BIN_PATH } from '@szip/bin';\nimport { handleExecaResult } from '@szip/helpers';\nimport { safeExec } from '@szip/utils/safe-exec';\nimport { SZipError } from 'szip';\n\ntype SZipExtractOptions = {\n  // -ai (Include archives)\n  includeArchives?: boolean;\n  // -an (Disable parsing of archive_name)\n  disableParsingArchiveName?: boolean;\n  // -ao (Overwrite mode)\n  overwriteMode?: string;\n  // -ax (Exclude archives)\n  excludeArchives?: boolean;\n  // -i (Include)\n  include?: string[];\n  // -m (Method)\n  method?: string;\n  // -o (Set Output Directory)\n  outDir?: string;\n  // -p (Set Password)\n  password?: string;\n  // -r (Recurse)\n  recurse?: boolean;\n  // -si (use StdIn)\n  stdin?: ContentLike;\n  // -sni (Store NT security information)\n  storeNTSecurityInformation?: boolean;\n  // -sns (Store NTFS alternate Streams)\n  storeNTFSAlternateStreams?: boolean;\n  // -so (use StdOut)\n  stdout?: WritableStream;\n  // -spf (Use fully qualified file paths)\n  fullyQualifiedPaths?: boolean;\n  // -spm (Require path separator mark for directory path)\n  requirePathSeparator?: boolean;\n  // -stx (Exclude archive type)\n  excludeArchiveType?: boolean;\n  // -t (Type of archive)\n  type?: string;\n  // -x (Exclude)\n  exclude?: string[];\n  // -y (Assume Yes on all queries)\n  assumeYes?: boolean;\n  // -scrc (Set hash method)\n  hashMethod?: string;\n  // -w (Working Dir)\n  cwd?: string;\n};\n\nexport async function extract(filename: string, options: SZipExtractOptions) {\n  const args = ['e', filename];\n\n  // Examples:\n  // 7z e archive.zip\n  // 7z e archive.zip -oc:\\soft *.cpp -r\n\n  const { data, error } = await safeExec(BIN_PATH, args, {\n    cwd: options?.cwd\n  });\n\n  if (error) {\n    return { error: SZipError.fromExecaError(error) };\n  }\n\n  return handleExecaResult(data, {\n    raw: true,\n    parser: () => true\n  });\n}\n"
  },
  {
    "path": "packages/szip/src/cmd/list.ts",
    "content": "import { normalizePathLike } from '@/utils/normalize';\nimport { BIN_PATH } from '@szip/bin';\nimport { debug } from '@szip/debugger';\nimport { SZipError } from '@szip/error';\nimport { handleExecaResult } from '@szip/helpers';\nimport { ArchiveInfo, ArchiveType, parseArchiveInfo } from '@szip/parser';\nimport type { SafeReturn } from '@szip/types';\nimport { safeExec } from '@szip/utils/safe-exec';\nimport type { PathLike } from 'node:fs';\n\ntype SZipListOptions = {\n  // -ai (Include archives)\n  includeArchives?: boolean;\n  // -an (Disable parsing of archive_name)\n  disableParsingArchiveName?: boolean;\n  // -ax (Exclude archives)\n  excludeArchives?: boolean;\n  // -i (Include)\n  include?: string[];\n  // // -slt (Show technical information)\n  // technicalInfo?: boolean;\n  // -sns (Store NTFS alternate Streams)\n  storeNTFSAlternateStreams?: boolean;\n  // -p (Set Password)\n  password?: string;\n  // -r (Recurse)\n  recurse?: boolean;\n  // -stx (Exclude archive type)\n  excludeArchiveType?: boolean;\n  // -t (Type of archive)\n  type?: string;\n  // -x (Exclude)\n  exclude?: string[];\n  // -w (Working Dir)\n  cwd?: string;\n};\n\nexport async function list<Type extends ArchiveType = ArchiveType>(\n  filename: PathLike,\n  options: SZipListOptions & { raw?: false }\n): Promise<SafeReturn<ArchiveInfo<Type>, SZipError>>;\n\nexport async function list(\n  filename: PathLike,\n  options: SZipListOptions & { raw: true }\n): Promise<SafeReturn<string, SZipError>>;\n\nexport async function list<Type extends ArchiveType = ArchiveType>(\n  filename: PathLike,\n  options: SZipListOptions & { raw?: boolean } = {}\n): Promise<SafeReturn<string | ArchiveInfo<Type>, SZipError>> {\n  const args: string[] = ['l', '-slt', normalizePathLike(filename)];\n\n  if (options?.password) {\n    args.push(`-p${options.password}`);\n  }\n\n  if (options?.recurse) {\n    args.push('-r');\n  }\n\n  if (options?.storeNTFSAlternateStreams) {\n    args.push('-sns');\n  }\n\n  if (options?.excludeArchiveType) {\n    args.push('-stx');\n  }\n\n  if (options?.include) {\n    options.include.forEach((include) => {\n      args.push('-i!' + include);\n    });\n  }\n\n  if (options?.excludeArchives) {\n    args.push('-ax');\n  }\n\n  if (options?.includeArchives) {\n    args.push('-ai');\n  }\n\n  const { data, error } = await safeExec(BIN_PATH, args, {\n    cwd: options?.cwd\n  });\n\n  if (error) {\n    return { error: SZipError.fromExecaError(error) };\n  }\n\n  debug('list', data.command);\n\n  return handleExecaResult(data, {\n    raw: options.raw || false,\n    parser: parseArchiveInfo\n  });\n}\n"
  },
  {
    "path": "packages/szip/src/cmd/update.ts",
    "content": "import { ContentLike, WritableStream } from '@/types';\nimport { PathLike } from 'node:fs';\n\ntype SZipUpdateOptions = {\n  // -bb (Set output log level)\n  logLevel?: string;\n  // -i (Include)\n  include?: string[];\n  // -m (Method)\n  method?: string;\n  // -p (Set Password)\n  password?: string;\n  // -r (Recurse)\n  recurse?: boolean;\n  // -sfx (create SFX)\n  sfx?: boolean;\n  // -so (use StdOut)\n  stdout?: WritableStream;\n  // -si (use StdIn)\n  stdin?: ContentLike;\n  // -sni (Store NT security information)\n  storeNTSecurityInformation?: boolean;\n  // -sns (Store NTFS alternate Streams)\n  storeNTFSAlternateStreams?: boolean;\n  // -ssw (Compress shared files)\n  compressSharedFiles?: boolean;\n  // -spf (Use fully qualified file paths)\n  fullyQualifiedPaths?: boolean;\n  // -spm (Require path separator mark for directory path)\n  requirePathSeparator?: boolean;\n  // -stl (Set archive timestamp from the most recently modified file)\n  setArchiveTimestamp?: boolean;\n  // -stx (Exclude archive type)\n  excludeArchiveType?: boolean;\n  // -t (Type of archive)\n  type?: string;\n  // -u (Update)\n  update?: boolean;\n  // -w (Working Dir)\n  workingDir?: string;\n  // -x (Exclude)\n  exclude?: string[];\n};\n\n/**\n * Update older files in the archive and add files that are not already in the archive.\n *\n * @param filename\n * @param options\n */\nexport async function update(filename: PathLike, options: SZipUpdateOptions) {}\n"
  },
  {
    "path": "packages/szip/src/debugger.ts",
    "content": "export function debug(...args: any[]) {\n  if (_debugger) {\n    _debugger(...args);\n  }\n}\n\nlet _debugger: (...args: any[]) => void;\n\n// Add debug\nimport('debug')\n  .then((pkg) => {\n    if (pkg) {\n      _debugger = pkg.default('SZip');\n    }\n  })\n  .catch(() => {});\n"
  },
  {
    "path": "packages/szip/src/error.ts",
    "content": "import { parseError } from '@szip/parser';\nimport { ExecaError } from 'execa';\n\nexport class SZipError extends Error {\n  constructor(\n    message: string,\n    private command?: string\n  ) {\n    super(message);\n  }\n\n  static fromStderr(message: string) {\n    return new SZipError(parseError(message));\n  }\n\n  static fromExecaError(result: ExecaError) {\n    return new SZipError(parseError(result.stderr), result.command);\n  }\n}\n"
  },
  {
    "path": "packages/szip/src/helpers.ts",
    "content": "import { fsAccessSync } from '@/utils/fs-access';\nimport { normalizePathLike } from '@/utils/normalize';\nimport type { ArchiveType } from '@szip/parser/types';\nimport { waitUtilOpenStream } from '@szip/utils/wait';\nimport { ExecaReturnValue } from 'execa';\nimport { PathLike, promises } from 'node:fs';\nimport type { Writable as WritableStream } from 'node:stream';\nimport { SafeReturn, SZipError } from 'szip';\n\nexport function detectArchiveType(message: string): ArchiveType | undefined {\n  const matches = /--\\n(?:.|\\n)+^Type = (.+)$/gm.exec(message);\n  if (!matches || !matches[1]) {\n    return;\n  }\n\n  return matches[1].trim() as ArchiveType;\n}\n\nexport function handleExecaResult<Value>(\n  result: ExecaReturnValue,\n  options: { raw: boolean; stdout?: WritableStream; parser?: (message: string) => Value }\n): SafeReturn<Value | string | boolean, SZipError> {\n  if (options.stdout) {\n    return { data: !result.failed };\n  }\n\n  const message = result.stdout !== '' ? result.stdout : result.stderr;\n  if (options.raw) {\n    return { data: message };\n  }\n\n  if (result.stderr !== '') {\n    return { error: SZipError.fromStderr(result.stderr) };\n  }\n\n  if (result.stdout === '') {\n    return { error: new SZipError('Empty') };\n  }\n\n  if (!options.parser) {\n    return { error: new SZipError('No parser is provided') };\n  }\n\n  return { data: options.parser(message) };\n}\n\nexport async function auditArgsWithStdout(\n  filename: PathLike | undefined,\n  args: string[],\n  options: { stdout?: WritableStream; force?: boolean; ignoreOverwrite?: boolean; raw?: boolean }\n): Promise<SafeReturn<string[], SZipError>> {\n  if (options.stdout) {\n    // Its using stdout. use a random str to as filename\n    args.push('-so');\n\n    const randomStr = Math.random().toString(36).substring(7);\n    const tempName = filename ? `${normalizePathLike(filename)}.${randomStr}` : `${randomStr}.tmp`;\n    args.push(tempName);\n\n    // We need to wait until the stream is open to write\n    await waitUtilOpenStream(options.stdout);\n\n    return { data: args };\n  }\n\n  // Passing IF statement means we're going to write stdout to a file\n\n  if (!filename) {\n    return { error: new SZipError('Filename is required') };\n  }\n\n  const normalizedFilename = normalizePathLike(filename);\n\n  if (!options.ignoreOverwrite) {\n    // Check if the file exists\n    const exists = fsAccessSync(filename);\n    if (exists && !options.force) {\n      return { error: new SZipError('File already exists.') };\n    }\n\n    if (options.force) {\n      // Remove previous file\n      try {\n        await promises.unlink(filename);\n      } catch (error) {\n        return { error: new SZipError('Error removing previous file') };\n      }\n    }\n  }\n\n  args.push(normalizedFilename);\n\n  return { data: args };\n}\n"
  },
  {
    "path": "packages/szip/src/parser/index.ts",
    "content": "export * from '@szip/parser/parse-archive-info';\nexport * from '@szip/parser/parse-error';\n\n// ------------------------------\n\nexport type * from '@szip/parser/types';\n\n// ------------------------------\n"
  },
  {
    "path": "packages/szip/src/parser/parse-archive-header.ts",
    "content": "import { detectArchiveType } from '@szip/helpers';\nimport {\n  BLOCKS_REGEX,\n  CHARACTERISTICS_REGEX,\n  CODE_PAGE_REGEX,\n  HEADERS_SIZE_REGEX,\n  METHOD_REGEX,\n  PHYSICAL_SIZE_REGEX,\n  SOLID_REGEX\n} from '@szip/parser/regex';\nimport { Archive7zHeader, ArchiveHeader, ArchiveTarHeader, ArchiveType } from '@szip/parser/types';\n\nexport function cRegExp(regex: RegExp): RegExp {\n  return new RegExp(regex.source, regex.flags);\n}\n\nfunction parseTarHeader(message: string): ArchiveTarHeader {\n  const physicalSize = cRegExp(PHYSICAL_SIZE_REGEX).exec(message);\n  const headersSize = cRegExp(HEADERS_SIZE_REGEX).exec(message);\n  const codePage = cRegExp(CODE_PAGE_REGEX).exec(message);\n  const characteristics = cRegExp(CHARACTERISTICS_REGEX).exec(message);\n\n  return {\n    type: 'tar',\n    physicalSize: physicalSize ? parseInt(physicalSize[1]) : 0,\n    headersSize: headersSize ? parseInt(headersSize[1]) : 0,\n    codePage: codePage ? codePage[1] : '',\n    characteristics: characteristics ? characteristics[1] : ''\n  };\n}\n\nfunction parse7zHeader(message: string): Archive7zHeader {\n  const physicalSize = cRegExp(PHYSICAL_SIZE_REGEX).exec(message);\n  const headersSize = cRegExp(HEADERS_SIZE_REGEX).exec(message);\n  const method = cRegExp(METHOD_REGEX).exec(message);\n  const solid = cRegExp(SOLID_REGEX).exec(message);\n  const blocks = cRegExp(BLOCKS_REGEX).exec(message);\n\n  return {\n    type: '7z',\n    physicalSize: physicalSize ? parseInt(physicalSize[1]) : 0,\n    headersSize: headersSize ? parseInt(headersSize[1]) : 0,\n    method: method![1].split(' '),\n    solid: solid![1] === '+',\n    blocks: parseInt(blocks![1])\n  };\n}\n\nexport function parseArchiveHeader<Type extends ArchiveType>(\n  message: string\n): ArchiveHeader<Type> | undefined {\n  const type = detectArchiveType(message);\n  switch (type) {\n    case '7z':\n      return parse7zHeader(message) as ArchiveHeader<Type>;\n    case 'tar':\n      return parseTarHeader(message) as ArchiveHeader<Type>;\n    case 'zip':\n      throw new Error('Not implemented');\n  }\n}\n"
  },
  {
    "path": "packages/szip/src/parser/parse-archive-info.ts",
    "content": "import { SZipError } from '@szip/error';\nimport type {\n  Archive7z,\n  ArchiveInfo,\n  ArchiveTarFile,\n  ArchiveTar,\n  Archive7zFile\n} from '@szip/parser/types';\nimport { detectArchiveType } from '@szip/helpers';\n\nfunction parse7zArchiveInfo(message: string): Archive7z {\n  const ARCHIVE_REGEX = /Listing archive: (.+)/gm;\n  const archivePath = ARCHIVE_REGEX.exec(message)![1];\n\n  const PHYSICAL_SIZE_REGEX = /^Physical Size = (\\d+)/gm;\n  const HEADERS_SIZE_REGEX = /^Headers Size = (\\d+)/gm;\n  const METHOD_REGEX = /^Method = (.+)/gm;\n  const SOLID_REGEX = /^Solid = (.+)/gm;\n  const BLOCKS_REGEX = /^Blocks = (\\d+)/gm;\n\n  const FILE_REGEX =\n    /Path = (.+)\\nSize = (\\d+)\\nPacked Size = (\\d+)\\nModified = (.+)\\nAttributes = (.+)\\nCRC = (.+)\\nEncrypted = (.+)\\nMethod = (.+)\\nBlock = (\\d+)/gm;\n\n  const physicalSize = parseInt(PHYSICAL_SIZE_REGEX.exec(message)![1]);\n  const headersSize = parseInt(HEADERS_SIZE_REGEX.exec(message)![1]);\n  const method = METHOD_REGEX.exec(message)![1].split(' ');\n  const solid = SOLID_REGEX.exec(message)![1] === '+';\n  const blocks = parseInt(BLOCKS_REGEX.exec(message)![1]);\n\n  const files: Archive7zFile[] = [];\n  let file: RegExpExecArray | null;\n  while ((file = FILE_REGEX.exec(message)) !== null) {\n    files.push({\n      path: file[1],\n      size: parseInt(file[2]),\n      packedSize: parseInt(file[3]),\n      modified: file[4],\n      attributes: file[5],\n      crc: file[6],\n      encrypted: file[7] === '+',\n      method: file[8].split(' '),\n      block: parseInt(file[9])\n    });\n  }\n\n  return {\n    path: archivePath,\n    type: '7z',\n    physicalSize,\n    headersSize,\n    method,\n    solid,\n    blocks,\n    files\n  };\n}\n\nfunction parseTarArchiveInfo(message: string): ArchiveTar {\n  const FILE_REGEX =\n    /Path = (.+)\\nFolder = (.+)\\nSize = (\\d+)\\nPacked Size = (\\d+)\\nModified = (.+)?\\nCreated = (.+)?\\nAccessed = (.+)?\\nMode = (.+)?\\nUser = (.+)?\\nGroup = (.+)?\\nUser ID = (.+)?\\nGroup ID = (.+)?\\nSymbolic Link = (.+)?\\nHard Link = (.+)?\\nCharacteristics = (.+)?\\nComment = (.+)?\\nDevice Major = (.+)?\\nDevice Minor = (.+)?/gm;\n\n  const files: ArchiveTarFile[] = [];\n  let file: RegExpExecArray | null;\n  while ((file = FILE_REGEX.exec(message)) !== null) {\n    files.push({\n      path: file[1],\n      folder: file[2] === '+',\n      size: parseInt(file[3]),\n      packedSize: parseInt(file[4]),\n      modified: file[5],\n      created: file[6],\n      accessed: file[7],\n      mode: file[8],\n      user: file[9],\n      group: file[10],\n      userID: parseInt(file[11]),\n      groupID: parseInt(file[12]),\n      symbolicLink: file[13] === '+',\n      hardLink: file[14] === '+',\n      characteristics: file[15],\n      comment: file[16],\n      deviceMajor: file[17],\n      deviceMinor: file[18]\n    });\n  }\n\n  const archivePath = /(?:Creating|Open|Updating|Listing) archive: (.+)$/gm.exec(message);\n  const physicalSize = /^Physical Size = (\\d+)/gm.exec(message);\n  const headersSize = /^Headers Size = (\\d+)/gm.exec(message);\n  const codePage = /^Code Page = (.+)/gm.exec(message);\n  const characteristics = /^Characteristics = (.+)/gm.exec(message);\n\n  return {\n    path: archivePath ? archivePath[1] : '',\n    type: 'tar',\n    physicalSize: physicalSize ? parseInt(physicalSize[1]) : 0,\n    headersSize: headersSize ? parseInt(headersSize[1]) : 0,\n    codePage: codePage ? codePage[1] : '',\n    characteristics: characteristics ? characteristics[1] : '',\n    files\n  };\n}\n\nexport function parseArchiveInfo(message: string): ArchiveInfo<any> | SZipError {\n  const type = detectArchiveType(message);\n\n  if (!type) {\n    throw new SZipError('Archive type not detected');\n  }\n\n  if (type === '7z') {\n    return parse7zArchiveInfo(message);\n  }\n\n  if (type === 'tar') {\n    return parseTarArchiveInfo(message);\n  }\n\n  throw new SZipError('Archive type not supported');\n}\n"
  },
  {
    "path": "packages/szip/src/parser/parse-archive-result.ts",
    "content": "import { parseArchiveHeader } from '@szip/parser/parse-archive-header';\nimport { ArchiveResult, ArchiveStats } from '@szip/parser/types';\n\nexport function parseArchiveResult(message: string): ArchiveResult {\n  const ADDED_FOLDER_FILE_BYTE_REGEX =\n    /^Add new data to archive: (?:(\\d+) folders, )?(\\d+) files?, (\\d+)/gm;\n\n  const PREVIOUS_FOLDER_FILE_BYTE_REGEX =\n    /^Keep old data in archive: (?:(\\d+) folders, )?(\\d+) files?, (\\d+)/gm;\n\n  const DELETED_FOLDER_FILE_BYTE_REGEX =\n    /^Delete data from archive: (?:(\\d+) folders, )?(\\d+) files?, (\\d+)/gm;\n\n  const ARCHIVE_SIZE_REGEX = /^Archive size: (\\d+) bytes/gm;\n\n  const ARCHIVE_REGEX = /^(Creating|Updating) archive: (.+)$/gm;\n\n  const archivePath = ARCHIVE_REGEX.exec(message);\n  const archiveSize = ARCHIVE_SIZE_REGEX.exec(message);\n  const result: Partial<ArchiveResult> = {\n    path: archivePath![2],\n    size: parseInt(archiveSize![1])\n  };\n\n  const parsedHeader = parseArchiveHeader(message);\n  if (parsedHeader) {\n    result.header = parsedHeader;\n  }\n\n  const deletedStats = DELETED_FOLDER_FILE_BYTE_REGEX.exec(message);\n  if (deletedStats) {\n    result.deleted = {\n      files: parseInt(deletedStats[2]),\n      bytes: parseInt(deletedStats[3])\n    };\n  }\n\n  [ADDED_FOLDER_FILE_BYTE_REGEX, PREVIOUS_FOLDER_FILE_BYTE_REGEX].forEach((regex) => {\n    const stats = regex.exec(message);\n    if (stats) {\n      const type = regex === ADDED_FOLDER_FILE_BYTE_REGEX ? 'added' : 'previous';\n      const res: ArchiveStats = {\n        folders: stats[1] ? parseInt(stats[1]) : undefined,\n        files: parseInt(stats[2]),\n        bytes: parseInt(stats[3])\n      };\n\n      if (typeof res.folders === 'undefined') {\n        delete res.folders;\n      }\n\n      result[type] = res;\n    }\n  });\n\n  return result as ArchiveResult;\n}\n"
  },
  {
    "path": "packages/szip/src/parser/parse-compress-message.ts",
    "content": "import { SZipCompressResult } from '@szip/parser/types';\n\nexport function parseCompressMessage(message: string): SZipCompressResult {\n  const ARCHIVE_SIZE_REGEX = /^Archive size: (\\d+) bytes/gm;\n  const ARCHIVE_REGEX = /^Creating archive: (.+)$/gm;\n\n  const archivePath = ARCHIVE_REGEX.exec(message);\n  const archiveSize = ARCHIVE_SIZE_REGEX.exec(message);\n\n  return {\n    path: archivePath![1],\n    size: parseInt(archiveSize![1])\n  };\n}\n"
  },
  {
    "path": "packages/szip/src/parser/parse-error.ts",
    "content": "export function parseError(message: string) {\n  if (message.startsWith('Command failed with')) {\n    message = message.split('\\n').slice(2).join('\\n');\n  }\n\n  message = message.trim();\n\n  const isMultiLine = message.includes('\\n\\n\\n');\n\n  if (isMultiLine) {\n    const errors = message.split('\\n\\n');\n    message = errors[0];\n  }\n\n  message = message.replaceAll('\\n', ' ');\n\n  return message;\n}\n"
  },
  {
    "path": "packages/szip/src/parser/regex.ts",
    "content": "export const TYPE_REGEX = /^Type = (.+)$/gm;\nexport const PHYSICAL_SIZE_REGEX = /^Physical Size = (\\d+)$/gm;\nexport const HEADERS_SIZE_REGEX = /^Headers Size = (\\d+)$/gm;\nexport const METHOD_REGEX = /^Method = (.+)$/gm;\nexport const SOLID_REGEX = /^Solid = (.+)$/gm;\nexport const BLOCKS_REGEX = /^Blocks = (\\d+)$/gm;\nexport const CODE_PAGE_REGEX = /^Code Page = (.+)$/gm;\nexport const CHARACTERISTICS_REGEX = /^Characteristics = (.+)$/gm;\n"
  },
  {
    "path": "packages/szip/src/parser/types.ts",
    "content": "export type ArchiveType = '7z' | 'tar' | 'zip';\n\nexport type Archive7z = {\n  path: string;\n  type: '7z';\n  physicalSize: number;\n  headersSize: number;\n  method: string[];\n  solid: boolean;\n  blocks: number;\n  files: Archive7zFile[];\n};\n\nexport type Archive7zFile = {\n  path: string;\n  size: number;\n  packedSize: number;\n  modified: string;\n  attributes: string;\n  crc: string;\n  encrypted: boolean;\n  method: string[];\n  block: number;\n};\n\nexport type ArchiveTar = {\n  path: string;\n  type: 'tar';\n  physicalSize: number;\n  headersSize: number;\n  codePage: string;\n  characteristics: string;\n  files: ArchiveTarFile[];\n};\n\nexport type ArchiveTarFile = {\n  path: string;\n  folder: boolean;\n  size: number;\n  packedSize: number;\n  modified: string;\n  created: string | undefined;\n  accessed: string | undefined;\n  mode: string;\n  user: string | undefined;\n  group: string | undefined;\n  userID: number;\n  groupID: number;\n  symbolicLink: boolean;\n  hardLink: boolean;\n  characteristics: string;\n  comment: string | undefined;\n  deviceMajor: string | undefined;\n  deviceMinor: string | undefined;\n};\n\nexport type ArchiveZip = {\n  path: string;\n  type: 'zip';\n  physicalSize: number;\n  files: ArchiveZipFile[];\n};\n\nexport type ArchiveZipFile = {\n  path: string;\n  folder: boolean;\n  size: number;\n  packedSize: number;\n  modified: string;\n  created: string | undefined;\n  accessed: string | undefined;\n  attributes: string | undefined;\n  encrypted: boolean;\n  comment: string | undefined;\n  crc: string | undefined;\n  method: string;\n  characteristics: string;\n  hostOS: string;\n  version: number;\n  volumeIndex: number;\n  offset: number;\n};\n\nexport type ArchiveInfo<Type extends ArchiveType> = Type extends ArchiveType\n  ? {\n      '7z': Archive7z;\n      tar: ArchiveTar;\n      zip: ArchiveZip;\n    }[Type]\n  : never;\n\n// -------------------------------\n\nexport interface SZipCompressResult {\n  path: string;\n  size: number;\n}\n\n// -------------------------------\n\nexport interface ArchiveTarHeader {\n  type: 'tar';\n  physicalSize: number;\n  headersSize: number;\n  codePage: string;\n  characteristics: string;\n}\n\nexport interface Archive7zHeader {\n  type: '7z';\n  physicalSize: number;\n  headersSize: number;\n  method: string[];\n  solid: boolean;\n  blocks: number;\n}\n\nexport type ArchiveHeader<Type extends ArchiveType> = Type extends ArchiveType\n  ? {\n      '7z': Archive7zHeader;\n      tar: ArchiveTarHeader;\n      zip: never;\n    }[Type]\n  : never;\n\n// -------------------------------\n\nexport type ArchiveStats<Operation extends ArchiveOperation = any> = {\n  files: number;\n  bytes: number;\n} & (Operation extends 'delete' ? { folders?: never } : { folders: number });\n\nexport type ArchiveOperation = 'create' | 'update' | 'delete';\n\nexport type ArchiveResult<\n  Operation extends ArchiveOperation = any,\n  Type extends ArchiveType = any\n> = {\n  path: string;\n  size: number;\n  previous?: ArchiveStats<Operation>;\n  added: ArchiveStats<Operation>;\n} & (Operation extends 'create'\n  ? { header?: never }\n  : {\n      header: ArchiveHeader<Type>;\n    }) &\n  (Operation extends 'delete' ? { deleted: ArchiveStats<Operation> } : { deleted?: never });\n\n// -------------------------------\n"
  },
  {
    "path": "packages/szip/src/types.ts",
    "content": "export type SafeReturn<T, K = any> = Partial<{\n  data: T;\n  error: K;\n}> &\n  (\n    | {\n        data: T;\n        error?: never;\n      }\n    | {\n        data?: never;\n        error: K;\n      }\n  );\n"
  },
  {
    "path": "packages/szip/src/utils/pattern.ts",
    "content": "export function isRecurse(path: string) {\n  return path.includes('**');\n}\n\nexport function addPattern(mode: 'x' | 'i', path: string, recurse: boolean) {\n  return `-${mode}${recurse ? 'r' : ''}!${path}`;\n}\n\nexport function isWildcard(path: string) {\n  return path.includes('*');\n}\n"
  },
  {
    "path": "packages/szip/src/utils/safe-exec.ts",
    "content": "import { execa, ExecaError, ExecaReturnValue, Options } from 'execa';\nimport { SafeReturn } from 'szip';\n\nexport async function safeExec(\n  file: string,\n  args: string[],\n  options: Options\n): Promise<SafeReturn<ExecaReturnValue, ExecaError>> {\n  return execa(file, args, options)\n    .catch((error) => error)\n    .then((result) => (result instanceof Error ? { error: result } : { data: result }));\n}\n"
  },
  {
    "path": "packages/szip/src/utils/wait.ts",
    "content": "import { WritableStream } from '@/types';\n\nexport async function sleep(ms: number) {\n  return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport async function waitUtilOpenStream(stream: WritableStream) {\n  return new Promise((resolve) => stream.once('open', resolve));\n}\n"
  },
  {
    "path": "packages/szip/tests/archive.test.ts",
    "content": "import { log } from '@tests/log';\nimport { expect } from 'chai';\nimport { promises } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { SZip } from 'szip';\nimport { ROOT_DIR } from './utils';\n\ndescribe('SZip - Create Archive', () => {\n  describe('Zip', () => {\n    it('archive `src` and `dist` directory', async () => {\n      const filename = resolve(ROOT_DIR, 'project.zip');\n\n      const output = await SZip.add(filename, ['src/*', 'dist/*'], {\n        type: 'zip',\n        cwd: ROOT_DIR,\n        raw: true\n      });\n\n      expect(output).to.have.property('data').that.is.a('string');\n      expect(output.data).to.contain('Everything is Ok');\n\n      await promises.unlink(filename);\n    });\n\n    it('archive `package.json` and `pnpm-lock.yaml`', async () => {\n      const filename = resolve(ROOT_DIR, 'package.zip');\n\n      const output = await SZip.add(filename, ['package.json', 'pnpm-lock.yaml'], {\n        type: 'zip',\n        cwd: ROOT_DIR,\n        raw: true\n      });\n\n      log(output);\n\n      await promises.unlink(filename);\n    });\n  });\n\n  describe('Tar', () => {\n    it('archive `src` directory', async () => {\n      const filename = 'project.tar';\n\n      const output = await SZip.add(filename, ['src/*'], {\n        type: 'tar',\n        cwd: ROOT_DIR,\n        raw: true\n      });\n\n      log(output);\n\n      await promises.unlink(resolve(ROOT_DIR, filename));\n    });\n\n    it('should archive `src` and then add `dist` directory to archive', async () => {\n      const filename = resolve(ROOT_DIR, 'project.tar');\n\n      const createdTar = await SZip.add(filename, ['src/*'], {\n        type: 'tar',\n        cwd: ROOT_DIR,\n        raw: true\n      });\n\n      log(createdTar);\n\n      const updatedTar = await SZip.add(filename, ['dist/*'], {\n        type: 'tar',\n        update: true, // Update the archive\n        cwd: ROOT_DIR,\n        raw: true\n      });\n\n      log(updatedTar);\n\n      await promises.unlink(filename);\n    });\n\n    it('archive `package.json` and `pnpm-lock.yaml` then removes `package.json` from archive', async () => {\n      const filename = resolve(ROOT_DIR, 'package.tar');\n\n      const createdTar = await SZip.add(filename, ['package.json', 'pnpm-lock.yaml'], {\n        type: 'tar',\n        cwd: ROOT_DIR\n      });\n\n      log(createdTar);\n\n      const updatedTar = await SZip.del(filename, ['package.json']);\n\n      log(updatedTar);\n\n      await promises.unlink(filename);\n    });\n  });\n\n  describe('7z', () => {\n    it('should archive `src` and `dist` directory', async () => {\n      const filename = resolve(ROOT_DIR, 'project.7z');\n\n      const output = await SZip.add(filename, ['src/*', 'dist/*'], {\n        type: '7z',\n        cwd: ROOT_DIR,\n        raw: true\n      });\n\n      expect(output, output.error?.message).to.have.property('data').that.is.a('string');\n      expect(output.data).to.contain('Everything is Ok');\n\n      log(output);\n\n      await promises.unlink(filename);\n    });\n  });\n\n  describe('With password', () => {\n    it('create a zip', async () => {\n      const filename = resolve(ROOT_DIR, 'source.zip');\n\n      const output = await SZip.add(filename, ['src/*', 'dist/*'], {\n        type: 'zip',\n        password: 'pa$$word @|',\n        cwd: ROOT_DIR,\n        raw: true\n      });\n\n      log(output);\n\n      await promises.unlink(filename);\n    });\n  });\n});\n"
  },
  {
    "path": "packages/szip/tests/compress.test.ts",
    "content": "import { Archive } from 'node-archive';\nimport { resolve } from 'node:path';\nimport { SZip } from 'szip';\nimport { log } from '@tests/log';\nimport { expect } from 'chai';\nimport { createReadStream, createWriteStream, promises } from 'node:fs';\nimport { createTar, ROOT_DIR } from './utils';\n\ndescribe('SZip - Compress', () => {\n  describe('Using Stream', () => {\n    it('compress data from read stream', async () => {\n      const tarName = resolve(ROOT_DIR, 'source.tar');\n      const { data } = await createTar(tarName);\n      expect(data).to.contain('Everything is Ok');\n\n      const filename = resolve(ROOT_DIR, 'source.tar.xz');\n\n      const { data: output } = await SZip.compress(filename, createReadStream(tarName), {\n        type: 'xz',\n        cwd: ROOT_DIR,\n        raw: true\n      });\n\n      log(output);\n\n      await promises.unlink(filename);\n      await promises.unlink(tarName);\n    });\n\n    it('compress content to write stream', async () => {\n      const tarName = resolve(ROOT_DIR, 'source.tar');\n      const { data } = await createTar(tarName);\n      expect(data).to.contain('Everything is Ok');\n\n      const filename = resolve(ROOT_DIR, 'source.tar.xz');\n\n      const stream = createWriteStream(filename);\n\n      const { data: output } = await SZip.compress(undefined, createReadStream(tarName), {\n        type: 'xz',\n        cwd: ROOT_DIR,\n        stdout: stream\n      });\n\n      expect(output).to.be.true;\n\n      await promises.unlink(filename);\n      await promises.unlink(tarName);\n    });\n  });\n\n  it('compress a string', async () => {\n    const tarName = resolve(ROOT_DIR, 'source.tar');\n\n    const { data } = await createTar(tarName);\n\n    expect(data).to.contain('Everything is Ok');\n\n    // Read the source.tar and pass it to compress\n    const content = await promises.readFile(tarName);\n\n    const filename = resolve(ROOT_DIR, 'source.tar.xz');\n\n    const output = await SZip.compress(filename, content, {\n      type: 'xz',\n      cwd: ROOT_DIR\n    });\n\n    log(output);\n\n    expect(output).to.have.property('data');\n    expect(output.data).to.have.property('size');\n    expect(output.data).to.have.property('path');\n\n    await promises.unlink(filename);\n    await promises.unlink(tarName);\n  });\n});\n"
  },
  {
    "path": "packages/szip/tests/delete.test.ts",
    "content": "import { log } from '@tests/log';\nimport { expect } from 'chai';\nimport { promises } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { SZip } from 'szip';\nimport { ROOT_DIR } from './utils';\n\ndescribe('SZip - Delete', () => {\n  it('should `Tar` project and then delete `*.test.ts` files', async () => {\n    const filename = resolve(ROOT_DIR, 'project.tar');\n    const createdTar = await SZip.add(filename, ['*'], {\n      exclude: ['node_modules', 'project.tar'],\n      type: 'tar',\n      recurse: true,\n      update: true,\n      cwd: ROOT_DIR\n    });\n\n    log(createdTar);\n\n    const deletedTar = await SZip.del(filename, ['*.test.ts'], {\n      recurse: true,\n      cwd: ROOT_DIR\n    });\n\n    log(deletedTar);\n    expect(deletedTar.error).to.be.undefined;\n    expect(deletedTar.data).to.be.an('object');\n    expect(deletedTar.data).to.have.property('deleted').property('files').to.be.greaterThan(0);\n\n    await promises.unlink(filename);\n  });\n});\n"
  },
  {
    "path": "packages/szip/tests/encrypt.test.ts",
    "content": "import { log } from '@tests/log';\nimport { expect } from 'chai';\nimport { createReadStream, promises } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { SZip } from 'szip';\nimport { createTar, createTar7z, ROOT_DIR } from './utils';\n\ndescribe('SZip - Encrypt Archive', () => {\n  it('encrypt data from read stream', async () => {\n    const tarName = resolve(ROOT_DIR, 'source.tar');\n    const createdTar = await createTar(tarName);\n\n    expect(createdTar, createdTar.error?.message).to.have.property('data');\n    expect(createdTar.data).to.contain('Everything is Ok');\n\n    const filename = resolve(ROOT_DIR, 'secure.tar.7z');\n\n    const output = await SZip.encrypt(filename, createReadStream(tarName), {\n      cwd: ROOT_DIR,\n      password: '1234',\n      raw: true\n    });\n\n    expect(output, output.error?.message).to.have.property('data');\n    expect(output.data).to.contain('Everything is Ok');\n\n    log(output.data);\n\n    await promises.unlink(filename);\n    await promises.unlink(tarName);\n  });\n\n  it('encrypt the an 7z archive', async () => {\n    const tarName = resolve(ROOT_DIR, 'source.tar.7z');\n    const createdTar = await createTar7z(tarName);\n\n    expect(createdTar, createdTar.error?.message).to.have.property('data');\n    expect(createdTar.data).to.contain('Everything is Ok');\n\n    // Read the source.tar and pass it to compress\n    const content = await promises.readFile(tarName);\n\n    const filename = resolve(ROOT_DIR, 'secure.tar.7z');\n\n    const output = await SZip.encrypt(filename, content, {\n      cwd: ROOT_DIR,\n      password: '1234'\n    });\n\n    log(output);\n\n    expect(output).to.have.property('data').to.be.true;\n\n    await promises.unlink(filename);\n    await promises.unlink(tarName);\n  });\n});\n"
  },
  {
    "path": "packages/szip/tests/list.test.ts",
    "content": "import { log } from '@tests/log';\nimport { promises } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { SZip } from 'szip';\nimport { createTar, createTar7z, createZip, ROOT_DIR } from './utils';\n\ndescribe('SZip - List', () => {\n  describe('Technical', () => {\n    it('list the info of a 7z file', async () => {\n      const filename = resolve(ROOT_DIR, 'source.tar.7z');\n      await createTar7z(filename);\n\n      const list = await SZip.list(filename, {\n        raw: true\n      });\n\n      log(list);\n\n      await promises.unlink(filename);\n    });\n\n    it('list the info of a tar file', async () => {\n      await createTar('source.tar');\n\n      const list = await SZip.list('source.tar', {\n        raw: true\n      });\n      log(list);\n\n      await promises.unlink('source.tar');\n    });\n\n    it('list the info of a zip file', async () => {\n      const filename = 'source.zip';\n      await createZip(filename);\n\n      const list = await SZip.list(filename, {\n        raw: true\n      });\n      log(list);\n\n      await promises.unlink(filename);\n    });\n  });\n});\n"
  },
  {
    "path": "packages/szip/tests/parser.test.ts",
    "content": "import {\n  ArchiveResult,\n  ArchiveTar,\n  parseArchiveInfo,\n  parseError,\n  SZipCompressResult\n} from '@szip/parser';\nimport { parseArchiveResult } from '@szip/parser/parse-archive-result';\nimport { parseCompressMessage } from '@szip/parser/parse-compress-message';\nimport { log } from '@tests/log';\nimport { expect } from 'chai';\nimport { Archive7z } from 'szip';\n\ndescribe('SZip - Message Parser', () => {\n  describe('Create and Modify', () => {\n    const MessageList = {\n      MODIFY_ARCHIVE: `\\\n7-Zip (z) 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20\n 64-bit locale=en_US.UTF-8 Threads:8 OPEN_MAX:524288, ASM\n\nOpen archive: source.tar\n--\nPath = source.tar\nType = tar\nPhysical Size = 13312\nHeaders Size = 5632\nCode Page = UTF-8\nCharacteristics = GNU ASCII\n\nScanning the drive:\n3 folders, 6 files, 6865 bytes (7 KiB)\n\nUpdating archive: source.tar\n\nAdd new data to archive: 3 folders, 6 files, 6865 bytes (7 KiB)\n\n\nFiles read from disk: 9\nArchive size: 13312 bytes (13 KiB)\nEverything is Ok`,\n      UPDATE_ADDED_ARCHIVE: `\\\n7-Zip (z) 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20\n 64-bit locale=en_US.UTF-8 Threads:8 OPEN_MAX:524288, ASM\n\nOpen archive: project.tar\n--\nPath = project.tar\nType = tar\nPhysical Size = 20992\nHeaders Size = 6656\nCode Page = UTF-8\nCharacteristics = GNU ASCII\n\nScanning the drive:\n2 folders, 7 files, 2837970 bytes (2772 KiB)\n\nUpdating archive: project.tar\n\nKeep old data in archive: 3 folders, 8 files, 12585 bytes (13 KiB)\nAdd new data to archive: 2 folders, 7 files, 2837970 bytes (2772 KiB)\n\n\nFiles read from disk: 9\nArchive size: 2865664 bytes (2799 KiB)\nEverything is Ok`,\n      UPDATE_DELETED_ARCHIVE: `\\\n7-Zip (z) 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20\n 64-bit locale=en_US.UTF-8 Threads:8 OPEN_MAX:524288, ASM\n\nOpen archive: package.tar\n--\nPath = package.tar\nType = tar\nPhysical Size = 78336\nHeaders Size = 2048\nCode Page = UTF-8\nCharacteristics = GNU ASCII\n\nUpdating archive: package.tar\n\n\nDelete data from archive: 1 file, 74192 bytes (73 KiB)\nKeep old data in archive: 1 file, 1760 bytes (2 KiB)\nAdd new data to archive: 0 files, 0 bytes\n\n\nFiles read from disk: 0\nArchive size: 3584 bytes (4 KiB)\nEverything is Ok`,\n      NEW_ARCHIVE: `\\\n7-Zip (z) 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20\n 64-bit locale=en_US.UTF-8 Threads:8 OPEN_MAX:524288, ASM\n\nScanning the drive:\n5 folders, 15 files, 2852280 bytes (2786 KiB)\n\nCreating archive: project.zip\n\nAdd new data to archive: 5 folders, 15 files, 2852280 bytes (2786 KiB)\n\n\nFiles read from disk: 15\nArchive size: 1231162 bytes (1203 KiB)\nEverything is Ok`\n    };\n\n    it('should parse a update message', () => {\n      const message = MessageList.MODIFY_ARCHIVE;\n\n      const expected: ArchiveResult<'update', 'tar'> = {\n        path: 'source.tar',\n        size: 13312,\n        header: {\n          type: 'tar',\n          physicalSize: 13312,\n          headersSize: 5632,\n          codePage: 'UTF-8',\n          characteristics: 'GNU ASCII'\n        },\n        added: {\n          folders: 3,\n          files: 6,\n          bytes: 6865\n        }\n      };\n\n      const result = parseArchiveResult(message);\n      log(result);\n\n      expect(result).to.deep.equal(expected);\n    });\n\n    it('should parse a update message with previous archive', () => {\n      const expected: ArchiveResult<'update', 'tar'> = {\n        path: 'project.tar',\n        size: 2865664,\n        header: {\n          type: 'tar',\n          physicalSize: 20992,\n          headersSize: 6656,\n          codePage: 'UTF-8',\n          characteristics: 'GNU ASCII'\n        },\n        added: {\n          folders: 2,\n          files: 7,\n          bytes: 2837970\n        },\n        previous: {\n          folders: 3,\n          files: 8,\n          bytes: 12585\n        }\n      };\n\n      const result = parseArchiveResult(MessageList.UPDATE_ADDED_ARCHIVE);\n      log(result);\n\n      expect(result).to.deep.equal(expected);\n    });\n\n    it('should parse a update message with deleted archive', () => {\n      const message = MessageList.UPDATE_DELETED_ARCHIVE;\n\n      const expected: ArchiveResult<'delete', 'tar'> = {\n        path: 'package.tar',\n        size: 3584,\n        header: {\n          type: 'tar',\n          physicalSize: 78336,\n          headersSize: 2048,\n          codePage: 'UTF-8',\n          characteristics: 'GNU ASCII'\n        },\n        deleted: {\n          files: 1,\n          bytes: 74192\n        },\n        previous: {\n          files: 1,\n          bytes: 1760\n        },\n        added: {\n          files: 0,\n          bytes: 0\n        }\n      };\n\n      const result = parseArchiveResult(message);\n      log(result);\n\n      expect(result).to.deep.equal(expected);\n    });\n\n    it('should parse a new archive message', () => {\n      const message = MessageList.NEW_ARCHIVE;\n\n      const expected: ArchiveResult<'create'> = {\n        path: 'project.zip',\n        size: 1231162,\n        added: {\n          folders: 5,\n          files: 15,\n          bytes: 2852280\n        }\n      };\n\n      const result = parseArchiveResult(message);\n      log(result);\n\n      expect(result).to.deep.equal(expected);\n    });\n  });\n\n  describe('List', () => {\n    const MessageList: Record<string, string> = {\n      LIST_7Z: `\\\n7-Zip (z) 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20\n 64-bit locale=en_US.UTF-8 Threads:8 OPEN_MAX:524288, ASM\n\nScanning the drive for archives:\n1 file, 1004250 bytes (981 KiB)\n\nListing archive: secure.tar.7z\n\n--\nPath = secure.tar.7z\nType = 7z\nPhysical Size = 1004250\nHeaders Size = 122\nMethod = LZMA2:24 7zAES\nSolid = -\nBlocks = 1\n\n----------\nPath = secure.tar\nSize = 2868224\nPacked Size = 1004128\nModified = 2024-03-08 00:09:39.2828660\nAttributes = RA ----------\nCRC = F2118818\nEncrypted = +\nMethod = LZMA2:24 7zAES:19\nBlock = 0`,\n      LIST_TAR: `\\\n7-Zip (z) 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20\n 64-bit locale=en_US.UTF-8 Threads:8 OPEN_MAX:524288, ASM\n\nScanning the drive for archives:\n1 file, 2868224 bytes (2801 KiB)\n\nListing archive: source.tar\n\n--\nPath = source.tar\nType = tar\nPhysical Size = 2868224\nHeaders Size = 11264\nCode Page = UTF-8\nCharacteristics = GNU ASCII\n\n----------\nPath = dist/bin\nFolder = +\nSize = 0\nPacked Size = 0\nModified = 2024-03-07 03:48:23\nCreated = \nAccessed = \nMode = drwxr-xr-x\nUser = \nGroup = \nUser ID = 0\nGroup ID = 0\nSymbolic Link = \nHard Link = \nCharacteristics = 5 GNU ASCII\nComment = \nDevice Major = \nDevice Minor = \n\nPath = dist/bin/7zz\nFolder = -\nSize = 2763304\nPacked Size = 2763776\nModified = 2024-03-07 03:48:23\nCreated = \nAccessed = \nMode = -rwxr-xr-x\nUser = \nGroup = \nUser ID = 0\nGroup ID = 0\nSymbolic Link = \nHard Link = \nCharacteristics = 0 GNU ASCII\nComment = \nDevice Major = \nDevice Minor = `,\n      LIST_ZIP: `\\\n7-Zip (z) 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20\n 64-bit locale=C.UTF-8 Threads:8 OPEN_MAX:524288, ASM\n\nScanning the drive for archives:\n1 file, 1231071 bytes (1203 KiB)\n\nListing archive: source.zip\n\n--\nPath = source.zip\nType = zip\nPhysical Size = 1231071\n\n----------\nPath = dist/bin\nFolder = +\nSize = 0\nPacked Size = 0\nModified = 2024-03-07 03:48:23.8745316\nCreated = \nAccessed = \nAttributes = D drwxr-xr-x\nEncrypted = -\nComment = \nCRC = \nMethod = Store\nCharacteristics = NTFS\nHost OS = Unix\nVersion = 20\nVolume Index = 0\nOffset = 0\n\nPath = dist/bin/7zz\nFolder = -\nSize = 2763304\nPacked Size = 1205072\nModified = 2024-03-07 03:48:23.8745316\nCreated = \nAccessed = \nAttributes =  -rwxr-xr-x\nEncrypted = -\nComment = \nCRC = 2375CC5A\nMethod = Deflate\nCharacteristics = NTFS\nHost OS = Unix\nVersion = 20\nVolume Index = 0\nOffset = 39`\n    };\n\n    it('should parse a 7z archive list', () => {\n      const message = MessageList.LIST_7Z;\n\n      const expected: Archive7z = {\n        path: 'secure.tar.7z',\n        type: '7z',\n        physicalSize: 1004250,\n        headersSize: 122,\n        method: ['LZMA2:24', '7zAES'],\n        solid: false,\n        blocks: 1,\n        files: [\n          {\n            path: 'secure.tar',\n            size: 2868224,\n            packedSize: 1004128,\n            modified: '2024-03-08 00:09:39.2828660',\n            attributes: 'RA ----------',\n            crc: 'F2118818',\n            encrypted: true,\n            method: ['LZMA2:24', '7zAES:19'],\n            block: 0\n          }\n        ]\n      };\n\n      const result = parseArchiveInfo(message);\n      log(result);\n\n      expect(result).to.deep.equal(expected);\n    });\n\n    it('should parse a tar archive list', () => {\n      const message = MessageList.LIST_TAR;\n\n      const expected: ArchiveTar = {\n        path: 'source.tar',\n        type: 'tar',\n        physicalSize: 2868224,\n        headersSize: 11264,\n        codePage: 'UTF-8',\n        characteristics: 'GNU ASCII',\n        files: [\n          {\n            path: 'dist/bin',\n            folder: true,\n            size: 0,\n            packedSize: 0,\n            modified: '2024-03-07 03:48:23',\n            created: undefined,\n            accessed: undefined,\n            mode: 'drwxr-xr-x',\n            user: undefined,\n            group: undefined,\n            userID: 0,\n            groupID: 0,\n            symbolicLink: false,\n            hardLink: false,\n            characteristics: '5 GNU ASCII',\n            comment: undefined,\n            deviceMajor: undefined,\n            deviceMinor: undefined\n          },\n          {\n            path: 'dist/bin/7zz',\n            folder: false,\n            size: 2763304,\n            packedSize: 2763776,\n            modified: '2024-03-07 03:48:23',\n            created: undefined,\n            accessed: undefined,\n            mode: '-rwxr-xr-x',\n            user: undefined,\n            group: undefined,\n            userID: 0,\n            groupID: 0,\n            symbolicLink: false,\n            hardLink: false,\n            characteristics: '0 GNU ASCII',\n            comment: undefined,\n            deviceMajor: undefined,\n            deviceMinor: undefined\n          }\n        ]\n      };\n\n      const result = parseArchiveInfo(message);\n      log(result);\n\n      expect(result).to.deep.equal(expected);\n    });\n  });\n\n  describe('Compress', () => {\n    const MessageList: Record<string, string> = {\n      COMPRESS_XZ: `\\\n7-Zip (z) 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20\n 64-bit locale=en_US.UTF-8 Threads:8 OPEN_MAX:1048576, ASM\n\nCreating archive: /home/master/Projects/WebstormProjects/Github/node-archive/source.tar.xz\n\nAdd new data to archive: 1 file\n\n\nFiles read from disk: 1\nArchive size: 1003532 bytes (981 KiB)\nEverything is Ok`\n    };\n\n    it('should parse a compress message', () => {\n      const message = MessageList.COMPRESS_XZ;\n\n      const expected: SZipCompressResult = {\n        path: '/home/master/Projects/WebstormProjects/Github/node-archive/source.tar.xz',\n        size: 1003532\n      };\n\n      const result = parseCompressMessage(message);\n      log(result);\n\n      expect(result).to.deep.equal(expected);\n    });\n  });\n\n  describe('Error', () => {\n    const MessageList = {\n      CMDLINE_ERROR_SINGLE: `\\\nCommand Line Error:\nIncorrect wildcard type marker\nsrc/*.*`,\n      CMDLINE_ERROR_SINGLE_2: `\\\nCommand Line Error:\nI won't write compressed data to a terminal`,\n      CMDLINE_ERROR_MULTI: `\\\nWARNING: errno=2 : No such file or directory\n!package.json\n\n\nWARNING: errno=2 : No such file or directory\n!pnpm-lock.yaml`\n    };\n\n    // Errors with \\n\\n as separator are multi-line errors\n\n    it('should parse a cmdline error message', async () => {\n      const message = MessageList.CMDLINE_ERROR_SINGLE;\n\n      const expected = 'Command Line Error: Incorrect wildcard type marker src/*.*';\n\n      const result = parseError(message);\n      log(result);\n\n      expect(result).to.equal(expected);\n    });\n\n    it('should parse a cmdline error message with multi-line', async () => {\n      const message = MessageList.CMDLINE_ERROR_MULTI;\n\n      const expected = `\\\nWARNING: errno=2 : No such file or directory !package.json`;\n\n      const result = parseError(message);\n      log(result);\n\n      expect(result).to.equal(expected);\n    });\n\n    it('should parse a cmdline error message with multi-line 2', async () => {\n      const message = MessageList.CMDLINE_ERROR_MULTI;\n\n      const expected = `\\\nWARNING: errno=2 : No such file or directory !package.json`;\n\n      const result = parseError(message);\n      log(result);\n\n      expect(result).to.equal(expected);\n    });\n  });\n});\n"
  },
  {
    "path": "packages/szip/tests/utils.test.ts",
    "content": "import { waitUtilOpenStream } from '@szip/utils/wait';\nimport { expect } from 'chai';\nimport { createWriteStream, promises } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { ROOT_DIR } from './utils';\n\ndescribe('Stream', () => {\n  it('should create write stream and wait until it is open', async () => {\n    const stream = createWriteStream(resolve(ROOT_DIR, 'test.txt'));\n\n    await waitUtilOpenStream(stream);\n\n    expect(stream.writable).to.be.true;\n\n    stream.write('Hello World');\n\n    stream.end();\n\n    await promises.unlink(resolve(ROOT_DIR, 'test.txt'));\n  });\n});\n"
  },
  {
    "path": "packages/szip/tests/utils.ts",
    "content": "import { fsAccessSync } from '@/utils/fs-access';\nimport { promises } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { SZip } from 'szip';\n\nexport async function createTar(filename: string = 'source.tar', password?: string) {\n  const output = await SZip.add(filename, ['src/*', 'dist/*'], {\n    type: 'tar',\n    password,\n    update: true,\n    cwd: ROOT_DIR,\n    raw: true\n  });\n\n  return output;\n}\n\nexport async function createTar7z(filename: string = 'secure.tar.7z', password?: string) {\n  const tarName = resolve(ROOT_DIR, 'source.tar');\n  await createTar(tarName);\n\n  const output = await SZip.add(filename, [tarName], {\n    type: '7z',\n    password,\n    cwd: ROOT_DIR,\n    raw: true\n  });\n\n  await promises.unlink(tarName);\n\n  return output;\n}\n\nexport async function createZip(filename: string = 'source.zip', password?: string) {\n  const output = await SZip.add(filename, ['src/*', 'dist/*'], {\n    type: 'zip',\n    password,\n    cwd: ROOT_DIR,\n    raw: true\n  });\n\n  return output;\n}\n\nexport const ROOT_DIR = fsAccessSync('packages')\n  ? process.cwd()\n  : process.cwd().replace('packages/szip', '');\n"
  },
  {
    "path": "pnpm-workspace.yaml",
    "content": "packages:\n  # all packages in direct subdirs of packages/\n  - 'packages/*'\n  # exclude packages that are inside test directories\n  - '!**/tests/**'\n"
  },
  {
    "path": "renovate.json",
    "content": "{\n  \"$schema\": \"https://docs.renovatebot.com/renovate-schema.json\",\n  \"extends\": [\"config:base\"]\n}\n"
  },
  {
    "path": "scripts/install.ts",
    "content": "#!/usr/bin/env node\n\n/**\n * The Purpose of this script is to download the 7zip binary\n * for the current platform.\n */\n\nasync function importInstaller() {\n  try {\n    return await import('./internal/installer');\n  } catch {\n    console.warn(\n      'Skipping binary installation because the build is not available. Run `npm install` again after you have re-built the package.'\n    );\n    process.exit(0);\n  }\n}\n\ntry {\n  const { download } = await importInstaller();\n  await download();\n} catch (error) {\n  console.warn('Binary download failed', error);\n}\n"
  },
  {
    "path": "scripts/internal/configuration.ts",
    "content": "import { homedir } from 'node:os';\nimport { join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport { Configuration } from './types';\nimport { getBooleanEnv } from './utils/boolean-env';\n\nexport function getConfiguration(): Configuration {\n  const configuration: Partial<Configuration> = {\n    version: '23.01',\n    downloadBaseUrl: 'https://7zip.s3.ir-thr-at1.arvanstorage.ir'\n  };\n\n  configuration.logLevel = (process.env['ARCHIVE_LOGLEVEL'] ??\n    process.env['npm_config_LOGLEVEL'] ??\n    process.env['npm_package_config_LOGLEVEL'] ??\n    configuration.logLevel ??\n    'warn') as 'silent' | 'error' | 'warn';\n\n  configuration.binPath =\n    process.env['ARCHIVE_BIN_PATH'] ??\n    process.env['npm_config_archive_bin_path'] ??\n    process.env['npm_package_config_archive_bin_path'] ??\n    configuration.binPath ??\n    // join(process.cwd(), 'node_modules', '.bin');\n    resolvePathFormPackage('../bin');\n\n  configuration.executablePath =\n    process.env['ARCHIVE_EXECUTABLE_PATH'] ??\n    process.env['npm_config_archive_executable_path'] ??\n    process.env['npm_package_config_archive_executable_path'] ??\n    configuration.executablePath ??\n    join(configuration.binPath, '7zz');\n\n  // Set skipDownload explicitly or from default\n  configuration.skipDownload = Boolean(\n    getBooleanEnv('PUPPETEER_SKIP_DOWNLOAD') ??\n      getBooleanEnv('npm_config_archive_skip_download') ??\n      getBooleanEnv('npm_package_config_archive_skip_download') ??\n      configuration.skipDownload\n  );\n\n  if (!configuration.skipDownload) {\n    configuration.downloadBaseUrl =\n      process.env['ARCHIVE_DOWNLOAD_BASE_URL'] ??\n      process.env['npm_config_archive_download_base_url'] ??\n      process.env['npm_package_config_archive_download_base_url'] ??\n      configuration.downloadBaseUrl;\n\n    configuration.version =\n      process.env['ARCHIVE_VERSION'] ??\n      process.env['npm_config_archive_version'] ??\n      process.env['npm_package_config_archive_version'] ??\n      configuration.version;\n  }\n\n  configuration.cacheDirectory =\n    process.env['ARCHIVE_CACHE_DIR'] ??\n    process.env['npm_config_archive_cache_dir'] ??\n    process.env['npm_package_config_archive_cache_dir'] ??\n    configuration.cacheDirectory ??\n    join(homedir(), '.cache', 'node-archive');\n\n  return configuration as Configuration;\n}\n\nfunction resolvePathFormPackage(filePath: string) {\n  const distPath =\n    typeof __dirname === 'undefined' ? fileURLToPath(new URL(`.`, import.meta.url)) : __dirname;\n\n  return resolve(distPath, filePath);\n}\n"
  },
  {
    "path": "scripts/internal/installer.ts",
    "content": "import { promises } from 'node:fs';\n\nimport { getConfiguration } from './configuration';\nimport { logPolitely } from './log';\nimport { detectPlatform } from './utils/detect-platform';\nimport { overrideProxy } from './utils/override-proxy';\nimport { tryOrExit } from './utils/try-exit';\n\nexport async function download(): Promise<void> {\n  overrideProxy();\n\n  const configuration = getConfiguration();\n  if (configuration.skipDownload) {\n    logPolitely('**INFO** Skipping 7zip download');\n    return;\n  }\n\n  const downloadBaseUrl = configuration.downloadBaseUrl;\n\n  const platform = detectPlatform();\n  if (!platform) {\n    throw new Error('The current platform is not supported.');\n  }\n\n  const arch = process.arch;\n\n  let downloadUrl: string;\n\n  switch (platform) {\n    case 'linux':\n      switch (arch) {\n        case 'x64' || 'arm' || 'arm64':\n          downloadUrl = `${downloadBaseUrl}/${configuration.version}/linux/linux-${arch}/7zz`;\n          break;\n        case 'ia32':\n          downloadUrl = `${downloadBaseUrl}/${configuration.version}/linux/linux-x86/7zz`;\n          break;\n        default:\n          throw new Error('The current architecture is not supported.');\n      }\n      break;\n    case 'mac':\n      downloadUrl = `${downloadBaseUrl}/${configuration.version}/mac/7zz`;\n      break;\n    case 'windows':\n      switch (arch) {\n        case 'x64':\n          downloadUrl = `${downloadBaseUrl}/${configuration.version}/windows/x64/7zz.exe`;\n          break;\n        case 'ia32': // This is the architecture for 32-bit Windows\n          downloadUrl = `${downloadBaseUrl}/${configuration.version}/windows/x86/7zz.exe`;\n          break;\n        default:\n          throw new Error('The current architecture is not supported.');\n      }\n      break;\n    default:\n      throw new Error('The current platform is not supported.');\n  }\n\n  // Download 7zip\n  if (configuration.logLevel !== 'silent') {\n    logPolitely(`**INFO** Downloading binary...`);\n  }\n\n  const cacheDirectory = configuration.cacheDirectory;\n\n  // Download it to the cache directory with a name that includes the version\n  const downloadPath = `${cacheDirectory}/7zz-${configuration.version}`;\n\n  // Download the file\n  await tryOrExit(async () => {\n    await promises.mkdir(configuration.cacheDirectory, { recursive: true });\n    await downloadFile(downloadUrl, downloadPath);\n  });\n\n  // Make the file executable\n  if (platform === 'linux' || platform === 'mac') {\n    await tryOrExit(async () => {\n      await promises.chmod(downloadPath, 0o755);\n    });\n  }\n\n  if (configuration.logLevel !== 'silent') {\n    logPolitely(`**INFO** Binary downloaded to ${downloadPath}`);\n  }\n\n  // Move it to the user bin directory\n  const destination = configuration.executablePath;\n\n  // @todo: install in node_modules instead of user bin directory\n  await tryOrExit(async () => {\n    await promises.mkdir(configuration.binPath, { recursive: true });\n    await promises.rename(downloadPath, destination);\n  });\n\n  if (configuration.logLevel !== 'silent') {\n    logPolitely(`**INFO** Binary moved to ${destination}`);\n  }\n\n  return;\n}\n\nasync function downloadFile(url: string, destination: string): Promise<void> {\n  const response = await fetch(url);\n  const buffer = await response.arrayBuffer();\n  await promises.writeFile(destination, Buffer.from(buffer));\n}\n"
  },
  {
    "path": "scripts/internal/log.ts",
    "content": "export function logPolitely(toBeLogged: unknown): void {\n  const logLevel = process.env['npm_config_loglevel'] || '';\n  const logLevelDisplay = ['silent', 'error', 'warn'].indexOf(logLevel) > -1;\n\n  if (!logLevelDisplay) {\n    // eslint-disable-next-line no-console\n    console.log(toBeLogged);\n  }\n}\n"
  },
  {
    "path": "scripts/internal/types.ts",
    "content": "export enum Platform {\n  Linux = 'linux',\n  Mac = 'mac',\n  Windows = 'windows'\n}\n\nexport interface Configuration {\n  version: string;\n  downloadBaseUrl: string;\n  skipDownload: boolean;\n  binPath: string;\n  cacheDirectory: string;\n  executablePath: string;\n  logLevel: string;\n}\n"
  },
  {
    "path": "scripts/internal/utils/boolean-env.ts",
    "content": "export function getBooleanEnv(name: string) {\n  const env = process.env[name];\n  if (env === undefined) {\n    return;\n  }\n  switch (env.toLowerCase()) {\n    case '':\n    case '0':\n    case 'false':\n    case 'off':\n      return false;\n    default:\n      return true;\n  }\n}\n"
  },
  {
    "path": "scripts/internal/utils/detect-platform.ts",
    "content": "import { Platform } from '../types';\n\nexport function detectPlatform(): Platform | undefined {\n  const platform = process.platform;\n  if (platform === 'win32') {\n    return Platform.Windows;\n  }\n  if (platform === 'darwin') {\n    return Platform.Mac;\n  }\n  if (platform === 'linux') {\n    return Platform.Linux;\n  }\n  return undefined;\n}\n"
  },
  {
    "path": "scripts/internal/utils/handle-error.ts",
    "content": "/* eslint-disable no-console */\n\nexport function handleError(error: unknown): void {\n  if (error instanceof Error) {\n    console.error(`**ERROR** ${error.message}`);\n    process.exit(1);\n  }\n\n  console.error(`**ERROR** ${error}`);\n  process.exit(1);\n}\n"
  },
  {
    "path": "scripts/internal/utils/override-proxy.ts",
    "content": "export function overrideProxy() {\n  // Override current environment proxy settings with npm configuration, if any.\n  const NPM_HTTPS_PROXY = process.env['npm_config_https_proxy'] || process.env['npm_config_proxy'];\n  const NPM_HTTP_PROXY = process.env['npm_config_http_proxy'] || process.env['npm_config_proxy'];\n  const NPM_NO_PROXY = process.env['npm_config_no_proxy'];\n\n  if (NPM_HTTPS_PROXY) {\n    process.env['HTTPS_PROXY'] = NPM_HTTPS_PROXY;\n  }\n  if (NPM_HTTP_PROXY) {\n    process.env['HTTP_PROXY'] = NPM_HTTP_PROXY;\n  }\n  if (NPM_NO_PROXY) {\n    process.env['NO_PROXY'] = NPM_NO_PROXY;\n  }\n}\n"
  },
  {
    "path": "scripts/internal/utils/try-exit.ts",
    "content": "import { handleError } from './handle-error';\n\nexport async function tryOrExit(fn: () => Promise<void>): Promise<void> {\n  try {\n    await fn();\n  } catch (error) {\n    handleError(error);\n  }\n}\n"
  },
  {
    "path": "src/index.ts",
    "content": "import { Archive } from '@/lib/archive';\nimport { SZip } from 'szip';\n\n// ------------------------------\n\nexport { Archive, SZip };\n\n// ------------------------------\n\nexport type * from '@/types';\n\n// ------------------------------\n\nexport default Archive;\n"
  },
  {
    "path": "src/lib/archive.ts",
    "content": "import { SZip, SZipError } from 'szip';\nimport { PathLike } from 'node:fs';\n\ntype ArchiveOptions = {\n  archive?: PathLike;\n  password?: string;\n  output?: PathLike;\n} & (\n  | {\n      archive: PathLike;\n      password?: string;\n    }\n  | {\n      output: PathLike;\n    }\n);\n\ntype ArchiveFormat = 'Zip' | 'GZip' | 'BZip2' | '7z' | 'XZ' | 'WIM' | 'Tar';\n\nclass Archive {\n  private _archive: PathLike | undefined;\n  private _password: string | undefined;\n\n  private _output: PathLike | undefined;\n\n  constructor(\n    private format: ArchiveFormat,\n    opts: ArchiveOptions\n  ) {\n    this._archive = opts.archive;\n    this._password = opts.password;\n    this._output = opts.output;\n  }\n\n  /**\n   * Modify an existing archive file.\n   * @param archive\n   * @param password\n   */\n  static fromArchive(archive: PathLike, password?: string): Archive {\n    // Check archive exists\n    // Get archive info\n    // Check if password is required, if it was, validate it\n    // Return new Archive instance\n    // return new Archive({\n    //   archive,\n    //   password\n    // });\n    throw new Error('Not implemented');\n  }\n\n  /**\n   * Lists contents of archive.\n   */\n  async list(): Promise<string[]> {\n    return [];\n  }\n\n  // ------------------------------\n  // Extract\n  // ------------------------------\n  static async extract(archive: PathLike, output: PathLike, files: string[]): Promise<void> {}\n\n  static async extractAll(archive: PathLike, output: PathLike): Promise<void> {}\n\n  // ------------------------------\n  // Add, Update, and Delete\n  // ------------------------------\n  async add(path: string, options: ArchiveAddOptions): Promise<void> {}\n\n  // ------------------------------\n  // Misc\n  // ------------------------------\n  setPassword(password: string): void {}\n\n  /**\n   * Get information about an archive.\n   * @param archive\n   */\n  static async getInfo(archive: PathLike) {\n    const info = await SZip.list(archive, {});\n\n    return info;\n  }\n\n  static async hasPassword(archive: PathLike): Promise<boolean> {\n    const { data, error } = await Archive.getInfo(archive);\n    if (error) {\n      throw error;\n    }\n\n    if (!data) {\n      throw new SZipError('No data');\n    }\n\n    switch (data.type) {\n      case '7z':\n      case 'zip':\n        return data.files.some((file) => file.encrypted);\n      case 'tar':\n        return false;\n      default:\n        throw new SZipError('Unsupported archive type');\n    }\n  }\n\n  async finalize(opts: FinalizeOptions): Promise<void> {}\n}\n\ntype FinalizeOptions = {\n  format: ArchiveFormat;\n} & (\n  | ({\n      format: 'Zip';\n    } & ArchiveZipOptions)\n  | ({\n      format: 'GZip';\n    } & ArchiveGZipOptions)\n);\n\ntype ArchiveZipOptions = {\n  method?: 'Copy' | 'Deflate' | 'Deflate64' | 'BZip2' | 'LZMA' | 'PPMd';\n  // Sets number of Fast Bytes for Deflate encoder.\n  fastBytes?: number;\n  // Sets number of Passes for Deflate encoder.\n  passes?: number;\n  // Sets Dictionary size for BZip2\n  dictionarySize?: number;\n  // Sets size of used memory for PPMd.\n  memorySize?: number;\n  // Sets model order for PPMd.\n  modelOrder?: number;\n  // Sets multithreading mode.\n  threads?: number;\n  // Sets a encryption method: ZipCrypto, AES128, AES192, AES256.\n  encryption?: 'ZipCrypto' | 'AES128' | 'AES192' | 'AES256';\n  // 7-Zip always uses local code page for file names.\n  localCodePage?: boolean;\n  // 7-Zip uses UTF-8 for file names that contain non-ASCII symbols.\n  utf8?: boolean;\n  // Sets code page\n  codePage?: boolean;\n  // Stores last Modified timestamps for files.\n  timestamps?: boolean;\n  // Stores Creation timestamps for files.\n  creationTimestamps?: boolean;\n  // Stores last Access timestamps for files\n  accessTimestamps?: boolean;\n  // Sets timestamp precision: 0 - Windows (100 ns), 1 - Unix (1 sec), 2 - DOS (2 sec). 3 - Windows (100 ns).\n  timestampPrecision?: 0 | 1 | 2 | 3;\n};\n\ntype ArchiveGZipOptions = Pick<ArchiveZipOptions, 'fastBytes' | 'passes'> & {\n  method?: 'Deflate';\n};\n\ninterface ArchiveAddOptions {\n  recursive?: boolean;\n}\n\nexport { Archive };\n"
  },
  {
    "path": "src/types.ts",
    "content": "import type { Readable as ReadableStream } from 'node:stream';\n\nexport type ContentLike = string | Buffer | ReadableStream;\n\nexport type { Readable as ReadableStream, Writable as WritableStream } from 'node:stream';\n"
  },
  {
    "path": "src/utils/fs-access.ts",
    "content": "import { PathLike, promises, accessSync } from 'node:fs';\n\nexport async function fsAccess(path: PathLike, mode?: number): Promise<boolean> {\n  try {\n    await promises.access(path, mode);\n    return true;\n  } catch (_) {\n    return false;\n  }\n}\n\nexport function fsAccessSync(path: PathLike, mode?: number): boolean {\n  try {\n    accessSync(path, mode);\n    return true;\n  } catch (_) {\n    return false;\n  }\n}\n"
  },
  {
    "path": "src/utils/get-dirname.ts",
    "content": "import { fileURLToPath } from 'node:url';\n\nexport function getDirname() {\n  return typeof __dirname === 'undefined'\n    ? fileURLToPath(new URL(`.`, import.meta.url))\n    : __dirname;\n}\n"
  },
  {
    "path": "src/utils/normalize.ts",
    "content": "import { PathLike } from 'node:fs';\nimport { fileURLToPath } from 'node:url';\n\nexport function normalizePathLike(path: PathLike): string {\n  if (path instanceof URL) {\n    return fileURLToPath(path);\n  }\n\n  return path.toString();\n}\n"
  },
  {
    "path": "tests/index.test.ts",
    "content": "import { expect } from 'chai';\n\ndescribe('Test', () => {\n  it('works', () => {\n    expect(true).to.equal(true);\n  });\n});\n"
  },
  {
    "path": "tests/log.ts",
    "content": "export function log(message: any): void {\n  // eslint-disable-next-line no-console\n  console.log(message);\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"$schema\": \"https://json.schemastore.org/tsconfig.json\",\n  \"compilerOptions\": {\n    \"lib\": [\"ESNext\"],\n    \"module\": \"esnext\",\n    \"target\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"moduleDetection\": \"force\",\n    \"strict\": true,\n    \"skipLibCheck\": true,\n    \"declaration\": true,\n    \"declarationMap\": true,\n    \"esModuleInterop\": true,\n    \"isolatedModules\": true,\n    \"noUnusedLocals\": false,\n    \"noUnusedParameters\": false,\n    \"strictNullChecks\": true,\n    \"allowSyntheticDefaultImports\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"allowJs\": true,\n    \"outDir\": \"dist\",\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"@/*\": [\"src/*\"],\n      \"@tests/*\": [\"tests/*\"],\n      \"@szip/*\": [\"packages/szip/src/*\"],\n      \"szip\": [\"packages/szip/index.ts\"],\n      \"node-archive\": [\"src/index.ts\"]\n    }\n  },\n  \"include\": [\"**/*.ts\"],\n  \"exclude\": [\"node_modules\", \"dist\"]\n}\n"
  },
  {
    "path": "tsup.config.ts",
    "content": "import { defineConfig } from 'tsup';\n\nexport default defineConfig([\n  {\n    clean: true,\n    dts: true,\n    entry: ['src/index.ts'],\n    format: ['cjs', 'esm'],\n    target: 'esnext',\n    outDir: 'dist'\n  },\n  {\n    clean: true,\n    entry: ['scripts/*.ts'],\n    format: ['esm'],\n    target: 'esnext',\n    outDir: 'dist/scripts'\n  }\n]);\n"
  }
]