commit e4eee1b3b7f85d5a690ef5193337839872ba7014 Author: liuyu65 Date: Mon Oct 26 17:44:44 2026 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..73ec0e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +node_modules/ +dist/ +samples/ +android/build/ +android/app/src/main/assets/www/ +android/keystore/ +*.jks +*.keystore +PhoneViewer-*.apk +*.dwg +*.DWG +.env +.env.* +*.local +.DS_Store +Thumbs.db diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..dba13ed --- /dev/null +++ b/LICENSE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f62c1ce --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# PhoneViewer / 万能看图 + +手机 / 平板上的本地 DWG、PDF、EPUB、FB2、XPS/OXPS、CBZ 和图片浏览器。 + +- DWG 解析:`@node-projects/acad-ts`(MIT),支持模型空间、块、布局、代理图形数据、图层、文字、填充、样条、尺寸等常见 2D 实体。 +- 文档渲染:MuPDF.js。 +- 前端:Vite + TypeScript + Canvas 2D,解析在 Web Worker 中执行。 +- Android:Kotlin WebView 壳,离线内置全部前端资源,支持文件关联、返回键和 PNG 保存。 +- 默认显示第三方代理对象,可在左侧立方体按钮中关闭;DWG 中代理数据本身没有图形时不会产生可见图元。 + +## 开发 + +```bash +npm install +npm run dev +npm run typecheck +npm run build +``` + +## 构建 Android APK + +需要 JDK 17、Android SDK 34 和 Gradle 的 Kotlin 编译器(脚本位于 `E:\AiCodeGitea\ven\AndroidDev`,可在 `scripts/build-apk.mjs` 中调整路径)。 + +签名信息不写入仓库。构建前设置: + +```bash +PHONEVIEWER_KEYSTORE_PASS=your-keystore-password +PHONEVIEWER_KEY_PASS=your-key-password +npm run apk +``` + +`android/keystore/`、测试 DWG、APK、`dist/`、`node_modules/` 均已加入 `.gitignore`。图纸不会上传,解析完全在本地进行。 + +## 许可 + +本项目以 AGPL-3.0-or-later 发布。第三方组件许可见应用内“关于 → 开源组件与许可”。 diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..72cd519 --- /dev/null +++ b/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/java/com/phoneviewer/app/MainActivity.kt b/android/app/src/main/java/com/phoneviewer/app/MainActivity.kt new file mode 100644 index 0000000..9b657dd --- /dev/null +++ b/android/app/src/main/java/com/phoneviewer/app/MainActivity.kt @@ -0,0 +1,396 @@ +package com.phoneviewer.app + +import android.app.Activity +import android.content.Intent +import android.content.pm.ApplicationInfo +import android.graphics.Color +import android.net.Uri +import android.os.Build +import android.os.Bundle +import android.os.Environment +import android.util.Base64 +import android.view.View +import android.view.WindowManager +import android.webkit.JavascriptInterface +import android.webkit.ValueCallback +import android.webkit.WebChromeClient +import android.webkit.WebResourceRequest +import android.webkit.WebResourceResponse +import android.webkit.WebSettings +import android.webkit.WebView +import android.webkit.WebViewClient +import android.widget.Toast +import org.json.JSONObject +import java.io.ByteArrayInputStream +import java.io.File + +class MainActivity : Activity() { + private lateinit var webView: WebView + private var filePathCallback: ValueCallback>? = null + private var pendingOpenUri: Uri? = null + private var pageReady = false + private var lastOpenedUri: Uri? = null + private var lastOpenedName = "file" + private var lastOpenedMime = "application/octet-stream" + + private companion object { + const val APP_HOST = "appassets-v5.androidplatform.net" + const val APP_URL = "https://appassets-v5.androidplatform.net/" + const val FILE_CHOOSER_REQUEST = 1001 + } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + if (intent?.action == Intent.ACTION_VIEW) { + pendingOpenUri = intent.data + } + window.statusBarColor = Color.parseColor("#0b0e14") + window.navigationBarColor = Color.parseColor("#0b0e14") + window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + window.isStatusBarContrastEnforced = false + window.isNavigationBarContrastEnforced = false + } + + webView = WebView(this) + webView.setBackgroundColor(Color.parseColor("#0b0e14")) + webView.overScrollMode = View.OVER_SCROLL_NEVER + webView.isVerticalScrollBarEnabled = false + webView.isHorizontalScrollBarEnabled = false + + webView.settings.apply { + javaScriptEnabled = true + domStorageEnabled = true + databaseEnabled = true + allowFileAccess = false + allowContentAccess = true + loadsImagesAutomatically = true + javaScriptCanOpenWindowsAutomatically = false + mediaPlaybackRequiresUserGesture = false + setSupportZoom(false) + builtInZoomControls = false + displayZoomControls = false + useWideViewPort = true + loadWithOverviewMode = false + textZoom = 100 + mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW + cacheMode = WebSettings.LOAD_NO_CACHE + } + + if ((applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE) != 0) { + WebView.setWebContentsDebuggingEnabled(true) + } + + webView.addJavascriptInterface(AndroidBridge(), "AndroidViewer") + webView.webViewClient = AssetClient() + webView.webChromeClient = object : WebChromeClient() { + override fun onShowFileChooser( + webView: WebView?, + callback: ValueCallback>?, + params: FileChooserParams? + ): Boolean { + this@MainActivity.filePathCallback?.onReceiveValue(null) + this@MainActivity.filePathCallback = callback + return try { + val intent = Intent(Intent.ACTION_GET_CONTENT).apply { + addCategory(Intent.CATEGORY_OPENABLE) + type = "*/*" + } + startActivityForResult(Intent.createChooser(intent, "选择文件"), FILE_CHOOSER_REQUEST) + true + } catch (_: Exception) { + this@MainActivity.filePathCallback = null + false + } + } + } + + webView.setDownloadListener { url, _, _, _, _ -> + if (url.startsWith("data:")) return@setDownloadListener + try { + startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(url))) + } catch (_: Exception) { + Toast.makeText(this@MainActivity, "无法打开下载链接", Toast.LENGTH_SHORT).show() + } + } + + setContentView(webView) + webView.loadUrl(APP_URL) + } + + override fun onNewIntent(intent: Intent?) { + super.onNewIntent(intent) + setIntent(intent) + if (intent?.action == Intent.ACTION_VIEW) { + pendingOpenUri = intent.data + dispatchPendingFile() + } + } + + private fun dispatchPendingFile() { + if (!pageReady) return + val uri = pendingOpenUri ?: return + pendingOpenUri = null + + var name = uri.lastPathSegment ?: "file" + var mime = contentResolver.getType(uri) ?: mimeFor(name) + try { + contentResolver.query( + uri, + arrayOf(android.provider.OpenableColumns.DISPLAY_NAME), + null, + null, + null + )?.use { cursor -> + if (cursor.moveToFirst()) { + val index = cursor.getColumnIndex(android.provider.OpenableColumns.DISPLAY_NAME) + if (index >= 0) { + name = cursor.getString(index) ?: name + } + } + } + } catch (_: Exception) { + /* use fallback name */ + } + if (!name.contains('.')) { + val ext = when (mime) { + "application/pdf" -> ".pdf" + "application/epub+zip" -> ".epub" + "application/vnd.ms-xpsdocument", "application/oxps" -> ".xps" + "application/vnd.comicbook+zip" -> ".cbz" + "image/png" -> ".png" + "image/jpeg" -> ".jpg" + else -> if (mime == "application/acad" || mime == "image/vnd.dwg") ".dwg" else "" + } + name += ext + mime = mimeFor(name) + } + + lastOpenedUri = uri + lastOpenedName = name + lastOpenedMime = mime + + val quotedUrl = JSONObject.quote("https://$APP_HOST/__opened__/open") + val quotedName = JSONObject.quote(name) + val quotedMime = JSONObject.quote(mime) + val js = """ + (function(){ + fetch($quotedUrl, {cache: 'no-store'}) + .then(function(r){ if(!r.ok) throw new Error('HTTP ' + r.status); return r.blob(); }) + .then(function(b){ + var f = new File([b], $quotedName, {type: $quotedMime}); + if (window.__phoneViewerOpenFile) window.__phoneViewerOpenFile(f); + }) + .catch(function(e){ + if (window.AndroidViewer && window.AndroidViewer.showToast) { + window.AndroidViewer.showToast('打开文件失败: ' + e.message); + } + }); + })(); + """.trimIndent() + webView.evaluateJavascript(js, null) + } + + @Deprecated("Deprecated in Java") + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + if (requestCode == FILE_CHOOSER_REQUEST) { + val callback = filePathCallback + filePathCallback = null + if (callback == null) return + if (resultCode == RESULT_OK && data?.data != null) { + callback.onReceiveValue(arrayOf(data.data!!)) + } else { + callback.onReceiveValue(null) + } + return + } + super.onActivityResult(requestCode, resultCode, data) + } + + @Deprecated("Deprecated in Java") + override fun onBackPressed() { + webView.evaluateJavascript( + "(function(){try{return !!(window.__phoneViewerBack&&window.__phoneViewerBack());}catch(e){return false;}})()" + ) { result -> + if (result != "true") finish() + } + } + + override fun onPause() { + webView.onPause() + super.onPause() + } + + override fun onResume() { + super.onResume() + webView.onResume() + } + + override fun onDestroy() { + webView.removeJavascriptInterface("AndroidViewer") + webView.stopLoading() + webView.destroy() + super.onDestroy() + } + + inner class AndroidBridge { + @JavascriptInterface + fun saveBase64(name: String, mime: String, data: String) { + try { + val bytes = Base64.decode(data, Base64.DEFAULT) + val extension = when (mime) { + "image/png" -> ".png" + "image/jpeg" -> ".jpg" + else -> "" + } + val safeName = name.replace(Regex("[\\\\/:*?\"<>|]+"), "_").let { + if (it.contains('.')) it else it + extension + } + val dir = getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS) ?: filesDir + if (!dir.exists()) dir.mkdirs() + val file = File(dir, safeName) + file.writeBytes(bytes) + runOnUiThread { + Toast.makeText( + this@MainActivity, + "已保存:${file.absolutePath}", + Toast.LENGTH_LONG + ).show() + } + } catch (error: Exception) { + runOnUiThread { + Toast.makeText( + this@MainActivity, + "保存失败:${error.message}", + Toast.LENGTH_LONG + ).show() + } + } + } + + @JavascriptInterface + fun showToast(message: String) { + runOnUiThread { + Toast.makeText(this@MainActivity, message, Toast.LENGTH_SHORT).show() + } + } + } + + inner class AssetClient : WebViewClient() { + override fun shouldInterceptRequest( + view: WebView?, + request: WebResourceRequest? + ): WebResourceResponse? { + val uri = request?.url ?: return null + if (!APP_HOST.equals(uri.host, ignoreCase = true)) return null + + var path = uri.path ?: "/" + if (path.isEmpty() || path == "/") path = "/index.html" + if (path == "/__opened__/open") return openPendingFile() + if (path.contains("..")) return notFound() + + return try { + val stream = assets.open("www$path") + val mime = mimeFor(path) + WebResourceResponse( + mime, + if (isTextMime(mime)) "UTF-8" else null, + 200, + "OK", + mapOf( + "Access-Control-Allow-Origin" to "*", + "Cache-Control" to "no-store, no-cache, must-revalidate", + "Pragma" to "no-cache", + "Expires" to "0" + ), + stream + ) + } catch (_: Exception) { + notFound() + } + } + + override fun shouldOverrideUrlLoading( + view: WebView?, + request: WebResourceRequest? + ): Boolean { + val url = request?.url ?: return false + if (APP_HOST.equals(url.host, ignoreCase = true)) return false + return try { + startActivity(Intent(Intent.ACTION_VIEW, url)) + true + } catch (_: Exception) { + true + } + } + + override fun onPageFinished(view: WebView?, url: String?) { + super.onPageFinished(view, url) + pageReady = true + dispatchPendingFile() + } + } + + private fun openPendingFile(): WebResourceResponse { + val uri = lastOpenedUri ?: return notFound() + return try { + val stream = contentResolver.openInputStream(uri) ?: return notFound() + WebResourceResponse( + lastOpenedMime, + null, + 200, + "OK", + mapOf( + "Access-Control-Allow-Origin" to "*", + "Cache-Control" to "no-store" + ), + stream + ) + } catch (_: Exception) { + notFound() + } + } + + private fun notFound(): WebResourceResponse = + WebResourceResponse( + "text/plain", + "UTF-8", + 404, + "Not Found", + mapOf("Cache-Control" to "no-store, no-cache, must-revalidate"), + ByteArrayInputStream(ByteArray(0)) + ) + + private fun isTextMime(mime: String): Boolean = + mime.startsWith("text/") || + mime == "application/javascript" || + mime == "application/json" || + mime == "image/svg+xml" + + private fun mimeFor(path: String): String { + val ext = path.substringAfterLast('.', "").lowercase() + return when (ext) { + "html", "htm" -> "text/html" + "js", "mjs" -> "application/javascript" + "css" -> "text/css" + "json", "webmanifest" -> "application/json" + "wasm" -> "application/wasm" + "svg" -> "image/svg+xml" + "png" -> "image/png" + "jpg", "jpeg" -> "image/jpeg" + "gif" -> "image/gif" + "bmp" -> "image/bmp" + "ico" -> "image/x-icon" + "woff" -> "font/woff" + "woff2" -> "font/woff2" + "ttf" -> "font/ttf" + "pdf" -> "application/pdf" + "epub" -> "application/epub+zip" + "dwg" -> "application/acad" + "cbz" -> "application/vnd.comicbook+zip" + "xps" -> "application/vnd.ms-xpsdocument" + "txt" -> "text/plain" + else -> "application/octet-stream" + } + } +} diff --git a/android/app/src/main/res/drawable/ic_launcher.png b/android/app/src/main/res/drawable/ic_launcher.png new file mode 100644 index 0000000..3777e72 Binary files /dev/null and b/android/app/src/main/res/drawable/ic_launcher.png differ diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..94bea7b --- /dev/null +++ b/android/app/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + 万能看图 + diff --git a/index.html b/index.html new file mode 100644 index 0000000..474e7de --- /dev/null +++ b/index.html @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + 万能看图 · DWG/PDF 浏览器 + + +
+
+ + + + + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..79deda5 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6018 @@ +{ + "name": "phone-viewer-app", + "version": "0.4.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "phone-viewer-app", + "version": "0.4.0", + "license": "AGPL-3.0-or-later", + "dependencies": { + "@node-projects/acad-ts": "^3.6.0", + "mupdf": "1.28.1" + }, + "devDependencies": { + "@mlightcad/libredwg-web": "0.8.2", + "adm-zip": "^0.6.1", + "playwright-core": "^1.64.1", + "typescript": "^5.6.3", + "vite": "^5.4.10", + "vite-plugin-pwa": "^0.20.5" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@apideck/better-ajv-errors": { + "version": "0.3.7", + "resolved": "https://registry.npmjs.org/@apideck/better-ajv-errors/-/better-ajv-errors-0.3.7.tgz", + "integrity": "sha512-TajUJwGWbDwkCx/CZi7tRE8PVB7simCvKJfHUsSdvps+aTM/PDPP4gkLmKnc+x3CE//y9i/nj74GqdL/hwk7Iw==", + "dev": true, + "license": "MIT", + "dependencies": { + "jsonpointer": "^5.0.1", + "leven": "^3.1.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "ajv": ">=8" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", + "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz", + "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helpers": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz", + "integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@babel/types": "^7.29.8", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-annotate-as-pure": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.29.7.tgz", + "integrity": "sha512-OoK6239jHPuSQOoS0kfTVKn0b/rVTk0seKq4Gd2UMLtmOVLjDC0ki3e+c90Trqv2gMfvJFqkiljrr568+qddiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", + "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-create-class-features-plugin": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.29.7.tgz", + "integrity": "sha512-IY3ZD9Tmooqr3TUhc3DUWxiuo8xx1DWLhd5M7hQ+ZWJamqM2BbalrBJb2MisSLoYorOj75U03qULCxQTY9r3hg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.29.7", + "@babel/helper-member-expression-to-functions": "^7.29.7", + "@babel/helper-optimise-call-expression": "^7.29.7", + "@babel/helper-replace-supers": "^7.29.7", + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7", + "@babel/traverse": "^7.29.7", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-create-regexp-features-plugin": { + "version": "7.29.10", + "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.29.10.tgz", + "integrity": "sha512-/YY9soQuWa8TURtHXHT+GbklpbAA+dZErxFGHIr6qgDg96xuGWrTAs1+MfjgVJPF0YLQsOVsOYs8lhgsPbOinQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.29.7", + "regexpu-core": "^6.5.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-define-polyfill-provider": { + "version": "0.6.8", + "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.6.8.tgz", + "integrity": "sha512-47UwBLPpQi1NoWzLuHNjRoHlYXMwIJoBf7MFou6viC/sIHWYygpvr0B6IAyh5sBdA2nr2LPIRww8lfaUVQINBA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-compilation-targets": "^7.28.6", + "@babel/helper-plugin-utils": "^7.28.6", + "debug": "^4.4.3", + "lodash.debounce": "^4.0.8", + "resolve": "^1.22.11" + }, + "peerDependencies": { + "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", + "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-member-expression-to-functions": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.29.7.tgz", + "integrity": "sha512-j+7JYmk1JYDtACIGj0QJqqWZjoUpMoEikQGADMaHgCMCSDqd2+P32rfcibUNrGOMWrlzK1WJBdxrB3JJQZwWtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", + "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", + "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-optimise-call-expression": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.29.7.tgz", + "integrity": "sha512-+kmGVjcT9RGYzoDwdwEqEvGgKe3BYq+O1iGzjFubaNgZHwYHP6lsF2Yghf4kEuv9BV7tYDZ913aBW9am6YKong==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz", + "integrity": "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-remap-async-to-generator": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.29.7.tgz", + "integrity": "sha512-16AMiW26DbXWBbr3B8wNozKM0ydMLB892vaOaJW/fPJdnT8vJk5sdkQcU/isqUxyCE0cEoa8wZOcbgDuC4b6Og==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.29.7", + "@babel/helper-wrap-function": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-replace-supers": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.29.7.tgz", + "integrity": "sha512-atfGXWSeCiF4DnKZIfmJfQRkSw9b9gNNXR1kqKjbhG4pGYCOnkp8OcTB8E3NXjBu8NpheSnOeNKz8KT7UNFTmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-member-expression-to-functions": "^7.29.7", + "@babel/helper-optimise-call-expression": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-skip-transparent-expression-wrappers": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.29.7.tgz", + "integrity": "sha512-brcMGQaVzIeUb+6/bs1Av0f8YuNNjKY2JyvfRCsFuFsdKccEQ5Ges2y74D74NZ1Rz8lKJ9ksJkfqwQFJ/iNEyQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.11.tgz", + "integrity": "sha512-snZbO7MEDOof+hvNa97EjEY7qD7h2kwvQr5AJC3ZhQudKW5dnej6k3kP9NQV88hJwaS8vDqRLFo9rivLEhle2g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", + "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-wrap-function": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.29.7.tgz", + "integrity": "sha512-iES0Skag9ERIF68aXadpO6dbXa03mNWK3sEqJaMnLNs/eC3l0lkImdfoy6Y09/SfkpawdAB4RjQ7PVA7TcVGdw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.29.10", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.10.tgz", + "integrity": "sha512-EMCx3AGZ3WfAl6ht7AyQoPm2Lh+BGYEMdc4Q6Hf7uSCDOZFuLq44qNwL+iaim8VlyYhRAo4X43+weadK8ZB4Yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.8" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.11.tgz", + "integrity": "sha512-OZ6+oaK7GMyg3IfCpj8JOmn8n+w2rJbDT0LLfVDTLb1ZFeKDh3AiNELgCMUw175IJHSkLl74hG0M0VLsvx+gag==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.11" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-bugfix-firefox-class-in-computed-class-key": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-firefox-class-in-computed-class-key/-/plugin-bugfix-firefox-class-in-computed-class-key-7.29.7.tgz", + "integrity": "sha512-j8SrR0zLZrRsC09DlszEx8FpMiwukKffYXMK0d5LmOglO7vGG6sz/BR/20yHqWH+Lnn31JTt2PE3hIWNgM2J6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-bugfix-safari-class-field-initializer-scope": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-class-field-initializer-scope/-/plugin-bugfix-safari-class-field-initializer-scope-7.29.7.tgz", + "integrity": "sha512-r8j8escF+U2FUHo0KOhPUdMzUO+jp9fInva6+ACVAF3Y97Ev+5iNZwiqTghmzNeWwDkOPlYuTcfb1vDaoZKmAQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.29.7.tgz", + "integrity": "sha512-GE1TFSiuFeGsCxmYXZl8HwoPrVlwe4rHPFE8weieGKZqnDORK+Ar3vgWMgW+AOxQ6/2TgLSKx9p6W7O4rC6qgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-bugfix-safari-rest-destructuring-rhs-array": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-rest-destructuring-rhs-array/-/plugin-bugfix-safari-rest-destructuring-rhs-array-7.29.7.tgz", + "integrity": "sha512-oBNVCvnO5tND+xSopWvV8WNGfpTfgP4Zr/YXXSj8zfmcPktp5Ku/aZlsIowgSD4fjmgHn6sGmB9APVsU5zOdhA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.29.7.tgz", + "integrity": "sha512-QQt9qKHZ2sg/kivaLr7lnQr8HVrQDdBNSfCsTjiDxRuX/K5ORyKq+Bu8Xr0cDE3Dfkv0cw28Ve0EKyKMvulkOw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7", + "@babel/plugin-transform-optional-chaining": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.13.0" + } + }, + "node_modules/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly/-/plugin-bugfix-v8-static-class-fields-redefine-readonly-7.29.7.tgz", + "integrity": "sha512-pn6QacGLgvCcwc+syUhKE/qSjV2D1IHDB84RNxWYSt1mW3K/SCtjinZ2p0cETJxAWBjPy3K/1lHwG5BjjPxNlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-proposal-private-property-in-object": { + "version": "7.21.0-placeholder-for-preset-env.2", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.21.0-placeholder-for-preset-env.2.tgz", + "integrity": "sha512-SOSkfJDddaM7mak6cPEpswyTRnuRltl429hMraQEglW+OkovnCzsiszTmsrlY//qLFjCpQDFRvjdm2wA5pPm9w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-assertions": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.29.7.tgz", + "integrity": "sha512-/An1OCBN93thpBAGyfsK2pcf0jvju1SAtKkL2Ny++B5Sy6sqgzXDQH1cZxWbF96Wuk+bn41MDA9bLd4VVAw6rw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-attributes": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-attributes/-/plugin-syntax-import-attributes-7.29.7.tgz", + "integrity": "sha512-zGYcYfq/WmZ4V+kBIXQon9dSSc8ircGZqw9ZaNhhGj9nZkeBu1jHLBDQqYYi5WA9uawvA2sIMbry2nCFhf5Djg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-unicode-sets-regex": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-unicode-sets-regex/-/plugin-syntax-unicode-sets-regex-7.18.6.tgz", + "integrity": "sha512-727YkEAPwSIQTv5im8QHz3upqp92JTWhidIC81Tdx4VJYIte/VndKf1qKrfnnhPLiPghStWfvC/iFaMCQu7Nqg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.18.6", + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-transform-arrow-functions": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.29.7.tgz", + "integrity": "sha512-N7zArUXWzAMzm+/N0uPBeVB3Fam5lMxtUwMmDK5f/IBBS7a7p1qeUoxd/6CckXoxUdgsntq1Dh8xNW06maZbDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-async-generator-functions": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-generator-functions/-/plugin-transform-async-generator-functions-7.29.7.tgz", + "integrity": "sha512-d98gXZkgswvkyohMBABkhm3GeXhYj8psWfwQ2C7gtfrKGTykQa/iOIi+JJhwMjPlZ6Vm2XN+DCf3Es1EoG4ZLA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-remap-async-to-generator": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-async-to-generator": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.29.7.tgz", + "integrity": "sha512-pcUb2SS+RMo9TWVBwKGI5ShtoG7R+zBsFmCKDa6fe8c+hPr3XJlZgoE5j6i8W7gDjhyvy+85vmYexanvXh3d1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-remap-async-to-generator": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-block-scoped-functions": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.29.7.tgz", + "integrity": "sha512-cUSmjh72N+rN4PrkFlN1dJwNCwjVp5d38/CQrEsFggkD10UiFlBFgdH3tv5dNsLuHY+3S8db2xCHjhZcv5WgvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-block-scoping": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.29.11.tgz", + "integrity": "sha512-iARF4jjHSM0v8DImCACPXrwEltBP3DgqDpXTvjAMBAVpyEY0LiGss78wvI+KtmW+IJNEvZ5sOhPDCsOsXsIybA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-class-properties": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-properties/-/plugin-transform-class-properties-7.29.7.tgz", + "integrity": "sha512-GtcpjFvanPfzNQi3eTitsCqtRRmmqzpy/A+yhTR1HaZo1Ly3EA8ZXxlPyHdR8/IuRMYc3E4wdGBewB2QKQjAaA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-class-static-block": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.29.7.tgz", + "integrity": "sha512-kibJgmEdX2iMwsHY2tSZNDgj8PwIlCQz7FK9KuGKO8zsuoUwSEhoNnNVp/emKWrbY4HeO6kkXfdMqRKKKXBm2A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.12.0" + } + }, + "node_modules/@babel/plugin-transform-classes": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.29.11.tgz", + "integrity": "sha512-f8kTDM/nTvpLeafb+TJ4jboFr/Y3BbC+QzgPpPGzSKJqWLnj9LW0WLqv4XKA11LX5sr+EgvLE6Ix3YsCEusodw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-globals": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-replace-supers": "^7.29.7", + "@babel/traverse": "^7.29.10" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-computed-properties": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.29.7.tgz", + "integrity": "sha512-RK7/IyU5phpuCdBAuig5VkzG/EnbDaui5SQGdU9BFrHdV+mV4cUjLMQ9lJDjLNtWHsqtiefpGZUXQP2BiTYMsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/template": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-destructuring": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.29.7.tgz", + "integrity": "sha512-iPX8aD6H9zV5s7ZsqTdNocPN/MGQ5sSMnElKrktxjJRMnB2jN/1p2+R7GkfD6CAYoVFqy5A4XnSIUeGgJzIWpg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-dotall-regex": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.29.7.tgz", + "integrity": "sha512-3qc18hsD2RdZiyJNDNc7HQpv6xbncwh8FYtxNFFzclSyh/trPD9KkVR9BDECUjDLvb7yJVF15GfYUuC+LMkkiQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-duplicate-keys": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.29.7.tgz", + "integrity": "sha512-6IvRRriEMqnBwD6chtxdLpMYCHWEzN+oL5cyQtjykya19UgzbmKhxmhZgKC/LHxS2nYr9Q/qYPZ5Lr6jOL9+yQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-duplicate-named-capturing-groups-regex": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-named-capturing-groups-regex/-/plugin-transform-duplicate-named-capturing-groups-regex-7.29.7.tgz", + "integrity": "sha512-2wiIyo2BjtgU7HufSeDnL9L2O7zr8jmhFKuSr65VpRkUiRKRNpb0mdlk56+XPPKoIrfHqzbMuglDvZun0RISsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-transform-dynamic-import": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dynamic-import/-/plugin-transform-dynamic-import-7.29.7.tgz", + "integrity": "sha512-giOlEm/EFjfjr+te9NsdjkUo2v4f8rS/SXPumRVHAtbNcyNlvtREkU1dZzaIDclNpnaVhlCqRdFKhJBjBikzLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-explicit-resource-management": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-explicit-resource-management/-/plugin-transform-explicit-resource-management-7.29.7.tgz", + "integrity": "sha512-Rstj7coNz8sE+7Ju7ihpHLI564lsK5pUpNNlvptCIC/16E/S5hbl6n3kESPKdNRmqEWlpn5xpS5Q2dvXBsySLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/plugin-transform-destructuring": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-exponentiation-operator": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.29.7.tgz", + "integrity": "sha512-zFpMOTLZBdW5LfObqcSbL6kefg4R4eLdmvS0wbN9M6D5Mym/sKm9toOoWyVOa+xDjvCnuWcHls2YonXwHvH3CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-export-namespace-from": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-export-namespace-from/-/plugin-transform-export-namespace-from-7.29.7.tgz", + "integrity": "sha512-24B2nOy2TeJSMheqwPD4DDQOV/elLSIlKxjZt4i05H5AgdPdWR3n18HnNrcJ+j76WJd9gbwb9jPjNYUy6RautA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-for-of": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.29.7.tgz", + "integrity": "sha512-zeSIHh0+E1Um1WJRXCFlHQYu2ieJNdivLLjlBEp+dIBu3S51n+SZZmIXjxnItw6pz56Cn+KvK68BIBVsxq2JiQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-function-name": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.29.7.tgz", + "integrity": "sha512-otRWaHXE6fbAGkePvaj/kvs3HsqXfPhlnzwSOlnFgbqCPMd975dW+4wZ00WFBt+/YlBGcJwNrARQTOJOb4ZrIg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-json-strings": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-json-strings/-/plugin-transform-json-strings-7.29.7.tgz", + "integrity": "sha512-RRnE2+eon1rJAq8MnoF1b5kTpY1vU88twHcvcKMrsqP/jxIRqDVs9iJB5fqPuqyeFAW0wJo4MlUIPpQCq/aRsg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-literals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.29.7.tgz", + "integrity": "sha512-DZ/oLP21ZuWx1vKqnoNv6/tvEK48AQOBRai40CX9dTjGluvT/YZCyY3rryDtyUqCEoyNroy5KKPwX2iQCiRvyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-logical-assignment-operators": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-logical-assignment-operators/-/plugin-transform-logical-assignment-operators-7.29.7.tgz", + "integrity": "sha512-A0H91hh6W8MFRkp5TqJmMr39jzGD1A1E1Ysiv2O06Sfbhkapm+XyIzxWCEh5kqwOZ1/8QZ0dY3SeQ7XBqfJd5Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-member-expression-literals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.29.7.tgz", + "integrity": "sha512-hl1kwFZCCiDyfH25Xmco9jTrkPgnS9pmOzSG7W5I4SaGbLeqKv417hcU2RKmaxoPEgsoJh7ZPOrnPGq99bHoUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-amd": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.29.7.tgz", + "integrity": "sha512-fxtQoH3m5ywUSIfaH0FGCzWu4McsYon5bD3K4XnskC7f+OyQMj7rsOMi4NvvmJ83WwBAg4UCe+ov4VZlqEvyew==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-commonjs": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.29.7.tgz", + "integrity": "sha512-j0vCldybPC5b5dwCQOJ21uKtHzt7hxLygJTg9eF1ScfaikEDNfzn94XoW5Fi+seBR0nCyL23xaBFFkq7dTM8XQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-systemjs": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.29.8.tgz", + "integrity": "sha512-6iSnEK0zlkLKU4heofK/AdmRD4e2SHVpJMtrwnTCzhnaM98ria4rTrOXBBi45BTTYnJtO8txnPsX4fChYXkmeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.8" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-umd": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.29.7.tgz", + "integrity": "sha512-B4UkaTK3QpgCwJnrxKfMPKdo92CN7OKXAlpAAnM3UPu0Q0lCCk57ylA9AJbRy2v8dDKOPAAWcoR6CMyeoHwRCA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-named-capturing-groups-regex": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.29.7.tgz", + "integrity": "sha512-vuFoLwr4qnv2xbZ16SQd6uPcH5FNrLHhk/Jzo++0XJFcaDsr4gjJVg6j398oMHiC+83k/GiBzviwF5KBJkPUtQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-transform-new-target": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.29.7.tgz", + "integrity": "sha512-fEo41GmsOUhOBlw8ioo6zvjX5Xc2Lqkzlyfqbpsk3eB6TReV18uhxZ0esfEokVbY2+PVJAQHNKxER6lGrzNd3A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-nullish-coalescing-operator": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.29.7.tgz", + "integrity": "sha512-idmp1dFaekP9GbcMvG24Kvw2BfhFZjHnNJCkV4WuIY4PskJzwI3f1N5OdgYke38T7rftO6ERulFRn2cFeZwRkg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-numeric-separator": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-numeric-separator/-/plugin-transform-numeric-separator-7.29.7.tgz", + "integrity": "sha512-zR7fv/z14OjgHl4AgRtkDBvBMhIzCxqV/qN/2BCRC7LjFwvuzjYe7gDWxC4Wl/SNsLM6SE1IWvRPYMgSJaUvNw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-object-rest-spread": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-rest-spread/-/plugin-transform-object-rest-spread-7.29.7.tgz", + "integrity": "sha512-Ld98jn4c0smUywL57m7SgsHq3OpThOa6LqZJif3G6jYOovPleoFhVrBJ1WegRApSFB2wu4+RelAj9AC9G08Z4A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/plugin-transform-destructuring": "^7.29.7", + "@babel/plugin-transform-parameters": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-object-super": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.29.7.tgz", + "integrity": "sha512-Ea/diGcw0twB5IlZPO5sgET6fJsLJqPABqTuFWIR+iMPGPZJkATEIWx0wa+aEQ5UY1CBQyP/gkAiLEqn1vBiQA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-replace-supers": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-optional-catch-binding": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-catch-binding/-/plugin-transform-optional-catch-binding-7.29.7.tgz", + "integrity": "sha512-sLsyndxK2VwX6yNUOakMb7Sh553ZTe/vVM1XJ+9Z5aW1ytsc8xOIwmyk05NNjN60vkc5/KqoTH6hB4V41LJhng==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-optional-chaining": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.29.7.tgz", + "integrity": "sha512-6GM1dhvK3gNODkXcEcMCOLEDCLSoZ/sBbro2Ax8HURyasQ4NshagQixkRFdh5niI6E4gmA/jYI/4aT7rRos3ZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-parameters": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.29.7.tgz", + "integrity": "sha512-ZDOBqV/qLYJI0YElr8DcENEyARsFQeESqWXH6gZlghYXuPPjvweuDhP4VyEi4BlUBlLRFZVjxoZDMjxhLW766g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-private-methods": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-methods/-/plugin-transform-private-methods-7.29.7.tgz", + "integrity": "sha512-/6Rz4DK1ETDEM/bWHsPHcaEe7ZaT1EqSXjtSP/L0DijOYuaUhiRiOKcwpZ8P7zR4xXEHc2ITdiCgBm9Tpyv9ug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-private-property-in-object": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-private-property-in-object/-/plugin-transform-private-property-in-object-7.29.7.tgz", + "integrity": "sha512-+BNo06dnrzdNNqCm1X6YUaVv0DKk8Q+JYcoZfOkLhYWNCXzlwTSRq8zGWayT1csjcpNXV9CQTBRRbmTLZac5cA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.29.7", + "@babel/helper-create-class-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-property-literals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.29.7.tgz", + "integrity": "sha512-bOMRLQuI0A5ZqHq3OWJ89/rXpJ/NJrbVhXiP4zwPGMs6kpcVsuTUNjwoE30K0Qm3mf48a/TnRYYD6vPNqcg6jA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-regenerator": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.29.8.tgz", + "integrity": "sha512-0UpIXPtdDtMXfnV2OJAVMLpj3H/92vmkA6lpSRakmycJvj3VUy6Xs1dM8tXRugupykr5WB+LpiVl0J8LMVg2mg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-regexp-modifiers": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regexp-modifiers/-/plugin-transform-regexp-modifiers-7.29.7.tgz", + "integrity": "sha512-mB5Fs0VWrJ42ZCmc8114v60qetdaUVNkj9PmSZRmanCZM3S9hm0CFRLjRmYIsuXav14l2jvZ+4T8iiCGnhj3nQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-transform-reserved-words": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.29.7.tgz", + "integrity": "sha512-5+YhdpVgmfSmwZyLMftfaiffLRMHjzIRHFHHLdibcSyJm2pasMrKHrO3Ptrt2DRshjvpgjEJJ1zVW14WPq/6QA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-shorthand-properties": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.29.7.tgz", + "integrity": "sha512-I+WYbGBAiCn7nA6xBrlgPH+MB7HWb4u8pv5S0Pv7OtwNvIFvCCb24YlttKEeUFVurfBCEaOTnuhlqsb7f0Z5Dg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-spread": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.29.11.tgz", + "integrity": "sha512-5xWGhfuMgbOfIjsk/I2c4uMnoqRwQdKYi4QjvybQrcEVE0G9/p3qmIkp2Sxe8YF8DGNNVs5whfwNqIM5684XoQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-sticky-regex": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.29.7.tgz", + "integrity": "sha512-BCHzNYJGe9l7EpwwDBN/ztlL2NYFFq8hp9ddjtUEM9f2O7S7kKV/lL6Fwo7IF7NSkYhPK2vO+86nIGltA90MsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-template-literals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.29.7.tgz", + "integrity": "sha512-NCSEJ4sLFU2gqAub45HYh4fus2yQ36rr6ei6vpU7NdoJqCpxvEG8E6eJpscGyXP3VHD2Ny+fSXr04k1hoUrFqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-typeof-symbol": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.29.7.tgz", + "integrity": "sha512-223mNGoTkBiTEWFoK+Q6Go3tueMRclO8vxxxxquNCYuNI4jWOofFKJRRDu6SDrB8Sgo1UEGW9T4GAQ8ZyRso1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-unicode-escapes": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.29.7.tgz", + "integrity": "sha512-jCfXxSjf94lf4E0hKE0AByxF6F3/pVFqRdUUNkDJhsY0m1ZKjnN6ZYyMeHNpzflxb/0q5b7t3p+BE+SLF1WOtA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-unicode-property-regex": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-property-regex/-/plugin-transform-unicode-property-regex-7.29.7.tgz", + "integrity": "sha512-OgZ+zoAJgZLUCunsTRQ5LAjOywDv5zzZ2/hQ5aMw1pGXyY2rtE8/chXYUmu3AlVHKpm10KEdG9aMwbI/K76ZGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-unicode-regex": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.29.7.tgz", + "integrity": "sha512-7D/x/23/d/3VqZ0QA+LGbZMlGwZjztBygSWWWsfTPoQ1oQ6Q1P6Mr3d0kk42XabyUVw+fha3LqdRsFqeKqvCyA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-unicode-sets-regex": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-sets-regex/-/plugin-transform-unicode-sets-regex-7.29.7.tgz", + "integrity": "sha512-BLOhLht9DOJwIxlmp91wHvkXv1lguuHS3/FwUO8HL1H0u8s4hR1gASVFyilu9iGtcTRYqjTZmlsFFeQletntEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/preset-env": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.29.7.tgz", + "integrity": "sha512-GYzX36n1nsciIb0uyH0GHwxwtNwPQIcpxSeiVLDtG/B7jB5xXgchnmL1f/jCX5o+pwnaDBtO60ONSJhEBJfxYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", + "@babel/plugin-bugfix-firefox-class-in-computed-class-key": "^7.29.7", + "@babel/plugin-bugfix-safari-class-field-initializer-scope": "^7.29.7", + "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.29.7", + "@babel/plugin-bugfix-safari-rest-destructuring-rhs-array": "^7.29.7", + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.29.7", + "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": "^7.29.7", + "@babel/plugin-proposal-private-property-in-object": "7.21.0-placeholder-for-preset-env.2", + "@babel/plugin-syntax-import-assertions": "^7.29.7", + "@babel/plugin-syntax-import-attributes": "^7.29.7", + "@babel/plugin-syntax-unicode-sets-regex": "^7.18.6", + "@babel/plugin-transform-arrow-functions": "^7.29.7", + "@babel/plugin-transform-async-generator-functions": "^7.29.7", + "@babel/plugin-transform-async-to-generator": "^7.29.7", + "@babel/plugin-transform-block-scoped-functions": "^7.29.7", + "@babel/plugin-transform-block-scoping": "^7.29.7", + "@babel/plugin-transform-class-properties": "^7.29.7", + "@babel/plugin-transform-class-static-block": "^7.29.7", + "@babel/plugin-transform-classes": "^7.29.7", + "@babel/plugin-transform-computed-properties": "^7.29.7", + "@babel/plugin-transform-destructuring": "^7.29.7", + "@babel/plugin-transform-dotall-regex": "^7.29.7", + "@babel/plugin-transform-duplicate-keys": "^7.29.7", + "@babel/plugin-transform-duplicate-named-capturing-groups-regex": "^7.29.7", + "@babel/plugin-transform-dynamic-import": "^7.29.7", + "@babel/plugin-transform-explicit-resource-management": "^7.29.7", + "@babel/plugin-transform-exponentiation-operator": "^7.29.7", + "@babel/plugin-transform-export-namespace-from": "^7.29.7", + "@babel/plugin-transform-for-of": "^7.29.7", + "@babel/plugin-transform-function-name": "^7.29.7", + "@babel/plugin-transform-json-strings": "^7.29.7", + "@babel/plugin-transform-literals": "^7.29.7", + "@babel/plugin-transform-logical-assignment-operators": "^7.29.7", + "@babel/plugin-transform-member-expression-literals": "^7.29.7", + "@babel/plugin-transform-modules-amd": "^7.29.7", + "@babel/plugin-transform-modules-commonjs": "^7.29.7", + "@babel/plugin-transform-modules-systemjs": "^7.29.7", + "@babel/plugin-transform-modules-umd": "^7.29.7", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.29.7", + "@babel/plugin-transform-new-target": "^7.29.7", + "@babel/plugin-transform-nullish-coalescing-operator": "^7.29.7", + "@babel/plugin-transform-numeric-separator": "^7.29.7", + "@babel/plugin-transform-object-rest-spread": "^7.29.7", + "@babel/plugin-transform-object-super": "^7.29.7", + "@babel/plugin-transform-optional-catch-binding": "^7.29.7", + "@babel/plugin-transform-optional-chaining": "^7.29.7", + "@babel/plugin-transform-parameters": "^7.29.7", + "@babel/plugin-transform-private-methods": "^7.29.7", + "@babel/plugin-transform-private-property-in-object": "^7.29.7", + "@babel/plugin-transform-property-literals": "^7.29.7", + "@babel/plugin-transform-regenerator": "^7.29.7", + "@babel/plugin-transform-regexp-modifiers": "^7.29.7", + "@babel/plugin-transform-reserved-words": "^7.29.7", + "@babel/plugin-transform-shorthand-properties": "^7.29.7", + "@babel/plugin-transform-spread": "^7.29.7", + "@babel/plugin-transform-sticky-regex": "^7.29.7", + "@babel/plugin-transform-template-literals": "^7.29.7", + "@babel/plugin-transform-typeof-symbol": "^7.29.7", + "@babel/plugin-transform-unicode-escapes": "^7.29.7", + "@babel/plugin-transform-unicode-property-regex": "^7.29.7", + "@babel/plugin-transform-unicode-regex": "^7.29.7", + "@babel/plugin-transform-unicode-sets-regex": "^7.29.7", + "@babel/preset-modules": "0.1.6-no-external-plugins", + "babel-plugin-polyfill-corejs2": "^0.4.15", + "babel-plugin-polyfill-corejs3": "^0.14.0", + "babel-plugin-polyfill-regenerator": "^0.6.6", + "core-js-compat": "^3.48.0", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/preset-modules": { + "version": "0.1.6-no-external-plugins", + "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.6-no-external-plugins.tgz", + "integrity": "sha512-HrcgcIESLm9aIR842yhJ5RWan/gebQUJ6E/E5+rf0y9o6oj7w0Br+sWuL6kEQ/o/AdfvR1Je9jG18/gnpwjEyA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/types": "^7.4.4", + "esutils": "^2.0.2" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0 || ^8.0.0-0 <8.0.0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.29.10", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.10.tgz", + "integrity": "sha512-NpugTzbKgGrNe45Ui32cN8vCFFMxVtP/9rtfwv0nP5FRDAjvYBxJcLVpYA9mr1jxP6cnIT7x9LUzuDTbWYYNRA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.10", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.10.tgz", + "integrity": "sha512-B3lYAs2nkKskbgQ1nfy8Ma9ao9Q1rntTAQHrzzyDuj+TSO+X3le6PfWwqDvodsb+OumE10eMFfuMCTQSQ5iuIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.8", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.9", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.8", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.11.tgz", + "integrity": "sha512-WCsemW40Cpc6gouC1SrY6PBaZ+oLRlEVY9XBvZBI7il/HyUrb2nJ505wE1MHEFyDZNnrWDEuy4jL50WVHfTTSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.11", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-9.0.0.tgz", + "integrity": "sha512-AokJm4tuBHillT+FpMtxQ60n8ObyXBatq7jD2/JA9dxbDDokKQm8KMht5ibGzLVU9IJDIKK4TPKgMHEYMn3lMg==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.11", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz", + "integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@mlightcad/libredwg-web": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/@mlightcad/libredwg-web/-/libredwg-web-0.8.2.tgz", + "integrity": "sha512-0iX1lbASPEWwhljHAmaB6/mNHAPObCMmlDIza1a6B0egpm0DGfaMjXimwWmVSPE+FNEMhQxB3Tw0mupDwkWHIQ==", + "dev": true, + "license": "GPL-3.0", + "engines": { + "node": ">=20" + } + }, + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^22.20 || ^24.12 || >=25" + } + }, + "node_modules/@node-projects/acad-ts": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@node-projects/acad-ts/-/acad-ts-3.6.0.tgz", + "integrity": "sha512-MQadFJafEuKDmzhi7GeoCV/YpPcbSVHMuuRhaQGuC9Xbzo8DdRpE8LWdV/fNT5FqbRXh60oK/B/2pPFR/ATpmw==", + "license": "MIT" + }, + "node_modules/@rollup/plugin-babel": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-6.1.0.tgz", + "integrity": "sha512-dFZNuFD2YRcoomP4oYf+DvQNSUA9ih+A3vUqopQx5EdtPGo3WBnQcI/S8pwpz91UsGfL0HsMSOlaMld8HrbubA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.18.6", + "@rollup/pluginutils": "^5.0.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0", + "@types/babel__core": "^7.1.9", + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "@types/babel__core": { + "optional": true + }, + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.3.tgz", + "integrity": "sha512-lUYM3UBGuM93CnMPG1YocWu7X802BrNF3jW2zny5gQyLQgRFJhV1Sq0Zi74+dh/6NBx1DxFC4b4GXg9wUCG5Qg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-replace": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-6.0.3.tgz", + "integrity": "sha512-J4RZarRvQAm5IF0/LwUUg+obsm+xZhYnbMXmXROyoSE1ATJe3oXSb9L5MMppdxP2ylNSjv6zFBwKYjcKMucVfA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "magic-string": "^0.30.3" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-terser": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-1.0.2.tgz", + "integrity": "sha512-+UihHnuLnQDQ/9wog7ym+7oawCXkjTIo0WwkK7s//0mkktTN0VhYk6fGVxH+NtGzW064w5RCGgreMDxRVhHCzw==", + "dev": true, + "license": "MIT", + "dependencies": { + "serialize-javascript": "^7.0.3", + "smob": "^1.0.0", + "terser": "^5.49.2" + }, + "engines": { + "node": ">=20.0.0" + }, + "peerDependencies": { + "rollup": "^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.5.1.tgz", + "integrity": "sha512-P9ZvnfouRu4MSC+ilERaw6FmZs8zqKhpHxEs4aGDGWQAMzQGXnhvCSvoNwokfNvdt7t3Y5Y4p6gStQgezeIqug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.65.0.tgz", + "integrity": "sha512-t2AnVba25baFdq7gczzS13JyVcdubLVbFX1X04mxrggDrTQPUXNv3XM0k9H1hr5tqvg7AVvtQ720QHAj0iYqhg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.65.0.tgz", + "integrity": "sha512-dNONUaEwPGhl/nuO2KV8VABWlcjYyU6KtZGN8dQv5OS5JU7JSCxPijVNKXbRJd0iuTzTiJ4TjPt/4bbvDRNiMQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.65.0.tgz", + "integrity": "sha512-zWQqUH+9zavr2Bxuzfpuv2SIF3X31cr58TvSQC9o1GhpOvkqRwr60GkZdQcudyT/BEgdpdSafjgd2I13MbTL7g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.65.0.tgz", + "integrity": "sha512-RQYreBFWtO4//hIuOaZkYUnF/lPU4lz35dveDimDshWCJvVisVtJ/shmT9bkXK8wFJY+FJF89X6F3Cq1qI3LCw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.65.0.tgz", + "integrity": "sha512-A0NfMj6Cuh/9BE5k3awJKv6HoxFVXIcLAb6SZqAMoxUHPA1ZNNK4RsGuUPD/vL7nEAm9LG+ZzXWWTrnC0XtkpA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.65.0.tgz", + "integrity": "sha512-BI6/H7q3aP0I7S7GOrjyxTjgEJlSnovXE38+bdxBpuKN6z+d//uF+T+VQ3Q7ltJL/71p17ufartARX9Ja5gOGQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.65.0.tgz", + "integrity": "sha512-W1vUprf09RWaVWnsFP1vlUkEWJzTZlpObOEAYZXt9Fq0UVAOYEkeGr7wBX7McKqqIQskXdBnpiOMgwPujordgA==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.65.0.tgz", + "integrity": "sha512-s8QTcZWgrl9haFzEGIqyE5BWyo89pFDGLMBFZ752WYxk8DJwNU/O1X6pZgPw829d9/sm6CCHyrMP3aurt76p1Q==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.65.0.tgz", + "integrity": "sha512-ke1f6dLRzkqveyjjF2fkEwQYZvxHtNNwjegY8nJrwcO0Bdqr8CzFO/pKE0Bns13cx0qz2Ba2Y0Hs3dSwMdnHxA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.65.0.tgz", + "integrity": "sha512-926SMeUcy4y18Rz/w2aJiUKOnyAnm6czg72bXkQEaeemsll+Wr0hnsjb2BGRpHvWgwAMYy5ACJCotbvfLCfj0A==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.65.0.tgz", + "integrity": "sha512-6T7JNRP1hc4hqF2dUsEoVLOt9K8tmODoCLldtQRYnrddGGQY8Gqe2pM/qMMUo7EMowpP7oa2N95k0/8sYK/ipw==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.65.0.tgz", + "integrity": "sha512-SImGFl1Je5kpyAgOCPONVT7h6ASV8mAUwGRjY7eZvVjPg//PfHOXgI+P241RF/+HqsA4PP3qD527ysWFKNQyhQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.65.0.tgz", + "integrity": "sha512-XeDTbmPF1Yu5asfXGPrMkWoxTDhgryQbmw5Q1+R582O51VNCk23J6f2pDrsAp5YkneBVBwtExx6ZGOb9D2aQ6A==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.65.0.tgz", + "integrity": "sha512-VS55JUI/1nsljmV/jfqNkLZXFw8uMO8nNlfoHmSevNf6fO3neuhyDvx9dv3c/Ytt8r/431SL8Qax1dpYvOMZTg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.65.0.tgz", + "integrity": "sha512-Vblw84TbX7RS4la1Y4+yQ7aore/oSyaNtFbppuBr5Vs/4LfBeXKq9dIfoExw6zOvRERqd2rRAjnZRaMhH/0x5w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.65.0.tgz", + "integrity": "sha512-7+gHjtONvKgwR9InTKFaLq53f6YzBJkgeMRBENdWTsQr+spahGqQm8HF5aXpq8i4JaRrOqYyv6Zn1WltDTxaZQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.65.0.tgz", + "integrity": "sha512-KvNDC0J6s4vVHhtJ6KrDXU0Er0au/hmRIBq/+1maCV8TseGupeKizq0bWcrbp2HE1T8xoknvN0Q/KZ/YF0qX3w==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.65.0.tgz", + "integrity": "sha512-GExdD15WPvu/x/drELjVam7vX8EsPgvTMOa/iJL/p/4m/oOqzbb7JXZg8fXR4hlXtg/sF2zyTZ3bR0AEtEMlhQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.65.0.tgz", + "integrity": "sha512-8sT9PemIZfIMED4Vd4KGoOXVDj5CMSWNcGdbheRUx9TYS03yOWdT2Q0lXPyEyNBB9YTilwewIQKNIBk6Nxi0Kg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.65.0.tgz", + "integrity": "sha512-pO6Ehi0jo5yE0R6PltKhJhv9mlIiyzBJk5N5NUF2OF6xtVKI+1bdXxj/rb0jGXy3hck1ELVT0QPY3tzkAm360w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.65.0.tgz", + "integrity": "sha512-vo7N3/+cjjPDYr8vtxC+qSNgWa9sDvJ7g8N8R5SWqFY4WiNH1ULcAU70SKVyHeiIZOYYwNP9pTipmhN5sl1NPw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.65.0.tgz", + "integrity": "sha512-ArwvgFAbjKcDM7qqotZ4OVYf+UMT9xH2YzkCzK4+AuZSDihMlz1Ekoe4INwBVXzn2mnJzuIYOcSx07iTBijGRQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.65.0.tgz", + "integrity": "sha512-QGMmK4/cxKE/36FoLMSHQBCyymv/eFTnsCvvsBF0rgmOvVbvX78VWZRerL3dHa77f4pM6Xcc2iGDhJ10w/svKQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.65.0.tgz", + "integrity": "sha512-XfKYFWHIPs4HPODIMsGF1IKlS3H1e3WokUZIgpmn4+uNnZBlnRDDHEylNyazbQXwhMKZre68OjtRYbKqb5+j8w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.65.0.tgz", + "integrity": "sha512-wPWi++K4Bs1VR4XihOhfGi4IGX6Cub7FlerTf8X2v+2BtDHddgSqWCXwGD+h2yAe4/niIhNDwAltioOC+wEogQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@trickfilm400/rollup-plugin-off-main-thread": { + "version": "3.0.0-pre1", + "resolved": "https://registry.npmjs.org/@trickfilm400/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-3.0.0-pre1.tgz", + "integrity": "sha512-/67zpWDBLV+oYAEL682s1ktXL0HgqX76f6gaVGkGnVZlBbm1zd0v4Bz8MFF2GGhoX9rvfq3KSQHubFHwa6w6/Q==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "ejs": "^3.1.10", + "json5": "^2.2.3", + "magic-string": "^0.30.21", + "string.prototype.matchall": "^4.0.12" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", + "dev": true, + "license": "MIT" + }, + "node_modules/acorn": { + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", + "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/adm-zip": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.6.1.tgz", + "integrity": "sha512-Xwrja8nx9e5o2N1my4DsKCeKpdrnACyr1wtbPxBDgGzKzKyE9kRtBFA8mWldI+RVlD7CBZNWY/wQ2+ydwOR6kQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0" + } + }, + "node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/array-buffer-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.2.tgz", + "integrity": "sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "is-array-buffer": "^3.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/arraybuffer.prototype.slice": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.4.tgz", + "integrity": "sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-buffer-byte-length": "^1.0.1", + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "is-array-buffer": "^3.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", + "dev": true, + "license": "MIT" + }, + "node_modules/async-function": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz", + "integrity": "sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/available-typed-arrays": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", + "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/babel-plugin-polyfill-corejs2": { + "version": "0.4.17", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.17.tgz", + "integrity": "sha512-aTyf30K/rqAsNwN76zYrdtx8obu0E4KoUME29B1xj+B3WxgvWkp943vYQ+z8Mv3lw9xHXMHpvSPOBxzAkIa94w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.28.6", + "@babel/helper-define-polyfill-provider": "^0.6.8", + "semver": "^6.3.1" + }, + "peerDependencies": { + "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" + } + }, + "node_modules/babel-plugin-polyfill-corejs3": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.14.2.tgz", + "integrity": "sha512-coWpDLJ410R781Npmn/SIBZEsAetR4xVi0SxLMXPaMO4lSf1MwnkGYMtkFxew0Dn8B3/CpbpYxN0JCgg8mn67g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-define-polyfill-provider": "^0.6.8", + "core-js-compat": "^3.48.0" + }, + "peerDependencies": { + "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" + } + }, + "node_modules/babel-plugin-polyfill-regenerator": { + "version": "0.6.8", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.6.8.tgz", + "integrity": "sha512-M762rNHfSF1EV3SLtnCJXFoQbbIIz0OyRwnCmV0KPC7qosSfCO0QLTSuJX3ayAebubhE6oYBAYPrBA5ljowaZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-define-polyfill-provider": "^0.6.8" + }, + "peerDependencies": { + "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.33", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.33.tgz", + "integrity": "sha512-yiVKDX+qCMRKBE084lXvq9EcwFUhKZ2nU8TK1EQQuOgPNR/lmbGxXOeDdlGUqC2Zz11Cs9rk1d/8NfgBmlkt0w==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", + "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/browserslist": { + "version": "4.29.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.4.tgz", + "integrity": "sha512-2TcbbiwXEq+N0kD36tykpCfyyQigUXmuwNQbnPp4Xk4PX9JOqVIKjJlIDjpH7uY6tmRGoAd+apeT1p60T8wsdA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.29", + "caniuse-lite": "^1.0.30001816", + "electron-to-chromium": "^1.5.459", + "node-releases": "^2.0.59", + "update-browserslist-db": "^1.3.4" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/call-bind": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.9.tgz", + "integrity": "sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "get-intrinsic": "^1.3.0", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001819", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001819.tgz", + "integrity": "sha512-LFUqIIAwpzsIuevnKnsR9qnStBcgzPShTX61lBwN9uFkkf8o8zLiebEjbW8AYtZiF+1YKDWfdt/pWDtMuG8Xwg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/common-tags": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.2.tgz", + "integrity": "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/core-js-compat": { + "version": "3.51.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.51.0.tgz", + "integrity": "sha512-52r6fkXgxv4GLMjmFcMWRx7X9bw071xTTdrDcdyPGRqU2oE+9pCG0bAOMifSBdLw0JRBZKEF0q3B55qPlLuE8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "browserslist": "^4.29.3" + }, + "engines": { + "node": ">=6.4.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/crypto-random-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz", + "integrity": "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/data-view-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz", + "integrity": "sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/data-view-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/data-view-byte-length/-/data-view-byte-length-1.0.2.tgz", + "integrity": "sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/inspect-js" + } + }, + "node_modules/data-view-byte-offset": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/data-view-byte-offset/-/data-view-byte-offset-1.0.1.tgz", + "integrity": "sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ejs": { + "version": "3.1.10", + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz", + "integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "jake": "^10.8.5" + }, + "bin": { + "ejs": "bin/cli.js" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.464", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.464.tgz", + "integrity": "sha512-nRa65aFge40viPAKxMKULIY8tcXKwKboJWNn4RoKwyWXJ6SP7BnrDGKUTzc64818jIciH0PK7LSF8QzZes19GA==", + "dev": true, + "license": "ISC" + }, + "node_modules/es-abstract": { + "version": "1.24.2", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.2.tgz", + "integrity": "sha512-2FpH9Q5i2RRwyEP1AylXe6nYLR5OhaJTZwmlcP0dL/+JCbgg7yyEo/sEK6HeGZRf3dFpWwThaRHVApXSkW3xeg==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-buffer-byte-length": "^1.0.2", + "arraybuffer.prototype.slice": "^1.0.4", + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "data-view-buffer": "^1.0.2", + "data-view-byte-length": "^1.0.2", + "data-view-byte-offset": "^1.0.1", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "es-set-tostringtag": "^2.1.0", + "es-to-primitive": "^1.3.0", + "function.prototype.name": "^1.1.8", + "get-intrinsic": "^1.3.0", + "get-proto": "^1.0.1", + "get-symbol-description": "^1.1.0", + "globalthis": "^1.0.4", + "gopd": "^1.2.0", + "has-property-descriptors": "^1.0.2", + "has-proto": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "internal-slot": "^1.1.0", + "is-array-buffer": "^3.0.5", + "is-callable": "^1.2.7", + "is-data-view": "^1.0.2", + "is-negative-zero": "^2.0.3", + "is-regex": "^1.2.1", + "is-set": "^2.0.3", + "is-shared-array-buffer": "^1.0.4", + "is-string": "^1.1.1", + "is-typed-array": "^1.1.15", + "is-weakref": "^1.1.1", + "math-intrinsics": "^1.1.0", + "object-inspect": "^1.13.4", + "object-keys": "^1.1.1", + "object.assign": "^4.1.7", + "own-keys": "^1.0.1", + "regexp.prototype.flags": "^1.5.4", + "safe-array-concat": "^1.1.3", + "safe-push-apply": "^1.0.0", + "safe-regex-test": "^1.1.0", + "set-proto": "^1.0.0", + "stop-iteration-iterator": "^1.1.0", + "string.prototype.trim": "^1.2.10", + "string.prototype.trimend": "^1.0.9", + "string.prototype.trimstart": "^1.0.8", + "typed-array-buffer": "^1.0.3", + "typed-array-byte-length": "^1.0.3", + "typed-array-byte-offset": "^1.0.4", + "typed-array-length": "^1.0.7", + "unbox-primitive": "^1.1.0", + "which-typed-array": "^1.1.19" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-abstract-get": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-abstract-get/-/es-abstract-get-1.0.0.tgz", + "integrity": "sha512-6PMWXpdhshVvFp+FoWYs1EvG1Nj0tvk0dZM+XcK0xMEM1czRVcP6ohqPWHy6qPagSpC8j4+p89WXlT+xXJs/fg==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.2", + "is-callable": "^1.2.7", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz", + "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-to-primitive": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.3.4.tgz", + "integrity": "sha512-yPDz7wqpg1/mmHLmS3tcfTfbw5f1eryXvyghYBffGdERwe+mV7ZcWzTR8LR17Kvqt3qfPurjlonmnq3MKXIOXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-abstract-get": "^1.0.0", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "is-callable": "^1.2.7", + "is-date-object": "^1.1.0", + "is-symbol": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/esbuild": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/eta": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/eta/-/eta-4.6.0.tgz", + "integrity": "sha512-lW6is4T1NFOYnmqGZIfvixqj7A7sSvScF+DN8EK6K58xI5MZ5UvYe0GjopxOXQtZvUn4eDdVuZ8XSoYWTMEKwA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + }, + "funding": { + "url": "https://github.com/bgub/eta?sponsor=1" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fast-uri": { + "version": "3.1.9", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz", + "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/filelist": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.6.tgz", + "integrity": "sha512-5giy2PkLYY1cP39p17Ech+2xlpTRL9HLspOfEgm0L6CwBXBTgsK5ou0JtzYuepxkaQ/tvhCFIJ5uXo0OrM2DxA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "minimatch": "^5.0.1" + } + }, + "node_modules/filelist/node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/filelist/node_modules/brace-expansion": { + "version": "2.1.7", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.7.tgz", + "integrity": "sha512-uZbew1NqdmPDTMJ8ah1y+b+9QEJrfkXFk3RcTQw3X0jW/xRUvFKsg1CfQdSYGdTbXZWExtU3J3ccxtnfw1Fi0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/filelist/node_modules/minimatch": { + "version": "5.1.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.9.tgz", + "integrity": "sha512-7o1wEA2RyMP7Iu7GNba9vc0RWWGACJOCZBJX2GJWip0ikV+wcOsgVuY9uE8CPiyQhkGFSlhuSkZPavN7u1c2Fw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/for-each": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", + "integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dev": true, + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/function.prototype.name": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.2.0.tgz", + "integrity": "sha512-jObKIik1P2QjPHP5nz5BaOtUlfgS0fWo8IUByNXkM+o+02sJOi94em77GwJKQSJ3gfPHdgzLNrHc1uokV4P/ew==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.2", + "hasown": "^2.0.4", + "is-callable": "^1.2.7", + "is-document.all": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/generator-function": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/generator-function/-/generator-function-2.0.1.tgz", + "integrity": "sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-own-enumerable-property-symbols": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz", + "integrity": "sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==", + "dev": true, + "license": "ISC" + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-symbol-description": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.1.0.tgz", + "integrity": "sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/glob": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.1.0.tgz", + "integrity": "sha512-vuNwKSaKiqm7g0THUBu2x7ckSs3XJLXE+2ssL7/MfTGPLLcrJQ/4Uq1CjPTtO5cCIiRxqvN6Twy1qOwhL0Xjcw==", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "foreground-child": "^3.3.1", + "jackspeak": "^4.1.1", + "minimatch": "^10.1.1", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/globalthis": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", + "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-properties": "^1.2.1", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/has-bigints": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz", + "integrity": "sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.2.0.tgz", + "integrity": "sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/idb": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/idb/-/idb-7.1.1.tgz", + "integrity": "sha512-gchesWBzyvGHRO9W8tzUWFDycow5gwjvFKfyV9FF32Y7F50yZMp7mP+T2mJIWFx49zicqyC4uefHM17o6xKIVQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/internal-slot": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz", + "integrity": "sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "hasown": "^2.0.2", + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/is-array-buffer": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", + "integrity": "sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-async-function": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.1.1.tgz", + "integrity": "sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "async-function": "^1.0.0", + "call-bound": "^1.0.3", + "get-proto": "^1.0.1", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bigint": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.1.0.tgz", + "integrity": "sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-bigints": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-boolean-object": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.2.tgz", + "integrity": "sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-core-module": { + "version": "2.17.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.17.0.tgz", + "integrity": "sha512-J/vG0zBCbIKOQFfufSwyXdMrsohyJIUNkrnmo6WZGzoM7tr/lsbfW5b2BvisL6zsyMzK9UxV9L6c7AoFbyXHOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-data-view": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-data-view/-/is-data-view-1.0.2.tgz", + "integrity": "sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "get-intrinsic": "^1.2.6", + "is-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.1.0.tgz", + "integrity": "sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-document.all": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-document.all/-/is-document.all-1.0.0.tgz", + "integrity": "sha512-+XSoyS05OdBbhFuELhgTCpFNHkpBOJqtsZfUFFpe5QTw+9Sjbh8zitxhQkYAo6wV7e1Vb8cAPvpCk9jGam/82g==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-finalizationregistry": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-finalizationregistry/-/is-finalizationregistry-1.1.1.tgz", + "integrity": "sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-generator-function": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.2.tgz", + "integrity": "sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.4", + "generator-function": "^2.0.0", + "get-proto": "^1.0.1", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz", + "integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-negative-zero": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz", + "integrity": "sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number-object": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.1.tgz", + "integrity": "sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-obj": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", + "integrity": "sha512-l4RyHgRqGN4Y3+9JHVrNqO+tN0rV5My76uW5/nuO4K1b6vw5G8d/cmFjP9tRfEsdhZNt0IFdZuK/c2Vr4Nb+Qg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", + "integrity": "sha512-7zjFAPO4/gwyQAAgRRmqeEeyIICSdmCqa3tsVHMdBzaXXRiqopZL4Cyghg/XulGWrtABTpbnYYzzIRffLkP4oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-set": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.3.tgz", + "integrity": "sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.4.tgz", + "integrity": "sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-string": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.1.1.tgz", + "integrity": "sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.1.1.tgz", + "integrity": "sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-symbols": "^1.1.0", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.15", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.15.tgz", + "integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakmap": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", + "integrity": "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakref": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.1.1.tgz", + "integrity": "sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakset": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.4.tgz", + "integrity": "sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true, + "license": "MIT" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/jackspeak": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.2.3.tgz", + "integrity": "sha512-ykkVRwrYvFm1nb2AJfKKYPr0emF6IiXDYUaFx4Zn9ZuIH7MrzEZ3sD5RlqGXNRpHtvUHJyOnCEFxOlNDtGo7wg==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^9.0.0" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/jake": { + "version": "10.9.4", + "resolved": "https://registry.npmjs.org/jake/-/jake-10.9.4.tgz", + "integrity": "sha512-wpHYzhxiVQL+IV05BLE2Xn34zW1S223hvjtqk0+gsPrwd/8JNLXJgZZM/iPFsYc1xyphF+6M6EvdE5E9MBGkDA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "async": "^3.2.6", + "filelist": "^1.0.4", + "picocolors": "^1.1.1" + }, + "bin": { + "jake": "bin/cli.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true, + "license": "MIT" + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonfile": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz", + "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/jsonpointer": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-5.0.1.tgz", + "integrity": "sha512-p/nXbhSEcu3pZRdkW1OfJhpsVtW1gd4Wa1fnQc9YLiTfAjn0312eMKimbdIQzuZl9aa9xUGaRlP9T/CJE/ditQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/lodash.debounce": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/minimatch": { + "version": "10.2.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", + "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "brace-expansion": "^5.0.8" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/mupdf": { + "version": "1.28.1", + "resolved": "https://registry.npmjs.org/mupdf/-/mupdf-1.28.1.tgz", + "integrity": "sha512-Gi11Ow2G1SlrXKJNZBL1eAIGFVih5+4ZKqjptamTVaj/5hnlrcVrVbyb7lHE2lfFKdxZPyv9ZtfOOq7XgjzEig==", + "license": "AGPL-3.0-or-later" + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-releases": { + "version": "2.0.60", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.60.tgz", + "integrity": "sha512-OmO8+GM1JUZqXET720VrJCwkjUCXmCMQm0Z3UDDRbfNLHS4NEAvY60j5jiFv0tkKw2PNNlqOLhahVmwJIOLDIQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.7.tgz", + "integrity": "sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0", + "has-symbols": "^1.1.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/own-keys": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.2.tgz", + "integrity": "sha512-19YVAg7T+WTrxggPukVq7DjTv6+PJ867TmhCvBsYwmbFCsZd344rq2Ld1p0wo8f8Qrrhgp82c6FJRqdXWtSEhg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.4", + "get-intrinsic": "^1.3.0", + "object-keys": "^1.1.1", + "safe-push-apply": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, + "node_modules/path-scurry": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", + "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-scurry/node_modules/lru-cache": { + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/playwright-core": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz", + "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/possible-typed-array-names": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", + "integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/postcss": { + "version": "8.5.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.31.tgz", + "integrity": "sha512-YUbWYCgErwnMAVkjUnYa+KlMBzGpHwiIt/DE7f0G33AuX2LH9UcTk6KgWxd3zRU+pN3u/C+Xl3EnMLM4Hea7Sg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/pretty-bytes": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-6.1.1.tgz", + "integrity": "sha512-mQUvGU6aUFQ+rNvTIAcZuWGRT9a6f6Yrg9bHs4ImKF+HZCEK+plBvnAZYSIQztknZF2qnzNtr6F8s0+IuptdlQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/reflect.getprototypeof": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", + "integrity": "sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.9", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "get-intrinsic": "^1.2.7", + "get-proto": "^1.0.1", + "which-builtin-type": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/regenerate": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.5.0.tgz", + "integrity": "sha512-1s+CxXjJ71i7LNVy8nYwg47XV4y6lAnOEhsMtSKq3WpmPfhl9LuKlTqKIn/3yUpE8lBz+W+TT88Bxyhnr0U4yw==", + "dev": true, + "license": "MIT" + }, + "node_modules/regenerate-unicode-properties": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-10.3.0.tgz", + "integrity": "sha512-9ns8odR8e9q3otKeHj3DE80jZYKg6zVeZKE+zQmRKXFoVUcuiTGeO6iusDhPRoIQQPVPRvH+SfBhrTud4eczuw==", + "dev": true, + "license": "MIT", + "dependencies": { + "regenerate": "^1.4.2" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", + "integrity": "sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-errors": "^1.3.0", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "set-function-name": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/regexpu-core": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-6.5.3.tgz", + "integrity": "sha512-E8VgUoSK+LMQrLboDxavm76MTBGrQhx9RiNuomRmYnZ10Uw12HrI8fkxOOncktb2hBpzIZ9SV/347euQHG5z+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "regenerate": "^1.5.0", + "regenerate-unicode-properties": "^10.3.0", + "regjsgen": "^0.8.0", + "regjsparser": "^0.13.0", + "unicode-match-property-ecmascript": "^2.0.0", + "unicode-match-property-value-ecmascript": "^2.2.1" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/regjsgen": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.8.0.tgz", + "integrity": "sha512-RvwtGe3d7LvWiDQXeQw8p5asZUmfU1G/l6WbUXeHta7Y2PEIvBTwH6E2EfmYUK8pxcxEdEmaomqyp0vZZ7C+3Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/regjsparser": { + "version": "0.13.4", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.4.tgz", + "integrity": "sha512-EWV80YgFaVgFrjGCAsV7oybp4GOxbls5RzBg8OB0nKEVXsBJR1JlV8Di1JhCROg3MzTfe1RI8yitIm1eOs68iA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "jsesc": "~3.1.0" + }, + "bin": { + "regjsparser": "bin/parser" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.22.13", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.13.tgz", + "integrity": "sha512-Dj/cW9zBV2aRj6XzCxuGIs3ESZKv02jixne3q6jFZYZ3/Tg09gHHviSMDL4kObh9pqSahdRHEnDoaP2gn8YLhA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "is-core-module": "^2.17.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/rollup": { + "version": "4.65.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.65.0.tgz", + "integrity": "sha512-QVCvQUTGDN6JRwi3jVGCY3H4aTHvi9rX0LyoBMkGUvdh/Z6O51CzcLz85BWZaTCDGhl6ySGqYZs+xI1jmPqGcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.9" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@napi-rs/lzma-linux-x64-gnu": "1.5.1", + "@rollup/rollup-android-arm-eabi": "4.65.0", + "@rollup/rollup-android-arm64": "4.65.0", + "@rollup/rollup-darwin-arm64": "4.65.0", + "@rollup/rollup-darwin-x64": "4.65.0", + "@rollup/rollup-freebsd-arm64": "4.65.0", + "@rollup/rollup-freebsd-x64": "4.65.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.65.0", + "@rollup/rollup-linux-arm-musleabihf": "4.65.0", + "@rollup/rollup-linux-arm64-gnu": "4.65.0", + "@rollup/rollup-linux-arm64-musl": "4.65.0", + "@rollup/rollup-linux-loong64-gnu": "4.65.0", + "@rollup/rollup-linux-loong64-musl": "4.65.0", + "@rollup/rollup-linux-ppc64-gnu": "4.65.0", + "@rollup/rollup-linux-ppc64-musl": "4.65.0", + "@rollup/rollup-linux-riscv64-gnu": "4.65.0", + "@rollup/rollup-linux-riscv64-musl": "4.65.0", + "@rollup/rollup-linux-s390x-gnu": "4.65.0", + "@rollup/rollup-linux-x64-gnu": "4.65.0", + "@rollup/rollup-linux-x64-musl": "4.65.0", + "@rollup/rollup-openbsd-x64": "4.65.0", + "@rollup/rollup-openharmony-arm64": "4.65.0", + "@rollup/rollup-win32-arm64-msvc": "4.65.0", + "@rollup/rollup-win32-ia32-msvc": "4.65.0", + "@rollup/rollup-win32-x64-gnu": "4.65.0", + "@rollup/rollup-win32-x64-msvc": "4.65.0", + "fsevents": "~2.3.2" + } + }, + "node_modules/safe-array-concat": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.4.tgz", + "integrity": "sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "get-intrinsic": "^1.3.0", + "has-symbols": "^1.1.0", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-push-apply": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/safe-push-apply/-/safe-push-apply-1.0.0.tgz", + "integrity": "sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-regex-test": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz", + "integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-regex": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/serialize-javascript": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-7.1.4.tgz", + "integrity": "sha512-FqlEuoTq/zRmA4Lg6aOqyH3lCHbUtCB0bmHCeFniX2GBdDqMJM3FwdvEhlE5Pim1dlt2FfBdVPmUNNiGhhKqpw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz", + "integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-proto": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/set-proto/-/set-proto-1.0.0.tgz", + "integrity": "sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/side-channel": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/smob": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/smob/-/smob-1.6.2.tgz", + "integrity": "sha512-RQsvleCbF8cVHEv+xuDGaA4pOizFqJ0GgjtMSRo6oP8pnN7WsigHgVGey6aILRBKv4W2YOMHLqbKdnB6hpB9fw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/source-map": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.8.0.tgz", + "integrity": "sha512-d8EqvL+k/SOXCreS/SUzg2ciyHqBBLcN/yuRjFsbvVhHTE2pgei7oAhmPM7kWFbkX6OSMQfUq4KbkF3au9lhYQ==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">= 12" + } + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/source-map-support/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stop-iteration-iterator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", + "integrity": "sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "internal-slot": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/string.prototype.matchall": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.1.0.tgz", + "integrity": "sha512-tHNHTxInrYLCga9O9YGxWA3G9/nnzQw8UGAyqGx3Ar1pSTTzIuM4woFSq4SowkXCjJIwq5sIiQvEfRI9tCH1qQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.24.2", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.2", + "get-intrinsic": "^1.3.0", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "internal-slot": "^1.1.0", + "regexp.prototype.flags": "^1.5.4", + "set-function-name": "^2.0.2", + "side-channel": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trim": { + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.11.tgz", + "integrity": "sha512-PwvK7BU+CMTJGYQCTZb5RWXIML92lftJLhQz1tBzgKiqGxJaMlBAa48POXaNAC2s4y8jr3EFqrkF9+44neS46w==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "define-data-property": "^1.1.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.24.2", + "es-object-atoms": "^1.1.2", + "has-property-descriptors": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimend": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.10.tgz", + "integrity": "sha512-2+3aDAOmPTmuFwjDnmJG2ctEkQKVki7vOSqaxkv42Mowj1V6PnvuwFCRrR5lChUux1TBskPjfkeTOhqczDMxTw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimstart": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.8.tgz", + "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/stringify-object": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", + "integrity": "sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "get-own-enumerable-property-symbols": "^3.0.0", + "is-obj": "^1.0.1", + "is-regexp": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/strip-comments": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/strip-comments/-/strip-comments-2.0.1.tgz", + "integrity": "sha512-ZprKx+bBLXv067WTCALv8SSz5l2+XhpYCsVtSqlMnkAXMWDq+/ekVbl1ghqP9rUHTzv6sm/DwCOiYutU/yp1fw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/temp-dir": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-2.0.0.tgz", + "integrity": "sha512-aoBAniQmmwtcKp/7BzsH8Cxzv8OL736p7v1ihGb5e9DJ9kTwGWHrQrVB5+lfVDzfGrdRzXch+ig7LHaY1JTOrg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/tempy": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tempy/-/tempy-0.6.0.tgz", + "integrity": "sha512-G13vtMYPT/J8A4X2SjdtBTphZlrp1gKv6hZiOjw14RCWg6GbHuQBGtjlx75xLbYV/wEc0D7G5K4rxKP/cXk8Bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-stream": "^2.0.0", + "temp-dir": "^2.0.0", + "type-fest": "^0.16.0", + "unique-string": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/terser": { + "version": "5.51.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.51.2.tgz", + "integrity": "sha512-bWnjSNscmuI+GJze6ZupnHP8G/cTcsJF+bXCeQknk2SHQsgbNJnLrqiH9jZ2W4STPVXH2mDKKRX3iwPhc9Cn/Q==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.15.0", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/type-fest": { + "version": "0.16.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.16.0.tgz", + "integrity": "sha512-eaBzG6MxNzEn9kiwvtre90cXaNLkmadMWa1zQMs3XORCXNbsH/OewwbxC5ia9dCxIxnTAsSxXJaa/p5y8DlvJg==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typed-array-buffer": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz", + "integrity": "sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typed-array-byte-length": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.3.tgz", + "integrity": "sha512-BaXgOuIxz8n8pIq3e7Atg/7s+DpiYrxn4vdot3w9KbnBhcRQq6o3xemQdIfynqSeXeDrF32x+WvfzmOjPiY9lg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "for-each": "^0.3.3", + "gopd": "^1.2.0", + "has-proto": "^1.2.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-byte-offset": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.5.tgz", + "integrity": "sha512-0FHJvLPqZ7KJzp17O13jfsAjsqazgrxBu2zEK95PmUz8lv2+GjRuxUInCr2Rk9Dms3ihN21zJ929ZO43yJ95QQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.9", + "for-each": "^0.3.5", + "gopd": "^1.2.0", + "is-typed-array": "^1.1.15", + "reflect.getprototypeof": "^1.0.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-length": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.8.tgz", + "integrity": "sha512-phPGCwqr2+Qo0fwniCE8e4pKnGu/yFb5nD5Y8bf0EEeiI5GklnACYA9GFy/DrAeRrKHXvHn+1SUsOWgJp6RO+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.9", + "for-each": "^0.3.5", + "gopd": "^1.2.0", + "is-typed-array": "^1.1.15", + "possible-typed-array-names": "^1.1.0", + "reflect.getprototypeof": "^1.0.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/unbox-primitive": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz", + "integrity": "sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-bigints": "^1.0.2", + "has-symbols": "^1.1.0", + "which-boxed-primitive": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/unicode-canonical-property-names-ecmascript": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.1.tgz", + "integrity": "sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-match-property-ecmascript": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-2.0.0.tgz", + "integrity": "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "unicode-canonical-property-names-ecmascript": "^2.0.0", + "unicode-property-aliases-ecmascript": "^2.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-match-property-value-ecmascript": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-2.2.1.tgz", + "integrity": "sha512-JQ84qTuMg4nVkx8ga4A16a1epI9H6uTXAknqxkGF/aFfRLw1xC/Bp24HNLaZhHSkWd3+84t8iXnp1J0kYcZHhg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-property-aliases-ecmascript": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.2.0.tgz", + "integrity": "sha512-hpbDzxUY9BFwX+UeBnxv3Sh1q7HFxj48DTmXchNgRa46lO8uj3/1iEn3MiNUYTg1g9ctIqXCCERn8gYZhHC5lQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/unique-string": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz", + "integrity": "sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==", + "dev": true, + "license": "MIT", + "dependencies": { + "crypto-random-string": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/upath": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", + "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4", + "yarn": "*" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.4.tgz", + "integrity": "sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/vite": { + "version": "5.4.21", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz", + "integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.21.3", + "postcss": "^8.4.43", + "rollup": "^4.20.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/vite-plugin-pwa": { + "version": "0.20.5", + "resolved": "https://registry.npmjs.org/vite-plugin-pwa/-/vite-plugin-pwa-0.20.5.tgz", + "integrity": "sha512-aweuI/6G6n4C5Inn0vwHumElU/UEpNuO+9iZzwPZGTCH87TeZ6YFMrEY6ZUBQdIHHlhTsbMDryFARcSuOdsz9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.3.6", + "pretty-bytes": "^6.1.1", + "tinyglobby": "^0.2.0", + "workbox-build": "^7.1.0", + "workbox-window": "^7.1.0" + }, + "engines": { + "node": ">=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vite-pwa/assets-generator": "^0.2.6", + "vite": "^3.1.0 || ^4.0.0 || ^5.0.0", + "workbox-build": "^7.1.0", + "workbox-window": "^7.1.0" + }, + "peerDependenciesMeta": { + "@vite-pwa/assets-generator": { + "optional": true + } + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-boxed-primitive": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz", + "integrity": "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-bigint": "^1.1.0", + "is-boolean-object": "^1.2.1", + "is-number-object": "^1.1.1", + "is-string": "^1.1.1", + "is-symbol": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-builtin-type": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.2.1.tgz", + "integrity": "sha512-6iBczoX+kDQ7a3+YJBnh3T+KZRxM/iYNPXicqk66/Qfm1b93iu+yOImkg0zHbj5LNOcNv1TEADiZ0xa34B4q6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "function.prototype.name": "^1.1.6", + "has-tostringtag": "^1.0.2", + "is-async-function": "^2.0.0", + "is-date-object": "^1.1.0", + "is-finalizationregistry": "^1.1.0", + "is-generator-function": "^1.0.10", + "is-regex": "^1.2.1", + "is-weakref": "^1.0.2", + "isarray": "^2.0.5", + "which-boxed-primitive": "^1.1.0", + "which-collection": "^1.0.2", + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-collection": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz", + "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-map": "^2.0.3", + "is-set": "^2.0.3", + "is-weakmap": "^2.0.2", + "is-weakset": "^2.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.24", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.24.tgz", + "integrity": "sha512-wk4Mf4pR5mRP7eYuuTBCIQ9d0ud2Fv2jRLQpfgnRjbOxAFHmjKFValgTpitVKzJJS8ajnYQV2Du1SZ8j6b/EUQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.9", + "call-bound": "^1.0.4", + "for-each": "^0.3.5", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/workbox-background-sync": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-background-sync/-/workbox-background-sync-7.4.1.tgz", + "integrity": "sha512-HhT7KE8tOWDm02wRNshXUnUPofMlhenF2DBdUnDPOubhizzPeItkYTmAB6td1Z2cjYPa98vzEiPLEuzn5hN66g==", + "dev": true, + "license": "MIT", + "dependencies": { + "idb": "^7.0.1", + "workbox-core": "7.4.1" + } + }, + "node_modules/workbox-broadcast-update": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-broadcast-update/-/workbox-broadcast-update-7.4.1.tgz", + "integrity": "sha512-uAlgslKLvbQY+suirIdnBCSYrcgBhjp81Nj4l1lj/Jmj0MJO2CJERnCJjT0GFVwmReV0N+zs78K6gqd5gr9/+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "workbox-core": "7.4.1" + } + }, + "node_modules/workbox-build": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-build/-/workbox-build-7.4.1.tgz", + "integrity": "sha512-SDhxIvEAde9Gy/5w4Yo1Jh/M49Z0qE3q0oteyE8zGq0DScxFqVBcCtIXFuLtmtxRQZCMbf0prco4VyEu3KBQuw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@apideck/better-ajv-errors": "^0.3.1", + "@babel/core": "^7.24.4", + "@babel/preset-env": "^7.11.0", + "@babel/runtime": "^7.11.2", + "@rollup/plugin-babel": "^6.1.0", + "@rollup/plugin-node-resolve": "^16.0.3", + "@rollup/plugin-replace": "^6.0.3", + "@rollup/plugin-terser": "^1.0.0", + "@trickfilm400/rollup-plugin-off-main-thread": "^3.0.0-pre1", + "ajv": "^8.6.0", + "common-tags": "^1.8.0", + "eta": "^4.5.1", + "fast-json-stable-stringify": "^2.1.0", + "fs-extra": "^9.0.1", + "glob": "^11.0.1", + "pretty-bytes": "^5.3.0", + "rollup": "^4.53.3", + "source-map": "^0.8.0-beta.0", + "stringify-object": "^3.3.0", + "strip-comments": "^2.0.1", + "tempy": "^0.6.0", + "upath": "^1.2.0", + "workbox-background-sync": "7.4.1", + "workbox-broadcast-update": "7.4.1", + "workbox-cacheable-response": "7.4.1", + "workbox-core": "7.4.1", + "workbox-expiration": "7.4.1", + "workbox-google-analytics": "7.4.1", + "workbox-navigation-preload": "7.4.1", + "workbox-precaching": "7.4.1", + "workbox-range-requests": "7.4.1", + "workbox-recipes": "7.4.1", + "workbox-routing": "7.4.1", + "workbox-strategies": "7.4.1", + "workbox-streams": "7.4.1", + "workbox-sw": "7.4.1", + "workbox-window": "7.4.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/workbox-build/node_modules/pretty-bytes": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", + "integrity": "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/workbox-cacheable-response": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-cacheable-response/-/workbox-cacheable-response-7.4.1.tgz", + "integrity": "sha512-8xaFoJdDc2OjrlbbL3gEeBO1WKcMwRqwLRupgqahYXu75yXajPLuwrbXMrIGZuWYXrQwk0xDjOxZ/ujCy/oJYw==", + "dev": true, + "license": "MIT", + "dependencies": { + "workbox-core": "7.4.1" + } + }, + "node_modules/workbox-core": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-core/-/workbox-core-7.4.1.tgz", + "integrity": "sha512-DT+vu46eh/2vRsSHTY4Xmc32Z1rr9PRlQUXr1Dx30ZuXRWwOsvZgGgcwxcasubQLQmbTNYZjv44LkBAQ4tT5tQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/workbox-expiration": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-expiration/-/workbox-expiration-7.4.1.tgz", + "integrity": "sha512-lRKUF7b+OGbeXkQk1s6MHXOa3d7Xxf7Of31W6c6hCfipfIyrtdWZ89stq21AHZMaoG7VNFoHply4Ox+rU31TWg==", + "dev": true, + "license": "MIT", + "dependencies": { + "idb": "^7.0.1", + "workbox-core": "7.4.1" + } + }, + "node_modules/workbox-google-analytics": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-google-analytics/-/workbox-google-analytics-7.4.1.tgz", + "integrity": "sha512-Mks1JwLEt++ZAkF6sS1OpSh9RtAMIsiDgRpK+codiHGIPXeaUOgi4cPc3GFadUl8V5QPeypEk8Oxgl3HlwVzHw==", + "dev": true, + "license": "MIT", + "dependencies": { + "workbox-background-sync": "7.4.1", + "workbox-core": "7.4.1", + "workbox-routing": "7.4.1", + "workbox-strategies": "7.4.1" + } + }, + "node_modules/workbox-navigation-preload": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-navigation-preload/-/workbox-navigation-preload-7.4.1.tgz", + "integrity": "sha512-C4KVsjPcYKJOhr631AxR9XoG2rLF3QiTk5aMv36MXOjtWvm8axwNFAtKUPGsWUwLXXAMgYM1En7fsvndaXeXRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "workbox-core": "7.4.1" + } + }, + "node_modules/workbox-precaching": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-precaching/-/workbox-precaching-7.4.1.tgz", + "integrity": "sha512-cdr/9qByww7yzEp7zg/qI4ukUrrNjQLgN+ONQRpjy/VqGQXwkgHwr00KksGJK8v0VifwDXBb8a4cWNZH71jn3Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "workbox-core": "7.4.1", + "workbox-routing": "7.4.1", + "workbox-strategies": "7.4.1" + } + }, + "node_modules/workbox-range-requests": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-range-requests/-/workbox-range-requests-7.4.1.tgz", + "integrity": "sha512-7i2oxAUE82gHdAJBCAQ04JzNOdRPqzuOzGfoUyJpFSmeqBNYGPrAH8GPoPjUQTfp+NycwrD2H68VtuF8qxv0vQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "workbox-core": "7.4.1" + } + }, + "node_modules/workbox-recipes": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-recipes/-/workbox-recipes-7.4.1.tgz", + "integrity": "sha512-gnbVfmV4/TtmQaM4x9AtuXhcdstJsep3XMVeztOrQVPT+R6+6DeBjGTCQ7fFCXm+4GEHUA5VEBTyi5+4gWGeog==", + "dev": true, + "license": "MIT", + "dependencies": { + "workbox-cacheable-response": "7.4.1", + "workbox-core": "7.4.1", + "workbox-expiration": "7.4.1", + "workbox-precaching": "7.4.1", + "workbox-routing": "7.4.1", + "workbox-strategies": "7.4.1" + } + }, + "node_modules/workbox-routing": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-routing/-/workbox-routing-7.4.1.tgz", + "integrity": "sha512-yubJGErZOusuidAenaL5ypfhQOa7urxP/f8E0ws7FPb4039RiWXUWBAyUkmUoOL/BcQGen3h0J8872d51IYxtA==", + "dev": true, + "license": "MIT", + "dependencies": { + "workbox-core": "7.4.1" + } + }, + "node_modules/workbox-strategies": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-strategies/-/workbox-strategies-7.4.1.tgz", + "integrity": "sha512-GZxpaw9NbmOelj7667uZ2kpk5BFpOGbO4X0qjwh5ls8XQ8C+Lha5LQchTiUzsTFSS+NlUpftYAyOVXvQUrcqOQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "workbox-core": "7.4.1" + } + }, + "node_modules/workbox-streams": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-streams/-/workbox-streams-7.4.1.tgz", + "integrity": "sha512-HWWtraKUbJknd9kgqGcpQ3G114HOPYvqs8HaJMDs2ebLNAimDkVDaWfAXE6Ybl+m8U6KsCE6pWyLYuigWmnAXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "workbox-core": "7.4.1", + "workbox-routing": "7.4.1" + } + }, + "node_modules/workbox-sw": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-sw/-/workbox-sw-7.4.1.tgz", + "integrity": "sha512-fez5f2DUlDJWTFYkCWQpY10N8gtztd849NswCbVFk0QlcSM4HT5A8x4g4ii650yem4I8tHY0R7JZahwp3ltIPw==", + "dev": true, + "license": "MIT" + }, + "node_modules/workbox-window": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/workbox-window/-/workbox-window-7.4.1.tgz", + "integrity": "sha512-notZDH2u8VXaqyuD7xaqIfEFi6SRM4SUSd7ewe9PDsVqADuepxX2ZMY3uvuZGxzY5ZOsGC/vD3A/3smFtJt4/A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/trusted-types": "^2.0.2", + "workbox-core": "7.4.1" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..ff2cf8e --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "phone-viewer-app", + "private": true, + "version": "0.4.1", + "type": "module", + "license": "AGPL-3.0-or-later", + "description": "Mobile/tablet all-in-one viewer: DWG (model & layout space) + PDF/EPUB/XPS/CBZ/images", + "engines": { + "node": ">=20" + }, + "scripts": { + "dev": "vite", + "build": "tsc --noEmit && vite build", + "preview": "vite preview", + "typecheck": "tsc --noEmit", + "icons": "node scripts/make-icons.mjs", + "patch:wasm": "node scripts/patch-wasm-memory.mjs", + "apk": "node scripts/build-apk.mjs" + }, + "dependencies": { + "@node-projects/acad-ts": "^3.6.0", + "mupdf": "1.28.1" + }, + "devDependencies": { + "adm-zip": "^0.6.1", + "playwright-core": "^1.64.1", + "typescript": "^5.6.3", + "vite": "^5.4.10", + "vite-plugin-pwa": "^0.20.5", + "@mlightcad/libredwg-web": "0.8.2" + } +} diff --git a/public/icons/apple-touch-icon.png b/public/icons/apple-touch-icon.png new file mode 100644 index 0000000..9497601 Binary files /dev/null and b/public/icons/apple-touch-icon.png differ diff --git a/public/icons/favicon.svg b/public/icons/favicon.svg new file mode 100644 index 0000000..46ad85d --- /dev/null +++ b/public/icons/favicon.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/public/icons/icon-192.png b/public/icons/icon-192.png new file mode 100644 index 0000000..482aa6c Binary files /dev/null and b/public/icons/icon-192.png differ diff --git a/public/icons/icon-512.png b/public/icons/icon-512.png new file mode 100644 index 0000000..3777e72 Binary files /dev/null and b/public/icons/icon-512.png differ diff --git a/public/icons/icon-maskable-512.png b/public/icons/icon-maskable-512.png new file mode 100644 index 0000000..9e26659 Binary files /dev/null and b/public/icons/icon-maskable-512.png differ diff --git a/public/vendor/mupdf/mupdf-wasm.js b/public/vendor/mupdf/mupdf-wasm.js new file mode 100644 index 0000000..5c11f3b --- /dev/null +++ b/public/vendor/mupdf/mupdf-wasm.js @@ -0,0 +1 @@ +var _=async function(_={}){var a,e,t=_,s=new Promise((_,t)=>{a=_,e=t}),n="object"==typeof window,i="undefined"!=typeof WorkerGlobalScope,m="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node&&"renderer"!=process.type;if(m){const{createRequire:_}=await(import("module"));var o=_(import.meta.url)}var r,p,d="./this.program",w=(_,a)=>{throw a},f=import.meta.url,l="";if(m){var c=o("fs"),g=o("path");f.startsWith("file:")&&(l=g.dirname(o("url").fileURLToPath(f))+"/"),p=_=>(_=U(_)?new URL(_):_,c.readFileSync(_)),r=async(_,a=!0)=>(_=U(_)?new URL(_):_,c.readFileSync(_,a?void 0:"utf8")),process.argv.length>1&&(d=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),w=(_,a)=>{throw process.exitCode=_,a}}else if(n||i){try{l=new URL(".",f).href}catch{}i&&(p=_=>{var a=new XMLHttpRequest;return a.open("GET",_,!1),a.responseType="arraybuffer",a.send(null),new Uint8Array(a.response)}),r=async _=>{if(U(_))return new Promise((a,e)=>{var t=new XMLHttpRequest;t.open("GET",_,!0),t.responseType="arraybuffer",t.onload=()=>{200==t.status||0==t.status&&t.response?a(t.response):e(t.status)},t.onerror=e,t.send(null)});var a=await fetch(_,{credentials:"same-origin"});if(a.ok)return a.arrayBuffer();throw new Error(a.status+" : "+a.url)}}var u,b,h,v,y,x,k,T=console.log.bind(console),j=console.error.bind(console),$=!1,A=!1,U=_=>_.startsWith("file://");function R(){var _=b.buffer;new Int8Array(_),new Int16Array(_),t.HEAPU8=h=new Uint8Array(_),new Uint16Array(_),t.HEAP32=v=new Int32Array(_),t.HEAPU32=y=new Uint32Array(_),t.HEAPF32=new Float32Array(_),k=new Float64Array(_),x=new BigInt64Array(_),new BigUint64Array(_)}var E,C=0,S=null;function M(_){t.onAbort?.(_),j(_="Aborted("+_+")"),$=!0,_+=". Build with -sASSERTIONS for more info.",A&&p_();var a=new WebAssembly.RuntimeError(_);throw e(a),a}function D(){return t.locateFile?(_="mupdf-wasm.wasm",t.locateFile?t.locateFile(_,l):l+_):new URL("mupdf-wasm.wasm",import.meta.url).href;var _}async function F(_){if(!u)try{var a=await r(_);return new Uint8Array(a)}catch{}return function(_){if(_==E&&u)return new Uint8Array(u);if(p)return p(_);throw"both async and sync fetching of the wasm failed"}(_)}async function I(_,a,e){if(!_&&"function"==typeof WebAssembly.instantiateStreaming&&!U(a)&&!m)try{var t=fetch(a,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(t,e)}catch(_){j(`wasm streaming compile failed: ${_}`),j("falling back to ArrayBuffer instantiation")}return async function(_,a){try{var e=await F(_);return await WebAssembly.instantiate(e,a)}catch(_){j(`failed to asynchronously prepare wasm: ${_}`),M(_)}}(a,e)}class P{name="ExitStatus";constructor(_){this.message=`Program terminated with exit(${_})`,this.status=_}}var B=_=>{for(;_.length>0;)_.shift()(t)},q=[],L=_=>q.push(_),z=[],H=_=>z.push(_),W=!0,N=new TextDecoder,G=(_,a)=>{if(!_)return"";for(var e=_+a,t=_;!(t>=e)&&h[t];)++t;return N.decode(h.subarray(_,t))},O={varargs:void 0,getStr:_=>G(_)},Y=_=>_<-9007199254740992||_>9007199254740992?NaN:Number(_),X=(_,a,e)=>((_,a,e,t)=>{if(!(t>0))return 0;for(var s=e,n=e+t-1,i=0;i<_.length;++i){var m=_.charCodeAt(i);if(m>=55296&&m<=57343&&(m=65536+((1023&m)<<10)|1023&_.charCodeAt(++i)),m<=127){if(e>=n)break;a[e++]=m}else if(m<=2047){if(e+1>=n)break;a[e++]=192|m>>6,a[e++]=128|63&m}else if(m<=65535){if(e+2>=n)break;a[e++]=224|m>>12,a[e++]=128|m>>6&63,a[e++]=128|63&m}else{if(e+3>=n)break;a[e++]=240|m>>18,a[e++]=128|m>>12&63,a[e++]=128|m>>6&63,a[e++]=128|63&m}}return a[e]=0,e-s})(_,h,a,e),J=()=>Date.now(),K=[],Q=(_,a,e)=>{var t=((_,a)=>{var e;for(K.length=0;e=h[_++];){var t=105!=e;a+=(t&=112!=e)&&a%8?4:0,K.push(112==e?y[a>>2]:106==e?x[a>>3]:105==e?v[a>>2]:k[a>>3]),a+=t?8:4}return K})(a,e);return m_[_](...t)},V=(_,a)=>Math.ceil(_/a)*a,Z=_=>{var a=(_-b.buffer.byteLength+65535)/65536|0;try{return b.grow(a),R(),1}catch(_){}},__={},a_=()=>{if(!a_.strings){var _={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:d||"./this.program"};for(var a in __)void 0===__[a]?delete _[a]:_[a]=__[a];var e=[];for(var a in _)e.push(`${a}=${_[a]}`);a_.strings=e}return a_.strings},e_=_=>{for(var a=0,e=0;e<_.length;++e){var t=_.charCodeAt(e);t<=127?a++:t<=2047?a+=2:t>=55296&&t<=57343?(a+=4,++e):a+=3}return a},t_=_=>{W||(t.onExit?.(_),$=!0),w(_,new P(_))},s_=(_,a)=>{t_(_)},n_=[null,[],[]],i_=(_,a)=>{var e=n_[_];0===a||10===a?((1===_?T:j)(((_,a=0,e=NaN)=>{for(var t=a+e,s=a;_[s]&&!(s>=t);)++s;return N.decode(_.buffer?_.subarray(a,s):new Uint8Array(_.slice(a,s)))})(e)),e.length=0):e.push(a)};t.noExitRuntime&&(W=t.noExitRuntime),t.print&&(T=t.print),t.printErr&&(j=t.printErr),t.wasmBinary&&(u=t.wasmBinary),t.arguments&&t.arguments,t.thisProgram&&(d=t.thisProgram),t.UTF8ToString=G,t.stringToUTF8=X,t.lengthBytesUTF8=e_;var m_={6168464:()=>{throw"TRYLATER"},6168486:()=>{throw"ABORT"},6168505:_=>{throw new Error(G(_))},6168544:()=>{throw new Error("Cannot create MuPDF context!")},6168597:(_,a,e,t,s,n,i)=>{globalThis.$libmupdf_text_walk.begin_span(_,a,e,t,s,n,i)},6168671:(_,a,e,t,s,n,i,m)=>{globalThis.$libmupdf_text_walk.show_glyph(_,a,e,t,s,n,i,m)},6168749:_=>{globalThis.$libmupdf_text_walk.end_span(_)},6168797:(_,a,e,t)=>globalThis.$libmupdf_load_font_file(_,a,e,t),6168860:(_,a,e,t)=>globalThis.$libmupdf_stm_read(_,a,e,t),6168918:_=>{globalThis.$libmupdf_stm_close(_)},6168958:(_,a,e,t)=>globalThis.$libmupdf_stm_seek(_,a,e,t),6169016:(_,a,e)=>{globalThis.$libmupdf_path_walk.moveto(_,a,e)},6169070:(_,a,e)=>{globalThis.$libmupdf_path_walk.lineto(_,a,e)},6169124:(_,a,e,t,s,n,i)=>{globalThis.$libmupdf_path_walk.curveto(_,a,e,t,s,n,i)},6169195:_=>{globalThis.$libmupdf_path_walk.closepath(_)},6169244:_=>{globalThis.$libmupdf_log_error(_)},6169283:_=>{globalThis.$libmupdf_log_warning(_)},6169324:_=>{globalThis.$libmupdf_device.close_device(_)},6169373:_=>{globalThis.$libmupdf_device.drop_device(_)},6169421:(_,a,e,t,s,n,i,m)=>{globalThis.$libmupdf_device.fill_path(_,a,e,t,s,n,i,m)},6169495:(_,a,e,t,s,n,i,m)=>{globalThis.$libmupdf_device.stroke_path(_,a,e,t,s,n,i,m)},6169571:(_,a,e,t)=>{globalThis.$libmupdf_device.clip_path(_,a,e,t)},6169629:(_,a,e,t)=>{globalThis.$libmupdf_device.clip_stroke_path(_,a,e,t)},6169694:(_,a,e,t,s,n,i)=>{globalThis.$libmupdf_device.fill_text(_,a,e,t,s,n,i)},6169764:(_,a,e,t,s,n,i,m)=>{globalThis.$libmupdf_device.stroke_text(_,a,e,t,s,n,i,m)},6169840:(_,a,e)=>{globalThis.$libmupdf_device.clip_text(_,a,e)},6169894:(_,a,e,t)=>{globalThis.$libmupdf_device.clip_stroke_text(_,a,e,t)},6169959:(_,a,e)=>{globalThis.$libmupdf_device.ignore_text(_,a,e)},6170015:(_,a,e,t)=>{globalThis.$libmupdf_device.fill_shade(_,a,e,t)},6170074:(_,a,e,t)=>{globalThis.$libmupdf_device.fill_image(_,a,e,t)},6170133:(_,a,e,t,s,n,i)=>{globalThis.$libmupdf_device.fill_image_mask(_,a,e,t,s,n,i)},6170209:(_,a,e)=>{globalThis.$libmupdf_device.clip_image_mask(_,a,e)},6170269:_=>{globalThis.$libmupdf_device.pop_clip(_)},6170314:(_,a,e,t,s,n)=>{globalThis.$libmupdf_device.begin_mask(_,a,e,t,s,n)},6170381:(_,a)=>{globalThis.$libmupdf_device.end_mask(_,a)},6170430:(_,a,e,t,s,n,i)=>{globalThis.$libmupdf_device.begin_group(_,a,e,t,s,n,i)},6170502:_=>{globalThis.$libmupdf_device.end_group(_)},6170548:(_,a,e,t,s,n,i)=>globalThis.$libmupdf_device.begin_tile(_,a,e,t,s,n,i),6170626:_=>{globalThis.$libmupdf_device.end_tile(_)},6170671:(_,a)=>{globalThis.$libmupdf_device.begin_layer(_,a)},6170723:_=>{globalThis.$libmupdf_device.end_layer(_)}},o_={g:function(_,a,e){return O.varargs=e,0},v:function(_,a){a=Y(a)},u:function(_,a,e){return O.varargs=e,0},f:function(_,a,e,t){O.varargs=t},t:_=>{},e:(_,a,e)=>{},n:()=>M(""),m:function(_,a){_=Y(_);var e=new Date(1e3*_);v[a>>2]=e.getUTCSeconds(),v[a+4>>2]=e.getUTCMinutes(),v[a+8>>2]=e.getUTCHours(),v[a+12>>2]=e.getUTCDate(),v[a+16>>2]=e.getUTCMonth(),v[a+20>>2]=e.getUTCFullYear()-1900,v[a+24>>2]=e.getUTCDay();var t=Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0),s=(e.getTime()-t)/864e5|0;v[a+28>>2]=s},l:function(_){var a=(()=>{var a=Date.UTC(v[_+20>>2]+1900,v[_+16>>2],v[_+12>>2],v[_+8>>2],v[_+4>>2],v[_>>2],0),e=new Date(a);v[_+24>>2]=e.getUTCDay();var t=Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0),s=(e.getTime()-t)/864e5|0;return v[_+28>>2]=s,e.getTime()/1e3})();return BigInt(a)},k:(_,a,e,t)=>{var s=(new Date).getFullYear(),n=new Date(s,0,1),i=new Date(s,6,1),m=n.getTimezoneOffset(),o=i.getTimezoneOffset(),r=Math.max(m,o);y[_>>2]=60*r,v[a>>2]=Number(m!=o);var p=_=>{var a=_>=0?"-":"+",e=Math.abs(_);return`UTC${a}${String(Math.floor(e/60)).padStart(2,"0")}${String(e%60).padStart(2,"0")}`},d=p(m),w=p(o);o=0&&t<=3))return 28;var t,s;s=0===_?J():performance.now();var n=Math.round(1e3*s*1e3);return x[e>>3]=BigInt(n),0},a:(_,a,e)=>Q(_,a,e),j:(_,a,e)=>Q(_,a,e),i:J,h:_=>{var a=h.length,e=2147483648;if((_>>>=0)>e)return!1;for(var t=1;t<=4;t*=2){var s=a*(1+.2/t);s=Math.min(s,_+100663296);var n=Math.min(e,V(Math.max(_,s),65536));if(Z(n))return!0}return!1},r:(_,a)=>{var e=0,t=0;for(var s of a_()){var n=a+e;y[_+t>>2]=n,e+=X(s,n,1/0)+1,t+=4}return 0},q:(_,a)=>{var e=a_();y[_>>2]=e.length;var t=0;for(var s of e)t+=e_(s)+1;return y[a>>2]=t,0},b:s_,d:_=>52,p:(_,a,e,t)=>52,o:function(_,a,e,t){return a=Y(a),70},c:(_,a,e,t)=>{for(var s=0,n=0;n>2],m=y[a+4>>2];a+=8;for(var o=0;o>2]=s,0}},r_=await async function(){function _(_,a){return r_=_.exports,b=r_.w,R(),function(){if(C--,t.monitorRunDependencies?.(C),0==C&&S){var _=S;S=null,_()}}(),r_}C++,t.monitorRunDependencies?.(C);var a={a:o_};if(t.instantiateWasm)return new Promise((e,s)=>{t.instantiateWasm(a,(a,t)=>{e(_(a))})});E??=D();try{var s=function(a){return _(a.instance)}(await I(u,E,a));return s}catch(_){return e(_),Promise.reject(_)}}(),p_=(r_.x,t._wasm_init_context=r_.y,t._wasm_malloc=r_.z,t._wasm_free=r_.A,t._wasm_enable_icc=r_.B,t._wasm_disable_icc=r_.C,t._wasm_set_user_css=r_.D,t._wasm_empty_store=r_.E,t._wasm_shrink_store=r_.F,t._wasm_Memento_checkAllMemory=r_.G,t._wasm_Memento_listBlocks=r_.H,t._wasm_keep_buffer=r_.I,t._wasm_drop_buffer=r_.J,t._wasm_keep_stream=r_.K,t._wasm_drop_stream=r_.L,t._wasm_keep_colorspace=r_.M,t._wasm_drop_colorspace=r_.N,t._wasm_keep_pixmap=r_.O,t._wasm_drop_pixmap=r_.P,t._wasm_keep_font=r_.Q,t._wasm_drop_font=r_.R,t._wasm_keep_stroke_state=r_.S,t._wasm_drop_stroke_state=r_.T,t._wasm_keep_image=r_.U,t._wasm_drop_image=r_.V,t._wasm_keep_shade=r_.W,t._wasm_drop_shade=r_.X,t._wasm_keep_path=r_.Y,t._wasm_drop_path=r_.Z,t._wasm_keep_text=r_._,t._wasm_drop_text=r_.$,t._wasm_keep_device=r_.aa,t._wasm_drop_device=r_.ba,t._wasm_keep_display_list=r_.ca,t._wasm_drop_display_list=r_.da,t._wasm_drop_stext_page=r_.ea,t._wasm_drop_document_writer=r_.fa,t._wasm_drop_outline_iterator=r_.ga,t._wasm_keep_document=r_.ha,t._wasm_drop_document=r_.ia,t._wasm_keep_page=r_.ja,t._wasm_drop_page=r_.ka,t._wasm_keep_link=r_.la,t._wasm_drop_link=r_.ma,t._wasm_keep_outline=r_.na,t._wasm_drop_outline=r_.oa,t._wasm_pdf_keep_annot=r_.pa,t._wasm_pdf_drop_annot=r_.qa,t._wasm_pdf_keep_obj=r_.ra,t._wasm_pdf_drop_obj=r_.sa,t._wasm_pdf_keep_graft_map=r_.ta,t._wasm_pdf_drop_graft_map=r_.ua,t._wasm_buffer_get_data=r_.va,t._wasm_buffer_get_len=r_.wa,t._wasm_colorspace_get_type=r_.xa,t._wasm_colorspace_get_n=r_.ya,t._wasm_colorspace_get_name=r_.za,t._wasm_pixmap_get_w=r_.Aa,t._wasm_pixmap_get_h=r_.Ba,t._wasm_pixmap_get_x=r_.Ca,t._wasm_pixmap_get_y=r_.Da,t._wasm_pixmap_get_n=r_.Ea,t._wasm_pixmap_get_stride=r_.Fa,t._wasm_pixmap_get_alpha=r_.Ga,t._wasm_pixmap_get_xres=r_.Ha,t._wasm_pixmap_get_yres=r_.Ia,t._wasm_pixmap_get_colorspace=r_.Ja,t._wasm_pixmap_get_samples=r_.Ka,t._wasm_pixmap_set_xres=r_.La,t._wasm_pixmap_set_yres=r_.Ma,t._wasm_font_get_name=r_.Na,t._wasm_stroke_state_get_start_cap=r_.Oa,t._wasm_stroke_state_set_start_cap=r_.Pa,t._wasm_stroke_state_get_dash_cap=r_.Qa,t._wasm_stroke_state_set_dash_cap=r_.Ra,t._wasm_stroke_state_get_end_cap=r_.Sa,t._wasm_stroke_state_set_end_cap=r_.Ta,t._wasm_stroke_state_get_linejoin=r_.Ua,t._wasm_stroke_state_set_linejoin=r_.Va,t._wasm_stroke_state_get_linewidth=r_.Wa,t._wasm_stroke_state_set_linewidth=r_.Xa,t._wasm_stroke_state_get_miterlimit=r_.Ya,t._wasm_stroke_state_set_miterlimit=r_.Za,t._wasm_stroke_state_get_dash_phase=r_._a,t._wasm_stroke_state_set_dash_phase=r_.$a,t._wasm_stroke_state_get_dash_len=r_.ab,t._wasm_image_get_w=r_.bb,t._wasm_image_get_h=r_.cb,t._wasm_image_get_n=r_.db,t._wasm_image_get_bpc=r_.eb,t._wasm_image_get_xres=r_.fb,t._wasm_image_get_yres=r_.gb,t._wasm_image_get_imagemask=r_.hb,t._wasm_image_get_colorspace=r_.ib,t._wasm_image_get_mask=r_.jb,t._wasm_outline_get_title=r_.kb,t._wasm_outline_get_uri=r_.lb,t._wasm_outline_get_next=r_.mb,t._wasm_outline_get_down=r_.nb,t._wasm_outline_get_is_open=r_.ob,t._wasm_outline_item_get_title=r_.pb,t._wasm_outline_item_get_uri=r_.qb,t._wasm_outline_item_get_is_open=r_.rb,t._wasm_link_get_rect=r_.sb,t._wasm_link_get_uri=r_.tb,t._wasm_link_get_next=r_.ub,t._wasm_stext_page_get_mediabox=r_.vb,t._wasm_stext_page_get_first_block=r_.wb,t._wasm_stext_block_get_next=r_.xb,t._wasm_stext_block_get_type=r_.yb,t._wasm_stext_block_get_bbox=r_.zb,t._wasm_stext_block_get_first_line=r_.Ab,t._wasm_stext_block_get_transform=r_.Bb,t._wasm_stext_block_get_image=r_.Cb,t._wasm_stext_block_get_v_flags=r_.Db,t._wasm_stext_block_get_v_argb=r_.Eb,t._wasm_stext_line_get_next=r_.Fb,t._wasm_stext_line_get_wmode=r_.Gb,t._wasm_stext_line_get_dir=r_.Hb,t._wasm_stext_line_get_bbox=r_.Ib,t._wasm_stext_line_get_first_char=r_.Jb,t._wasm_stext_char_get_next=r_.Kb,t._wasm_stext_char_get_c=r_.Lb,t._wasm_stext_char_get_origin=r_.Mb,t._wasm_stext_char_get_quad=r_.Nb,t._wasm_stext_char_get_size=r_.Ob,t._wasm_stext_char_get_font=r_.Pb,t._wasm_stext_char_get_argb=r_.Qb,t._wasm_stext_char_get_bidi=r_.Rb,t._wasm_link_dest_get_chapter=r_.Sb,t._wasm_link_dest_get_page=r_.Tb,t._wasm_link_dest_get_type=r_.Ub,t._wasm_link_dest_get_x=r_.Vb,t._wasm_link_dest_get_y=r_.Wb,t._wasm_link_dest_get_w=r_.Xb,t._wasm_link_dest_get_h=r_.Yb,t._wasm_link_dest_get_zoom=r_.Zb,t._wasm_pdf_layer_config_ui_get_text=r_._b,t._wasm_pdf_layer_config_ui_get_depth=r_.$b,t._wasm_pdf_layer_config_ui_get_type=r_.ac,t._wasm_pdf_layer_config_ui_get_selected=r_.bc,t._wasm_pdf_layer_config_ui_get_locked=r_.cc,t._wasm_pdf_filespec_params_get_filename=r_.dc,t._wasm_pdf_filespec_params_get_mimetype=r_.ec,t._wasm_pdf_filespec_params_get_size=r_.fc,t._wasm_pdf_filespec_params_get_created=r_.gc,t._wasm_pdf_filespec_params_get_modified=r_.hc,t._wasm_pdf_page_get_obj=r_.ic,t._wasm_new_buffer=r_.jc,t._wasm_new_buffer_from_data=r_.kc,t._wasm_append_string=r_.lc,t._wasm_append_byte=r_.mc,t._wasm_append_buffer=r_.nc,t._wasm_slice_buffer=r_.oc,t._wasm_string_from_buffer=r_.pc,t._wasm_device_gray=r_.qc,t._wasm_device_rgb=r_.rc,t._wasm_device_bgr=r_.sc,t._wasm_device_cmyk=r_.tc,t._wasm_device_lab=r_.uc,t._wasm_new_icc_colorspace=r_.vc,t._wasm_new_stroke_state=r_.wc,t._wasm_stroke_state_get_dash_item=r_.xc,t._wasm_stroke_state_set_dash_item=r_.yc,t._wasm_new_base14_font=r_.zc,t._wasm_new_cjk_font=r_.Ac,t._wasm_new_font_from_buffer=r_.Bc,t._wasm_encode_character=r_.Cc,t._wasm_advance_glyph=r_.Dc,t._wasm_font_is_monospaced=r_.Ec,t._wasm_font_is_serif=r_.Fc,t._wasm_font_is_bold=r_.Gc,t._wasm_font_is_italic=r_.Hc,t._wasm_new_image_from_pixmap=r_.Ic,t._wasm_new_image_from_buffer=r_.Jc,t._wasm_get_pixmap_from_image=r_.Kc,t._wasm_new_pixmap_from_page=r_.Lc,t._wasm_new_pixmap_from_page_contents=r_.Mc,t._wasm_pdf_new_pixmap_from_page_with_usage=r_.Nc,t._wasm_pdf_new_pixmap_from_page_contents_with_usage=r_.Oc,t._wasm_new_pixmap_with_bbox=r_.Pc,t._wasm_clear_pixmap=r_.Qc,t._wasm_clear_pixmap_with_value=r_.Rc,t._wasm_invert_pixmap=r_.Sc,t._wasm_invert_pixmap_luminance=r_.Tc,t._wasm_gamma_pixmap=r_.Uc,t._wasm_tint_pixmap=r_.Vc,t._wasm_new_buffer_from_pixmap_as_png=r_.Wc,t._wasm_new_buffer_from_pixmap_as_pam=r_.Xc,t._wasm_new_buffer_from_pixmap_as_psd=r_.Yc,t._wasm_new_buffer_from_pixmap_as_jpeg=r_.Zc,t._wasm_convert_pixmap=r_._c,t._wasm_warp_pixmap=r_.$c,t._wasm_bound_shade=r_.ad,t._wasm_new_display_list=r_.bd,t._wasm_bound_display_list=r_.cd,t._wasm_run_display_list=r_.dd,t._wasm_new_pixmap_from_display_list=r_.ed,t._wasm_new_stext_page_from_display_list=r_.fd,t._wasm_search_display_list=r_.gd,t._wasm_new_path=r_.hd,t._wasm_moveto=r_.id,t._wasm_lineto=r_.jd,t._wasm_curveto=r_.kd,t._wasm_curvetov=r_.ld,t._wasm_curvetoy=r_.md,t._wasm_closepath=r_.nd,t._wasm_rectto=r_.od,t._wasm_transform_path=r_.pd,t._wasm_bound_path=r_.qd,t._wasm_new_text=r_.rd,t._wasm_bound_text=r_.sd,t._wasm_show_glyph=r_.td,t._wasm_show_string=r_.ud,t._wasm_new_draw_device=r_.vd,t._wasm_new_display_list_device=r_.wd,t._wasm_close_device=r_.xd,t._wasm_fill_path=r_.yd,t._wasm_stroke_path=r_.zd,t._wasm_clip_path=r_.Ad,t._wasm_clip_stroke_path=r_.Bd,t._wasm_fill_text=r_.Cd,t._wasm_stroke_text=r_.Dd,t._wasm_clip_text=r_.Ed,t._wasm_clip_stroke_text=r_.Fd,t._wasm_ignore_text=r_.Gd,t._wasm_fill_shade=r_.Hd,t._wasm_fill_image=r_.Id,t._wasm_fill_image_mask=r_.Jd,t._wasm_clip_image_mask=r_.Kd,t._wasm_pop_clip=r_.Ld,t._wasm_begin_mask=r_.Md,t._wasm_end_mask=r_.Nd,t._wasm_begin_group=r_.Od,t._wasm_end_group=r_.Pd,t._wasm_begin_tile=r_.Qd,t._wasm_end_tile=r_.Rd,t._wasm_begin_layer=r_.Sd,t._wasm_end_layer=r_.Td,t._wasm_new_document_writer_with_buffer=r_.Ud,t._wasm_begin_page=r_.Vd,t._wasm_end_page=r_.Wd,t._wasm_close_document_writer=r_.Xd,t._wasm_print_stext_page_as_json=r_.Yd,t._wasm_search_stext_page=r_.Zd,t._wasm_snap_selection=r_._d,t._wasm_copy_selection=r_.$d,t._wasm_highlight_selection=r_.ae,t._wasm_print_stext_page_as_html=r_.be,t._wasm_print_stext_page_as_text=r_.ce,t._wasm_open_document_with_buffer=r_.de,t._wasm_open_document_with_stream=r_.ee,t._wasm_format_link_uri=r_.fe,t._wasm_needs_password=r_.ge,t._wasm_authenticate_password=r_.he,t._wasm_has_permission=r_.ie,t._wasm_count_pages=r_.je,t._wasm_load_page=r_.ke,t._wasm_lookup_metadata=r_.le,t._wasm_set_metadata=r_.me,t._wasm_resolve_link=r_.ne,t._wasm_resolve_link_dest=r_.oe,t._wasm_load_outline=r_.pe,t._wasm_outline_get_page=r_.qe,t._wasm_style_document=r_.re,t._wasm_layout_document=r_.se,t._wasm_is_document_reflowable=r_.te,t._wasm_link_set_rect=r_.ue,t._wasm_link_set_uri=r_.ve,t._wasm_bound_page=r_.we,t._wasm_load_links=r_.xe,t._wasm_create_link=r_.ye,t._wasm_delete_link=r_.ze,t._wasm_run_page=r_.Ae,t._wasm_run_page_contents=r_.Be,t._wasm_run_page_annots=r_.Ce,t._wasm_run_page_widgets=r_.De,t._wasm_new_stext_page_from_page=r_.Ee,t._wasm_new_display_list_from_page=r_.Fe,t._wasm_new_display_list_from_page_contents=r_.Ge,t._wasm_page_label=r_.He,t._wasm_search_page=r_.Ie,t._wasm_new_outline_iterator=r_.Je,t._wasm_outline_iterator_next=r_.Ke,t._wasm_outline_iterator_prev=r_.Le,t._wasm_outline_iterator_up=r_.Me,t._wasm_outline_iterator_down=r_.Ne,t._wasm_outline_iterator_delete=r_.Oe,t._wasm_outline_iterator_item=r_.Pe,t._wasm_outline_iterator_insert=r_.Qe,t._wasm_outline_iterator_update=r_.Re,t._wasm_pdf_document_from_fz_document=r_.Se,t._wasm_pdf_page_from_fz_page=r_.Te,t._wasm_pdf_create_document=r_.Ue,t._wasm_pdf_version=r_.Ve,t._wasm_pdf_was_repaired=r_.We,t._wasm_pdf_has_unsaved_changes=r_.Xe,t._wasm_pdf_can_be_saved_incrementally=r_.Ye,t._wasm_pdf_count_versions=r_.Ze,t._wasm_pdf_count_unsaved_versions=r_._e,t._wasm_pdf_validate_change_history=r_.$e,t._wasm_pdf_enable_journal=r_.af,t._wasm_pdf_undoredo_state_position=r_.bf,t._wasm_pdf_undoredo_state_count=r_.cf,t._wasm_pdf_undoredo_step=r_.df,t._wasm_pdf_begin_operation=r_.ef,t._wasm_pdf_begin_implicit_operation=r_.ff,t._wasm_pdf_end_operation=r_.gf,t._wasm_pdf_abandon_operation=r_.hf,t._wasm_pdf_undo=r_.jf,t._wasm_pdf_redo=r_.kf,t._wasm_pdf_can_undo=r_.lf,t._wasm_pdf_can_redo=r_.mf,t._wasm_pdf_document_language=r_.nf,t._wasm_pdf_set_document_language=r_.of,t._wasm_pdf_trailer=r_.pf,t._wasm_pdf_xref_len=r_.qf,t._wasm_pdf_lookup_page_obj=r_.rf,t._wasm_pdf_add_object=r_.sf,t._wasm_pdf_create_object=r_.tf,t._wasm_pdf_delete_object=r_.uf,t._wasm_pdf_add_stream=r_.vf,t._wasm_pdf_add_simple_font=r_.wf,t._wasm_pdf_add_cjk_font=r_.xf,t._wasm_pdf_add_cid_font=r_.yf,t._wasm_pdf_add_image=r_.zf,t._wasm_pdf_load_image=r_.Af,t._wasm_pdf_set_page_tree_cache=r_.Bf,t._wasm_pdf_add_page=r_.Cf,t._wasm_pdf_insert_page=r_.Df,t._wasm_pdf_delete_page=r_.Ef,t._wasm_pdf_set_page_labels=r_.Ff,t._wasm_pdf_delete_page_labels=r_.Gf,t._wasm_pdf_is_embedded_file=r_.Hf,t._wasm_pdf_get_filespec_params=r_.If,t._wasm_pdf_add_embedded_file=r_.Jf,t._wasm_pdf_load_embedded_file_contents=r_.Kf,t._wasm_pdf_write_document_buffer=r_.Lf,t._wasm_pdf_js_supported=r_.Mf,t._wasm_pdf_enable_js=r_.Nf,t._wasm_pdf_disable_js=r_.Of,t._wasm_pdf_rearrange_pages=r_.Pf,t._wasm_pdf_subset_fonts=r_.Qf,t._wasm_pdf_bake_document=r_.Rf,t._wasm_pdf_count_layer_configs=r_.Sf,t._wasm_pdf_layer_config_creator=r_.Tf,t._wasm_pdf_layer_config_name=r_.Uf,t._wasm_pdf_select_layer_config=r_.Vf,t._wasm_pdf_count_layer_config_uis=r_.Wf,t._wasm_pdf_layer_config_ui_info=r_.Xf,t._wasm_pdf_count_layers=r_.Yf,t._wasm_pdf_layer_name=r_.Zf,t._wasm_pdf_layer_is_enabled=r_._f,t._wasm_pdf_enable_layer=r_.$f,t._wasm_pdf_page_transform=r_.ag,t._wasm_pdf_set_page_box=r_.bg,t._wasm_pdf_first_annot=r_.cg,t._wasm_pdf_next_annot=r_.dg,t._wasm_pdf_first_widget=r_.eg,t._wasm_pdf_next_widget=r_.fg,t._wasm_pdf_create_annot=r_.gg,t._wasm_pdf_delete_annot=r_.hg,t._wasm_pdf_update_page=r_.ig,t._wasm_pdf_redact_page=r_.jg,t._wasm_pdf_new_graft_map=r_.kg,t._wasm_pdf_graft_mapped_object=r_.lg,t._wasm_pdf_graft_object=r_.mg,t._wasm_pdf_graft_mapped_page=r_.ng,t._wasm_pdf_graft_page=r_.og,t._wasm_pdf_bound_annot=r_.pg,t._wasm_pdf_run_annot=r_.qg,t._wasm_pdf_new_pixmap_from_annot=r_.rg,t._wasm_pdf_new_display_list_from_annot=r_.sg,t._wasm_pdf_update_annot=r_.tg,t._wasm_pdf_annot_obj=r_.ug,t._wasm_pdf_annot_type=r_.vg,t._wasm_pdf_annot_flags=r_.wg,t._wasm_pdf_set_annot_flags=r_.xg,t._wasm_pdf_annot_contents=r_.yg,t._wasm_pdf_set_annot_contents=r_.zg,t._wasm_pdf_annot_name=r_.Ag,t._wasm_pdf_set_annot_name=r_.Bg,t._wasm_pdf_annot_author=r_.Cg,t._wasm_pdf_set_annot_author=r_.Dg,t._wasm_pdf_annot_subject=r_.Eg,t._wasm_pdf_set_annot_subject=r_.Fg,t._wasm_pdf_annot_creation_date=r_.Gg,t._wasm_pdf_set_annot_creation_date=r_.Hg,t._wasm_pdf_annot_modification_date=r_.Ig,t._wasm_pdf_set_annot_modification_date=r_.Jg,t._wasm_pdf_annot_border_width=r_.Kg,t._wasm_pdf_set_annot_border_width=r_.Lg,t._wasm_pdf_annot_border_style=r_.Mg,t._wasm_pdf_set_annot_border_style=r_.Ng,t._wasm_pdf_annot_border_effect=r_.Og,t._wasm_pdf_set_annot_border_effect=r_.Pg,t._wasm_pdf_annot_border_effect_intensity=r_.Qg,t._wasm_pdf_set_annot_border_effect_intensity=r_.Rg,t._wasm_pdf_annot_opacity=r_.Sg,t._wasm_pdf_set_annot_opacity=r_.Tg,t._wasm_pdf_annot_filespec=r_.Ug,t._wasm_pdf_set_annot_filespec=r_.Vg,t._wasm_pdf_annot_quadding=r_.Wg,t._wasm_pdf_set_annot_quadding=r_.Xg,t._wasm_pdf_annot_is_open=r_.Yg,t._wasm_pdf_set_annot_is_open=r_.Zg,t._wasm_pdf_annot_hidden_for_editing=r_._g,t._wasm_pdf_set_annot_hidden_for_editing=r_.$g,t._wasm_pdf_annot_icon_name=r_.ah,t._wasm_pdf_set_annot_icon_name=r_.bh,t._wasm_pdf_annot_intent=r_.ch,t._wasm_pdf_set_annot_intent=r_.dh,t._wasm_pdf_annot_callout_style=r_.eh,t._wasm_pdf_set_annot_callout_style=r_.fh,t._wasm_pdf_annot_line_leader=r_.gh,t._wasm_pdf_set_annot_line_leader=r_.hh,t._wasm_pdf_annot_line_leader_extension=r_.ih,t._wasm_pdf_set_annot_line_leader_extension=r_.jh,t._wasm_pdf_annot_line_leader_offset=r_.kh,t._wasm_pdf_set_annot_line_leader_offset=r_.lh,t._wasm_pdf_annot_line_caption=r_.mh,t._wasm_pdf_set_annot_line_caption=r_.nh,t._wasm_pdf_annot_rich_defaults=r_.oh,t._wasm_pdf_set_annot_rich_defaults=r_.ph,t._wasm_pdf_annot_callout_point=r_.qh,t._wasm_pdf_annot_line_caption_offset=r_.rh,t._wasm_pdf_annot_rect=r_.sh,t._wasm_pdf_annot_popup=r_.th,t._wasm_pdf_annot_quad_point_count=r_.uh,t._wasm_pdf_annot_quad_point=r_.vh,t._wasm_pdf_annot_vertex_count=r_.wh,t._wasm_pdf_annot_vertex=r_.xh,t._wasm_pdf_annot_ink_list_count=r_.yh,t._wasm_pdf_annot_ink_list_stroke_count=r_.zh,t._wasm_pdf_annot_ink_list_stroke_vertex=r_.Ah,t._wasm_pdf_annot_rich_contents=r_.Bh,t._wasm_pdf_annot_border_dash_count=r_.Ch,t._wasm_pdf_annot_border_dash_item=r_.Dh,t._wasm_pdf_annot_has_rect=r_.Eh,t._wasm_pdf_annot_has_ink_list=r_.Fh,t._wasm_pdf_annot_has_quad_points=r_.Gh,t._wasm_pdf_annot_has_vertices=r_.Hh,t._wasm_pdf_annot_has_line=r_.Ih,t._wasm_pdf_annot_has_interior_color=r_.Jh,t._wasm_pdf_annot_has_line_ending_styles=r_.Kh,t._wasm_pdf_annot_has_border=r_.Lh,t._wasm_pdf_annot_has_border_effect=r_.Mh,t._wasm_pdf_annot_has_icon_name=r_.Nh,t._wasm_pdf_annot_has_open=r_.Oh,t._wasm_pdf_annot_has_author=r_.Ph,t._wasm_pdf_annot_has_subject=r_.Qh,t._wasm_pdf_annot_has_filespec=r_.Rh,t._wasm_pdf_annot_has_callout=r_.Sh,t._wasm_pdf_annot_has_rich_contents=r_.Th,t._wasm_pdf_annot_language=r_.Uh,t._wasm_pdf_set_annot_language=r_.Vh,t._wasm_pdf_set_annot_popup=r_.Wh,t._wasm_pdf_set_annot_rect=r_.Xh,t._wasm_pdf_clear_annot_quad_points=r_.Yh,t._wasm_pdf_clear_annot_vertices=r_.Zh,t._wasm_pdf_clear_annot_ink_list=r_._h,t._wasm_pdf_clear_annot_border_dash=r_.$h,t._wasm_pdf_add_annot_quad_point=r_.ai,t._wasm_pdf_add_annot_vertex=r_.bi,t._wasm_pdf_add_annot_ink_list_stroke=r_.ci,t._wasm_pdf_add_annot_ink_list_stroke_vertex=r_.di,t._wasm_pdf_add_annot_border_dash_item=r_.ei,t._wasm_pdf_annot_line_ending_styles_start=r_.fi,t._wasm_pdf_annot_line_1=r_.gi,t._wasm_pdf_annot_line_2=r_.hi,t._wasm_pdf_set_annot_line=r_.ii,t._wasm_pdf_set_annot_callout_point=r_.ji,t._wasm_pdf_annot_callout_line=r_.ki,t._wasm_pdf_set_annot_callout_line=r_.li,t._wasm_pdf_set_annot_line_caption_offset=r_.mi,t._wasm_pdf_annot_line_ending_styles_end=r_.ni,t._wasm_pdf_set_annot_line_ending_styles=r_.oi,t._wasm_pdf_annot_color=r_.pi,t._wasm_pdf_annot_interior_color=r_.qi,t._wasm_pdf_set_annot_color=r_.ri,t._wasm_pdf_set_annot_interior_color=r_.si,t._wasm_pdf_set_annot_default_appearance=r_.ti,t._wasm_pdf_annot_default_appearance_font=r_.ui,t._wasm_pdf_annot_default_appearance_size=r_.vi,t._wasm_pdf_annot_default_appearance_color=r_.wi,t._wasm_pdf_set_annot_rich_contents=r_.xi,t._wasm_pdf_set_annot_stamp_image=r_.yi,t._wasm_pdf_set_annot_appearance_from_display_list=r_.zi,t._wasm_pdf_set_annot_appearance=r_.Ai,t._wasm_pdf_apply_redaction=r_.Bi,t._wasm_pdf_reset_form=r_.Ci,t._wasm_pdf_annot_field_type=r_.Di,t._wasm_pdf_annot_field_flags=r_.Ei,t._wasm_pdf_annot_field_label=r_.Fi,t._wasm_pdf_annot_field_value=r_.Gi,t._wasm_pdf_load_field_name=r_.Hi,t._wasm_pdf_annot_text_widget_max_len=r_.Ii,t._wasm_pdf_set_annot_text_field_value=r_.Ji,t._wasm_pdf_set_annot_choice_field_value=r_.Ki,t._wasm_pdf_annot_choice_field_option_count=r_.Li,t._wasm_pdf_annot_choice_field_option=r_.Mi,t._wasm_pdf_toggle_widget=r_.Ni,t._wasm_pdf_is_indirect=r_.Oi,t._wasm_pdf_is_bool=r_.Pi,t._wasm_pdf_is_int=r_.Qi,t._wasm_pdf_is_real=r_.Ri,t._wasm_pdf_is_number=r_.Si,t._wasm_pdf_is_name=r_.Ti,t._wasm_pdf_is_string=r_.Ui,t._wasm_pdf_is_array=r_.Vi,t._wasm_pdf_is_dict=r_.Wi,t._wasm_pdf_is_stream=r_.Xi,t._wasm_pdf_to_num=r_.Yi,t._wasm_pdf_to_bool=r_.Zi,t._wasm_pdf_to_real=r_._i,t._wasm_pdf_to_name=r_.$i,t._wasm_pdf_to_text_string=r_.aj,t._wasm_pdf_new_indirect=r_.bj,t._wasm_pdf_new_array=r_.cj,t._wasm_pdf_new_dict=r_.dj,t._wasm_pdf_new_bool=r_.ej,t._wasm_pdf_new_int=r_.fj,t._wasm_pdf_new_real=r_.gj,t._wasm_pdf_new_name=r_.hj,t._wasm_pdf_new_text_string=r_.ij,t._wasm_pdf_new_string=r_.jj,t._wasm_pdf_resolve_indirect=r_.kj,t._wasm_pdf_array_len=r_.lj,t._wasm_pdf_array_get=r_.mj,t._wasm_pdf_dict_get=r_.nj,t._wasm_pdf_dict_len=r_.oj,t._wasm_pdf_dict_get_key=r_.pj,t._wasm_pdf_dict_get_val=r_.qj,t._wasm_pdf_dict_get_inheritable=r_.rj,t._wasm_pdf_dict_gets=r_.sj,t._wasm_pdf_dict_gets_inheritable=r_.tj,t._wasm_pdf_dict_put=r_.uj,t._wasm_pdf_dict_puts=r_.vj,t._wasm_pdf_dict_del=r_.wj,t._wasm_pdf_dict_dels=r_.xj,t._wasm_pdf_array_put=r_.yj,t._wasm_pdf_array_push=r_.zj,t._wasm_pdf_array_delete=r_.Aj,t._wasm_pdf_sprint_obj=r_.Bj,t._wasm_pdf_load_stream=r_.Cj,t._wasm_pdf_load_raw_stream=r_.Dj,t._wasm_pdf_update_object=r_.Ej,t._wasm_pdf_update_stream=r_.Fj,t._wasm_pdf_to_string=r_.Gj,t._wasm_new_stream=r_.Hj,t._wasm_walk_path=r_.Ij,t._wasm_walk_text=r_.Jj,t._wasm_enable_log_callback=r_.Kj,t._wasm_new_js_device=r_.Lj,r_.Mj);return function(){if(t.preInit)for("function"==typeof t.preInit&&(t.preInit=[t.preInit]);t.preInit.length>0;)t.preInit.shift()()}(),function _(){function e(){t.calledRun=!0,$||(A=!0,r_.x(),a(t),t.onRuntimeInitialized?.(),function(){if(t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;)L(t.postRun.shift());B(q)}())}C>0?S=_:(function(){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)H(t.preRun.shift());B(z)}(),C>0?S=_:t.setStatus?(t.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>t.setStatus(""),1),e()},1)):e())}(),s};export default _; \ No newline at end of file diff --git a/public/vendor/mupdf/mupdf-wasm.wasm b/public/vendor/mupdf/mupdf-wasm.wasm new file mode 100644 index 0000000..8288739 Binary files /dev/null and b/public/vendor/mupdf/mupdf-wasm.wasm differ diff --git a/public/vendor/mupdf/mupdf.js b/public/vendor/mupdf/mupdf.js new file mode 100644 index 0000000..849fee6 --- /dev/null +++ b/public/vendor/mupdf/mupdf.js @@ -0,0 +1,3317 @@ +// Copyright (C) 2004-2026 Artifex Software, Inc. +// +// This file is part of MuPDF WASM Library. +// +// MuPDF is free software: you can redistribute it and/or modify it under the +// terms of the GNU Affero General Public License as published by the Free +// Software Foundation, either version 3 of the License, or (at your option) +// any later version. +// +// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +// details. +// +// You should have received a copy of the GNU Affero General Public License +// along with MuPDF. If not, see +// +// Alternative licensing terms are available from the licensor. +// For commercial licensing, see or contact +// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, +// CA 94129, USA, for further information. +"use strict"; +import libmupdf_wasm from "./mupdf-wasm.js"; +var node_fs = null; +if (typeof process !== "undefined" && process.versions && process.versions.node) + node_fs = await import("node:fs"); +const libmupdf = await libmupdf_wasm(globalThis["$libmupdf_wasm_Module"]); +libmupdf._wasm_init_context(); +function Malloc(size) { + return libmupdf._wasm_malloc(size); +} +function Free(ptr) { + libmupdf._wasm_free(ptr); +} +export const memento = { + listBlocks() { + libmupdf._wasm_Memento_listBlocks(); + }, + checkAllMemory() { + libmupdf._wasm_Memento_checkAllMemory(); + }, +}; +export const Matrix = { + identity: [1, 0, 0, 1, 0, 0], + scale(sx, sy) { + return [sx, 0, 0, sy, 0, 0]; + }, + translate(tx, ty) { + return [1, 0, 0, 1, tx, ty]; + }, + rotate(d) { + while (d < 0) + d += 360; + while (d >= 360) + d -= 360; + let s = Math.sin((d * Math.PI) / 180); + let c = Math.cos((d * Math.PI) / 180); + return [c, s, -s, c, 0, 0]; + }, + invert(m) { + checkMatrix(m); + let det = m[0] * m[3] - m[1] * m[2]; + if (det > -1e-23 && det < 1e-23) + return m; + let rdet = 1 / det; + let inva = m[3] * rdet; + let invb = -m[1] * rdet; + let invc = -m[2] * rdet; + let invd = m[0] * rdet; + let inve = -m[4] * inva - m[5] * invc; + let invf = -m[4] * invb - m[5] * invd; + return [inva, invb, invc, invd, inve, invf]; + }, + concat(one, two) { + checkMatrix(one); + checkMatrix(two); + return [ + one[0] * two[0] + one[1] * two[2], + one[0] * two[1] + one[1] * two[3], + one[2] * two[0] + one[3] * two[2], + one[2] * two[1] + one[3] * two[3], + one[4] * two[0] + one[5] * two[2] + two[4], + one[4] * two[1] + one[5] * two[3] + two[5], + ]; + }, +}; +export const Rect = { + MIN_INF_RECT: 0x80000000, + MAX_INF_RECT: 0x7fffff80, + empty: [0x80000000, 0x80000000, 0x7fffff80, 0x7fffff80], + invalid: [0, 0, -1, -1], + infinite: [0x7fffff80, 0x7fffff80, 0x80000000, 0x80000000], + isEmpty: function (rect) { + checkRect(rect); + return rect[0] >= rect[2] || rect[1] >= rect[3]; + }, + isValid: function (rect) { + checkRect(rect); + return rect[0] <= rect[2] && rect[1] <= rect[3]; + }, + isInfinite: function (rect) { + checkRect(rect); + return (rect[0] === Rect.MAX_INF_RECT && + rect[1] === Rect.MAX_INF_RECT && + rect[2] === Rect.MIN_INF_RECT && + rect[3] === Rect.MIN_INF_RECT); + }, + transform: function (rect, matrix) { + checkRect(rect); + checkMatrix(matrix); + var t; + if (Rect.isInfinite(rect)) + return rect; + if (!Rect.isValid(rect)) + return rect; + var ax0 = rect[0] * matrix[0]; + var ax1 = rect[2] * matrix[0]; + if (ax0 > ax1) + t = ax0, ax0 = ax1, ax1 = t; + var cy0 = rect[1] * matrix[2]; + var cy1 = rect[3] * matrix[2]; + if (cy0 > cy1) + t = cy0, cy0 = cy1, cy1 = t; + ax0 += cy0 + matrix[4]; + ax1 += cy1 + matrix[4]; + var bx0 = rect[0] * matrix[1]; + var bx1 = rect[2] * matrix[1]; + if (bx0 > bx1) + t = bx0, bx0 = bx1, bx1 = t; + var dy0 = rect[1] * matrix[3]; + var dy1 = rect[3] * matrix[3]; + if (dy0 > dy1) + t = dy0, dy0 = dy1, dy1 = t; + bx0 += dy0 + matrix[5]; + bx1 += dy1 + matrix[5]; + return [ax0, bx0, ax1, bx1]; + }, +}; +export function enableICC() { + libmupdf._wasm_enable_icc(); +} +export function disableICC() { + libmupdf._wasm_disable_icc(); +} +export function setUserCSS(text) { + libmupdf._wasm_set_user_css(STRING(text)); +} +export function emptyStore() { + libmupdf._wasm_empty_store(); +} +export function shrinkStore(percent) { + return libmupdf._wasm_shrink_store(percent); +} +export function installLoadFontFunction(f) { + $libmupdf_load_font_file_js = f; +} +var $libmupdf_log = null; +globalThis.$libmupdf_log_error = function (message) { + $libmupdf_log?.error?.(fromString(message)); +}; +globalThis.$libmupdf_log_warning = function (message) { + $libmupdf_log?.warning?.(fromString(message)); +}; +export function setLog(log) { + if (typeof log === "function") { + $libmupdf_log = { error: log, warning: log }; + } + else { + $libmupdf_log = log; + } + libmupdf._wasm_enable_log_callback(log !== null); +} +/* -------------------------------------------------------------------------- */ +// To pass Rect and Matrix as pointer arguments +const _wasm_int = Malloc(4); +const _wasm_point = Malloc(4 * 6) >> 2; +const _wasm_rect = Malloc(4 * 8) >> 2; +const _wasm_matrix = Malloc(4 * 6) >> 2; +const _wasm_color = Malloc(4 * 4) >> 2; +const _wasm_quad = Malloc(4 * 8) >> 2; +const _wasm_string = [0, 0]; +function checkType(value, type) { + if (typeof type === "string" && typeof value !== type) + throw new TypeError("expected " + type); + if (typeof type === "function" && !(value instanceof type)) + throw new TypeError("expected " + type.name); +} +function checkPoint(value) { + if (!Array.isArray(value) || value.length !== 2) + throw new TypeError("expected point"); +} +function checkRect(value) { + if (!Array.isArray(value) || value.length !== 4) + throw new TypeError("expected rectangle"); +} +function checkMatrix(value) { + if (!Array.isArray(value) || value.length !== 6) + throw new TypeError("expected matrix"); +} +function checkQuad(value) { + if (!Array.isArray(value) || value.length !== 8) + throw new TypeError("expected quad"); +} +function checkColor(value) { + if (!Array.isArray(value) || (value.length !== 1 && value.length !== 3 && value.length !== 4)) + throw new TypeError("expected color array"); +} +function checkAnnotColor(value) { + if (!Array.isArray(value) || (value.length !== 0 && value.length !== 1 && value.length !== 3 && value.length !== 4)) + throw new TypeError("expected color array"); +} +function BUFFER(input) { + if (input instanceof Buffer) + return input.pointer; + if (input instanceof ArrayBuffer || input instanceof Uint8Array) + return new Buffer(input).pointer; + if (typeof input === "string") + return new Buffer(input).pointer; + throw new TypeError("expected buffer"); +} +function ENUM(value, list) { + if (typeof value === "number") { + if (value >= 0 && value < list.length) + return value; + } + if (typeof value === "string") { + let idx = list.indexOf(value); + if (idx >= 0) + return idx; + } + throw new TypeError(`invalid enum value ("${value}"; expected ${list.join(", ")})`); +} +function allocateUTF8(str) { + var size = libmupdf.lengthBytesUTF8(str) + 1; + var pointer = Malloc(size); + libmupdf.stringToUTF8(str, pointer, size); + return pointer; +} +function STRING_N(s, i) { + if (_wasm_string[i]) { + Free(_wasm_string[i]); + _wasm_string[i] = 0; + } + return _wasm_string[i] = allocateUTF8(s); +} +function STRING(s) { + return STRING_N(s, 0); +} +function STRING2(s) { + return STRING_N(s, 1); +} +function STRING_OPT(s) { + return typeof s === "string" ? STRING_N(s, 0) : 0; +} +function STRING2_OPT(s) { + return typeof s === "string" ? STRING_N(s, 1) : 0; +} +function POINT(p) { + libmupdf.HEAPF32[_wasm_point + 0] = p[0]; + libmupdf.HEAPF32[_wasm_point + 1] = p[1]; + return _wasm_point << 2; +} +function POINT2(p) { + libmupdf.HEAPF32[_wasm_point + 2] = p[0]; + libmupdf.HEAPF32[_wasm_point + 3] = p[1]; + return (_wasm_point + 2) << 2; +} +function POINT3(p) { + libmupdf.HEAPF32[_wasm_point + 4] = p[0]; + libmupdf.HEAPF32[_wasm_point + 5] = p[1]; + return (_wasm_point + 4) << 2; +} +function RECT(r) { + libmupdf.HEAPF32[_wasm_rect + 0] = r[0]; + libmupdf.HEAPF32[_wasm_rect + 1] = r[1]; + libmupdf.HEAPF32[_wasm_rect + 2] = r[2]; + libmupdf.HEAPF32[_wasm_rect + 3] = r[3]; + return _wasm_rect << 2; +} +function RECT2(r) { + libmupdf.HEAPF32[_wasm_rect + 4] = r[0]; + libmupdf.HEAPF32[_wasm_rect + 5] = r[1]; + libmupdf.HEAPF32[_wasm_rect + 6] = r[2]; + libmupdf.HEAPF32[_wasm_rect + 7] = r[3]; + return (_wasm_rect + 4) << 2; +} +function MATRIX(m) { + libmupdf.HEAPF32[_wasm_matrix + 0] = m[0]; + libmupdf.HEAPF32[_wasm_matrix + 1] = m[1]; + libmupdf.HEAPF32[_wasm_matrix + 2] = m[2]; + libmupdf.HEAPF32[_wasm_matrix + 3] = m[3]; + libmupdf.HEAPF32[_wasm_matrix + 4] = m[4]; + libmupdf.HEAPF32[_wasm_matrix + 5] = m[5]; + return _wasm_matrix << 2; +} +function QUAD(q) { + libmupdf.HEAPF32[_wasm_quad + 0] = q[0]; + libmupdf.HEAPF32[_wasm_quad + 1] = q[1]; + libmupdf.HEAPF32[_wasm_quad + 2] = q[2]; + libmupdf.HEAPF32[_wasm_quad + 3] = q[3]; + libmupdf.HEAPF32[_wasm_quad + 4] = q[4]; + libmupdf.HEAPF32[_wasm_quad + 5] = q[5]; + libmupdf.HEAPF32[_wasm_quad + 6] = q[6]; + libmupdf.HEAPF32[_wasm_quad + 7] = q[7]; + return _wasm_quad << 2; +} +function COLOR(c) { + if (typeof c !== "undefined") { + switch (c.length) { + case 0: + break; + case 1: + libmupdf.HEAPF32[_wasm_color + 0] = c[0]; + break; + case 3: + libmupdf.HEAPF32[_wasm_color + 0] = c[0]; + libmupdf.HEAPF32[_wasm_color + 1] = c[1]; + libmupdf.HEAPF32[_wasm_color + 2] = c[2]; + break; + case 4: + libmupdf.HEAPF32[_wasm_color + 0] = c[0]; + libmupdf.HEAPF32[_wasm_color + 1] = c[1]; + libmupdf.HEAPF32[_wasm_color + 2] = c[2]; + libmupdf.HEAPF32[_wasm_color + 3] = c[3]; + break; + } + } + return _wasm_color << 2; +} +function ensureOptions(value) { + if (value === (void 0) || value === null) + return ""; + if (typeof value === "string") + return value; + return JSON.stringify(value); +} +/* -------------------------------------------------------------------------- */ +function fromColor(n) { + if (n === 1) + return [ + libmupdf.HEAPF32[_wasm_color] + ]; + if (n === 3) + return [ + libmupdf.HEAPF32[_wasm_color + 0], + libmupdf.HEAPF32[_wasm_color + 1], + libmupdf.HEAPF32[_wasm_color + 2], + ]; + if (n === 4) + return [ + libmupdf.HEAPF32[_wasm_color + 0], + libmupdf.HEAPF32[_wasm_color + 1], + libmupdf.HEAPF32[_wasm_color + 2], + libmupdf.HEAPF32[_wasm_color + 3], + ]; + throw new TypeError("invalid number of components for Color: " + n); +} +function fromAnnotColor(n) { + if (n === 0) + return []; + return fromColor(n); +} +function fromColorArray(n, ptr) { + let addr = ptr >> 2; + let color = []; + for (let i = 0; i < n; ++i) + color.push(libmupdf.HEAPF32[addr + i]); + return color; +} +function fromStringOrNull(ptr) { + if (ptr === 0) + return null; + return libmupdf.UTF8ToString(ptr); +} +function fromString(ptr) { + return libmupdf.UTF8ToString(ptr); +} +function fromStringFree(ptr) { + let str = libmupdf.UTF8ToString(ptr); + Free(ptr); + return str; +} +function fromPoint(ptr) { + let addr = ptr >> 2; + return [ + libmupdf.HEAPF32[addr + 0], + libmupdf.HEAPF32[addr + 1], + ]; +} +function fromRect(ptr) { + let addr = ptr >> 2; + return [ + libmupdf.HEAPF32[addr + 0], + libmupdf.HEAPF32[addr + 1], + libmupdf.HEAPF32[addr + 2], + libmupdf.HEAPF32[addr + 3], + ]; +} +function fromMatrix(ptr) { + let addr = ptr >> 2; + return [ + libmupdf.HEAPF32[addr + 0], + libmupdf.HEAPF32[addr + 1], + libmupdf.HEAPF32[addr + 2], + libmupdf.HEAPF32[addr + 3], + libmupdf.HEAPF32[addr + 4], + libmupdf.HEAPF32[addr + 5], + ]; +} +function fromQuad(ptr) { + let addr = ptr >> 2; + return [ + libmupdf.HEAPF32[addr + 0], + libmupdf.HEAPF32[addr + 1], + libmupdf.HEAPF32[addr + 2], + libmupdf.HEAPF32[addr + 3], + libmupdf.HEAPF32[addr + 4], + libmupdf.HEAPF32[addr + 5], + libmupdf.HEAPF32[addr + 6], + libmupdf.HEAPF32[addr + 7], + ]; +} +function fromBuffer(ptr) { + let data = libmupdf._wasm_buffer_get_data(ptr); + let size = libmupdf._wasm_buffer_get_len(ptr); + return libmupdf.HEAPU8.slice(data, data + size); +} +function fromLayerConfigUIInfo(ptr) { + return { + text: libmupdf._wasm_pdf_layer_config_ui_get_text(ptr), + depth: libmupdf._wasm_pdf_layer_config_ui_get_depth(ptr), + type: libmupdf._wasm_pdf_layer_config_ui_get_type(ptr), + selected: libmupdf._wasm_pdf_layer_config_ui_get_selected(ptr), + locked: libmupdf._wasm_pdf_layer_config_ui_get_locked(ptr), + }; +} +/* unused for now +function rgbFromColor(c?: Color): [number, number, number] { + var r = 0, g = 0, b = 0 + if (typeof c !== "undefined") { + switch (c.length) { + case 1: + r = g = b = c[0] + break + case 3: + r = c[0] + g = c[1] + b = c[2] + break + case 4: + r = 1 - Math.min(1, c[0] + c[3]) + g = 1 - Math.min(1, c[1] + c[3]) + b = 1 - Math.min(1, c[2] + c[3]) + break + } + } + return [ r, g, b ] +} + +function numberFromColor(c?: Color): number { + var [ r, g, b ] = rgbFromColor(c) + return (255 << 24) | (r << 16) | (g << 8) | b +} +*/ +function colorFromNumber(argb) { + var r = (argb >> 16) & 255; + var g = (argb >> 8) & 255; + var b = (argb) & 255; + return [r / 255, g / 255, b / 255]; +} +function runSearch(searchFun, haystack, needle, options) { + const max_hits = 500; + checkType(needle, "string"); + options = ensureOptions(options); + let hits = 0; + let marks = 0; + try { + hits = Malloc(32 * max_hits); + marks = Malloc(4 * max_hits); + let n = searchFun(haystack, STRING(needle), marks, hits, max_hits, STRING2(options)); + let outer = []; + if (n > 0) { + let inner = []; + for (let i = 0; i < n; ++i) { + let mark = libmupdf.HEAP32[(marks >> 2) + i]; + let quad = fromQuad(hits + i * 32); + if (i > 0 && mark) { + outer.push(inner); + inner = []; + } + inner.push(quad); + } + outer.push(inner); + } + return outer; + } + finally { + Free(marks); + Free(hits); + } +} +/* -------------------------------------------------------------------------- */ +class Userdata { + constructor(pointer) { + if (typeof pointer !== "number") + throw new Error("invalid pointer: " + typeof pointer); + if (pointer !== 0) { + let ctor = this.constructor; + if (!ctor._finalizer) + ctor._finalizer = new FinalizationRegistry(ctor._drop); + ctor._finalizer.register(this, pointer, this); + } + this.pointer = pointer; + } + destroy() { + if (this.pointer !== 0) { + let ctor = this.constructor; + ctor._finalizer.unregister(this); + ctor._drop(this.pointer); + } + this.pointer = 0; + } + // Custom "console.log" formatting for Node + [Symbol.for("nodejs.util.inspect.custom")]() { + return this.toString(); + } + toString() { + return `[${this.constructor.name} ${this.pointer}]`; + } + valueOf() { + throw new Error("cannot convert Userdata to Javascript value"); + } +} +export class Buffer extends Userdata { + constructor(arg) { + if (typeof arg === "undefined") + super(libmupdf._wasm_new_buffer(1024)); + else if (typeof arg === "number") + super(arg); + else if (typeof arg === "string") { + let data_len = libmupdf.lengthBytesUTF8(arg); + let data_ptr = Malloc(data_len + 1); + libmupdf.stringToUTF8(arg, data_ptr, data_len + 1); + super(libmupdf._wasm_new_buffer_from_data(data_ptr, data_len)); + } + else if (arg instanceof ArrayBuffer || arg instanceof Uint8Array) { + let data_len = arg.byteLength; + let data_ptr = Malloc(data_len); + libmupdf.HEAPU8.set(new Uint8Array(arg), data_ptr); + super(libmupdf._wasm_new_buffer_from_data(data_ptr, data_len)); + } + } + get length() { + return this.getLength(); + } + set length(_) { + throw new TypeError("buffer length is read-only"); + } + getLength() { + return libmupdf._wasm_buffer_get_len(this.pointer); + } + readByte(at) { + let data = libmupdf._wasm_buffer_get_data(this.pointer); + return libmupdf.HEAPU8[data + at]; + } + write(s) { + libmupdf._wasm_append_string(this.pointer, STRING(s)); + } + writeByte(b) { + libmupdf._wasm_append_byte(this.pointer, b); + } + writeLine(s) { + this.write(s); + this.writeByte(10); + } + writeBuffer(other) { + libmupdf._wasm_append_buffer(this.pointer, BUFFER(other)); + } + asUint8Array() { + let data = libmupdf._wasm_buffer_get_data(this.pointer); + let size = libmupdf._wasm_buffer_get_len(this.pointer); + return libmupdf.HEAPU8.subarray(data, data + size); + } + slice(start, end) { + if (typeof end === "undefined") + end = this.getLength(); + return new Buffer(libmupdf._wasm_slice_buffer(this.pointer, start, end)); + } + asString() { + return fromString(libmupdf._wasm_string_from_buffer(this.pointer)); + } + save(filename) { + if (node_fs) + node_fs.writeFileSync(filename, this.asUint8Array()); + else + throw new Error("missing 'fs' module"); + } +} +Buffer._drop = libmupdf._wasm_drop_buffer; +export class ColorSpace extends Userdata { + constructor(from, name) { + if (typeof from === "number") { + super(from); + } + else { + if (typeof from === "string") { + if (node_fs) + from = node_fs.readFileSync(from); + else + throw new Error("missing 'fs' module"); + } + super(libmupdf._wasm_new_icc_colorspace(STRING_OPT(name), BUFFER(from))); + } + } + getName() { + return fromString(libmupdf._wasm_colorspace_get_name(this.pointer)); + } + getType() { + return ColorSpace.COLORSPACE_TYPES[libmupdf._wasm_colorspace_get_type(this.pointer)] || "None"; + } + getNumberOfComponents() { + return libmupdf._wasm_colorspace_get_n(this.pointer); + } + isGray() { return this.getType() === "Gray"; } + isRGB() { return this.getType() === "RGB"; } + isCMYK() { return this.getType() === "CMYK"; } + isIndexed() { return this.getType() === "Indexed"; } + isLab() { return this.getType() === "Lab"; } + isDeviceN() { return this.getType() === "Separation"; } + isSubtractive() { return this.getType() === "CMYK" || this.getType() === "Separation"; } + toString() { + return "[ColorSpace " + this.getName() + "]"; + } +} +ColorSpace._drop = libmupdf._wasm_drop_colorspace; +ColorSpace.COLORSPACE_TYPES = [ + "None", + "Gray", + "RGB", + "BGR", + "CMYK", + "Lab", + "Indexed", + "Separation" +]; +ColorSpace.DeviceGray = new ColorSpace(libmupdf._wasm_device_gray()); +ColorSpace.DeviceRGB = new ColorSpace(libmupdf._wasm_device_rgb()); +ColorSpace.DeviceBGR = new ColorSpace(libmupdf._wasm_device_bgr()); +ColorSpace.DeviceCMYK = new ColorSpace(libmupdf._wasm_device_cmyk()); +ColorSpace.Lab = new ColorSpace(libmupdf._wasm_device_lab()); +export class Font extends Userdata { + constructor(name_or_pointer, data, subfont = 0) { + let pointer = 0; + if (typeof name_or_pointer === "number") { + pointer = libmupdf._wasm_keep_font(name_or_pointer); + } + else { + if (typeof data === "string") { + if (node_fs) + data = node_fs.readFileSync(data); + else + throw new Error("missing 'fs' module"); + } + if (data) + pointer = libmupdf._wasm_new_font_from_buffer(STRING(name_or_pointer), BUFFER(data), subfont); + else if (name_or_pointer === "zh-Hant") + pointer = libmupdf._wasm_new_cjk_font(Font.ADOBE_CNS); + else if (name_or_pointer === "zh-Hans") + pointer = libmupdf._wasm_new_cjk_font(Font.ADOBE_GB); + else if (name_or_pointer === "ja") + pointer = libmupdf._wasm_new_cjk_font(Font.ADOBE_JAPAN); + else if (name_or_pointer === "ko") + pointer = libmupdf._wasm_new_cjk_font(Font.ADOBE_KOREA); + else + pointer = libmupdf._wasm_new_base14_font(STRING(name_or_pointer)); + } + super(pointer); + } + getName() { + return fromString(libmupdf._wasm_font_get_name(this.pointer)); + } + encodeCharacter(uni) { + if (typeof uni === "string") + uni = uni.charCodeAt(0); + return libmupdf._wasm_encode_character(this.pointer, uni); + } + advanceGlyph(gid, wmode = 0) { + return libmupdf._wasm_advance_glyph(this.pointer, gid, wmode); + } + isMono() { + return !!libmupdf._wasm_font_is_monospaced(this.pointer); + } + isSerif() { + return !!libmupdf._wasm_font_is_serif(this.pointer); + } + isBold() { + return !!libmupdf._wasm_font_is_bold(this.pointer); + } + isItalic() { + return !!libmupdf._wasm_font_is_italic(this.pointer); + } +} +Font._drop = libmupdf._wasm_drop_font; +Font.SIMPLE_ENCODING = [ + "Latin", + "Greek", + "Cyrillic" +]; +Font.SIMPLE_ENCODING_LATIN = "Latin"; +Font.SIMPLE_ENCODING_GREEK = "Greek"; +Font.SIMPLE_ENCODING_CYRILLIC = "Cyrillic"; +Font.ADOBE_CNS = 0; +Font.ADOBE_GB = 1; +Font.ADOBE_JAPAN = 2; +Font.ADOBE_KOREA = 3; +Font.CJK_ORDERING_BY_LANG = { + "Adobe-CNS1": 0, + "Adobe-GB1": 1, + "Adobe-Japan1": 2, + "Adobe-Korea1": 3, + "zh-Hant": 0, + "zh-TW": 0, + "zh-HK": 0, + "zh-Hans": 1, + "zh-CN": 1, + "ja": 2, + "ko": 3, +}; +export class Image extends Userdata { + constructor(data, mask) { + let pointer = 0; + if (typeof data === "number") { + pointer = libmupdf._wasm_keep_image(data); + } + else if (data instanceof Pixmap) { + pointer = libmupdf._wasm_new_image_from_pixmap(data.pointer, mask ? mask.pointer : 0); + } + else { + if (typeof data === "string") { + if (node_fs) + data = node_fs.readFileSync(data); + else + throw new Error("missing 'fs' module"); + } + pointer = libmupdf._wasm_new_image_from_buffer(BUFFER(data)); + } + super(pointer); + } + getWidth() { + return libmupdf._wasm_image_get_w(this.pointer); + } + getHeight() { + return libmupdf._wasm_image_get_h(this.pointer); + } + getNumberOfComponents() { + return libmupdf._wasm_image_get_n(this.pointer); + } + getBitsPerComponent() { + return libmupdf._wasm_image_get_bpc(this.pointer); + } + getXResolution() { + return libmupdf._wasm_image_get_xres(this.pointer); + } + getYResolution() { + return libmupdf._wasm_image_get_yres(this.pointer); + } + getImageMask() { + return !!libmupdf._wasm_image_get_imagemask(this.pointer); + } + getColorSpace() { + let cs = libmupdf._wasm_image_get_colorspace(this.pointer); + if (cs) + return new ColorSpace(libmupdf._wasm_keep_colorspace(cs)); + return null; + } + getMask() { + let mask = libmupdf._wasm_image_get_mask(this.pointer); + if (mask) + return new Image(libmupdf._wasm_keep_image(mask)); + return null; + } + toPixmap() { + return new Pixmap(libmupdf._wasm_get_pixmap_from_image(this.pointer)); + } +} +Image._drop = libmupdf._wasm_drop_image; +export class StrokeState extends Userdata { + constructor(data) { + if (typeof data === "number") { + super(data); + return this; + } + super(libmupdf._wasm_new_stroke_state(data?.dashes?.length ?? 0)); + let lineCap = ENUM(data.lineCap, StrokeState.LINE_CAP); + let lineJoin = ENUM(data.lineJoin, StrokeState.LINE_JOIN); + libmupdf._wasm_stroke_state_set_start_cap(this.pointer, lineCap); + libmupdf._wasm_stroke_state_set_dash_cap(this.pointer, lineCap); + libmupdf._wasm_stroke_state_set_end_cap(this.pointer, lineCap); + libmupdf._wasm_stroke_state_set_linejoin(this.pointer, lineJoin); + libmupdf._wasm_stroke_state_set_linewidth(this.pointer, data.lineWidth); + libmupdf._wasm_stroke_state_set_miterlimit(this.pointer, data.miterLimit); + libmupdf._wasm_stroke_state_set_dash_phase(this.pointer, data.dashPhase ?? 0); + if (data.dashes) { + for (let i = 0; i < data.dashes.length; ++i) + libmupdf._wasm_stroke_state_set_dash_item(this.pointer, i, data.dashes[i] ?? 0); + } + } + getLineCap() { + return libmupdf._wasm_stroke_state_get_start_cap(this.pointer); + } + getLineJoin() { + return libmupdf._wasm_stroke_state_get_linejoin(this.pointer); + } + getLineWidth() { + return libmupdf._wasm_stroke_state_get_linewidth(this.pointer); + } + getMiterLimit() { + return libmupdf._wasm_stroke_state_get_miterlimit(this.pointer); + } + getDashPhase() { + return libmupdf._wasm_stroke_state_get_dash_phase(this.pointer); + } + getDashes() { + var n = libmupdf._wasm_stroke_state_get_dash_len(this.pointer); + if (n > 0) { + var out = []; + for (let i = 0; i < n; ++i) + out[i] = libmupdf._wasm_stroke_state_get_dash_item(this.pointer, i); + return out; + } + return null; + } +} +StrokeState._drop = libmupdf._wasm_drop_stroke_state; +StrokeState.LINE_CAP = [ + "Butt", + "Round", + "Square", + "Triangle" +]; +StrokeState.LINE_JOIN = [ + "Miter", + "Round", + "Bevel", + "MiterXPS" +]; +export class Path extends Userdata { + constructor(pointer) { + if (typeof pointer === "number") + super(pointer); + else + super(libmupdf._wasm_new_path()); + } + getBounds(strokeState, transform) { + if (strokeState !== null) + checkType(strokeState, StrokeState); + checkMatrix(transform); + return fromRect(libmupdf._wasm_bound_path(this.pointer, strokeState?.pointer, MATRIX(transform))); + } + moveTo(x, y) { + checkType(x, "number"); + checkType(y, "number"); + libmupdf._wasm_moveto(this.pointer, x, y); + } + lineTo(x, y) { + checkType(x, "number"); + checkType(y, "number"); + libmupdf._wasm_lineto(this.pointer, x, y); + } + curveTo(x1, y1, x2, y2, x3, y3) { + checkType(x1, "number"); + checkType(y1, "number"); + checkType(x2, "number"); + checkType(y2, "number"); + checkType(x3, "number"); + checkType(y3, "number"); + libmupdf._wasm_curveto(this.pointer, x1, y1, x2, y2, x3, y3); + } + curveToV(cx, cy, ex, ey) { + checkType(cx, "number"); + checkType(cy, "number"); + checkType(ex, "number"); + checkType(ey, "number"); + libmupdf._wasm_curvetov(this.pointer, cx, cy, ex, ey); + } + curveToY(cx, cy, ex, ey) { + checkType(cx, "number"); + checkType(cy, "number"); + checkType(ex, "number"); + checkType(ey, "number"); + libmupdf._wasm_curvetoy(this.pointer, cx, cy, ex, ey); + } + closePath() { + libmupdf._wasm_closepath(this.pointer); + } + rect(x1, y1, x2, y2) { + checkType(x1, "number"); + checkType(y1, "number"); + checkType(x2, "number"); + checkType(y2, "number"); + libmupdf._wasm_rectto(this.pointer, x1, y1, x2, y2); + } + transform(matrix) { + checkMatrix(matrix); + libmupdf._wasm_transform_path(this.pointer, MATRIX(matrix)); + } + walk(walker) { + let id = $libmupdf_path_id++; + $libmupdf_path_table.set(id, walker); + libmupdf._wasm_walk_path(this.pointer, id); + $libmupdf_path_table.delete(id); + } +} +Path._drop = libmupdf._wasm_drop_path; +export class Text extends Userdata { + constructor(pointer) { + if (typeof pointer === "number") + super(pointer); + else + super(libmupdf._wasm_new_text()); + } + getBounds(strokeState, transform) { + if (strokeState !== null) + checkType(strokeState, StrokeState); + checkMatrix(transform); + return fromRect(libmupdf._wasm_bound_text(this.pointer, strokeState?.pointer, MATRIX(transform))); + } + showGlyph(font, trm, gid, uni, wmode = 0) { + checkType(font, Font); + checkMatrix(trm); + checkType(gid, "number"); + checkType(uni, "number"); + libmupdf._wasm_show_glyph(this.pointer, font.pointer, MATRIX(trm), gid, uni, wmode); + } + showString(font, trm, str, wmode = 0) { + checkType(font, Font); + checkMatrix(trm); + checkType(str, "string"); + return fromMatrix(libmupdf._wasm_show_string(this.pointer, font.pointer, MATRIX(trm), STRING(str), wmode)); + } + walk(walker) { + let id = $libmupdf_text_id++; + $libmupdf_text_table.set(id, walker); + libmupdf._wasm_walk_text(this.pointer, id); + $libmupdf_text_table.delete(id); + } +} +Text._drop = libmupdf._wasm_drop_text; +export class DisplayList extends Userdata { + constructor(arg1) { + let pointer = 0; + if (typeof arg1 === "number") { + pointer = arg1; + } + else { + checkRect(arg1); + pointer = libmupdf._wasm_new_display_list(RECT(arg1)); + } + super(pointer); + } + getBounds() { + return fromRect(libmupdf._wasm_bound_display_list(this.pointer)); + } + toPixmap(matrix, colorspace, alpha = false) { + checkMatrix(matrix); + checkType(colorspace, ColorSpace); + return new Pixmap(libmupdf._wasm_new_pixmap_from_display_list(this.pointer, MATRIX(matrix), colorspace.pointer, alpha)); + } + toStructuredText(options) { + options = ensureOptions(options); + return new StructuredText(libmupdf._wasm_new_stext_page_from_display_list(this.pointer, STRING(options))); + } + run(device, matrix) { + checkType(device, Device); + checkMatrix(matrix); + libmupdf._wasm_run_display_list(this.pointer, device.pointer, MATRIX(matrix)); + } + search(needle, options) { + return runSearch(libmupdf._wasm_search_display_list, this.pointer, needle, options); + } +} +DisplayList._drop = libmupdf._wasm_drop_display_list; +export class Pixmap extends Userdata { + constructor(arg1, bbox, alpha = false) { + if (typeof arg1 === "number") { + super(arg1); + } + if (arg1 instanceof ColorSpace) { + checkRect(bbox); + super(libmupdf._wasm_new_pixmap_with_bbox(arg1.pointer, RECT(bbox), alpha)); + } + if (arg1 === null) { + checkRect(bbox); + super(libmupdf._wasm_new_pixmap_with_bbox(0, RECT(bbox), alpha)); + } + } + getBounds() { + let x = libmupdf._wasm_pixmap_get_x(this.pointer); + let y = libmupdf._wasm_pixmap_get_y(this.pointer); + let w = libmupdf._wasm_pixmap_get_w(this.pointer); + let h = libmupdf._wasm_pixmap_get_h(this.pointer); + return [x, y, x + w, y + h]; + } + clear(value) { + if (typeof value === "undefined") + libmupdf._wasm_clear_pixmap(this.pointer); + else + libmupdf._wasm_clear_pixmap_with_value(this.pointer, value); + } + getWidth() { + return libmupdf._wasm_pixmap_get_w(this.pointer); + } + getHeight() { + return libmupdf._wasm_pixmap_get_h(this.pointer); + } + getX() { + return libmupdf._wasm_pixmap_get_x(this.pointer); + } + getY() { + return libmupdf._wasm_pixmap_get_y(this.pointer); + } + getStride() { + return libmupdf._wasm_pixmap_get_stride(this.pointer); + } + getNumberOfComponents() { + return libmupdf._wasm_pixmap_get_n(this.pointer); + } + getAlpha() { + return libmupdf._wasm_pixmap_get_alpha(this.pointer); + } + getXResolution() { + return libmupdf._wasm_pixmap_get_xres(this.pointer); + } + getYResolution() { + return libmupdf._wasm_pixmap_get_yres(this.pointer); + } + setResolution(x, y) { + libmupdf._wasm_pixmap_set_xres(this.pointer, x); + libmupdf._wasm_pixmap_set_yres(this.pointer, y); + } + getColorSpace() { + let cs = libmupdf._wasm_pixmap_get_colorspace(this.pointer); + if (cs) + return new ColorSpace(libmupdf._wasm_keep_colorspace(cs)); + return null; + } + getPixels() { + let s = libmupdf._wasm_pixmap_get_stride(this.pointer); + let h = libmupdf._wasm_pixmap_get_h(this.pointer); + let p = libmupdf._wasm_pixmap_get_samples(this.pointer); + return new Uint8ClampedArray(libmupdf.HEAPU8.buffer, p, s * h); + } + asPNG() { + let buf = libmupdf._wasm_new_buffer_from_pixmap_as_png(this.pointer); + try { + return fromBuffer(buf); + } + finally { + libmupdf._wasm_drop_buffer(buf); + } + } + asPSD() { + let buf = libmupdf._wasm_new_buffer_from_pixmap_as_psd(this.pointer); + try { + return fromBuffer(buf); + } + finally { + libmupdf._wasm_drop_buffer(buf); + } + } + asPAM() { + let buf = libmupdf._wasm_new_buffer_from_pixmap_as_pam(this.pointer); + try { + return fromBuffer(buf); + } + finally { + libmupdf._wasm_drop_buffer(buf); + } + } + asJPEG(quality, invert_cmyk = false) { + let buf = libmupdf._wasm_new_buffer_from_pixmap_as_jpeg(this.pointer, quality, invert_cmyk); + try { + return fromBuffer(buf); + } + finally { + libmupdf._wasm_drop_buffer(buf); + } + } + invert() { + libmupdf._wasm_invert_pixmap(this.pointer); + } + invertLuminance() { + libmupdf._wasm_invert_pixmap_luminance(this.pointer); + } + gamma(p) { + libmupdf._wasm_gamma_pixmap(this.pointer, p); + } + tint(black, white) { + let black_hex = 0x000000; + let white_hex = 0xffffff; + if (typeof black === "number") + black_hex = black; + else if (black instanceof Array && black.length === 3) + black_hex = (((black[0] * 255) << 16) | ((black[1] * 255) << 8) | ((black[2] * 255))); + if (typeof white === "number") + white_hex = white; + else if (white instanceof Array && white.length === 3) + white = (((white[0] * 255) << 16) | ((white[1] * 255) << 8) | ((white[2] * 255))); + libmupdf._wasm_tint_pixmap(this.pointer, black_hex, white_hex); + } + convertToColorSpace(colorspace, keepAlpha = false) { + checkType(colorspace, ColorSpace); + checkType(keepAlpha, "boolean"); + return new Pixmap(libmupdf._wasm_convert_pixmap(this.pointer, colorspace.pointer, keepAlpha)); + } + warp(points, width, height) { + let quad = points.flat(); + checkQuad(quad); + checkType(width, "number"); + checkType(height, "number"); + return new Pixmap(libmupdf._wasm_warp_pixmap(this.pointer, QUAD(quad), width, height)); + } +} +Pixmap._drop = libmupdf._wasm_drop_pixmap; +export class Shade extends Userdata { + getBounds() { + return fromRect(libmupdf._wasm_bound_shade(this.pointer)); + } +} +Shade._drop = libmupdf._wasm_drop_shade; +export class StructuredText extends Userdata { + walk(walker) { + let block = libmupdf._wasm_stext_page_get_first_block(this.pointer); + while (block) { + let block_type = libmupdf._wasm_stext_block_get_type(block); + let block_bbox = fromRect(libmupdf._wasm_stext_block_get_bbox(block)); + if (block_type === 0) { + if (walker.beginTextBlock) + walker.beginTextBlock(block_bbox); + let line = libmupdf._wasm_stext_block_get_first_line(block); + while (line) { + let line_bbox = fromRect(libmupdf._wasm_stext_line_get_bbox(line)); + let line_wmode = libmupdf._wasm_stext_line_get_wmode(line); + let line_dir = fromPoint(libmupdf._wasm_stext_line_get_dir(line)); + if (walker.beginLine) + walker.beginLine(line_bbox, line_wmode, line_dir); + if (walker.onChar) { + let ch = libmupdf._wasm_stext_line_get_first_char(line); + while (ch) { + let ch_rune = String.fromCharCode(libmupdf._wasm_stext_char_get_c(ch)); + let ch_origin = fromPoint(libmupdf._wasm_stext_char_get_origin(ch)); + let ch_font = new Font(libmupdf._wasm_stext_char_get_font(ch)); + let ch_size = libmupdf._wasm_stext_char_get_size(ch); + let ch_quad = fromQuad(libmupdf._wasm_stext_char_get_quad(ch)); + let ch_color = colorFromNumber(libmupdf._wasm_stext_char_get_argb(ch)); + let ch_bidi = libmupdf._wasm_stext_char_get_bidi(ch); + walker.onChar(ch_rune, ch_origin, ch_font, ch_size, ch_quad, ch_color, ch_bidi); + ch = libmupdf._wasm_stext_char_get_next(ch); + } + } + if (walker.endLine) + walker.endLine(); + line = libmupdf._wasm_stext_line_get_next(line); + } + if (walker.endTextBlock) + walker.endTextBlock(); + } + else if (block_type === 1) { + /* image */ + if (walker.onImageBlock) { + let matrix = fromMatrix(libmupdf._wasm_stext_block_get_transform(block)); + let image = new Image(libmupdf._wasm_stext_block_get_image(block)); + walker.onImageBlock(block_bbox, matrix, image); + } + } + else if (block_type === 2) { + /* struct */ + } + else if (block_type === 3) { + /* vector */ + if (walker.onVector) { + let v_flags_word = libmupdf._wasm_stext_block_get_v_flags(block); + let v_flags = { + isStroked: !!(v_flags_word & 1), + isRectangle: !!(v_flags_word & 2), + }; + let v_color = colorFromNumber(libmupdf._wasm_stext_block_get_v_argb(block)); + walker.onVector(block_bbox, v_flags, v_color); + } + } + else if (block_type === 4) { + /* grid */ + } + block = libmupdf._wasm_stext_block_get_next(block); + } + } + asJSON(scale = 1) { + return fromStringFree(libmupdf._wasm_print_stext_page_as_json(this.pointer, scale)); + } + asHTML(id) { + return fromStringFree(libmupdf._wasm_print_stext_page_as_html(this.pointer, id)); + } + asText() { + return fromStringFree(libmupdf._wasm_print_stext_page_as_text(this.pointer)); + } + snap(p, q, mode) { + let mm = ENUM(mode, StructuredText.SELECT_MODE); + return fromQuad(libmupdf._wasm_snap_selection(this.pointer, POINT(p), POINT2(q), mm)); + } + copy(p, q) { + return fromStringFree(libmupdf._wasm_copy_selection(this.pointer, POINT(p), POINT2(q))); + } + highlight(p, q, max_hits = 100) { + let hits = 0; + let result = []; + try { + hits = Malloc(32 * max_hits); + let n = libmupdf._wasm_highlight_selection(this.pointer, POINT(p), POINT2(q), hits, max_hits); + for (let i = 0; i < n; ++i) + result.push(fromQuad(hits + i * 32)); + } + finally { + Free(hits); + } + return result; + } + search(needle, options) { + return runSearch(libmupdf._wasm_search_stext_page, this.pointer, needle, options); + } +} +StructuredText._drop = libmupdf._wasm_drop_stext_page; +StructuredText.SELECT_MODE = [ + "chars", + "words", + "lines" +]; +StructuredText.SELECT_CHARS = "chars"; +StructuredText.SELECT_WORDS = "words"; +StructuredText.SELECT_LINES = "lines"; +export class Device extends Userdata { + constructor(pointer_or_callbacks) { + if (typeof pointer_or_callbacks === "number") + super(pointer_or_callbacks); + else { + let id = $libmupdf_device_id++; + $libmupdf_device_table.set(id, pointer_or_callbacks); + super(libmupdf._wasm_new_js_device(id)); + } + } + fillPath(path, evenOdd, ctm, colorspace, color, alpha) { + checkType(path, Path); + checkMatrix(ctm); + checkType(colorspace, ColorSpace); + checkColor(color); + libmupdf._wasm_fill_path(this.pointer, path.pointer, evenOdd, MATRIX(ctm), colorspace.pointer, COLOR(color), alpha); + } + strokePath(path, stroke, ctm, colorspace, color, alpha) { + checkType(path, Path); + checkType(stroke, StrokeState); + checkMatrix(ctm); + checkType(colorspace, ColorSpace); + checkColor(color); + libmupdf._wasm_stroke_path(this.pointer, path.pointer, stroke.pointer, MATRIX(ctm), colorspace.pointer, COLOR(color), alpha); + } + clipPath(path, evenOdd, ctm) { + checkType(path, Path); + checkMatrix(ctm); + libmupdf._wasm_clip_path(this.pointer, path.pointer, evenOdd, MATRIX(ctm)); + } + clipStrokePath(path, stroke, ctm) { + checkType(path, Path); + checkType(stroke, StrokeState); + checkMatrix(ctm); + libmupdf._wasm_clip_stroke_path(this.pointer, path.pointer, stroke.pointer, MATRIX(ctm)); + } + fillText(text, ctm, colorspace, color, alpha) { + checkType(text, Text); + checkMatrix(ctm); + checkType(colorspace, ColorSpace); + checkColor(color); + libmupdf._wasm_fill_text(this.pointer, text.pointer, MATRIX(ctm), colorspace.pointer, COLOR(color), alpha); + } + strokeText(text, stroke, ctm, colorspace, color, alpha) { + checkType(text, Text); + checkType(stroke, StrokeState); + checkMatrix(ctm); + checkType(colorspace, ColorSpace); + checkColor(color); + libmupdf._wasm_stroke_text(this.pointer, text.pointer, stroke.pointer, MATRIX(ctm), colorspace.pointer, COLOR(color), alpha); + } + clipText(text, ctm) { + checkType(text, Text); + checkMatrix(ctm); + libmupdf._wasm_clip_text(this.pointer, text.pointer, MATRIX(ctm)); + } + clipStrokeText(text, stroke, ctm) { + checkType(text, Text); + checkType(stroke, StrokeState); + checkMatrix(ctm); + libmupdf._wasm_clip_stroke_text(this.pointer, text.pointer, stroke.pointer, MATRIX(ctm)); + } + ignoreText(text, ctm) { + checkType(text, Text); + checkMatrix(ctm); + libmupdf._wasm_ignore_text(this.pointer, text.pointer, MATRIX(ctm)); + } + fillShade(shade, ctm, alpha) { + checkType(shade, Shade); + checkMatrix(ctm); + libmupdf._wasm_fill_shade(this.pointer, shade.pointer, MATRIX(ctm), alpha); + } + fillImage(image, ctm, alpha) { + checkType(image, Image); + checkMatrix(ctm); + libmupdf._wasm_fill_image(this.pointer, image.pointer, MATRIX(ctm), alpha); + } + fillImageMask(image, ctm, colorspace, color, alpha) { + checkType(image, Image); + checkMatrix(ctm); + checkType(colorspace, ColorSpace); + checkColor(color); + libmupdf._wasm_fill_image_mask(this.pointer, image.pointer, MATRIX(ctm), colorspace.pointer, COLOR(color), alpha); + } + clipImageMask(image, ctm) { + checkType(image, Image); + checkMatrix(ctm); + libmupdf._wasm_clip_image_mask(this.pointer, image.pointer, MATRIX(ctm)); + } + popClip() { + libmupdf._wasm_pop_clip(this.pointer); + } + beginMask(area, luminosity, colorspace, color) { + checkRect(area); + checkType(colorspace, ColorSpace); + checkColor(color); + libmupdf._wasm_begin_mask(this.pointer, RECT(area), luminosity, colorspace.pointer, COLOR(color)); + } + endMask() { + libmupdf._wasm_end_mask(this.pointer); + } + beginGroup(area, colorspace, isolated, knockout, blendmode, alpha) { + checkRect(area); + checkType(colorspace, ColorSpace); + let blendmode_ix = ENUM(blendmode, Device.BLEND_MODES); + libmupdf._wasm_begin_group(this.pointer, RECT(area), colorspace.pointer, isolated, knockout, blendmode_ix, alpha); + } + endGroup() { + libmupdf._wasm_end_group(this.pointer); + } + beginTile(area, view, xstep, ystep, ctm, id, doc_id) { + checkRect(area); + checkRect(view); + checkMatrix(ctm); + return libmupdf._wasm_begin_tile(this.pointer, RECT(area), RECT2(view), xstep, ystep, MATRIX(ctm), id, doc_id); + } + endTile() { + libmupdf._wasm_end_tile(this.pointer); + } + beginLayer(name) { + libmupdf._wasm_begin_layer(this.pointer, STRING(name)); + } + endLayer() { + libmupdf._wasm_end_layer(this.pointer); + } + close() { + libmupdf._wasm_close_device(this.pointer); + } +} +Device._drop = libmupdf._wasm_drop_device; +Device.BLEND_MODES = [ + "Normal", + "Multiply", + "Screen", + "Overlay", + "Darken", + "Lighten", + "ColorDodge", + "ColorBurn", + "HardLight", + "SoftLight", + "Difference", + "Exclusion", + "Hue", + "Saturation", + "Color", + "Luminosity", +]; +Device.BLEND_NORMAL = "Normal"; +Device.BLEND_MULTIPLY = "Multiply"; +Device.BLEND_SCREEN = "Screen"; +Device.BLEND_OVERLAY = "Overlay"; +Device.BLEND_DARKEN = "Darken"; +Device.BLEND_LIGHTEN = "Lighten"; +Device.BLEND_COLOR_DODGE = "ColorDodge"; +Device.BLEND_COLOR_BURN = "ColorBurn"; +Device.BLEND_HARD_LIGHT = "HardLight"; +Device.BLEND_SOFT_LIGHT = "SoftLight"; +Device.BLEND_DIFFERENCE = "Difference"; +Device.BLEND_EXCLUSION = "Exclusion"; +Device.BLEND_HUE = "Hue"; +Device.BLEND_SATURATION = "Saturation"; +Device.BLEND_COLOR = "Color"; +Device.BLEND_LUMINOSITY = "Luminosity"; +export class DrawDevice extends Device { + constructor(matrix, pixmap) { + checkMatrix(matrix); + checkType(pixmap, Pixmap); + super(libmupdf._wasm_new_draw_device(MATRIX(matrix), pixmap.pointer)); + } +} +export class DisplayListDevice extends Device { + constructor(displayList) { + checkType(displayList, DisplayList); + super(libmupdf._wasm_new_display_list_device(displayList.pointer)); + } +} +export class DocumentWriter extends Userdata { + constructor(buffer, format, options) { + options = ensureOptions(options); + super(libmupdf._wasm_new_document_writer_with_buffer(BUFFER(buffer), STRING(format), STRING2(options))); + } + beginPage(mediabox) { + checkRect(mediabox); + return new Device(libmupdf._wasm_keep_device(libmupdf._wasm_begin_page(this.pointer, RECT(mediabox)))); + } + endPage() { + libmupdf._wasm_end_page(this.pointer); + } + close() { + libmupdf._wasm_close_document_writer(this.pointer); + } +} +DocumentWriter._drop = libmupdf._wasm_drop_document_writer; +export class LinkDestination { + constructor(chapter = 0, page = 0, type = "Fit", x = NaN, y = NaN, width = NaN, height = NaN, zoom = NaN) { + this.chapter = chapter; + this.page = page; + this.type = type; + this.x = x; + this.y = y; + this.width = width; + this.height = height; + this.zoom = zoom; + } +} +LinkDestination.LINK_DEST = [ + "Fit", + "FitB", + "FitH", + "FitBH", + "FitV", + "FitBV", + "FitR", + "XYZ", +]; +LinkDestination.FIT = "Fit"; +LinkDestination.FIT_B = "FitB"; +LinkDestination.FIT_H = "FitH"; +LinkDestination.FIT_BH = "FitBH"; +LinkDestination.FIT_V = "FitV"; +LinkDestination.FIT_BV = "FitBV"; +LinkDestination.FIT_R = "FitR"; +LinkDestination.XYZ = "XYZ"; +export class Document extends Userdata { + static openDocument(from, magic) { + let pointer = 0; + let free_from = false; + if (typeof from === "string") { + magic = from; + if (node_fs) + from = node_fs.readFileSync(from); + else + throw new Error("missing 'fs' module"); + } + else { + if (typeof magic === "undefined") + magic = "application/pdf"; + } + checkType(magic, "string"); + if (from instanceof ArrayBuffer || from instanceof Uint8Array) { + from = new Buffer(from); + free_from = true; + } + if (from instanceof Buffer) + pointer = libmupdf._wasm_open_document_with_buffer(STRING(magic), from.pointer); + else if (from instanceof Stream) + pointer = libmupdf._wasm_open_document_with_stream(STRING(magic), from.pointer); + else + throw new Error("not a Buffer or Stream"); + if (free_from) { + // Destroy any implicit Buffer instances immediately! + // This may help the GC and FinalizationRegistry out when + // processing many documents without a pause. + from.destroy(); + } + let pdf = libmupdf._wasm_pdf_document_from_fz_document(pointer); + if (pdf) + return new PDFDocument(pdf); + return new Document(pointer); + } + formatLinkURI(dest) { + return fromStringFree(libmupdf._wasm_format_link_uri(this.pointer, dest.chapter | 0, dest.page | 0, ENUM(dest.type, LinkDestination.LINK_DEST), +dest.x, +dest.y, +dest.width, +dest.height, +dest.zoom)); + } + asPDF() { + if (this instanceof PDFDocument) + return this; + return null; + } + isPDF() { + return this instanceof PDFDocument; + } + needsPassword() { + return !!libmupdf._wasm_needs_password(this.pointer); + } + authenticatePassword(password) { + return libmupdf._wasm_authenticate_password(this.pointer, STRING(password)); + } + hasPermission(perm) { + let perm_ix = (typeof perm === "number") ? perm : Document.PERMISSION[perm]; + return !!libmupdf._wasm_has_permission(this.pointer, perm_ix); + } + getMetaData(key) { + let value = libmupdf._wasm_lookup_metadata(this.pointer, STRING(key)); + if (value) + return fromString(value); + return undefined; + } + setMetaData(key, value) { + libmupdf._wasm_set_metadata(this.pointer, STRING(key), STRING2(value)); + } + countPages() { + return libmupdf._wasm_count_pages(this.pointer); + } + isReflowable() { + libmupdf._wasm_is_document_reflowable(this.pointer); + } + style(publisherCSS, userCSS) { + checkType(publisherCSS, "boolean"); + checkType(userCSS, "string"); + libmupdf._wasm_style_document(this.pointer, publisherCSS, STRING(userCSS)); + } + layout(w, h, em) { + libmupdf._wasm_layout_document(this.pointer, w, h, em); + } + loadPage(index) { + let fz_ptr = libmupdf._wasm_load_page(this.pointer, index); + if (this instanceof PDFDocument) { + let pdf_ptr = libmupdf._wasm_pdf_page_from_fz_page(fz_ptr); + if (pdf_ptr) + return new PDFPage(this, pdf_ptr); + } + return new Page(fz_ptr); + } + loadOutline() { + let doc = this.pointer; + function to_outline(outline) { + let result = []; + while (outline) { + let title = libmupdf._wasm_outline_get_title(outline); + let uri = libmupdf._wasm_outline_get_uri(outline); + let open = libmupdf._wasm_outline_get_is_open(outline); + let item = { + title: title ? fromString(title) : undefined, + uri: uri ? fromString(uri) : undefined, + open: !!open, + }; + let page = libmupdf._wasm_outline_get_page(doc, outline); + if (page >= 0) + item.page = page; + let down = libmupdf._wasm_outline_get_down(outline); + if (down) + item.down = to_outline(down); + result.push(item); + outline = libmupdf._wasm_outline_get_next(outline); + } + return result; + } + let root = libmupdf._wasm_load_outline(doc); + if (root) + return to_outline(root); + return null; + } + resolveLink(link) { + if (link instanceof Link) + return libmupdf._wasm_resolve_link(this.pointer, libmupdf._wasm_link_get_uri(link.pointer)); + return libmupdf._wasm_resolve_link(this.pointer, STRING(link)); + } + resolveLinkDestination(link) { + let dest; + if (link instanceof Link) + dest = libmupdf._wasm_resolve_link_dest(this.pointer, libmupdf._wasm_link_get_uri(link.pointer)); + else + dest = libmupdf._wasm_resolve_link_dest(this.pointer, STRING(link)); + return { + type: LinkDestination.LINK_DEST[libmupdf._wasm_link_dest_get_type(dest)], + chapter: libmupdf._wasm_link_dest_get_chapter(dest), + page: libmupdf._wasm_link_dest_get_page(dest), + x: libmupdf._wasm_link_dest_get_x(dest), + y: libmupdf._wasm_link_dest_get_y(dest), + width: libmupdf._wasm_link_dest_get_w(dest), + height: libmupdf._wasm_link_dest_get_h(dest), + zoom: libmupdf._wasm_link_dest_get_zoom(dest), + }; + } + outlineIterator() { + return new OutlineIterator(libmupdf._wasm_new_outline_iterator(this.pointer)); + } +} +Document._drop = libmupdf._wasm_drop_document; +Document.META_FORMAT = "format"; +Document.META_ENCRYPTION = "encryption"; +Document.META_INFO_AUTHOR = "info:Author"; +Document.META_INFO_TITLE = "info:Title"; +Document.META_INFO_SUBJECT = "info:Subject"; +Document.META_INFO_KEYWORDS = "info:Keywords"; +Document.META_INFO_CREATOR = "info:Creator"; +Document.META_INFO_PRODUCER = "info:Producer"; +Document.META_INFO_CREATIONDATE = "info:CreationDate"; +Document.META_INFO_MODIFICATIONDATE = "info:ModDate"; +Document.PERMISSION_PRINT = "print"; +Document.PERMISSION_COPY = "copy"; +Document.PERMISSION_EDIT = "eedit"; +Document.PERMISSION_ANNOTATE = "annotate"; +Document.PERMISSION_FORM = "form"; +Document.PERMISSION_ACCESSIBILITY = "accessibility"; +Document.PERMISSION_ASSEMBLE = "assemble"; +Document.PERMISSION_PRINT_HQ = "print-hq"; +Document.PERMISSION = { + "print": "p".charCodeAt(0), + "copy": "c".charCodeAt(0), + "edit": "e".charCodeAt(0), + "annotate": "n".charCodeAt(0), + "form": "f".charCodeAt(0), + "accessibility": "y".charCodeAt(0), + "assemble": "a".charCodeAt(0), + "print-hq": "h".charCodeAt(0), +}; +export class OutlineIterator extends Userdata { + item() { + let item = libmupdf._wasm_outline_iterator_item(this.pointer); + if (item) { + let title_ptr = libmupdf._wasm_outline_item_get_title(item); + let uri_ptr = libmupdf._wasm_outline_item_get_uri(item); + let is_open = libmupdf._wasm_outline_item_get_is_open(item); + return { + title: title_ptr ? fromString(title_ptr) : undefined, + uri: uri_ptr ? fromString(uri_ptr) : undefined, + open: !!is_open, + }; + } + return null; + } + next() { + return libmupdf._wasm_outline_iterator_next(this.pointer); + } + prev() { + return libmupdf._wasm_outline_iterator_prev(this.pointer); + } + up() { + return libmupdf._wasm_outline_iterator_up(this.pointer); + } + down() { + return libmupdf._wasm_outline_iterator_down(this.pointer); + } + delete() { + return libmupdf._wasm_outline_iterator_delete(this.pointer); + } + insert(item) { + return libmupdf._wasm_outline_iterator_insert(this.pointer, STRING_OPT(item.title), STRING2_OPT(item.uri), item.open); + } + update(item) { + libmupdf._wasm_outline_iterator_update(this.pointer, STRING_OPT(item.title), STRING2_OPT(item.uri), item.open); + } +} +OutlineIterator._drop = libmupdf._wasm_drop_outline_iterator; +OutlineIterator.ITERATOR_DID_NOT_MOVE = -1; +OutlineIterator.ITERATOR_AT_ITEM = 0; +OutlineIterator.ITERATOR_AT_EMPTY = 1; +OutlineIterator.FLAG_BOLD = 1; +OutlineIterator.FLAG_ITALIC = 2; +export class Link extends Userdata { + getBounds() { + return fromRect(libmupdf._wasm_link_get_rect(this.pointer)); + } + setBounds(rect) { + checkRect(rect); + libmupdf._wasm_link_set_rect(this.pointer, RECT(rect)); + } + getURI() { + return fromString(libmupdf._wasm_link_get_uri(this.pointer)); + } + setURI(uri) { + checkType(uri, "string"); + libmupdf._wasm_link_set_uri(this.pointer, STRING(uri)); + } + isExternal() { + return /^\w[\w+-.]*:/.test(this.getURI()); + } +} +Link._drop = libmupdf._wasm_drop_link; +export class Page extends Userdata { + isPDF() { + return this instanceof PDFPage; + } + getBounds(box = "CropBox") { + let box_ix = ENUM(box, Page.BOXES); + return fromRect(libmupdf._wasm_bound_page(this.pointer, box_ix)); + } + getLabel() { + return fromString(libmupdf._wasm_page_label(this.pointer)); + } + run(device, matrix) { + checkType(device, Device); + checkMatrix(matrix); + libmupdf._wasm_run_page(this.pointer, device.pointer, MATRIX(matrix)); + } + runPageContents(device, matrix) { + checkType(device, Device); + checkMatrix(matrix); + libmupdf._wasm_run_page_contents(this.pointer, device.pointer, MATRIX(matrix)); + } + runPageAnnots(device, matrix) { + checkType(device, Device); + checkMatrix(matrix); + libmupdf._wasm_run_page_annots(this.pointer, device.pointer, MATRIX(matrix)); + } + runPageWidgets(device, matrix) { + checkType(device, Device); + checkMatrix(matrix); + libmupdf._wasm_run_page_widgets(this.pointer, device.pointer, MATRIX(matrix)); + } + toPixmap(matrix, colorspace, alpha = false, showExtras = true) { + checkType(colorspace, ColorSpace); + checkMatrix(matrix); + let result; + if (showExtras) + result = libmupdf._wasm_new_pixmap_from_page(this.pointer, MATRIX(matrix), colorspace.pointer, alpha); + else + result = libmupdf._wasm_new_pixmap_from_page_contents(this.pointer, MATRIX(matrix), colorspace.pointer, alpha); + return new Pixmap(result); + } + toDisplayList(showExtras = true) { + let result; + if (showExtras) + result = libmupdf._wasm_new_display_list_from_page(this.pointer); + else + result = libmupdf._wasm_new_display_list_from_page_contents(this.pointer); + return new DisplayList(result); + } + toStructuredText(options) { + options = ensureOptions(options); + return new StructuredText(libmupdf._wasm_new_stext_page_from_page(this.pointer, STRING(options))); + } + getLinks() { + let links = []; + let link = libmupdf._wasm_load_links(this.pointer); + while (link) { + links.push(new Link(libmupdf._wasm_keep_link(link))); + link = libmupdf._wasm_link_get_next(link); + } + return links; + } + createLink(bbox, uri) { + checkRect(bbox); + return new Link(libmupdf._wasm_create_link(this.pointer, RECT(bbox), STRING(uri))); + } + deleteLink(link) { + checkType(link, Link); + libmupdf._wasm_delete_link(this.pointer, link.pointer); + } + search(needle, options) { + return runSearch(libmupdf._wasm_search_page, this.pointer, needle, options); + } +} +Page._drop = libmupdf._wasm_drop_page; +Page.BOXES = [ + "MediaBox", + "CropBox", + "BleedBox", + "TrimBox", + "ArtBox" +]; +Page.MEDIA_BOX = "MediaBox"; +Page.CROP_BOX = "CropBox"; +Page.BLEED_BOX = "BleedBox"; +Page.TRIM_BOX = "TrimBox"; +Page.ART_BOX = "ArtBox"; +/* -------------------------------------------------------------------------- */ +export class PDFDocument extends Document { + constructor(arg1) { + if (typeof arg1 === "undefined") + super(libmupdf._wasm_pdf_create_document()); + else if (typeof arg1 === "number") + super(arg1); + else if (arg1 instanceof PDFDocument) { + super(arg1.pointer); + libmupdf._wasm_keep_document(this.pointer); + } + else { + let doc = Document.openDocument(arg1, "application/pdf"); + if (doc instanceof PDFDocument) + return doc; + throw new Error("not a PDF document"); + } + } + loadPage(index) { + return super.loadPage(index); + } + // PDFObject instances are always bound to a document, so the WASM/JS value interface lives here. + // Wrap a pdf_obj in a Userdata object. The pointer must be newly created or we already own it. + _fromPDFObjectNew(ptr) { + if (ptr === 0) + return PDFObject.Null; + return new PDFObject(this, ptr); + } + // Wrap a pdf_obj in a Userdata object. The pointer must be a borrowed pointer, so we have to take ownership. + _fromPDFObjectKeep(ptr) { + if (ptr === 0) + return PDFObject.Null; + return new PDFObject(this, libmupdf._wasm_pdf_keep_obj(ptr)); + } + _toPDFObject(obj) { + if (obj instanceof PDFObject) + return obj; + if (obj === null || obj === undefined) + return this.newNull(); + if (typeof obj === "string") { + // if a JS string is surrounded by parens, convert it to a PDF string + if (obj.startsWith("(") && obj.endsWith(")")) + return this.newString(obj.slice(1, -1)); + // otherwise treat it as a name + return this.newName(obj); + } + if (typeof obj === "number") { + if (obj === (obj | 0)) + return this.newInteger(obj); + return this.newReal(obj); + } + if (typeof obj === "boolean") + return this.newBoolean(obj); + if (obj instanceof Array) { + let result = this.newArray(); + for (let item of obj) + result.push(item); + return result; + } + if (obj instanceof Object) { + let result = this.newDictionary(); + for (let key in obj) + result.put(key, obj[key]); + return result; + } + throw new TypeError("cannot convert value to PDFObject"); + } + _PDFOBJ(obj) { + // Note: We have to create a PDFObject instance for garbage collection. + return this._toPDFObject(obj).pointer; + } + getVersion() { + return libmupdf._wasm_pdf_version(this.pointer); + } + getLanguage() { + return fromStringOrNull(libmupdf._wasm_pdf_document_language(this.pointer)); + } + setLanguage(lang) { + libmupdf._wasm_pdf_set_document_language(this.pointer, STRING(lang)); + } + countObjects() { + return libmupdf._wasm_pdf_xref_len(this.pointer); + } + getTrailer() { + return new PDFObject(this, libmupdf._wasm_pdf_trailer(this.pointer)); + } + createObject() { + let num = libmupdf._wasm_pdf_create_object(this.pointer); + return this._fromPDFObjectNew(libmupdf._wasm_pdf_new_indirect(this.pointer, num)); + } + newNull() { return PDFObject.Null; } + newBoolean(v) { return this._fromPDFObjectNew(libmupdf._wasm_pdf_new_bool(v)); } + newInteger(v) { return this._fromPDFObjectNew(libmupdf._wasm_pdf_new_int(v)); } + newReal(v) { return this._fromPDFObjectNew(libmupdf._wasm_pdf_new_real(v)); } + newName(v) { return this._fromPDFObjectNew(libmupdf._wasm_pdf_new_name(STRING(v))); } + newString(v) { return this._fromPDFObjectNew(libmupdf._wasm_pdf_new_text_string(STRING(v))); } + newByteString(v) { + if (v instanceof Array) + v = Uint8Array.from(v); + checkType(v, Uint8Array); + let len = v.byteLength; + let ptr = Malloc(len); + libmupdf.HEAPU8.set(v, ptr); + try { + return this._fromPDFObjectNew(libmupdf._wasm_pdf_new_string(ptr, len)); + } + finally { + Free(ptr); + } + } + newIndirect(v) { return this._fromPDFObjectNew(libmupdf._wasm_pdf_new_indirect(this.pointer, v)); } + newArray() { return this._fromPDFObjectNew(libmupdf._wasm_pdf_new_array(this.pointer)); } + newDictionary() { return this._fromPDFObjectNew(libmupdf._wasm_pdf_new_dict(this.pointer)); } + deleteObject(num) { + if (num instanceof PDFObject) + num = num.asIndirect(); + else + checkType(num, "number"); + libmupdf._wasm_pdf_delete_object(this.pointer, num); + } + addObject(obj) { + return this._fromPDFObjectNew(libmupdf._wasm_pdf_add_object(this.pointer, this._PDFOBJ(obj))); + } + addStream(buf, obj) { + return this._fromPDFObjectNew(libmupdf._wasm_pdf_add_stream(this.pointer, BUFFER(buf), this._PDFOBJ(obj), 0)); + } + addRawStream(buf, obj) { + return this._fromPDFObjectNew(libmupdf._wasm_pdf_add_stream(this.pointer, BUFFER(buf), this._PDFOBJ(obj), 1)); + } + newGraftMap() { + return new PDFGraftMap(this, libmupdf._wasm_pdf_new_graft_map(this.pointer)); + } + graftObject(obj) { + checkType(obj, PDFObject); + return this._fromPDFObjectNew(libmupdf._wasm_pdf_graft_object(this.pointer, obj.pointer)); + } + graftPage(to, srcDoc, srcPage) { + checkType(to, "number"); + checkType(srcDoc, PDFDocument); + checkType(srcPage, "number"); + libmupdf._wasm_pdf_graft_page(this.pointer, to, srcDoc.pointer, srcPage); + } + addSimpleFont(font, encoding = "Latin") { + checkType(font, Font); + var encoding_ix = ENUM(encoding, Font.SIMPLE_ENCODING); + return this._fromPDFObjectNew(libmupdf._wasm_pdf_add_simple_font(this.pointer, font.pointer, encoding_ix)); + } + addCJKFont(font, lang, wmode = 0, serif = true) { + checkType(font, Font); + if (typeof lang === "string") + lang = Font.CJK_ORDERING_BY_LANG[lang]; + return this._fromPDFObjectNew(libmupdf._wasm_pdf_add_cjk_font(this.pointer, font.pointer, lang, wmode, serif)); + } + addFont(font) { + checkType(font, Font); + return this._fromPDFObjectNew(libmupdf._wasm_pdf_add_cid_font(this.pointer, font.pointer)); + } + addImage(image) { + checkType(image, Image); + return this._fromPDFObjectNew(libmupdf._wasm_pdf_add_image(this.pointer, image.pointer)); + } + loadImage(ref) { + checkType(ref, PDFObject); + return new Image(libmupdf._wasm_pdf_load_image(this.pointer, ref.pointer)); + } + findPage(index) { + checkType(index, "number"); + return this._fromPDFObjectKeep(libmupdf._wasm_pdf_lookup_page_obj(this.pointer, index)); + } + setPageTreeCache(enabled) { + checkType(enabled, "boolean"); + libmupdf._wasm_pdf_set_page_tree_cache(this.pointer, enabled); + } + addPage(mediabox, rotate, resources, contents) { + checkRect(mediabox); + checkType(rotate, "number"); + return this._fromPDFObjectNew(libmupdf._wasm_pdf_add_page(this.pointer, RECT(mediabox), rotate, this._PDFOBJ(resources), BUFFER(contents))); + } + insertPage(at, obj) { + checkType(at, "number"); + libmupdf._wasm_pdf_insert_page(this.pointer, at, this._PDFOBJ(obj)); + } + deletePage(at) { + checkType(at, "number"); + libmupdf._wasm_pdf_delete_page(this.pointer, at); + } + isEmbeddedFile(ref) { + checkType(ref, PDFObject); + return !!libmupdf._wasm_pdf_is_embedded_file(ref.pointer); + } + addEmbeddedFile(filename, mimetype, contents, created, modified, checksum = false) { + checkType(filename, "string"); + checkType(mimetype, "string"); + checkType(created, Date); + checkType(modified, Date); + checkType(checksum, "boolean"); + return this._fromPDFObjectNew(libmupdf._wasm_pdf_add_embedded_file(this.pointer, STRING(filename), STRING2(mimetype), BUFFER(contents), created.getTime() / 1000 | 0, modified.getTime() / 1000 | 0, checksum)); + } + getFilespecParams(ref) { + checkType(ref, PDFObject); + let ptr = libmupdf._wasm_pdf_get_filespec_params(ref.pointer); + return { + filename: fromString(libmupdf._wasm_pdf_filespec_params_get_filename(ptr)), + mimetype: fromString(libmupdf._wasm_pdf_filespec_params_get_mimetype(ptr)), + size: libmupdf._wasm_pdf_filespec_params_get_filename(ptr), + creationDate: new Date(libmupdf._wasm_pdf_filespec_params_get_created(ptr) * 1000), + modificationDate: new Date(libmupdf._wasm_pdf_filespec_params_get_modified(ptr) * 1000), + }; + } + getEmbeddedFileContents(ref) { + checkType(ref, PDFObject); + let contents = libmupdf._wasm_pdf_load_embedded_file_contents(ref.pointer); + if (contents) + return new Buffer(contents); + return null; + } + getEmbeddedFiles() { + function _getEmbeddedFilesRec(result, N) { + var i, n; + if (N.isDictionary()) { + var NN = N.get("Names"); + if (NN) + for (i = 0, n = NN.length; i < n; i += 2) + result[NN.get(i + 0).asString()] = NN.get(i + 1); + var NK = N.get("Kids"); + if (NK) + for (i = 0, n = NK.length; i < n; i += 1) + _getEmbeddedFilesRec(result, NK.get(i)); + } + return result; + } + return _getEmbeddedFilesRec({}, this.getTrailer().get("Root", "Names", "EmbeddedFiles")); + } + loadNameTree(treeName) { + function _loadNameTreeRec(dict, node) { + var kids = node.get("Kids"); + if (kids && kids.isArray()) + for (var i = 0; i < kids.length; i += 1) + _loadNameTreeRec(dict, kids.get(i)); + var names = node.get("Names"); + if (names && names.isArray()) + for (var i = 0; i < names.length; i += 2) + dict[names.get(i).asString()] = names.get(i + 1); + } + var node = this.getTrailer().get("Root").get("Names").get(treeName); + var dict = {}; + if (node.isDictionary()) + _loadNameTreeRec(dict, node); + return dict; + } + insertEmbeddedFile(filename, filespec) { + var efs = this.getEmbeddedFiles(); + efs[filename] = filespec; + this._rewriteEmbeddedFiles(efs); + } + deleteEmbeddedFile(filename) { + var efs = this.getEmbeddedFiles(); + delete efs[filename]; + this._rewriteEmbeddedFiles(efs); + } + _rewriteEmbeddedFiles(efs) { + var efs_keys = Object.keys(efs); + efs_keys.sort(); + var root = this.getTrailer().get("Root"); + var root_names = root.get("Names"); + if (!root_names.isDictionary()) + root_names = root.put("Names", this.newDictionary()); + var root_names_efs = root_names.put("EmbeddedFiles", this.newDictionary()); + var root_names_efs_names = root_names_efs.put("Names", this.newArray()); + for (var key of efs_keys) { + root_names_efs_names.push(this.newString(key)); + root_names_efs_names.push(efs[key]); + } + } + saveToBuffer(options) { + options = ensureOptions(options); + return new Buffer(libmupdf._wasm_pdf_write_document_buffer(this.pointer, STRING(options))); + } + save(filename, options) { + if (node_fs) + node_fs.writeFileSync(filename, this.saveToBuffer(options).asUint8Array()); + else + throw new Error("missing 'fs' module"); + } + setPageLabels(index, style = "D", prefix = "", start = 1) { + libmupdf._wasm_pdf_set_page_labels(this.pointer, index, style.charCodeAt(0), STRING(prefix), start); + } + deletePageLabels(index) { + libmupdf._wasm_pdf_delete_page_labels(this.pointer, index); + } + wasRepaired() { + return !!libmupdf._wasm_pdf_was_repaired(this.pointer); + } + hasUnsavedChanges() { + return !!libmupdf._wasm_pdf_has_unsaved_changes(this.pointer); + } + countVersions() { + return libmupdf._wasm_pdf_count_versions(this.pointer); + } + countUnsavedVersions() { + return libmupdf._wasm_pdf_count_unsaved_versions(this.pointer); + } + validateChangeHistory() { + return libmupdf._wasm_pdf_validate_change_history(this.pointer); + } + canBeSavedIncrementally() { + return !!libmupdf._wasm_pdf_can_be_saved_incrementally(this.pointer); + } + enableJournal() { + libmupdf._wasm_pdf_enable_journal(this.pointer); + } + getJournal() { + let position = libmupdf._wasm_pdf_undoredo_state_position(this.pointer); + let n = libmupdf._wasm_pdf_undoredo_state_count(this.pointer); + let steps = []; + for (let i = 0; i < n; ++i) + steps.push(fromString(libmupdf._wasm_pdf_undoredo_step(this.pointer, i))); + return { position, steps }; + } + beginOperation(op) { + libmupdf._wasm_pdf_begin_operation(this.pointer, STRING(op)); + } + beginImplicitOperation() { + libmupdf._wasm_pdf_begin_implicit_operation(this.pointer); + } + endOperation() { + libmupdf._wasm_pdf_end_operation(this.pointer); + } + abandonOperation() { + libmupdf._wasm_pdf_abandon_operation(this.pointer); + } + canUndo() { + return !!libmupdf._wasm_pdf_can_undo(this.pointer); + } + canRedo() { + return !!libmupdf._wasm_pdf_can_redo(this.pointer); + } + undo() { + libmupdf._wasm_pdf_undo(this.pointer); + } + redo() { + libmupdf._wasm_pdf_redo(this.pointer); + } + isJSSupported() { + return !!libmupdf._wasm_pdf_js_supported(this.pointer); + } + enableJS() { + libmupdf._wasm_pdf_enable_js(this.pointer); + } + disableJS() { + libmupdf._wasm_pdf_disable_js(this.pointer); + } + setJSEventListener(_listener) { + throw "TODO"; + } + rearrangePages(pages) { + let n = pages.length; + let ptr = Malloc(n << 2); + for (let i = 0; i < n; ++i) + libmupdf.HEAPU32[(ptr >> 2) + i] = pages[i] || 0; + try { + libmupdf._wasm_pdf_rearrange_pages(this.pointer, n, ptr); + } + finally { + Free(ptr); + } + } + subsetFonts() { + libmupdf._wasm_pdf_subset_fonts(this.pointer); + } + bake(bakeAnnots = true, bakeWidgets = true) { + libmupdf._wasm_pdf_bake_document(this.pointer, bakeAnnots, bakeWidgets); + } + countLayerConfigs() { + return libmupdf._wasm_pdf_count_layer_configs(this.pointer); + } + getLayerConfigCreator(config) { + return fromString(libmupdf._wasm_pdf_layer_config_creator(this.pointer, config)); + } + getLayerConfigName(config) { + return fromString(libmupdf._wasm_pdf_layer_config_name(this.pointer, config)); + } + selectLayerConfig(config) { + libmupdf._wasm_pdf_select_layer_config(this.pointer, config); + } + countLayerConfigUIs() { + return libmupdf._wasm_pdf_count_layer_config_uis(this.pointer); + } + getLayerConfigUIInfo(configui) { + return fromLayerConfigUIInfo(libmupdf._wasm_pdf_layer_config_ui_info(this.pointer, configui)); + } + countLayers() { + return libmupdf._wasm_pdf_count_layers(this.pointer); + } + isLayerVisible(layer) { + return !!libmupdf._wasm_pdf_layer_is_enabled(this.pointer, layer); + } + setLayerVisible(layer, visible) { + libmupdf._wasm_pdf_enable_layer(this.pointer, layer, Number(visible)); + } + getLayerName(layer) { + return fromString(libmupdf._wasm_pdf_layer_name(this.pointer, layer)); + } + resetForm(fields, exclude) { + libmupdf._wasm_pdf_reset_form(this.pointer, this._PDFOBJ(fields), Number(exclude)); + } +} +PDFDocument.PAGE_LABEL_NONE = "\0"; +PDFDocument.PAGE_LABEL_DECIMAL = "D"; +PDFDocument.PAGE_LABEL_ROMAN_UC = "R"; +PDFDocument.PAGE_LABEL_ROMAN_LC = "r"; +PDFDocument.PAGE_LABEL_ALPHA_UC = "A"; +PDFDocument.PAGE_LABEL_ALPHA_LC = "a"; +export class PDFPage extends Page { + // PRIVATE + constructor(doc, pointer) { + super(pointer); + this._doc = doc; + this._annots = null; + this._widgets = null; + } + getObject() { + return this._doc._fromPDFObjectKeep(libmupdf._wasm_pdf_page_get_obj(this.pointer)); + } + getTransform() { + return fromMatrix(libmupdf._wasm_pdf_page_transform(this.pointer)); + } + setPageBox(box, rect) { + let box_ix = ENUM(box, Page.BOXES); + checkRect(rect); + libmupdf._wasm_pdf_set_page_box(this.pointer, box_ix, RECT(rect)); + } + toPixmap(matrix, colorspace, alpha = false, showExtras = true, usage = "View", box = "CropBox") { + checkMatrix(matrix); + checkType(colorspace, ColorSpace); + let box_ix = ENUM(box, Page.BOXES); + let result; + if (showExtras) + result = libmupdf._wasm_pdf_new_pixmap_from_page_with_usage(this.pointer, MATRIX(matrix), colorspace.pointer, alpha, STRING(usage), box_ix); + else + result = libmupdf._wasm_pdf_new_pixmap_from_page_contents_with_usage(this.pointer, MATRIX(matrix), colorspace.pointer, alpha, STRING(usage), box_ix); + return new Pixmap(result); + } + getWidgets() { + if (!this._widgets) { + this._widgets = []; + let widget = libmupdf._wasm_pdf_first_widget(this.pointer); + while (widget) { + this._widgets.push(new PDFWidget(this._doc, libmupdf._wasm_pdf_keep_annot(widget))); + widget = libmupdf._wasm_pdf_next_widget(widget); + } + } + return this._widgets; + } + getAnnotations() { + if (!this._annots) { + this._annots = []; + let annot = libmupdf._wasm_pdf_first_annot(this.pointer); + while (annot) { + this._annots.push(new PDFAnnotation(this._doc, libmupdf._wasm_pdf_keep_annot(annot))); + annot = libmupdf._wasm_pdf_next_annot(annot); + } + } + return this._annots; + } + createAnnotation(type) { + let type_ix = ENUM(type, PDFAnnotation.ANNOT_TYPES); + let annot = new PDFAnnotation(this._doc, libmupdf._wasm_pdf_create_annot(this.pointer, type_ix)); + if (this._annots) + this._annots.push(annot); + return annot; + } + deleteAnnotation(annot) { + checkType(annot, PDFAnnotation); + libmupdf._wasm_pdf_delete_annot(this.pointer, annot.pointer); + if (this._annots) { + let ix = this._annots.indexOf(annot); + if (ix >= 0) + this._annots.splice(ix, 1); + } + } + applyRedactions(black_boxes = true, image_method = 2, line_art_method = 1, text_method = 0) { + libmupdf._wasm_pdf_redact_page(this.pointer, Number(black_boxes), image_method, line_art_method, text_method); + } + update() { + return !!libmupdf._wasm_pdf_update_page(this.pointer); + } +} +PDFPage.REDACT_IMAGE_NONE = 0; +PDFPage.REDACT_IMAGE_REMOVE = 1; +PDFPage.REDACT_IMAGE_PIXELS = 2; +PDFPage.REDACT_IMAGE_UNLESS_INVISIBLE = 3; +PDFPage.REDACT_LINE_ART_NONE = 0; +PDFPage.REDACT_LINE_ART_REMOVE_IF_COVERED = 1; +PDFPage.REDACT_LINE_ART_REMOVE_IF_TOUCHED = 2; +PDFPage.REDACT_TEXT_REMOVE = 0; +PDFPage.REDACT_TEXT_NONE = 1; +export class PDFObject extends Userdata { + // PRIVATE + constructor(doc, pointer) { + super(libmupdf._wasm_pdf_keep_obj(pointer)); + this._doc = doc; + } + isNull() { return this === PDFObject.Null; } + isIndirect() { return !!libmupdf._wasm_pdf_is_indirect(this.pointer); } + isBoolean() { return !!libmupdf._wasm_pdf_is_bool(this.pointer); } + isInteger() { return !!libmupdf._wasm_pdf_is_int(this.pointer); } + isReal() { return !!libmupdf._wasm_pdf_is_real(this.pointer); } + isNumber() { return !!libmupdf._wasm_pdf_is_number(this.pointer); } + isName() { return !!libmupdf._wasm_pdf_is_name(this.pointer); } + isString() { return !!libmupdf._wasm_pdf_is_string(this.pointer); } + isArray() { return !!libmupdf._wasm_pdf_is_array(this.pointer); } + isDictionary() { return !!libmupdf._wasm_pdf_is_dict(this.pointer); } + isStream() { return !!libmupdf._wasm_pdf_is_stream(this.pointer); } + asIndirect() { return libmupdf._wasm_pdf_to_num(this.pointer); } + asBoolean() { return !!libmupdf._wasm_pdf_to_bool(this.pointer); } + asNumber() { return libmupdf._wasm_pdf_to_real(this.pointer); } + asName() { return fromString(libmupdf._wasm_pdf_to_name(this.pointer)); } + asString() { return fromString(libmupdf._wasm_pdf_to_text_string(this.pointer)); } + asByteString() { + let ptr = libmupdf._wasm_pdf_to_string(this.pointer, _wasm_int); + let len = libmupdf.HEAPU32[_wasm_int >> 2]; + return libmupdf.HEAPU8.slice(ptr, ptr + len); + } + readStream() { return new Buffer(libmupdf._wasm_pdf_load_stream(this.pointer)); } + readRawStream() { return new Buffer(libmupdf._wasm_pdf_load_raw_stream(this.pointer)); } + writeObject(obj) { + if (!this.isIndirect()) + throw new TypeError("can only call PDFObject.writeObject on an indirect reference"); + libmupdf._wasm_pdf_update_object(this._doc.pointer, this.asIndirect(), this._doc._PDFOBJ(obj)); + } + writeStream(buf) { + if (!this.isIndirect()) + throw new TypeError("can only call PDFObject.writeStream on an indirect reference"); + libmupdf._wasm_pdf_update_stream(this._doc.pointer, this.pointer, BUFFER(buf), 0); + } + writeRawStream(buf) { + if (!this.isIndirect()) + throw new TypeError("can only call PDFObject.writeRawStream on an indirect reference"); + libmupdf._wasm_pdf_update_stream(this._doc.pointer, this.pointer, BUFFER(buf), 1); + } + resolve() { + return this._doc._fromPDFObjectKeep(libmupdf._wasm_pdf_resolve_indirect(this.pointer)); + } + get length() { + return libmupdf._wasm_pdf_array_len(this.pointer); + } + set length(_) { + throw new TypeError("object length is read-only"); + } + _get(path) { + let obj = this.pointer; + for (let key of path) { + if (typeof key === "number") + obj = libmupdf._wasm_pdf_array_get(obj, key); + else if (key instanceof PDFObject) + obj = libmupdf._wasm_pdf_dict_get(obj, key.pointer); + else + obj = libmupdf._wasm_pdf_dict_gets(obj, STRING(key)); + if (obj === 0) + break; + } + return obj; + } + get(...path) { + return this._doc._fromPDFObjectKeep(this._get(path)); + } + getInheritable(key) { + if (key instanceof PDFObject) + return this._doc._fromPDFObjectKeep(libmupdf._wasm_pdf_dict_get_inheritable(this.pointer, key.pointer)); + return this._doc._fromPDFObjectKeep(libmupdf._wasm_pdf_dict_gets_inheritable(this.pointer, STRING(key))); + } + put(key, value) { + value = this._doc._toPDFObject(value); + if (typeof key === "number") + libmupdf._wasm_pdf_array_put(this.pointer, key, value.pointer); + else if (key instanceof PDFObject) + libmupdf._wasm_pdf_dict_put(this.pointer, key.pointer, value.pointer); + else + libmupdf._wasm_pdf_dict_puts(this.pointer, STRING(key), value.pointer); + return value; + } + push(value) { + value = this._doc._toPDFObject(value); + libmupdf._wasm_pdf_array_push(this.pointer, value.pointer); + return value; + } + delete(key) { + if (typeof key === "number") + libmupdf._wasm_pdf_array_delete(this.pointer, key); + else if (key instanceof PDFObject) + libmupdf._wasm_pdf_dict_del(this.pointer, key.pointer); + else + libmupdf._wasm_pdf_dict_dels(this.pointer, STRING(key)); + } + valueOf() { + if (this.isNull()) + return null; + if (this.isBoolean()) + return this.asBoolean(); + if (this.isNumber()) + return this.asNumber(); + if (this.isName()) + return this.asName(); + if (this.isString()) + return this.asString(); + if (this.isIndirect()) + return `${this.asIndirect()} 0 R`; + return this; + } + toString(tight = true, ascii = true) { + return fromStringFree(libmupdf._wasm_pdf_sprint_obj(this.pointer, tight, ascii)); + } + forEach(fn) { + if (this.isArray()) { + let n = this.length; + for (let i = 0; i < n; ++i) + fn(this.get(i), i, this); + } + else if (this.isDictionary()) { + let n = libmupdf._wasm_pdf_dict_len(this.pointer); + for (let i = 0; i < n; ++i) { + let key = this._doc._fromPDFObjectKeep(libmupdf._wasm_pdf_dict_get_key(this.pointer, i)); + let val = this._doc._fromPDFObjectKeep(libmupdf._wasm_pdf_dict_get_val(this.pointer, i)); + fn(val, key.asName(), this); + } + } + } + // Convert to plain Javascript values, objects, and arrays. + // If you want to resolve indirect references, pass an empty object or array as the first argument. + // On exit, this object will contain all indirect objects encountered indexed by object number. + // Note: This function will omit cyclic references. + asJS(seen) { + if (this.isIndirect()) { + let ref = this.asIndirect(); + if (!seen) + return `${ref} 0 R`; + if (ref in seen) + return seen[ref]; + seen[ref] = PDFObject.Null; // stop recursion! + return seen[ref] = this.resolve().asJS(seen); + } + if (this.isArray()) { + let result = []; + this.forEach(val => { + result.push(val.asJS(seen)); + }); + return result; + } + if (this.isDictionary()) { + let result = {}; + this.forEach((val, key) => { + result[key] = val.asJS(seen); + }); + return result; + } + return this.valueOf(); + } +} +PDFObject._drop = libmupdf._wasm_pdf_drop_obj; +PDFObject.Null = new PDFObject(null, 0); +export class PDFGraftMap extends Userdata { + // PRIVATE + constructor(doc, pointer) { + super(pointer); + this._doc = doc; + } + graftObject(obj) { + checkType(obj, PDFObject); + return this._doc._fromPDFObjectNew(libmupdf._wasm_pdf_graft_mapped_object(this.pointer, obj.pointer)); + } + graftPage(to, srcDoc, srcPage) { + checkType(to, "number"); + checkType(srcDoc, PDFDocument); + checkType(srcPage, "number"); + libmupdf._wasm_pdf_graft_mapped_page(this.pointer, to, srcDoc.pointer, srcPage); + } +} +PDFGraftMap._drop = libmupdf._wasm_pdf_drop_graft_map; +export class PDFAnnotation extends Userdata { + // PRIVATE + constructor(doc, pointer) { + super(pointer); + this._doc = doc; + } + getObject() { + return this._doc._fromPDFObjectKeep(libmupdf._wasm_pdf_annot_obj(this.pointer)); + } + getBounds() { + return fromRect(libmupdf._wasm_pdf_bound_annot(this.pointer)); + } + run(device, matrix) { + checkType(device, Device); + checkMatrix(matrix); + libmupdf._wasm_pdf_run_annot(this.pointer, device.pointer, MATRIX(matrix)); + } + toPixmap(matrix, colorspace, alpha = false) { + checkMatrix(matrix); + checkType(colorspace, ColorSpace); + return new Pixmap(libmupdf._wasm_pdf_new_pixmap_from_annot(this.pointer, MATRIX(matrix), colorspace.pointer, alpha)); + } + toDisplayList() { + return new DisplayList(libmupdf._wasm_pdf_new_display_list_from_annot(this.pointer)); + } + update() { + return !!libmupdf._wasm_pdf_update_annot(this.pointer); + } + getType() { + let type = libmupdf._wasm_pdf_annot_type(this.pointer); + return PDFAnnotation.ANNOT_TYPES[type] || "Text"; + } + getLanguage() { + return fromStringOrNull(libmupdf._wasm_pdf_annot_language(this.pointer)); + } + setLanguage(lang) { + libmupdf._wasm_pdf_set_annot_language(this.pointer, STRING(lang)); + } + getFlags() { + return libmupdf._wasm_pdf_annot_flags(this.pointer); + } + setFlags(flags) { + return libmupdf._wasm_pdf_set_annot_flags(this.pointer, flags); + } + getContents() { + return fromString(libmupdf._wasm_pdf_annot_contents(this.pointer)); + } + setContents(text) { + libmupdf._wasm_pdf_set_annot_contents(this.pointer, STRING(text)); + } + getName() { + return fromString(libmupdf._wasm_pdf_annot_name(this.pointer)); + } + setName(text) { + libmupdf._wasm_pdf_set_annot_name(this.pointer, STRING(text)); + } + getAuthor() { + return fromString(libmupdf._wasm_pdf_annot_author(this.pointer)); + } + setAuthor(text) { + libmupdf._wasm_pdf_set_annot_author(this.pointer, STRING(text)); + } + getSubject() { + return fromString(libmupdf._wasm_pdf_annot_subject(this.pointer)); + } + setSubject(text) { + libmupdf._wasm_pdf_set_annot_subject(this.pointer, STRING(text)); + } + getCreationDate() { + return new Date(libmupdf._wasm_pdf_annot_creation_date(this.pointer) * 1000); + } + setCreationDate(date) { + checkType(date, Date); + libmupdf._wasm_pdf_set_annot_creation_date(this.pointer, date.getTime() / 1000); + } + getModificationDate() { + return new Date(libmupdf._wasm_pdf_annot_modification_date(this.pointer) * 1000); + } + setModificationDate(date) { + checkType(date, Date); + libmupdf._wasm_pdf_set_annot_modification_date(this.pointer, date.getTime() / 1000); + } + hasRect() { + return !!libmupdf._wasm_pdf_annot_has_rect(this.pointer); + } + hasInkList() { + return !!libmupdf._wasm_pdf_annot_has_ink_list(this.pointer); + } + hasQuadPoints() { + return !!libmupdf._wasm_pdf_annot_has_quad_points(this.pointer); + } + hasVertices() { + return !!libmupdf._wasm_pdf_annot_has_vertices(this.pointer); + } + hasLine() { + return !!libmupdf._wasm_pdf_annot_has_line(this.pointer); + } + hasInteriorColor() { + return !!libmupdf._wasm_pdf_annot_has_interior_color(this.pointer); + } + hasLineEndingStyles() { + return !!libmupdf._wasm_pdf_annot_has_line_ending_styles(this.pointer); + } + hasBorder() { + return !!libmupdf._wasm_pdf_annot_has_border(this.pointer); + } + hasBorderEffect() { + return !!libmupdf._wasm_pdf_annot_has_border_effect(this.pointer); + } + hasIcon() { + return !!libmupdf._wasm_pdf_annot_has_icon_name(this.pointer); + } + hasOpen() { + return !!libmupdf._wasm_pdf_annot_has_open(this.pointer); + } + hasAuthor() { + return !!libmupdf._wasm_pdf_annot_has_author(this.pointer); + } + hasSubject() { + return !!libmupdf._wasm_pdf_annot_has_subject(this.pointer); + } + hasFilespec() { + return !!libmupdf._wasm_pdf_annot_has_filespec(this.pointer); + } + hasCallout() { + return !!libmupdf._wasm_pdf_annot_has_callout(this.pointer); + } + hasRichContents() { + return !!libmupdf._wasm_pdf_annot_has_rich_contents(this.pointer); + } + getRect() { + return fromRect(libmupdf._wasm_pdf_annot_rect(this.pointer)); + } + setRect(rect) { + checkRect(rect); + libmupdf._wasm_pdf_set_annot_rect(this.pointer, RECT(rect)); + } + getPopup() { + return fromRect(libmupdf._wasm_pdf_annot_popup(this.pointer)); + } + setPopup(rect) { + checkRect(rect); + libmupdf._wasm_pdf_set_annot_popup(this.pointer, RECT(rect)); + } + getIsOpen() { + return !!libmupdf._wasm_pdf_annot_is_open(this.pointer); + } + setIsOpen(isOpen) { + checkType(isOpen, "boolean"); + libmupdf._wasm_pdf_set_annot_is_open(this.pointer, isOpen); + } + getHiddenForEditing() { + return !!libmupdf._wasm_pdf_annot_hidden_for_editing(this.pointer); + } + setHiddenForEditing(isHidden) { + checkType(isHidden, "boolean"); + libmupdf._wasm_pdf_set_annot_hidden_for_editing(this.pointer, isHidden); + } + getIcon() { + return fromString(libmupdf._wasm_pdf_annot_icon_name(this.pointer)); + } + setIcon(text) { + checkType(text, "string"); + libmupdf._wasm_pdf_set_annot_icon_name(this.pointer, STRING(text)); + } + getOpacity() { + return libmupdf._wasm_pdf_annot_opacity(this.pointer); + } + setOpacity(opacity) { + checkType(opacity, "number"); + libmupdf._wasm_pdf_set_annot_opacity(this.pointer, opacity); + } + getQuadding() { + return libmupdf._wasm_pdf_annot_quadding(this.pointer); + } + setQuadding(quadding) { + checkType(quadding, "number"); + libmupdf._wasm_pdf_set_annot_quadding(this.pointer, quadding); + } + getLine() { + let a = fromPoint(libmupdf._wasm_pdf_annot_line_1(this.pointer)); + let b = fromPoint(libmupdf._wasm_pdf_annot_line_2(this.pointer)); + return [a, b]; + } + setLine(a, b) { + checkPoint(a); + checkPoint(b); + libmupdf._wasm_pdf_set_annot_line(this.pointer, POINT(a), POINT2(b)); + } + getLineEndingStyles() { + let a = libmupdf._wasm_pdf_annot_line_ending_styles_start(this.pointer); + let b = libmupdf._wasm_pdf_annot_line_ending_styles_end(this.pointer); + return { + start: PDFAnnotation.LINE_ENDING[a] || "None", + end: PDFAnnotation.LINE_ENDING[b] || "None", + }; + } + setLineEndingStyles(start, end) { + let start_ix = ENUM(start, PDFAnnotation.LINE_ENDING); + let end_ix = ENUM(end, PDFAnnotation.LINE_ENDING); + libmupdf._wasm_pdf_set_annot_line_ending_styles(this.pointer, start_ix, end_ix); + } + getLineCaption() { + return libmupdf._wasm_pdf_annot_line_caption(this.pointer); + } + setLineCaption(on) { + return libmupdf._wasm_pdf_set_annot_line_caption(this.pointer, on); + } + getLineCaptionOffset() { + return fromPoint(libmupdf._wasm_pdf_annot_line_caption_offset(this.pointer)); + } + setLineCaptionOffset(p) { + return libmupdf._wasm_pdf_set_annot_line_caption_offset(this.pointer, POINT(p)); + } + getLineLeader() { + return libmupdf._wasm_pdf_annot_line_leader(this.pointer); + } + getLineLeaderExtension() { + return libmupdf._wasm_pdf_annot_line_leader_extension(this.pointer); + } + getLineLeaderOffset() { + return libmupdf._wasm_pdf_annot_line_leader_offset(this.pointer); + } + setLineLeader(v) { + return libmupdf._wasm_pdf_set_annot_line_leader(this.pointer, v); + } + setLineLeaderExtension(v) { + return libmupdf._wasm_pdf_set_annot_line_leader_extension(this.pointer, v); + } + setLineLeaderOffset(v) { + return libmupdf._wasm_pdf_set_annot_line_leader_offset(this.pointer, v); + } + getCalloutStyle() { + let style = libmupdf._wasm_pdf_annot_callout_style(this.pointer); + return PDFAnnotation.LINE_ENDING[style] || "None"; + } + setCalloutStyle(style) { + let style_ix = ENUM(style, PDFAnnotation.LINE_ENDING); + libmupdf._wasm_pdf_set_annot_callout_style(this.pointer, style_ix); + } + getCalloutLine() { + let n = libmupdf._wasm_pdf_annot_callout_line(this.pointer, (_wasm_point << 2)); + if (n == 3) + return [ + fromPoint((_wasm_point + 0) << 2), + fromPoint((_wasm_point + 1) << 2), + fromPoint((_wasm_point + 2) << 2) + ]; + if (n == 2) + return [ + fromPoint((_wasm_point + 0) << 2), + fromPoint((_wasm_point + 1) << 2) + ]; + return null; + } + setCalloutLine(line) { + let a = line[0] || [0, 0]; + let b = line[1] || [0, 0]; + let c = line[2] || [0, 0]; + libmupdf._wasm_pdf_set_annot_callout_line(this.pointer, line.length, POINT(a), POINT2(b), POINT3(c)); + } + getCalloutPoint() { + let line = this.getCalloutLine(); + if (line) + return line[0]; + return undefined; + } + setCalloutPoint(p) { + libmupdf._wasm_pdf_set_annot_callout_point(this.pointer, POINT(p)); + } + getColor() { + return fromAnnotColor(libmupdf._wasm_pdf_annot_color(this.pointer, COLOR())); + } + getInteriorColor() { + return fromAnnotColor(libmupdf._wasm_pdf_annot_interior_color(this.pointer, COLOR())); + } + setColor(color) { + checkAnnotColor(color); + libmupdf._wasm_pdf_set_annot_color(this.pointer, color.length, COLOR(color)); + } + setInteriorColor(color) { + checkAnnotColor(color); + libmupdf._wasm_pdf_set_annot_interior_color(this.pointer, color.length, COLOR(color)); + } + getBorderWidth() { + return libmupdf._wasm_pdf_annot_border_width(this.pointer); + } + setBorderWidth(value) { + checkType(value, "number"); + return libmupdf._wasm_pdf_set_annot_border_width(this.pointer, value); + } + getBorderStyle() { + return PDFAnnotation.BORDER_STYLE[libmupdf._wasm_pdf_annot_border_style(this.pointer)] || "Solid"; + } + setBorderStyle(value) { + let value_ix = ENUM(value, PDFAnnotation.BORDER_STYLE); + return libmupdf._wasm_pdf_set_annot_border_style(this.pointer, value_ix); + } + getBorderEffect() { + return PDFAnnotation.BORDER_EFFECT[libmupdf._wasm_pdf_annot_border_effect(this.pointer)] || "None"; + } + setBorderEffect(value) { + let value_ix = ENUM(value, PDFAnnotation.BORDER_EFFECT); + return libmupdf._wasm_pdf_set_annot_border_effect(this.pointer, value_ix); + } + getBorderEffectIntensity() { + return libmupdf._wasm_pdf_annot_border_effect_intensity(this.pointer); + } + setBorderEffectIntensity(value) { + checkType(value, "number"); + return libmupdf._wasm_pdf_set_annot_border_effect_intensity(this.pointer, value); + } + getBorderDashCount() { + return libmupdf._wasm_pdf_annot_border_dash_count(this.pointer); + } + getBorderDashItem(idx) { + return libmupdf._wasm_pdf_annot_border_dash_item(this.pointer, idx); + } + clearBorderDash() { + libmupdf._wasm_pdf_clear_annot_border_dash(this.pointer); + } + addBorderDashItem(v) { + checkType(v, "number"); + return libmupdf._wasm_pdf_add_annot_border_dash_item(this.pointer, v); + } + getBorderDashPattern() { + let n = this.getBorderDashCount(); + let result = new Array(n); + for (let i = 0; i < n; ++i) + result[i] = this.getBorderDashItem(i); + return result; + } + setBorderDashPattern(list) { + this.clearBorderDash(); + for (let v of list) + this.addBorderDashItem(v); + } + getIntent() { + return PDFAnnotation.INTENT[libmupdf._wasm_pdf_annot_intent(this.pointer)] || null; + } + setIntent(value) { + let value_ix = ENUM(value, PDFAnnotation.INTENT); + return libmupdf._wasm_pdf_set_annot_intent(this.pointer, value_ix); + } + setDefaultAppearance(fontName, size, color) { + checkType(fontName, "string"); + checkType(size, "number"); + checkAnnotColor(color); + libmupdf._wasm_pdf_set_annot_default_appearance(this.pointer, STRING(fontName), size, color.length, COLOR(color)); + } + getDefaultAppearance() { + let font = fromString(libmupdf._wasm_pdf_annot_default_appearance_font(this.pointer)); + let size = libmupdf._wasm_pdf_annot_default_appearance_size(this.pointer); + let color = fromAnnotColor(libmupdf._wasm_pdf_annot_default_appearance_color(this.pointer, COLOR())); + return { font, size, color }; + } + getFileSpec() { + return this._doc._fromPDFObjectKeep(libmupdf._wasm_pdf_annot_filespec(this.pointer)); + } + setFileSpec(fs) { + return libmupdf._wasm_pdf_set_annot_filespec(this.pointer, this._doc._PDFOBJ(fs)); + } + getQuadPoints() { + let n = libmupdf._wasm_pdf_annot_quad_point_count(this.pointer); + let result = []; + for (let i = 0; i < n; ++i) + result.push(fromQuad(libmupdf._wasm_pdf_annot_quad_point(this.pointer, i))); + return result; + } + clearQuadPoints() { + libmupdf._wasm_pdf_clear_annot_quad_points(this.pointer); + } + addQuadPoint(quad) { + checkQuad(quad); + libmupdf._wasm_pdf_add_annot_quad_point(this.pointer, QUAD(quad)); + } + setQuadPoints(quadlist) { + this.clearQuadPoints(); + for (let quad of quadlist) + this.addQuadPoint(quad); + } + getVertices() { + let n = libmupdf._wasm_pdf_annot_vertex_count(this.pointer); + let result = new Array(n); + for (let i = 0; i < n; ++i) + result[i] = fromPoint(libmupdf._wasm_pdf_annot_vertex(this.pointer, i)); + return result; + } + clearVertices() { + libmupdf._wasm_pdf_clear_annot_vertices(this.pointer); + } + addVertex(vertex) { + checkPoint(vertex); + libmupdf._wasm_pdf_add_annot_vertex(this.pointer, POINT(vertex)); + } + setVertices(vertexlist) { + this.clearVertices(); + for (let vertex of vertexlist) + this.addVertex(vertex); + } + getInkList() { + let n = libmupdf._wasm_pdf_annot_ink_list_count(this.pointer); + let outer = []; + for (let i = 0; i < n; ++i) { + let m = libmupdf._wasm_pdf_annot_ink_list_stroke_count(this.pointer, i); + let inner = new Array(m); + for (let k = 0; k < m; ++k) + inner[k] = fromPoint(libmupdf._wasm_pdf_annot_ink_list_stroke_vertex(this.pointer, i, k)); + outer.push(inner); + } + return outer; + } + clearInkList() { + libmupdf._wasm_pdf_clear_annot_ink_list(this.pointer); + } + addInkListStroke() { + libmupdf._wasm_pdf_add_annot_ink_list_stroke(this.pointer); + } + addInkListStrokeVertex(v) { + checkPoint(v); + libmupdf._wasm_pdf_add_annot_ink_list_stroke_vertex(this.pointer, POINT(v)); + } + setInkList(inklist) { + this.clearInkList(); + for (let stroke of inklist) { + this.addInkListStroke(); + for (let vertex of stroke) + this.addInkListStrokeVertex(vertex); + } + } + getRichContents() { + return fromString(libmupdf._wasm_pdf_annot_rich_contents(this.pointer)); + } + setRichContents(plain, html) { + checkType(plain, "string"); + checkType(html, "string"); + libmupdf._wasm_pdf_set_annot_rich_contents(this.pointer, STRING(plain), STRING2(html)); + } + getRichDefaults() { + return fromString(libmupdf._wasm_pdf_annot_rich_defaults(this.pointer)); + } + setRichDefaults(style) { + checkType(style, "string"); + libmupdf._wasm_pdf_set_annot_rich_defaults(this.pointer, STRING(style)); + } + setStampImage(image) { + libmupdf._wasm_pdf_set_annot_stamp_image(this.pointer, image.pointer); + } + setAppearanceFromDisplayList(appearance, state, transform, list) { + checkMatrix(transform); + checkType(list, DisplayList); + libmupdf._wasm_pdf_set_annot_appearance_from_display_list(this.pointer, STRING_OPT(appearance), STRING2_OPT(state), MATRIX(transform), list.pointer); + } + setAppearance(appearance, state, transform, bbox, resources, contents) { + checkMatrix(transform); + checkRect(bbox); + libmupdf._wasm_pdf_set_annot_appearance(this.pointer, STRING_OPT(appearance), STRING2_OPT(state), MATRIX(transform), RECT(bbox), this._doc._PDFOBJ(resources), BUFFER(contents)); + } + applyRedaction(black_boxes = 1, image_method = 2, line_art_method = 1, text_method = 0) { + libmupdf._wasm_pdf_apply_redaction(this.pointer, black_boxes, image_method, line_art_method, text_method); + } +} +PDFAnnotation._drop = libmupdf._wasm_pdf_drop_annot; +/* IMPORTANT: Keep in sync with mupdf/pdf/annot.h and PDFAnnotation.java */ +PDFAnnotation.ANNOT_TYPES = [ + "Text", + "Link", + "FreeText", + "Line", + "Square", + "Circle", + "Polygon", + "PolyLine", + "Highlight", + "Underline", + "Squiggly", + "StrikeOut", + "Redact", + "Stamp", + "Caret", + "Ink", + "Popup", + "FileAttachment", + "Sound", + "Movie", + "RichMedia", + "Widget", + "Screen", + "PrinterMark", + "TrapNet", + "Watermark", + "3D", + "Projection", +]; +PDFAnnotation.LINE_ENDING = [ + "None", + "Square", + "Circle", + "Diamond", + "OpenArrow", + "ClosedArrow", + "Butt", + "ROpenArrow", + "RClosedArrow", + "Slash", +]; +PDFAnnotation.BORDER_STYLE = ["Solid", "Dashed", "Beveled", "Inset", "Underline"]; +PDFAnnotation.BORDER_EFFECT = ["None", "Cloudy"]; +PDFAnnotation.INTENT = [ + null, + "FreeTextCallout", + "FreeTextTypeWriter", + "LineArrow", + "LineDimension", + "PloyLine", + "PolygonCloud", + "PolygonDimension", + "StampImage", + "StampSnapshot" +]; +// Bit masks for getFlags and setFlags +PDFAnnotation.IS_INVISIBLE = 1 << (1 - 1); +PDFAnnotation.IS_HIDDEN = 1 << (2 - 1); +PDFAnnotation.IS_PRINT = 1 << (3 - 1); +PDFAnnotation.IS_NO_ZOOM = 1 << (4 - 1); +PDFAnnotation.IS_NO_ROTATE = 1 << (5 - 1); +PDFAnnotation.IS_NO_VIEW = 1 << (6 - 1); +PDFAnnotation.IS_READ_ONLY = 1 << (7 - 1); +PDFAnnotation.IS_LOCKED = 1 << (8 - 1); +PDFAnnotation.IS_TOGGLE_NO_VIEW = 1 << (9 - 1); +PDFAnnotation.IS_LOCKED_CONTENTS = 1 << (10 - 1); +export class PDFWidget extends PDFAnnotation { + getFieldType() { + return PDFWidget.WIDGET_TYPES[libmupdf._wasm_pdf_annot_field_type(this.pointer)] || "button"; + } + isButton() { + let type = this.getFieldType(); + return type === "button" || type === "checkbox" || type === "radiobutton"; + } + isPushButton() { + return this.getFieldType() === "button"; + } + isCheckbox() { + return this.getFieldType() === "checkbox"; + } + isRadioButton() { + return this.getFieldType() === "radiobutton"; + } + isText() { + return this.getFieldType() === "text"; + } + isChoice() { + let type = this.getFieldType(); + return type === "combobox" || type === "listbox"; + } + isListBox() { + return this.getFieldType() === "listbox"; + } + isComboBox() { + return this.getFieldType() === "combobox"; + } + getFieldFlags() { + return libmupdf._wasm_pdf_annot_field_flags(this.pointer); + } + isMultiline() { + return (this.getFieldFlags() & PDFWidget.TX_FIELD_IS_MULTILINE) !== 0; + } + isPassword() { + return (this.getFieldFlags() & PDFWidget.TX_FIELD_IS_PASSWORD) !== 0; + } + isComb() { + return (this.getFieldFlags() & PDFWidget.TX_FIELD_IS_COMB) !== 0; + } + isReadOnly() { + return (this.getFieldFlags() & PDFWidget.FIELD_IS_READ_ONLY) !== 0; + } + getLabel() { + return fromString(libmupdf._wasm_pdf_annot_field_label(this.pointer)); + } + getName() { + return fromStringFree(libmupdf._wasm_pdf_load_field_name(this.pointer)); + } + setName() { + throw new Error("widget field name is read-only"); + } + getValue() { + return fromString(libmupdf._wasm_pdf_annot_field_value(this.pointer)); + } + setTextValue(value) { + return libmupdf._wasm_pdf_set_annot_text_field_value(this.pointer, STRING(value)); + } + getMaxLen() { + return libmupdf._wasm_pdf_annot_text_widget_max_len(this.pointer); + } + setChoiceValue(value) { + return libmupdf._wasm_pdf_set_annot_choice_field_value(this.pointer, STRING(value)); + } + getOptions(isExport = false) { + let result = []; + let n = libmupdf._wasm_pdf_annot_choice_field_option_count(this.pointer); + for (let i = 0; i < n; ++i) { + result.push(fromString(libmupdf._wasm_pdf_annot_choice_field_option(this.pointer, isExport, i))); + } + return result; + } + toggle() { + return libmupdf._wasm_pdf_toggle_widget(this.pointer); + } +} +/* IMPORTANT: Keep in sync with mupdf/pdf/widget.h and PDFWidget.java */ +PDFWidget.WIDGET_TYPES = [ + "widget", // unknown + "button", + "checkbox", + "combobox", + "listbox", + "radiobutton", + "signature", + "text", +]; +/* Field flags */ +PDFWidget.FIELD_IS_READ_ONLY = 1; +PDFWidget.FIELD_IS_REQUIRED = 1 << 1; +PDFWidget.FIELD_IS_NO_EXPORT = 1 << 2; +/* Text fields */ +PDFWidget.TX_FIELD_IS_MULTILINE = 1 << 12; +PDFWidget.TX_FIELD_IS_PASSWORD = 1 << 13; +PDFWidget.TX_FIELD_IS_FILE_SELECT = 1 << 20; +PDFWidget.TX_FIELD_IS_DO_NOT_SPELL_CHECK = 1 << 22; +PDFWidget.TX_FIELD_IS_DO_NOT_SCROLL = 1 << 23; +PDFWidget.TX_FIELD_IS_COMB = 1 << 24; +PDFWidget.TX_FIELD_IS_RICH_TEXT = 1 << 25; +/* Button fields */ +PDFWidget.BTN_FIELD_IS_NO_TOGGLE_TO_OFF = 1 << 14; +PDFWidget.BTN_FIELD_IS_RADIO = 1 << 15; +PDFWidget.BTN_FIELD_IS_PUSHBUTTON = 1 << 16; +PDFWidget.BTN_FIELD_IS_RADIOS_IN_UNISON = 1 << 25; +/* Choice fields */ +PDFWidget.CH_FIELD_IS_COMBO = 1 << 17; +PDFWidget.CH_FIELD_IS_EDIT = 1 << 18; +PDFWidget.CH_FIELD_IS_SORT = 1 << 19; +PDFWidget.CH_FIELD_IS_MULTI_SELECT = 1 << 21; +PDFWidget.CH_FIELD_IS_DO_NOT_SPELL_CHECK = 1 << 22; +PDFWidget.CH_FIELD_IS_COMMIT_ON_SEL_CHANGE = 1 << 25; +var $libmupdf_stm_id = 0; +var $libmupdf_stm_table = new Map(); +globalThis.$libmupdf_stm_close = function (id) { + let handle = $libmupdf_stm_table.get(id); + if (handle) { + handle.close(); + $libmupdf_stm_table.delete(id); + return; + } + throw new Error("invalid file handle"); +}; +globalThis.$libmupdf_stm_seek = function (id, pos, offset, whence) { + let handle = $libmupdf_stm_table.get(id); + if (handle) { + if (whence === 0) + return offset; + if (whence === 1) + return pos + offset; + if (whence === 2) { + let size = handle.fileSize(); + if (size < 0) + return -1; + return size + offset; + } + throw new Error("invalid whence argument"); + } + throw new Error("invalid file handle"); +}; +globalThis.$libmupdf_stm_read = function (id, pos, addr, size) { + let handle = $libmupdf_stm_table.get(id); + if (handle) { + return handle.read(libmupdf.HEAPU8, addr, size, pos); + } + throw new Error("invalid file handle"); +}; +export class Stream extends Userdata { + constructor(handle) { + let id = $libmupdf_stm_id++; + $libmupdf_stm_table.set(id, handle); + super(libmupdf._wasm_new_stream(id)); + } +} +Stream._drop = libmupdf._wasm_drop_stream; +/* -------------------------------------------------------------------------- */ +var $libmupdf_load_font_file_js; +globalThis.$libmupdf_load_font_file = function (name, script, bold, italic) { + if ($libmupdf_load_font_file_js) { + var font = $libmupdf_load_font_file_js(fromString(name), fromString(script), bold, italic); + if (font) { + checkType(font, Font); + return font.pointer; + } + } + return 0; +}; +var $libmupdf_device_id = 0; +var $libmupdf_device_table = new Map(); +var $libmupdf_path_id = 0; +var $libmupdf_path_table = new Map(); +var $libmupdf_text_id = 0; +var $libmupdf_text_table = new Map(); +globalThis.$libmupdf_path_walk = { + moveto(id, x, y) { + $libmupdf_path_table.get(id)?.moveTo?.(x, y); + }, + lineto(id, x, y) { + $libmupdf_path_table.get(id)?.lineTo?.(x, y); + }, + curveto(id, x1, y1, x2, y2, x3, y3) { + $libmupdf_path_table.get(id)?.curveTo?.(x1, y1, x2, y2, x3, y3); + }, + closepath(id) { + $libmupdf_path_table.get(id)?.closePath?.(); + }, +}; +var $libmupdf_text_font = null; +globalThis.$libmupdf_text_walk = { + begin_span(id, font, trm, wmode, bidi, dir, lang) { + if (font !== $libmupdf_text_font?.pointer) + $libmupdf_text_font = new Font(font); + $libmupdf_text_table.get(id)?.beginSpan?.($libmupdf_text_font, fromMatrix(trm), wmode, bidi, dir, fromString(lang)); + }, + end_span(id) { + $libmupdf_text_table.get(id)?.endSpan?.(); + }, + show_glyph(id, font, trm, glyph, unicode, wmode, bidi) { + if (font !== $libmupdf_text_font?.pointer) + $libmupdf_text_font = new Font(font); + $libmupdf_text_table.get(id)?.showGlyph?.($libmupdf_text_font, fromMatrix(trm), glyph, unicode, wmode, bidi); + }, +}; +globalThis.$libmupdf_device = { + drop_device(id) { + $libmupdf_device_table.get(id)?.drop?.(); + $libmupdf_device_table.delete(id); + }, + close_device(id) { + $libmupdf_device_table.get(id)?.close?.(); + }, + fill_path(id, path, even_odd, ctm, colorspace, color_n, color_arr, alpha) { + $libmupdf_device_table.get(id)?.fillPath?.(new Path(libmupdf._wasm_keep_path(path)), !!even_odd, fromMatrix(ctm), new ColorSpace(libmupdf._wasm_keep_colorspace(colorspace)), fromColorArray(color_n, color_arr), alpha); + }, + clip_path(id, path, even_odd, ctm) { + $libmupdf_device_table.get(id)?.clipPath?.(new Path(libmupdf._wasm_keep_path(path)), !!even_odd, fromMatrix(ctm)); + }, + stroke_path(id, path, stroke, ctm, colorspace, color_n, color_arr, alpha) { + $libmupdf_device_table.get(id)?.strokePath?.(new Path(libmupdf._wasm_keep_path(path)), new StrokeState(libmupdf._wasm_keep_stroke_state(stroke)), fromMatrix(ctm), new ColorSpace(libmupdf._wasm_keep_colorspace(colorspace)), fromColorArray(color_n, color_arr), alpha); + }, + clip_stroke_path(id, path, stroke, ctm) { + $libmupdf_device_table.get(id)?.clipStrokePath?.(new Path(libmupdf._wasm_keep_path(path)), new StrokeState(libmupdf._wasm_keep_stroke_state(stroke)), fromMatrix(ctm)); + }, + fill_text(id, text, ctm, colorspace, color_n, color_arr, alpha) { + $libmupdf_device_table.get(id)?.fillText?.(new Text(libmupdf._wasm_keep_text(text)), fromMatrix(ctm), new ColorSpace(libmupdf._wasm_keep_colorspace(colorspace)), fromColorArray(color_n, color_arr), alpha); + }, + stroke_text(id, text, stroke, ctm, colorspace, color_n, color_arr, alpha) { + $libmupdf_device_table.get(id)?.strokeText?.(new Text(libmupdf._wasm_keep_text(text)), new StrokeState(libmupdf._wasm_keep_stroke_state(stroke)), fromMatrix(ctm), new ColorSpace(libmupdf._wasm_keep_colorspace(colorspace)), fromColorArray(color_n, color_arr), alpha); + }, + clip_text(id, text, ctm) { + $libmupdf_device_table.get(id)?.clipText?.(new Text(libmupdf._wasm_keep_text(text)), fromMatrix(ctm)); + }, + clip_stroke_text(id, text, stroke, ctm) { + $libmupdf_device_table.get(id)?.clipStrokeText?.(new Text(libmupdf._wasm_keep_text(text)), new StrokeState(libmupdf._wasm_keep_stroke_state(stroke)), fromMatrix(ctm)); + }, + ignore_text(id, text, ctm) { + $libmupdf_device_table.get(id)?.ignoreText?.(new Text(libmupdf._wasm_keep_text(text)), fromMatrix(ctm)); + }, + fill_shade(id, shade, ctm, alpha) { + $libmupdf_device_table.get(id)?.fillShade?.(new Shade(shade), fromMatrix(ctm), alpha); + }, + fill_image(id, image, ctm, alpha) { + $libmupdf_device_table.get(id)?.fillImage?.(new Image(image), fromMatrix(ctm), alpha); + }, + fill_image_mask(id, image, ctm, colorspace, color_n, color_arr, alpha) { + $libmupdf_device_table.get(id)?.fillImageMask?.(new Image(image), fromMatrix(ctm), new ColorSpace(libmupdf._wasm_keep_colorspace(colorspace)), fromColorArray(color_n, color_arr), alpha); + }, + clip_image_mask(id, image, ctm) { + $libmupdf_device_table.get(id)?.clipImageMask?.(new Image(image), fromMatrix(ctm)); + }, + pop_clip(id) { + $libmupdf_device_table.get(id)?.popClip?.(); + }, + begin_mask(id, bbox, luminosity, colorspace, color_n, color_arr) { + $libmupdf_device_table.get(id)?.beginMask?.(fromRect(bbox), !!luminosity, new ColorSpace(libmupdf._wasm_keep_colorspace(colorspace)), fromColorArray(color_n, color_arr)); + }, + begin_group(id, bbox, colorspace, isolated, knockout, blendmode, alpha) { + $libmupdf_device_table.get(id)?.beginGroup?.(fromRect(bbox), new ColorSpace(libmupdf._wasm_keep_colorspace(colorspace)), !!isolated, !!knockout, Device.BLEND_MODES[blendmode], alpha); + }, + begin_tile(id, area, view, xstep, ystep, ctm, tile_id, doc_id) { + return $libmupdf_device_table.get(id)?.beginTile?.(fromRect(area), fromRect(view), xstep, ystep, fromMatrix(ctm), tile_id, doc_id) || 0; + }, + begin_layer(id, name) { + $libmupdf_device_table.get(id)?.beginLayer?.(fromString(name)); + }, + end_mask(id) { + $libmupdf_device_table.get(id)?.endMask?.(); + }, + end_group(id) { + $libmupdf_device_table.get(id)?.endGroup?.(); + }, + end_tile(id) { + $libmupdf_device_table.get(id)?.endTile?.(); + }, + end_layer(id) { + $libmupdf_device_table.get(id)?.endLayer?.(); + }, +}; +/* default exports */ +export default { + // const + Matrix, + Rect, + // function + enableICC, + disableICC, + setUserCSS, + installLoadFontFunction, + setLog, + // class + Buffer, + ColorSpace, + Font, + Image, + StrokeState, + Path, + Text, + DisplayList, + Pixmap, + Shade, + StructuredText, + Device, + DrawDevice, + DisplayListDevice, + DocumentWriter, + Document, + OutlineIterator, + Link, + Page, + PDFDocument, + PDFPage, + PDFObject, + PDFGraftMap, + PDFAnnotation, + PDFWidget, + Stream, + // debugging + memento +}; diff --git a/scripts/build-apk.mjs b/scripts/build-apk.mjs new file mode 100644 index 0000000..56540d6 --- /dev/null +++ b/scripts/build-apk.mjs @@ -0,0 +1,228 @@ +import fs from 'node:fs' +import path from 'node:path' +import { execFileSync } from 'node:child_process' +import AdmZip from 'adm-zip' + +const root = process.cwd() +const devRoot = process.env.ANDROID_DEV_ROOT || 'E:\\AiCodeGitea\\ven\\AndroidDev' +const jdkHome = fs.existsSync(path.join(process.env.JAVA_HOME || '', 'bin', 'java.exe')) + ? process.env.JAVA_HOME + : path.join(devRoot, 'jdk17') +const sdkHome = fs.existsSync(path.join(process.env.ANDROID_HOME || '', 'platforms')) + ? process.env.ANDROID_HOME + : path.join(devRoot, 'Sdk') +const gradleHome = path.join(devRoot, 'gradle-8.7') +const buildTools = path.join(sdkHome, 'build-tools', '34.0.0') +const androidJar = path.join(sdkHome, 'platforms', 'android-34', 'android.jar') +const java = path.join(jdkHome, 'bin', 'java.exe') +const jar = path.join(jdkHome, 'bin', 'jar.exe') +const keytool = path.join(jdkHome, 'bin', 'keytool.exe') +const kotlincJars = path.join(gradleHome, 'lib', '*') +const kotlinStdlib = fs + .readdirSync(path.join(gradleHome, 'lib')) + .filter((name) => /^kotlin-stdlib-[\d.]+\.jar$/.test(name)) + .sort() + .pop() +if (!kotlinStdlib) throw new Error('kotlin-stdlib not found in Gradle lib') + +const env = { + ...process.env, + JAVA_HOME: jdkHome, + ANDROID_HOME: sdkHome, + ANDROID_SDK_ROOT: sdkHome, + PATH: [ + path.join(jdkHome, 'bin'), + buildTools, + path.join(sdkHome, 'platform-tools'), + process.env.PATH || '' + ].join(';') +} + +const appDir = path.join(root, 'android', 'app', 'src', 'main') +const manifest = path.join(appDir, 'AndroidManifest.xml') +const resDir = path.join(appDir, 'res') +const assetsDir = path.join(appDir, 'assets') +const wwwDir = path.join(assetsDir, 'www') +const sourceDir = path.join(appDir, 'java') +const outDir = path.join(root, 'android', 'build') +const classesDir = path.join(outDir, 'classes') +const dexDir = path.join(outDir, 'dex') +const apkName = 'PhoneViewer-0.4.1.apk' + +function run(command, args, options = {}) { + console.log('>', path.basename(command), args.join(' ')) + execFileSync(command, args, { stdio: 'inherit', env, ...options }) +} + +function runBat(batFile, args, options = {}) { + run('cmd.exe', ['/c', batFile, ...args], options) +} + +fs.rmSync(outDir, { recursive: true, force: true }) +fs.mkdirSync(outDir, { recursive: true }) +fs.mkdirSync(classesDir, { recursive: true }) +fs.mkdirSync(dexDir, { recursive: true }) + +console.log('== building web assets ==') +run('cmd.exe', ['/c', 'npm run build'], { cwd: root }) + +console.log('== copying web assets into Android assets ==') +fs.rmSync(wwwDir, { recursive: true, force: true }) +fs.mkdirSync(wwwDir, { recursive: true }) +fs.cpSync(path.join(root, 'dist'), wwwDir, { recursive: true }) +for (const name of fs.readdirSync(wwwDir)) { + if (name === 'sw.js' || name.startsWith('workbox-')) { + fs.rmSync(path.join(wwwDir, name), { force: true }) + } +} + +console.log('== compiling Kotlin ==') +const kotlinFiles = [] +function walk(dir) { + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + const full = path.join(dir, entry.name) + if (entry.isDirectory()) walk(full) + else if (entry.name.endsWith('.kt')) kotlinFiles.push(full) + } +} +walk(sourceDir) +run(java, [ + '-cp', + kotlincJars, + 'org.jetbrains.kotlin.cli.jvm.K2JVMCompiler', + '-no-stdlib', + '-no-reflect', + '-classpath', + `${androidJar};${path.join(gradleHome, 'lib', kotlinStdlib)}`, + '-jvm-target', + '17', + '-d', + classesDir, + ...kotlinFiles +]) + +console.log('== creating classes.jar ==') +const classesJar = path.join(outDir, 'classes.jar') +run(jar, ['cf', classesJar, '-C', classesDir, '.']) + +console.log('== dexing with d8 ==') +runBat(path.join(buildTools, 'd8.bat'), [ + '--release', + '--lib', + androidJar, + '--min-api', + '26', + '--output', + dexDir, + classesJar, + path.join(gradleHome, 'lib', kotlinStdlib) +]) + +console.log('== compiling resources ==') +const resZip = path.join(outDir, 'resources.zip') +run(path.join(buildTools, 'aapt2.exe'), ['compile', '-o', resZip, '--dir', resDir]) + +console.log('== linking base apk ==') +const baseApk = path.join(outDir, 'base.apk') +run(path.join(buildTools, 'aapt2.exe'), [ + 'link', + '-o', + baseApk, + '-I', + androidJar, + '--manifest', + manifest, + '-R', + resZip, + '--min-sdk-version', + '26', + '--target-sdk-version', + '34', + '--version-code', + '5', + '--version-name', + '0.4.1', + '--auto-add-overlay' +]) + +console.log('== adding assets and classes.dex ==') +const unsigned = path.join(outDir, 'unsigned.apk') +fs.rmSync(unsigned, { force: true }) +const zip = new AdmZip(baseApk) + +function addDirectoryToZip(directory, prefix) { + for (const entry of fs.readdirSync(directory, { withFileTypes: true })) { + const full = path.join(directory, entry.name) + const name = `${prefix}/${entry.name}` + if (entry.isDirectory()) addDirectoryToZip(full, name) + else zip.addFile(name, fs.readFileSync(full)) + } +} + +addDirectoryToZip(wwwDir, 'assets/www') +for (const dex of fs.readdirSync(dexDir).filter((name) => name.endsWith('.dex'))) { + zip.addFile(dex, fs.readFileSync(path.join(dexDir, dex))) +} +zip.writeZip(unsigned) + +console.log('== zipalign ==') +const aligned = path.join(outDir, 'aligned.apk') +run(path.join(buildTools, 'zipalign.exe'), ['-p', '-f', '4', unsigned, aligned]) + +console.log('== signing ==') +const keystoreDir = path.join(root, 'android', 'keystore') +const keystore = path.join(keystoreDir, 'phoneviewer.jks') +const storePass = process.env.PHONEVIEWER_KEYSTORE_PASS +const keyPass = process.env.PHONEVIEWER_KEY_PASS ?? storePass +if (!storePass) { + throw new Error('Set PHONEVIEWER_KEYSTORE_PASS before building the signed APK.') +} +const alias = 'phoneviewer' +if (!fs.existsSync(keystore)) { + fs.mkdirSync(keystoreDir, { recursive: true }) + run(keytool, [ + '-genkeypair', + '-v', + '-keystore', + keystore, + '-storetype', + 'JKS', + '-alias', + alias, + '-keyalg', + 'RSA', + '-keysize', + '2048', + '-validity', + '10000', + '-storepass', + storePass, + '-keypass', + keyPass, + '-dname', + 'CN=PhoneViewer, OU=Android, O=PhoneViewer, L=Beijing, ST=Beijing, C=CN', + '-noprompt' + ]) +} +const finalApk = path.join(outDir, apkName) +runBat(path.join(buildTools, 'apksigner.bat'), [ + 'sign', + '--ks', + keystore, + '--ks-key-alias', + alias, + '--ks-pass', + `pass:${storePass}`, + '--key-pass', + `pass:${keyPass}`, + '--out', + finalApk, + aligned +]) +runBat(path.join(buildTools, 'apksigner.bat'), ['verify', '--verbose', '--print-certs', finalApk]) + +const rootApk = path.join(root, apkName) +fs.copyFileSync(finalApk, rootApk) +console.log('') +console.log('APK ready:', rootApk) +console.log('APK size:', (fs.statSync(rootApk).size / 1024 / 1024).toFixed(2), 'MB') diff --git a/scripts/make-icons.mjs b/scripts/make-icons.mjs new file mode 100644 index 0000000..3151251 --- /dev/null +++ b/scripts/make-icons.mjs @@ -0,0 +1,174 @@ +import fs from 'node:fs' +import path from 'node:path' +import zlib from 'node:zlib' + +const OUT = path.resolve('public/icons') +fs.mkdirSync(OUT, { recursive: true }) + +const CRC_TABLE = (() => { + const table = new Uint32Array(256) + for (let n = 0; n < 256; n++) { + let c = n + for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1 + table[n] = c >>> 0 + } + return table +})() + +function crc32(buf) { + let c = 0xffffffff + for (const b of buf) c = CRC_TABLE[(c ^ b) & 0xff] ^ (c >>> 8) + return (c ^ 0xffffffff) >>> 0 +} + +function chunk(type, data) { + const len = Buffer.alloc(4) + len.writeUInt32BE(data.length, 0) + const t = Buffer.from(type, 'ascii') + const crc = Buffer.alloc(4) + crc.writeUInt32BE(crc32(Buffer.concat([t, data])), 0) + return Buffer.concat([len, t, data, crc]) +} + +function encodePng(width, height, rgba) { + const ihdr = Buffer.alloc(13) + ihdr.writeUInt32BE(width, 0) + ihdr.writeUInt32BE(height, 4) + ihdr[8] = 8 + ihdr[9] = 6 + ihdr[10] = 0 + ihdr[11] = 0 + ihdr[12] = 0 + const raw = Buffer.alloc((width * 4 + 1) * height) + for (let y = 0; y < height; y++) { + raw[y * (width * 4 + 1)] = 0 + rgba.copy(raw, y * (width * 4 + 1) + 1, y * width * 4, (y + 1) * width * 4) + } + const idat = zlib.deflateSync(raw, { level: 9 }) + return Buffer.concat([ + Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]), + chunk('IHDR', ihdr), + chunk('IDAT', idat), + chunk('IEND', Buffer.alloc(0)) + ]) +} + +function clamp01(v) { + return v < 0 ? 0 : v > 1 ? 1 : v +} + +function mix(a, b, t) { + return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t] +} + +function roundedRectInside(x, y, cx, cy, hw, hh, r) { + const dx = Math.abs(x - cx) - (hw - r) + const dy = Math.abs(y - cy) - (hh - r) + const ox = Math.max(dx, 0) + const oy = Math.max(dy, 0) + return Math.hypot(ox, oy) + Math.min(Math.max(dx, dy), 0) - r <= 0 +} + +function segmentDistance(px, py, ax, ay, bx, by) { + const dx = bx - ax + const dy = by - ay + const len2 = dx * dx + dy * dy || 1 + let t = ((px - ax) * dx + (py - ay) * dy) / len2 + t = t < 0 ? 0 : t > 1 ? 1 : t + return Math.hypot(px - (ax + dx * t), py - (ay + dy * t)) +} + +function ringInside(px, py, cx, cy, r, width) { + return Math.abs(Math.hypot(px - cx, py - cy) - r) <= width / 2 +} + +function arcInside(px, py, cx, cy, r, width, a0, a1) { + if (!ringInside(px, py, cx, cy, r, width)) return false + let a = Math.atan2(py - cy, px - cx) + while (a < a0) a += Math.PI * 2 + return a <= a1 +} + +function samplePlan(x, y, pad) { + const sx = (x - pad) / (1 - pad * 2) + const sy = (y - pad) / (1 - pad * 2) + const line = 0.048 + const l = 0.022 + // outer wall + if (segmentDistance(sx, sy, 0.2, 0.3, 0.8, 0.3) < line / 2) return true + if (segmentDistance(sx, sy, 0.8, 0.3, 0.8, 0.7) < line / 2) return true + if (segmentDistance(sx, sy, 0.8, 0.7, 0.2, 0.7) < line / 2) return true + if (segmentDistance(sx, sy, 0.2, 0.7, 0.2, 0.3) < line / 2) return true + // inner walls + if (segmentDistance(sx, sy, 0.52, 0.3, 0.52, 0.7) < l) return true + if (segmentDistance(sx, sy, 0.52, 0.5, 0.8, 0.5) < l) return true + // door swing + if (arcInside(sx, sy, 0.52, 0.5, 0.15, l * 1.2, -Math.PI / 2, 0)) return true + if (segmentDistance(sx, sy, 0.52, 0.5, 0.52, 0.65) < l * 0.9) return true + // round table + if (ringInside(sx, sy, 0.34, 0.42, 0.075, l * 1.3)) return true + if (ringInside(sx, sy, 0.34, 0.42, 0.028, l)) return true + // bed + if (segmentDistance(sx, sy, 0.58, 0.57, 0.74, 0.57) < l * 0.9) return true + if (segmentDistance(sx, sy, 0.74, 0.57, 0.74, 0.66) < l * 0.9) return true + if (segmentDistance(sx, sy, 0.74, 0.66, 0.58, 0.66) < l * 0.9) return true + if (segmentDistance(sx, sy, 0.58, 0.66, 0.58, 0.57) < l * 0.9) return true + return false +} + +function render(size, { maskable = false, fullSquare = false } = {}) { + const aa = 4 + const w = size * aa + const rgba = Buffer.alloc(size * size * 4) + const pad = maskable ? 0.2 : 0.14 + const bgTop = [96, 156, 255] + const bgBottom = [29, 78, 216] + const bgDeep = [12, 22, 44] + for (let py = 0; py < size; py++) { + for (let px = 0; px < size; px++) { + let sr = 0 + let sg = 0 + let sb = 0 + let sa = 0 + for (let oy = 0; oy < aa; oy++) { + for (let ox = 0; ox < aa; ox++) { + const x = (px + (ox + 0.5) / aa) / size + const y = (py + (oy + 0.5) / aa) / size + const insideBg = fullSquare || roundedRectInside(x, y, 0.5, 0.5, 0.5, 0.5, 0.235) + if (!insideBg) continue + const t = clamp01((x + y) / 2.2) + let color = mix(bgTop, bgBottom, t) + const vignette = clamp01(Math.hypot(x - 0.3, y - 0.26) * 1.35) + color = mix(color, bgDeep, vignette * 0.24) + if (samplePlan(x, y, pad)) { + color = mix([255, 255, 255], [192, 219, 255], clamp01((x + y) / 2.4) * 0.45) + } + sr += color[0] + sg += color[1] + sb += color[2] + sa += 1 + } + } + const total = aa * aa + const i = (py * size + px) * 4 + if (sa === 0) { + rgba[i] = 0 + rgba[i + 1] = 0 + rgba[i + 2] = 0 + rgba[i + 3] = 0 + } else { + rgba[i] = Math.round(sr / sa) + rgba[i + 1] = Math.round(sg / sa) + rgba[i + 2] = Math.round(sb / sa) + rgba[i + 3] = Math.round((sa / total) * 255) + } + } + } + return encodePng(size, size, rgba) +} + +fs.writeFileSync(path.join(OUT, 'icon-192.png'), render(192)) +fs.writeFileSync(path.join(OUT, 'icon-512.png'), render(512)) +fs.writeFileSync(path.join(OUT, 'apple-touch-icon.png'), render(180, { fullSquare: true })) +fs.writeFileSync(path.join(OUT, 'icon-maskable-512.png'), render(512, { maskable: true, fullSquare: true })) +console.log('icons written to', OUT) diff --git a/scripts/patch-wasm-memory.mjs b/scripts/patch-wasm-memory.mjs new file mode 100644 index 0000000..5464889 --- /dev/null +++ b/scripts/patch-wasm-memory.mjs @@ -0,0 +1,86 @@ +import fs from 'node:fs' +import path from 'node:path' + +const source = process.argv[2] ?? 'node_modules/@mlightcad/libredwg-web/wasm/libredwg-web.wasm' +const target = process.argv[3] ?? 'public/vendor/libredwg/wasm/libredwg-web.wasm' +const INITIAL_PAGES = 4096 // 256 MiB; the module can still grow up to its 4 GiB maximum. +const MAX_PAGES = 65536 + +const buf = fs.readFileSync(source) +if (buf.readUInt32LE(0) !== 0x6d736100 || buf.readUInt32LE(4) !== 1) { + throw new Error('Not a WebAssembly module') +} + +function readU32(data, offset) { + let value = 0 + let shift = 0 + let pos = offset + while (true) { + const byte = data[pos++] + value += (byte & 0x7f) * 2 ** shift + if (!(byte & 0x80)) break + shift += 7 + if (shift > 35) throw new Error('Invalid LEB128 value') + } + return [value >>> 0, pos] +} + +function encodeU32(value) { + const bytes = [] + let v = value >>> 0 + do { + let byte = v & 0x7f + v >>>= 7 + if (v) byte |= 0x80 + bytes.push(byte) + } while (v) + return Buffer.from(bytes) +} + +function encodeSection(id, payload) { + return Buffer.concat([Buffer.from([id]), encodeU32(payload.length), payload]) +} + +const sections = [] +let pos = 8 +while (pos < buf.length) { + const id = buf[pos++] + const [size, afterSize] = readU32(buf, pos) + const payload = buf.subarray(afterSize, afterSize + size) + sections.push({ id, payload }) + pos = afterSize + size +} + +let patched = false +const output = [] +output.push(buf.subarray(0, 8)) +for (const section of sections) { + if (section.id === 5 && !patched) { + const [count, afterCount] = readU32(section.payload, 0) + if (count < 1) throw new Error('Memory section has no memory') + const flags = section.payload[afterCount] + if ((flags & 0x01) === 0) throw new Error('Memory has no maximum; refusing to patch') + const [oldMin, afterMin] = readU32(section.payload, afterCount + 1) + const [oldMax] = readU32(section.payload, afterMin) + if (oldMin !== 16384) throw new Error(`Unexpected initial memory: ${oldMin}`) + const payload = Buffer.concat([ + encodeU32(count), + Buffer.from([flags]), + encodeU32(INITIAL_PAGES), + encodeU32(MAX_PAGES), + section.payload.subarray(afterMin + encodeU32(oldMax).length) + ]) + output.push(encodeSection(5, payload)) + patched = true + console.log( + `patched memory: ${oldMin} -> ${INITIAL_PAGES} pages (${Math.round((INITIAL_PAGES * 64) / 1024)} MiB)` + ) + } else { + output.push(encodeSection(section.id, section.payload)) + } +} +if (!patched) throw new Error('Memory section not found') + +fs.mkdirSync(path.dirname(target), { recursive: true }) +fs.writeFileSync(target, Buffer.concat(output)) +console.log('wrote', target, fs.statSync(target).size, 'bytes') diff --git a/src/cad/acadAdapter.ts b/src/cad/acadAdapter.ts new file mode 100644 index 0000000..2fb51b7 --- /dev/null +++ b/src/cad/acadAdapter.ts @@ -0,0 +1,845 @@ +import './polyfills' +import { DwgReader } from '@node-projects/acad-ts' +import type { DwgDatabase } from '@mlightcad/libredwg-web' +import { IDENTITY, applyMat, matMul, matScaleAvg } from './geom' +import type { Mat } from './geom' +import { buildCadDocument } from './build' +import type { CadDocument } from './types' + +type AcadDoc = ReturnType +type AcadEntity = Record + +interface NormalizeState { + unknown: number +} + +interface BuildOptions { + fileName: string + fileSize: number + unknownCount: number + warnings: string[] +} + +const GRAPHICS = { + Extents: 1, + Circle: 2, + CirclePt3: 3, + CircularArc: 4, + CircularArc3Pt: 5, + Polyline: 6, + Polygon: 7, + Mesh: 8, + Shell: 9, + Text: 10, + Text2: 11, + XLine: 12, + Ray: 13, + SubentColor: 14, + SubentLayer: 16, + SubentLineType: 18, + SubentMarker: 19, + SubentFillon: 20, + SubentTrueColor: 22, + SubentLineWeight: 23, + SubentLineTypeScale: 24, + SubentThickness: 25, + SubentPlotStyleName: 26, + PushClip: 27, + PopClip: 28, + PushModelTransform: 29, + PushModelTransform2: 30, + PopModelTransform: 31, + PolylineWithNormal: 32, + LwPolyine: 33, + UnicodeText: 36, + UnicodeText2: 38 +} as const + +const DYNAMIC_BLOCK_TYPES = new Set([ + 'ACAD_PROXY_ENTITY', + 'ACAD_PROXY_OBJECT', + 'AEC_WALL', + 'AEC_WINDOW', + 'AEC_DOOR', + 'AEC_OPENING', + 'AEC_SLAB', + 'AEC_ROOF', + 'AEC_STAIR', + 'AEC_RAILING', + 'AEC_GRID', + 'AEC_COLUMN', + 'AEC_BEAM', + 'MULTILEADER' +]) + +export function buildAcadDocument( + buffer: ArrayBuffer, + fileName: string, + fileSize: number +): CadDocument { + const acad = DwgReader.readFromStream(buffer) + if (!acad.modelSpace) throw new Error('DWG 中没有可显示的模型空间。') + const state: NormalizeState = { unknown: 0 } + const blocks = normalizeBlocks(acad, state) + const layouts = normalizeLayouts(acad, blocks.map) + const layers = normalizeLayers(acad) + const lineTypes = normalizeLineTypes(acad) + const vports = normalizeVPorts(acad) + const imageDefs = normalizeImageDefs(acad) + const header = normalizeHeader(acad) + const unknownCount = state.unknown + const warnings: string[] = [] + if (unknownCount > 0) warnings.push(`${unknownCount} 个实体类型暂不支持显示。`) + const db = { + tables: { + LAYER: { entries: layers }, + BLOCK_RECORD: { entries: blocks.entries }, + LTYPE: { entries: lineTypes }, + VPORT: { entries: vports } + }, + objects: { + LAYOUT: layouts, + IMAGEDEF: imageDefs + }, + header, + entities: [] + } as unknown as DwgDatabase + return buildCadDocument(db, { + fileName, + fileSize, + unknownCount, + warnings + } satisfies BuildOptions) +} + +function normalizeBlocks(acad: AcadDoc, state: NormalizeState) { + const entries: Record[] = [] + const map = new Map>() + let index = 0 + for (const block of acad.blockRecords ?? []) { + const handle = String(block.handle ?? `block-${index}`) + const base = block.blockEntity?.basePoint ?? { x: 0, y: 0, z: 0 } + const entities: Record[] = [] + for (const entity of block.entities ?? []) { + entities.push(...normalizeEntity(entity, state)) + } + const entry = { + name: block.name ?? `*BLOCK${index}`, + handle, + baseX: Number(base.x) || 0, + baseY: Number(base.y) || 0, + baseZ: Number(base.z) || 0, + layoutHandle: block.layout?.handle == null ? '' : String(block.layout.handle), + entities + } + entries.push(entry) + if (block.handle != null) map.set(block.handle, entry) + index++ + } + return { entries, map } +} + +function normalizeLayouts(acad: AcadDoc, blocks: Map>) { + const layouts: Record[] = [] + let index = 0 + for (const layout of acad.layouts ?? []) { + const block = layout.associatedBlock + if (!block) continue + const entry = blocks.get(block.handle) + if (!entry) continue + const known = new Set(entry.entities.map((entity: any) => String(entity.handle ?? ''))) + for (const viewport of layout.viewports ?? []) { + const handle = String(viewport.handle ?? '') + if (handle && known.has(handle)) continue + entry.entities.push(...normalizeEntity(viewport, { unknown: 0 })) + if (handle) known.add(handle) + } + layouts.push({ + layoutName: layout.name ?? `Layout${index + 1}`, + tabOrder: Number(layout.tabOrder) || index, + handle: String(layout.handle ?? `layout-${index}`), + paperSpaceTableId: String(block.handle), + minExtent: layout.minExtents, + maxExtent: layout.maxExtents + }) + index++ + } + return layouts +} + +function normalizeLayers(acad: AcadDoc) { + const entries: Record[] = [] + for (const layer of acad.layers ?? []) { + const color = layer.color + const aci = color?.isTrueColor ? 7 : Number(color?.index) || 7 + const rgb = color?.isTrueColor ? Number(color.trueColor) >>> 0 : undefined + const flags = Number(layer.layerFlags) || 0 + entries.push({ + name: layer.name ?? '0', + handle: String(layer.handle ?? ''), + colorIndex: aci, + color: rgb, + off: layer.isOn === false, + frozen: (flags & 1) === 1, + lineType: layer.lineType?.name ?? 'Continuous', + lineweight: Number(layer.lineWeight) + }) + } + return entries +} + +function normalizeLineTypes(acad: AcadDoc) { + const entries: Record[] = [] + for (const lineType of acad.lineTypes ?? []) { + const segments = lineType.segments ?? [] + if (!segments.length) continue + entries.push({ + name: lineType.name, + pattern: segments.map((segment: any) => ({ + elementLength: Math.abs(Number(segment.length) || 0) + })) + }) + } + return entries +} + +function normalizeVPorts(acad: AcadDoc) { + const entries: Record[] = [] + for (const vport of acad.vPorts ?? []) { + entries.push({ + name: vport.name ?? '*Active', + center: { x: Number(vport.center?.x) || 0, y: Number(vport.center?.y) || 0 }, + viewTarget: { + x: Number(vport.target?.x) || 0, + y: Number(vport.target?.y) || 0 + }, + viewHeight: Number(vport.viewHeight) || 0, + aspectRatio: Number(vport.aspectRatio) || 1 + }) + } + return entries +} + +function normalizeImageDefs(acad: AcadDoc) { + const entries: Record[] = [] + for (const image of acad.imageDefinitions ?? []) { + entries.push({ + handle: String(image.handle ?? ''), + fileName: image.fileName ?? '栅格图像' + }) + } + return entries +} + +function normalizeHeader(acad: AcadDoc) { + const header = acad.header + return { + EXTMIN: header?.modelSpaceExtMin ?? { x: 0, y: 0, z: 0 }, + EXTMAX: header?.modelSpaceExtMax ?? { x: 0, y: 0, z: 0 }, + INSUNITS: Number(header?.insUnits) || 0, + LTSCALE: Number(header?.lineTypeScale) || 1, + ACADVER: header?.versionString ?? '' + } +} + +function normalizeEntity(entity: AcadEntity, state: NormalizeState): Record[] { + if (!entity) return [] + const type = String(entity.objectName ?? '').toUpperCase() + const base = commonFields(entity) + switch (type) { + case 'LINE': { + const start = entity.startPoint + const end = entity.endPoint + if (!start || !end) return [] + return [{ ...base, type, startPoint: start, endPoint: end, extrusionDirection: entity.normal }] + } + case 'CIRCLE': { + if (!entity.center) return [] + return [ + { + ...base, + type, + center: entity.center, + radius: Number(entity.radius) || 0, + extrusionDirection: entity.normal + } + ] + } + case 'ARC': { + if (!entity.center) return [] + const start = Number(entity.startAngle) || 0 + const end = Number(entity.endAngle) || 0 + return [ + { + ...base, + type, + center: entity.center, + radius: Number(entity.radius) || 0, + startAngle: start, + endAngle: end, + extrusionDirection: entity.normal + } + ] + } + case 'ELLIPSE': { + if (!entity.center || !entity.majorAxisEndPoint) return [] + const start = entity.isFullEllipse ? 0 : Number(entity.startParameter) || 0 + const end = entity.isFullEllipse ? Math.PI * 2 : Number(entity.endParameter) || 0 + return [ + { + ...base, + type, + center: entity.center, + majorAxisEndPoint: entity.majorAxisEndPoint, + axisRatio: Number(entity.radiusRatio) || 1, + startAngle: start, + endAngle: end, + extrusionDirection: entity.normal + } + ] + } + case 'LWPOLYLINE': { + const vertices = Array.isArray(entity.vertices) ? entity.vertices : [] + if (vertices.length < 2) return [] + return [ + { + ...base, + type, + vertices: vertices.map((vertex: any) => ({ + x: Number(vertex.location?.x) || 0, + y: Number(vertex.location?.y) || 0, + bulge: Number(vertex.bulge) || 0 + })), + flag: entity.isClosed ? 1 : 0, + constantWidth: Number(entity.constantWidth) || 0, + extrusionDirection: entity.normal + } + ] + } + case 'POLYLINE': { + const vertices = [...(entity.vertices ?? [])] + if (vertices.length < 2) return [] + return [ + { + ...base, + type, + vertices: vertices.map((vertex: any) => ({ + x: Number(vertex.location?.x) || 0, + y: Number(vertex.location?.y) || 0, + bulge: Number(vertex.bulge) || 0 + })), + flag: entity.isClosed ? 1 : 0, + extrusionDirection: entity.normal + } + ] + } + case 'SPLINE': { + const control = Array.isArray(entity.controlPoints) ? entity.controlPoints : [] + const fit = Array.isArray(entity.fitPoints) ? entity.fitPoints : [] + if (control.length < 2 && fit.length < 2) return [] + return [ + { + ...base, + type, + controlPoints: control, + fitPoints: fit, + degree: Number(entity.degree) || 3, + knots: Array.isArray(entity.knots) ? entity.knots : [], + weights: Array.isArray(entity.weights) && entity.weights.length ? entity.weights : undefined, + flag: entity.isClosed ? 1 : 0, + extrusionDirection: entity.normal + } + ] + } + case 'POINT': { + if (!entity.location) return [] + return [{ ...base, type, position: entity.location, extrusionDirection: entity.normal }] + } + case 'TEXT': { + return [normalizeText(entity, base)] + } + case 'MTEXT': { + if (!entity.insertPoint) return [] + return [ + { + ...base, + type, + text: entity.value ?? '', + insertionPoint: entity.insertPoint, + textHeight: Number(entity.height) || 0, + rotation: Number(entity.rotation) || 0, + rectWidth: Number(entity.rectangleWidth) || 0, + attachmentPoint: Number(entity.attachmentPoint) || 1, + lineSpacing: Number(entity.lineSpacing) || 1, + styleName: entity.style?.name + } + ] + } + case 'INSERT': { + const block = entity.block + if (!block) return [] + const attribs: Record[] = [] + for (const attribute of entity.attributes ?? []) { + if (!attribute || attribute.isInvisible) continue + if ((Number(attribute.flags) & 1) === 1) continue + attribs.push(normalizeText(attribute, commonFields(attribute), 'ATTRIB')) + } + return [ + { + ...base, + type, + name: block.name, + insertionPoint: entity.insertPoint, + rotation: Number(entity.rotation) || 0, + xScale: Number(entity.xScale) || 1, + yScale: Number(entity.yScale) || 1, + zScale: Number(entity.zScale) || 1, + rowCount: Number(entity.rowCount) || 1, + columnCount: Number(entity.columnCount) || 1, + rowSpacing: Number(entity.rowSpacing) || 0, + columnSpacing: Number(entity.columnSpacing) || 0, + extrusionDirection: entity.normal, + attribs + } + ] + } + case 'DIMENSION': { + const block = entity.block + if (!block) return [] + return [ + { + ...base, + type, + name: block.name, + blockName: block.name, + extrusionDirection: entity.normal + } + ] + } + case 'HATCH': { + return [normalizeHatch(entity, base)] + } + case 'SOLID': { + if (!entity.firstCorner || !entity.secondCorner || !entity.thirdCorner) return [] + return [ + { + ...base, + type, + corner1: entity.firstCorner, + corner2: entity.secondCorner, + corner3: entity.thirdCorner, + corner4: entity.fourthCorner ?? entity.thirdCorner, + extrusionDirection: entity.normal + } + ] + } + case '3DFACE': { + if (!entity.firstCorner || !entity.secondCorner || !entity.thirdCorner) return [] + return [ + { + ...base, + type, + corner1: entity.firstCorner, + corner2: entity.secondCorner, + corner3: entity.thirdCorner, + corner4: entity.fourthCorner ?? entity.thirdCorner, + extrusionDirection: entity.normal + } + ] + } + case 'WIPEOUT': { + const points = wipeoutPoints(entity) + if (points.length < 6) return [] + return [{ ...base, type, clippingBoundaryPath: points }] + } + case 'IMAGE': { + if (!entity.insertPoint) return [] + return [ + { + ...base, + type, + position: entity.insertPoint, + uPixel: entity.uVector, + vPixel: entity.vVector, + imageSize: entity.size, + imageDefHandle: entity.definition?.handle == null ? '' : String(entity.definition.handle) + } + ] + } + case 'OLE2FRAME': { + if (!entity.upperLeftCorner || !entity.lowerRightCorner) return [] + return [ + { + ...base, + type, + corner1: entity.upperLeftCorner, + corner2: entity.lowerRightCorner, + label: entity.sourceApplication || 'OLE 对象' + } + ] + } + case 'VIEWPORT': { + return [ + { + ...base, + type, + width: Number(entity.width) || 0, + height: Number(entity.height) || 0, + viewHeight: Number(entity.viewHeight) || 0, + viewportCenter: entity.center, + displayCenter: entity.viewCenter, + viewTwistAngle: Number(entity.twistAngle) || 0, + statusBitFlags: Number(entity.status) || 0, + isVisible: true + } + ] + } + case 'ACAD_PROXY_ENTITY': { + return normalizeProxyGeometries(entity, base, state) + } + case 'ATTDEF': + return [] + default: { + if (entity.proxyGeometries?.length) { + return normalizeProxyGeometries(entity, base, state) + } + if (DYNAMIC_BLOCK_TYPES.has(type)) { + state.unknown++ + } else if (type) { + state.unknown++ + } + return [] + } + } +} + +function commonFields(entity: AcadEntity) { + const color = entity.color + let colorIndex = 256 + let trueColor: number | undefined + if (color?.isByBlock) { + colorIndex = 0 + } else if (color?.isByLayer) { + colorIndex = 256 + } else if (color?.isTrueColor) { + colorIndex = 256 + trueColor = Number(color.trueColor) >>> 0 + } else if (Number.isFinite(color?.index)) { + colorIndex = Number(color.index) + } + return { + layer: entity.layer?.name ?? '0', + colorIndex, + color: trueColor, + lineweight: Number(entity.lineWeight), + lineType: entity.lineType?.name, + lineTypeScale: Number(entity.lineTypeScale) || 1, + isVisible: !entity.isInvisible + } +} + +function normalizeText(entity: AcadEntity, base: Record, type = 'TEXT') { + const horizontal = Number(entity.horizontalAlignment) || 0 + const vertical = Number(entity.verticalAlignment) || 0 + const hasAlignment = horizontal !== 0 || vertical !== 0 + const halign = horizontal === 2 ? 2 : horizontal === 1 || horizontal === 4 || horizontal === 3 || horizontal === 5 ? 1 : 0 + const start = entity.insertPoint ?? { x: 0, y: 0, z: 0 } + const end = hasAlignment ? entity.alignmentPoint ?? start : start + return { + ...base, + type, + text: entity.value ?? '', + startPoint: start, + endPoint: end, + textHeight: Number(entity.height) || 0, + rotation: Number(entity.rotation) || 0, + xScale: Number(entity.widthFactor) || 1, + halign, + valign: vertical, + generationFlag: Number(entity.mirror) || 0, + flags: Number(entity.flags) || 0, + extrusionDirection: entity.normal + } +} + +function normalizeHatch(entity: AcadEntity, base: Record) { + const paths: Record[] = [] + for (const path of entity.paths ?? []) { + let points: any[] = [] + try { + points = path.getPoints(48) ?? [] + } catch { + points = [] + } + if (points.length < 2) continue + paths.push({ + vertices: points.map((point: any) => ({ + x: Number(point.x) || 0, + y: Number(point.y) || 0, + bulge: 0 + })) + }) + } + const patternAngle = Number(entity.patternAngle) || 0 + const patternScale = Number(entity.patternScale) || 1 + const definitionLines = (entity.pattern?.lines ?? []).map((line: any) => ({ + offset: { x: Number(line.offset?.x) || 0, y: Number(line.offset?.y) || 0 } + })) + return { + ...base, + type: 'HATCH', + boundaryPaths: paths, + solidFill: entity.isSolid ? 1 : 0, + patternName: entity.pattern?.name ?? '', + patternAngle, + patternScale, + definitionLines + } +} + +function wipeoutPoints(entity: AcadEntity) { + const vertices = entity.clipBoundaryVertices ?? [] + if (!vertices.length) return [] + const origin = entity.insertPoint ?? { x: 0, y: 0, z: 0 } + const u = entity.uVector ?? { x: 1, y: 0, z: 0 } + const v = entity.vVector ?? { x: 0, y: 1, z: 0 } + const points: number[] = [] + for (const vertex of vertices) { + points.push( + (Number(origin.x) || 0) + (Number(u.x) || 0) * (Number(vertex.x) || 0) + (Number(v.x) || 0) * (Number(vertex.y) || 0), + (Number(origin.y) || 0) + (Number(u.y) || 0) * (Number(vertex.x) || 0) + (Number(v.y) || 0) * (Number(vertex.y) || 0) + ) + } + return points +} + +function normalizeProxyGeometries( + entity: AcadEntity, + base: Record, + state: NormalizeState +): Record[] { + const geometries = entity.proxyGeometries ?? [] + if (!geometries.length) return [] + const out: Record[] = [] + const stack: Mat[] = [] + let current: Mat = IDENTITY + const add = (shape: Record) => { + out.push({ ...base, ...shape, proxy: true }) + } + for (const geometry of geometries) { + const type = Number(geometry?.graphicsType) || 0 + switch (type) { + case GRAPHICS.Circle: { + const center = applyMat(current, Number(geometry.center?.x) || 0, Number(geometry.center?.y) || 0) + add({ + type: 'CIRCLE', + center: { x: center[0], y: center[1] }, + radius: Math.abs(Number(geometry.radius) || 0) * matScaleAvg(current) + }) + break + } + case GRAPHICS.CirclePt3: { + const circle = circleFrom3(geometry.point1, geometry.point2, geometry.point3) + if (!circle) break + const center = applyMat(current, circle.cx, circle.cy) + add({ + type: 'CIRCLE', + center: { x: center[0], y: center[1] }, + radius: circle.r * matScaleAvg(current) + }) + break + } + case GRAPHICS.CircularArc: { + const center = applyMat(current, Number(geometry.center?.x) || 0, Number(geometry.center?.y) || 0) + const start = Math.atan2(Number(geometry.startVectorDirection?.y) || 0, Number(geometry.startVectorDirection?.x) || 1) + const rotation = Math.atan2(current[1], current[0]) + const sweep = Math.abs(Number(geometry.sweepAngle) || 0) * (Number(geometry.arcType) === 2 ? -1 : 1) + add({ + type: 'ARC', + center: { x: center[0], y: center[1] }, + radius: Math.abs(Number(geometry.radius) || 0) * matScaleAvg(current), + startAngle: start + rotation, + endAngle: start + rotation + sweep + }) + break + } + case GRAPHICS.CircularArc3Pt: { + const circle = circleFrom3(geometry.point1, geometry.point2, geometry.point3) + if (!circle) break + const center = applyMat(current, circle.cx, circle.cy) + const start = Math.atan2(Number(geometry.point1?.y) - circle.cy, Number(geometry.point1?.x) - circle.cx) + const mid = Math.atan2(Number(geometry.point2?.y) - circle.cy, Number(geometry.point2?.x) - circle.cx) + const end = Math.atan2(Number(geometry.point3?.y) - circle.cy, Number(geometry.point3?.x) - circle.cx) + const rotation = Math.atan2(current[1], current[0]) + add({ + type: 'ARC', + center: { x: center[0], y: center[1] }, + radius: circle.r * matScaleAvg(current), + startAngle: start + rotation, + endAngle: start + rotation + sweepThrough(start, end, mid, Number(geometry.arcType) === 2) + }) + break + } + case GRAPHICS.Polyline: + case GRAPHICS.Polygon: + case GRAPHICS.PolylineWithNormal: { + const points = transformPoints(current, geometry.points) + if (points.length >= 4) { + add({ + type: 'LWPOLYLINE', + vertices: pointsToVertices(points), + flag: type === GRAPHICS.Polygon ? 1 : 0 + }) + } + break + } + case GRAPHICS.Mesh: { + const rows = Math.max(0, Number(geometry.rowCount) || 0) + const columns = Math.max(0, Number(geometry.columnCount) || 0) + const vertices = geometry.vertices ?? [] + for (let row = 0; row < rows; row++) { + const points: number[] = [] + for (let col = 0; col < columns; col++) { + const vertex = vertices[row * columns + col] + if (!vertex) continue + const point = applyMat(current, Number(vertex.x) || 0, Number(vertex.y) || 0) + points.push(point[0], point[1]) + } + if (points.length >= 4) { + add({ type: 'LWPOLYLINE', vertices: pointsToVertices(points), flag: 0 }) + } + } + for (let col = 0; col < columns; col++) { + const points: number[] = [] + for (let row = 0; row < rows; row++) { + const vertex = vertices[row * columns + col] + if (!vertex) continue + const point = applyMat(current, Number(vertex.x) || 0, Number(vertex.y) || 0) + points.push(point[0], point[1]) + } + if (points.length >= 4) { + add({ type: 'LWPOLYLINE', vertices: pointsToVertices(points), flag: 0 }) + } + } + break + } + case GRAPHICS.Shell: { + const vertices = geometry.vertices ?? [] + for (const face of geometry.faces ?? []) { + const points: number[] = [] + for (const index of face) { + const vertex = vertices[Math.abs(Number(index)) - 1] ?? vertices[Number(index)] + if (!vertex) continue + const point = applyMat(current, Number(vertex.x) || 0, Number(vertex.y) || 0) + points.push(point[0], point[1]) + } + if (points.length >= 6) { + add({ type: 'LWPOLYLINE', vertices: pointsToVertices(points), flag: 1 }) + } + } + break + } + case GRAPHICS.XLine: + case GRAPHICS.Ray: { + const p1 = geometry.point1 ?? geometry.constructionLinePoint + const p2 = geometry.point2 + if (!p1 || !p2) break + const a = applyMat(current, Number(p1.x) || 0, Number(p1.y) || 0) + const b = applyMat(current, Number(p2.x) || 0, Number(p2.y) || 0) + const dx = b[0] - a[0] + const dy = b[1] - a[1] + const len = Math.hypot(dx, dy) || 1 + const ux = dx / len + const uy = dy / len + const length = 1e6 + const points = + type === GRAPHICS.XLine + ? [a[0] - ux * length, a[1] - uy * length, a[0] + ux * length, a[1] + uy * length] + : [a[0], a[1], a[0] + ux * length, a[1] + uy * length] + add({ + type: type === GRAPHICS.XLine ? 'XLINE' : 'RAY', + firstPoint: { x: points[0], y: points[1] }, + unitDirection: { x: ux, y: uy } + }) + break + } + case GRAPHICS.PushModelTransform: + case GRAPHICS.PushModelTransform2: { + stack.push(current) + current = matMul(current, matrixToMat(geometry.matrix)) + break + } + case GRAPHICS.PopModelTransform: { + current = stack.pop() ?? IDENTITY + break + } + default: + break + } + } + if (!out.length && !entity.proxyGeometries?.length) state.unknown++ + return out +} + +function matrixToMat(matrix: any): Mat { + return [ + Number(matrix?.m00) || 0, + Number(matrix?.m10) || 0, + Number(matrix?.m01) || 0, + Number(matrix?.m11) || 0, + Number(matrix?.m03) || 0, + Number(matrix?.m13) || 0 + ] +} + +function transformPoints(mat: Mat, points: any[] = []) { + const out: number[] = [] + for (const point of points) { + const mapped = applyMat(mat, Number(point?.x) || 0, Number(point?.y) || 0) + out.push(mapped[0], mapped[1]) + } + return out +} + +function pointsToVertices(points: number[]) { + const vertices: Record[] = [] + for (let index = 0; index + 1 < points.length; index += 2) { + vertices.push({ x: points[index], y: points[index + 1], bulge: 0 }) + } + return vertices +} + +function circleFrom3(p1: any, p2: any, p3: any) { + if (!p1 || !p2 || !p3) return null + const ax = Number(p1.x) || 0 + const ay = Number(p1.y) || 0 + const bx = Number(p2.x) || 0 + const by = Number(p2.y) || 0 + const cx = Number(p3.x) || 0 + const cy = Number(p3.y) || 0 + const d = 2 * (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by)) + if (Math.abs(d) < 1e-12) return null + const a2 = ax * ax + ay * ay + const b2 = bx * bx + by * by + const c2 = cx * cx + cy * cy + const ux = (a2 * (by - cy) + b2 * (cy - ay) + c2 * (ay - by)) / d + const uy = (a2 * (cx - bx) + b2 * (ax - cx) + c2 * (bx - ax)) / d + return { cx: ux, cy: uy, r: Math.hypot(ux - ax, uy - ay) } +} + +function normalizeAngle(value: number) { + const tau = Math.PI * 2 + return ((value % tau) + tau) % tau +} + +function sweepThrough(start: number, end: number, mid: number, clockwise: boolean) { + if (clockwise) { + const full = Math.PI * 2 + const s = normalizeAngle(start - end) + const m = normalizeAngle(start - mid) + return m <= s ? -s : -(s + full) + } + const s = normalizeAngle(end - start) + const m = normalizeAngle(mid - start) + return m <= s ? s : s - Math.PI * 2 +} diff --git a/src/cad/build.ts b/src/cad/build.ts new file mode 100644 index 0000000..fd8120a --- /dev/null +++ b/src/cad/build.ts @@ -0,0 +1,1593 @@ +import type { + DwgDatabase, + DwgEntity, + DwgLayoutObject, + DwgViewportEntity +} from '@mlightcad/libredwg-web' +import { + IDENTITY, + applyMat, + bboxAddPoint, + bboxCenter, + bboxExpand, + bboxFromPoints, + bboxHeight, + bboxTransform, + bboxUnion, + bboxValid, + bboxWidth, + bulgeToArc, + clamp, + emptyBBox, + matMul, + matRotate, + matScale, + matTranslate +} from './geom' +import type { Mat } from './geom' +import type { ColorSpec } from './colors' +import { decodeCadEscapes, parseMText, textWidth } from './text' +import type { + ArcPrim, + BulgePrim, + CadBlockInfo, + CadDocument, + CadSpace, + CirclePrim, + EllipsePrim, + HatchPrim, + ImagePrim, + LayerInfo, + PointPrim, + PolyPrim, + PrimBase, + Primitive, + SpaceGrid, + SplinePrim, + TextPrim +} from './types' + +type AnyEntity = DwgEntity & Record + +interface BuildState { + doc: CadDocument + paper: boolean + prims: Primitive[] + depth: number + stack: Set +} + +interface BuildOptions { + fileName: string + fileSize: number + unknownCount: number + warnings: string[] +} + +const MODEL_PREFIX = 'MODEL_SPACE' +const PAPER_PREFIX = 'PAPER_SPACE' + +export function buildCadDocument(db: DwgDatabase, options: BuildOptions): CadDocument { + const layerMap = new Map() + const layers: LayerInfo[] = [] + for (const entry of db.tables.LAYER.entries) { + const aci = typeof entry.colorIndex === 'number' ? entry.colorIndex : 7 + const rgb = + typeof entry.color === 'number' && entry.color > 0 && entry.color !== 0xffffff + ? entry.color >>> 0 + : undefined + const info: LayerInfo = { + name: entry.name || '0', + handle: entry.handle, + aci: aci > 0 && aci < 256 ? aci : 7, + rgb, + visible: !entry.off && !entry.frozen, + off: !!entry.off, + frozen: !!entry.frozen, + count: 0, + lineType: entry.lineType || 'Continuous', + lineWeight: Number(entry.lineweight) || -1 + } + layers.push(info) + layerMap.set(info.name, info) + layerMap.set(info.name.toLowerCase(), info) + } + if (!layerMap.has('0')) { + const fallback: LayerInfo = { + name: '0', + handle: '0', + aci: 7, + visible: true, + off: false, + frozen: false, + count: 0, + lineType: 'Continuous', + lineWeight: -1 + } + layers.unshift(fallback) + layerMap.set('0', fallback) + } + + const blocks = new Map() + const blockByHandle = new Map() + for (const entry of db.tables.BLOCK_RECORD.entries) { + const info: CadBlockInfo = { + name: entry.name, + handle: entry.handle, + layoutHandle: entry.layout || '', + baseX: entry.basePoint?.x ?? 0, + baseY: entry.basePoint?.y ?? 0, + entities: entry.entities ?? [] + } + blocks.set(entry.name.toUpperCase(), info) + blockByHandle.set(entry.handle, info) + } + + const dashPatterns = new Map() + for (const ltype of db.tables.LTYPE.entries) { + if (!ltype.pattern || ltype.pattern.length === 0) continue + const pattern = ltype.pattern.map((el) => { + const len = Number(el.elementLength) + if (!Number.isFinite(len) || len === 0) return 0.12 + return Math.abs(len) + }) + dashPatterns.set(ltype.name, pattern) + dashPatterns.set(ltype.name.toLowerCase(), pattern) + } + + const imageNames = new Map() + for (const image of db.objects.IMAGEDEF) { + imageNames.set(image.handle, image.fileName || '栅格图像') + } + + const modelBlock = + findBlockByName(blocks, '*Model_Space') ?? + [...blocks.values()].find((b) => b.name.toUpperCase().includes(MODEL_PREFIX)) + if (!modelBlock) { + options.warnings.push('未找到模型空间,图纸可能已损坏。') + } + + const doc: CadDocument = { + db, + fileName: options.fileName, + fileSize: options.fileSize, + layers, + layerMap, + blocks, + blockByHandle, + dashPatterns, + imageNames, + spaces: [], + model: null as unknown as CadSpace, + units: String(db.header.INSUNITS ?? 0), + unitLabel: unitLabelFor(db.header.INSUNITS), + version: db.header.ACADVER ?? '', + unknownCount: options.unknownCount, + warnings: options.warnings + } + + const ltscale = Number(db.header.LTSCALE) > 0 ? Number(db.header.LTSCALE) : 1 + const modelEntities = modelBlock + ? modelBlock.entities.length + ? modelBlock.entities + : db.entities.filter((e) => e.ownerBlockRecordSoftId === modelBlock.handle) + : db.entities + + const model: CadSpace = { + id: 'model', + name: '模型', + kind: 'model', + blockHandle: modelBlock?.handle ?? '', + entities: modelEntities, + entityCount: modelEntities.length, + prims: [], + bbox: emptyBBox(), + viewports: [] + } + const modelState: BuildState = { doc, paper: false, prims: [], depth: 0, stack: new Set() } + buildEntities(modelEntities, modelState, IDENTITY, undefined, ltscale) + model.prims = modelState.prims + model.bbox = boundsOfPrims(model.prims) + if (!bboxValid(model.bbox) || bboxWidth(model.bbox) <= 0 || bboxHeight(model.bbox) <= 0) { + model.bbox = headerBounds(db) + } + if (!bboxValid(model.bbox)) model.bbox = { minX: 0, minY: 0, maxX: 100, maxY: 100 } + const robust = robustFitBounds(model.prims, model.bbox) + const header = headerBoundsOrNull(db) + let fit = robust + if (header) { + const headerArea = bboxWidth(header) * bboxHeight(header) + const robustArea = bboxWidth(robust) * bboxHeight(robust) + if (headerArea > 0 && headerArea < robustArea) fit = header + } + model.fitBBox = fit + model.savedView = findSavedView(db, header, robust) + model.grid = buildSpaceGrid(model.prims, fit) + doc.model = model + doc.spaces.push(model) + + const layoutObjects = [...db.objects.LAYOUT].sort((a, b) => { + const ta = Number(a.tabOrder) || 0 + const tb = Number(b.tabOrder) || 0 + if (ta !== tb) return ta - tb + return (a.layoutName || '').localeCompare(b.layoutName || '') + }) + + const usedBlocks = new Set() + const layoutSpaces: CadSpace[] = [] + for (const layout of layoutObjects) { + if (isModelLayout(layout)) continue + let block = blockByHandle.get(layout.paperSpaceTableId) + if (!block) { + block = [...blocks.values()].find((b) => b.layoutHandle === layout.handle) + } + if (!block) { + block = [...blocks.values()].find((b) => b.handle === layout.paperSpaceTableId) + } + if (!block) continue + if (block.handle === modelBlock?.handle) continue + if (usedBlocks.has(block.handle)) continue + usedBlocks.add(block.handle) + const entities = block.entities.length + ? block.entities + : db.entities.filter((e) => e.ownerBlockRecordSoftId === block!.handle) + const state: BuildState = { doc, paper: true, prims: [], depth: 0, stack: new Set() } + buildEntities(entities, state, IDENTITY, undefined, ltscale) + const viewports = entities.filter((e) => e.type === 'VIEWPORT') as DwgViewportEntity[] + let bbox = boundsOfPrims(state.prims) + for (const vp of viewports) { + const vb = viewportBBox(vp) + if (vb) bbox = bboxUnion(bbox, vb) + } + const extent = layoutExtent(layout) + if (extent && bboxValid(extent)) { + if (!bboxValid(bbox)) bbox = extent + else if ( + bboxWidth(extent) < bboxWidth(bbox) * 8 + 2000 && + bboxHeight(extent) < bboxHeight(bbox) * 8 + 2000 + ) { + bbox = bboxUnion(bbox, extent) + } + } + if (!bboxValid(bbox) || bboxWidth(bbox) <= 0 || bboxHeight(bbox) <= 0) { + bbox = { minX: 0, minY: 0, maxX: 420, maxY: 297 } + } + layoutSpaces.push({ + id: `layout:${block.handle}`, + name: friendlyLayoutName(layout.layoutName, layoutSpaces.length + 1), + kind: 'layout', + blockHandle: block.handle, + entities, + entityCount: entities.length, + prims: state.prims, + grid: buildSpaceGrid(state.prims, bbox), + bbox, + fitBBox: bbox, + viewports, + layout + }) + } + + if (layoutSpaces.length === 0) { + const paperBlocks = [...blocks.values()] + .filter((b) => b.name.toUpperCase().includes(PAPER_PREFIX) && b.handle !== modelBlock?.handle) + .sort((a, b) => a.name.localeCompare(b.name)) + for (const block of paperBlocks) { + if (usedBlocks.has(block.handle)) continue + usedBlocks.add(block.handle) + const entities = block.entities.length + ? block.entities + : db.entities.filter((e) => e.ownerBlockRecordSoftId === block.handle) + const state: BuildState = { doc, paper: true, prims: [], depth: 0, stack: new Set() } + buildEntities(entities, state, IDENTITY, undefined, ltscale) + const viewports = entities.filter((e) => e.type === 'VIEWPORT') as DwgViewportEntity[] + let bbox = boundsOfPrims(state.prims) + for (const vp of viewports) { + const vb = viewportBBox(vp) + if (vb) bbox = bboxUnion(bbox, vb) + } + if (!bboxValid(bbox)) bbox = { minX: 0, minY: 0, maxX: 420, maxY: 297 } + layoutSpaces.push({ + id: `layout:${block.handle}`, + name: `布局 ${layoutSpaces.length + 1}`, + kind: 'layout', + blockHandle: block.handle, + entities, + entityCount: entities.length, + prims: state.prims, + grid: buildSpaceGrid(state.prims, bbox), + bbox, + fitBBox: bbox, + viewports + }) + } + } + + layoutSpaces.sort((a, b) => { + const ta = Number(a.layout?.tabOrder) || 0 + const tb = Number(b.layout?.tabOrder) || 0 + if (ta !== tb) return ta - tb + return a.name.localeCompare(b.name) + }) + doc.spaces.push(...layoutSpaces) + const counts = new Map() + for (const space of doc.spaces) { + for (const entity of space.entities) { + const name = entity.layer || '0' + counts.set(name, (counts.get(name) ?? 0) + 1) + } + } + for (const layer of layers) layer.count = counts.get(layer.name) ?? 0 + if (layoutSpaces.length === 0) { + options.warnings.push('此图纸没有可用的布局空间(仅显示模型空间)。') + } + return doc +} + +function findBlockByName(blocks: Map, name: string): CadBlockInfo | undefined { + return blocks.get(name.toUpperCase()) +} + +function isModelLayout(layout: DwgLayoutObject): boolean { + const name = (layout.layoutName || '').trim().toLowerCase() + return name === 'model' || name === '模型' +} + +function friendlyLayoutName(name: string | undefined, fallbackIndex: number): string { + const trimmed = (name || '').trim() + if (!trimmed) return `布局 ${fallbackIndex}` + const match = /^layout\s*(\d+)$/i.exec(trimmed) + if (match) return `布局 ${match[1]}` + return trimmed +} + +function unitLabelFor(insunits: unknown): string { + const value = Number(insunits) + switch (value) { + case 1: + return 'in' + case 2: + return 'ft' + case 3: + return 'mi' + case 4: + return 'mm' + case 5: + return 'cm' + case 6: + return 'm' + case 7: + return 'km' + case 8: + return 'µin' + case 9: + return 'mil' + case 10: + return 'yd' + case 13: + return 'µm' + case 14: + return 'dm' + default: + return '' + } +} + +function headerBounds(db: DwgDatabase): BBoxLike { + return headerBoundsOrNull(db) ?? { minX: 0, minY: 0, maxX: 100, maxY: 100 } +} + +function headerBoundsOrNull(db: DwgDatabase): BBoxLike | null { + const min = db.header.EXTMIN + const max = db.header.EXTMAX + if ( + min && + max && + [min.x, min.y, max.x, max.y].every((v) => Number.isFinite(v)) && + Math.abs(min.x) < 1e12 && + Math.abs(min.y) < 1e12 && + Math.abs(max.x) < 1e12 && + Math.abs(max.y) < 1e12 && + max.x > min.x && + max.y > min.y + ) { + return { minX: min.x, minY: min.y, maxX: max.x, maxY: max.y } + } + return null +} + +function insideBox(x: number, y: number, box: BBoxLike): boolean { + return x >= box.minX && x <= box.maxX && y >= box.minY && y <= box.maxY +} + +function findSavedView( + db: DwgDatabase, + header: BBoxLike | null, + robust: BBoxLike +): { cx: number; cy: number; width: number; height: number } | undefined { + const vports = db.tables.VPORT.entries + if (!vports.length) return undefined + const vp = + vports.find((entry) => entry.name.toUpperCase() === '*ACTIVE') ?? + vports.find((entry) => Number(entry.viewHeight) > 0) ?? + vports[0] + const height = Number(vp.viewHeight) + if (!Number.isFinite(height) || height <= 0) return undefined + const center = vp.center + const target = vp.viewTarget + const cx = Number(center?.x) + const cy = Number(center?.y) + const tx = Number(target?.x) + const ty = Number(target?.y) + const useCenter = Number.isFinite(cx) && Number.isFinite(cy) + const px = useCenter ? cx : tx + const py = useCenter ? cy : ty + if (!Number.isFinite(px) || !Number.isFinite(py)) return undefined + if (!insideBox(px, py, robust) && !(header && insideBox(px, py, header))) { + return undefined + } + const aspect = Number(vp.aspectRatio) + const width = height * (Number.isFinite(aspect) && aspect > 0 ? aspect : 1.6) + return { cx: px, cy: py, width, height } +} + +type BBoxLike = { minX: number; minY: number; maxX: number; maxY: number } + +function layoutExtent(layout: DwgLayoutObject): BBoxLike | null { + const min = layout.minExtent + const max = layout.maxExtent + if ( + min && + max && + [min.x, min.y, max.x, max.y].every((v) => Number.isFinite(v)) && + max.x > min.x && + max.y > min.y && + max.x - min.x < 1e7 && + max.y - min.y < 1e7 + ) { + return { minX: min.x, minY: min.y, maxX: max.x, maxY: max.y } + } + return null +} + +function viewportBBox(vp: DwgViewportEntity): BBoxLike | null { + const width = Math.abs(Number(vp.width) || 0) + const height = Math.abs(Number(vp.height) || 0) + if (width <= 0 || height <= 0) return null + const cx = vp.viewportCenter?.x ?? 0 + const cy = vp.viewportCenter?.y ?? 0 + return { minX: cx - width / 2, minY: cy - height / 2, maxX: cx + width / 2, maxY: cy + height / 2 } +} + +function boundsOfPrims(prims: Primitive[]): BBoxLike { + let bbox = emptyBBox() + for (const prim of prims) { + if (prim.ignoreBounds) continue + bbox = bboxUnion(bbox, prim.bbox) + } + return bbox +} + +function buildSpaceGrid(prims: Primitive[], bbox: BBoxLike): SpaceGrid | undefined { + if (!prims.length || !bboxValid(bbox)) return undefined + const width = Math.max(bboxWidth(bbox), 1e-9) + const height = Math.max(bboxHeight(bbox), 1e-9) + const size = clamp(Math.ceil(Math.sqrt(prims.length)), 8, 96) + const cols = size + const rows = size + const cellW = width / cols + const cellH = height / rows + const cells: number[][] = Array.from({ length: cols * rows }, () => []) + const big: number[] = [] + + for (let index = 0; index < prims.length; index++) { + const prim = prims[index] + if (prim.ignoreBounds || !bboxValid(prim.bbox)) { + big.push(index) + continue + } + if ( + prim.bbox.maxX < bbox.minX || + prim.bbox.minX > bbox.maxX || + prim.bbox.maxY < bbox.minY || + prim.bbox.minY > bbox.maxY + ) { + big.push(index) + continue + } + const c0 = clamp(Math.floor((prim.bbox.minX - bbox.minX) / cellW), 0, cols - 1) + const c1 = clamp(Math.floor((prim.bbox.maxX - bbox.minX) / cellW), 0, cols - 1) + const r0 = clamp(Math.floor((prim.bbox.minY - bbox.minY) / cellH), 0, rows - 1) + const r1 = clamp(Math.floor((prim.bbox.maxY - bbox.minY) / cellH), 0, rows - 1) + if ((c1 - c0 + 1) * (r1 - r0 + 1) > 256) { + big.push(index) + continue + } + for (let row = r0; row <= r1; row++) { + for (let col = c0; col <= c1; col++) { + cells[row * cols + col].push(index) + } + } + } + + return { minX: bbox.minX, minY: bbox.minY, cellW, cellH, cols, rows, cells, big } +} + +function robustFitBounds(prims: Primitive[], raw: BBoxLike): BBoxLike { + if (!bboxValid(raw) || prims.length < 100) return raw + const xs: number[] = [] + const ys: number[] = [] + for (const prim of prims) { + if (prim.ignoreBounds || !bboxValid(prim.bbox)) continue + xs.push((prim.bbox.minX + prim.bbox.maxX) / 2) + ys.push((prim.bbox.minY + prim.bbox.maxY) / 2) + } + if (xs.length < 100) return raw + xs.sort((a, b) => a - b) + ys.sort((a, b) => a - b) + const n = xs.length + const trim = n > 20000 ? 0.01 : 0.02 + const lo = Math.floor(n * trim) + const hi = Math.max(lo, Math.ceil(n * (1 - trim)) - 1) + let candidate: BBoxLike = { + minX: xs[lo], + minY: ys[lo], + maxX: xs[hi], + maxY: ys[hi] + } + if (!bboxValid(candidate) || bboxWidth(candidate) <= 0 || bboxHeight(candidate) <= 0) { + return raw + } + candidate = bboxExpand( + candidate, + Math.max(bboxWidth(candidate) * 0.04, 1e-9), + Math.max(bboxHeight(candidate) * 0.04, 1e-9) + ) + return candidate +} + +function buildEntities( + entities: DwgEntity[], + state: BuildState, + mat: Mat, + inherit: ColorSpec | undefined, + ltscale: number +): void { + for (const entity of entities) { + buildEntity(entity as AnyEntity, state, mat, inherit, ltscale) + } +} + +function buildEntity( + entity: AnyEntity, + state: BuildState, + mat: Mat, + inherit: ColorSpec | undefined, + ltscale: number +): void { + if (!entity || entity.isVisible === false) return + const type = String(entity.type || '').toUpperCase() + if (type === 'VIEWPORT' && !state.paper) return + const extrusion = entity.extrusionDirection + const mirror = extrusion && Number(extrusion.z) === -1 ? matScale(-1, 1) : null + const em = mirror ? matMul(mat, mirror) : mat + const color = resolveColor(entity, state.doc, inherit) + const width = lineWidthOf(entity, state.paper, state.doc) + const dashInfo = resolveDash(entity, state.doc, ltscale) + + switch (type) { + case 'LINE': { + const a = entity.startPoint + const b = entity.endPoint + if (!a || !b) return + const points = [a.x, a.y, b.x, b.y] + addPoly(state, entity, em, points, false, false, true, color, width, dashInfo) + return + } + case 'CIRCLE': { + const c = entity.center + const r = Math.abs(Number(entity.radius) || 0) + if (!c || r <= 0) return + const prim: CirclePrim = { + kind: 'circle', +...base(entity, em, color, width, dashInfo), + cx: c.x, + cy: c.y, + r, + fill: false + } + prim.bbox = circleBBox(c.x, c.y, r, em) + state.prims.push(prim) + return + } + case 'ARC': { + const c = entity.center + const r = Math.abs(Number(entity.radius) || 0) + if (!c || r <= 0) return + const a0 = Number(entity.startAngle) || 0 + const a1 = Number(entity.endAngle) || 0 + let sweep = a1 - a0 + while (sweep <= 0) sweep += Math.PI * 2 + const prim: ArcPrim = { + kind: 'arc', +...base(entity, em, color, width, dashInfo), + cx: c.x, + cy: c.y, + r, + a0, + sweep + } + prim.bbox = circleBBox(c.x, c.y, r, em) + state.prims.push(prim) + return + } + case 'ELLIPSE': { + const c = entity.center + const major = entity.majorAxisEndPoint + if (!c || !major) return + const mx = Number(major.x) || 0 + const my = Number(major.y) || 0 + if (Math.abs(mx) + Math.abs(my) < 1e-12) return + const ratio = clamp(Number(entity.axisRatio) || 1, 0.0001, 1) + const a0 = Number(entity.startAngle) || 0 + const a1 = Number(entity.endAngle) || Math.PI * 2 + let sweep = a1 - a0 + if (Math.abs(sweep) < 1e-9) sweep = Math.PI * 2 + if (sweep < 0) sweep += Math.PI * 2 + const prim: EllipsePrim = { + kind: 'ellipse', +...base(entity, em, color, width, dashInfo), + cx: c.x, + cy: c.y, + mx, + my, + ratio, + a0, + sweep, + fill: false + } + const r = Math.hypot(mx, my) * Math.max(ratio, 1) + prim.bbox = circleBBox(c.x, c.y, r, em) + state.prims.push(prim) + return + } + case 'LWPOLYLINE': { + const vertices = Array.isArray(entity.vertices) ? entity.vertices : [] + if (vertices.length < 2) return + const closed = (Number(entity.flag) & 1) === 1 + const hasBulge = vertices.some((v: any) => Math.abs(Number(v.bulge) || 0) > 1e-9) + const worldWidth = Math.abs(Number(entity.constantWidth) || 0) + if (hasBulge) { + const prim: BulgePrim = { + kind: 'bulge', +...base(entity, em, color, width, dashInfo, worldWidth > 0 ? worldWidth : undefined), + vertices: vertices.map((v: any) => ({ + x: Number(v.x) || 0, + y: Number(v.y) || 0, + bulge: Number(v.bulge) || 0 + })), + closed + } + prim.bbox = bulgeBounds(prim.vertices, closed, em) + state.prims.push(prim) + } else { + const points: number[] = [] + for (const v of vertices) points.push(Number(v.x) || 0, Number(v.y) || 0) + addPoly(state, entity, em, points, closed, false, true, color, width, dashInfo, worldWidth) + } + return + } + case 'POLYLINE': + case 'POLYLINE2D': + case 'POLYLINE3D': + case 'POLYLINE_PFACE': + case 'POLYLINE_MESH': { + const vertices = Array.isArray(entity.vertices) ? entity.vertices : [] + if (vertices.length < 2) return + const closed = (Number(entity.flag) & 1) === 1 + const hasBulge = vertices.some((v: any) => Math.abs(Number(v.bulge) || 0) > 1e-9) + if (hasBulge) { + const prim: BulgePrim = { + kind: 'bulge', +...base(entity, em, color, width, dashInfo), + vertices: vertices.map((v: any) => ({ + x: Number(v.x) || 0, + y: Number(v.y) || 0, + bulge: Number(v.bulge) || 0 + })), + closed + } + prim.bbox = bulgeBounds(prim.vertices, closed, em) + state.prims.push(prim) + } else { + const points: number[] = [] + for (const v of vertices) points.push(Number(v.x) || 0, Number(v.y) || 0) + addPoly(state, entity, em, points, closed, false, true, color, width, dashInfo) + } + return + } + case 'SPLINE': { + const control = Array.isArray(entity.controlPoints) ? entity.controlPoints : [] + const fit = Array.isArray(entity.fitPoints) ? entity.fitPoints : [] + const source = control.length >= 2 ? control : fit + if (source.length < 2) return + const flat: number[] = [] + for (const p of source) flat.push(Number(p.x) || 0, Number(p.y) || 0) + const prim: SplinePrim = { + kind: 'spline', + ...base(entity, em, color, width, dashInfo), + control: flat, + degree: Math.max(1, Number(entity.degree) || 3), + knots: Array.isArray(entity.knots) ? entity.knots.map((n: any) => Number(n) || 0) : [], + weights: Array.isArray(entity.weights) && entity.weights.length ? entity.weights : undefined, + closed: (Number(entity.flag) & 1) === 1 + } + prim.bbox = bboxTransform(em, bboxFromPoints(flat)) + if (!bboxValid(prim.bbox)) prim.bbox = circleBBox(flat[0] ?? 0, flat[1] ?? 0, 1, em) + state.prims.push(prim) + return + } + case 'TEXT': { + addTextEntity(entity, state, em, color, width, dashInfo) + return + } + case 'MTEXT': { + addMTextEntity(entity, state, em, color, width, dashInfo) + return + } + case 'ATTRIB': { + const data = entity.text + if (!data) return + addTextData(data, state, em, color, width, dashInfo, inherit, entity) + return + } + case 'ATTDEF': + case 'SEQEND': + case 'ENDBLK': + case 'BLOCK': + return + case 'INSERT': + case 'MINSERT': { + addInsert(entity, state, em, color, width, dashInfo, ltscale) + return + } + case 'DIMENSION': { + const name = String(entity.name || entity.blockName || '') + const block = state.doc.blocks.get(name.toUpperCase()) + if (!block || state.stack.has(block.name) || state.depth > 12) return + state.stack.add(block.name) + state.depth++ + buildEntities(block.entities, state, em, color, ltscale) + state.depth-- + state.stack.delete(block.name) + return + } + case 'LEADER': { + addLeader(entity, state, em, color, width, dashInfo) + return + } + case 'RAY': + case 'XLINE': { + const p = entity.firstPoint + const d = entity.unitDirection + if (!p || !d) return + const length = 1e6 + const dx = Number(d.x) || 0 + const dy = Number(d.y) || 0 + const len = Math.hypot(dx, dy) || 1 + const ux = dx / len + const uy = dy / len + const points = + type === 'XLINE' + ? [p.x - ux * length, p.y - uy * length, p.x + ux * length, p.y + uy * length] + : [p.x, p.y, p.x + ux * length, p.y + uy * length] + addPoly(state, entity, em, points, false, false, true, color, width, dashInfo, undefined, true) + return + } + case 'SOLID': + case 'TRACE': + case '3DFACE': { + const c1 = entity.corner1 + const c2 = entity.corner2 + const c3 = entity.corner3 + const c4 = entity.corner4 ?? entity.corner3 + if (!c1 || !c2 || !c3) return + const points = + type === '3DFACE' + ? [c1.x, c1.y, c2.x, c2.y, c3.x, c3.y, c4.x, c4.y] + : [c1.x, c1.y, c2.x, c2.y, c4.x, c4.y, c3.x, c3.y] + addPoly(state, entity, em, points, true, type !== '3DFACE', type === '3DFACE', color, width, dashInfo) + return + } + case 'POINT': { + const p = entity.position + if (!p) return + const prim: PointPrim = { + kind: 'point', +...base(entity, em, color, width, dashInfo), + x: p.x, + y: p.y + } + prim.bbox = bboxTransform(em, { minX: p.x, minY: p.y, maxX: p.x, maxY: p.y }) + state.prims.push(prim) + return + } + case 'HATCH': { + addHatch(entity, state, em, color, width, dashInfo) + return + } + case 'WIPEOUT': { + const pts = wipeoutPoints(entity) + if (pts.length < 6) return + const prim: PolyPrim = { + kind: 'poly', +...base(entity, em, color, width, dashInfo), + points: pts, + closed: true, + fill: true, + fillBackground: true, + stroke: false + } + prim.bbox = bboxTransform(em, bboxFromPoints(pts)) + state.prims.push(prim) + return + } + case 'IMAGE': { + const pos = entity.position + const u = entity.uPixel + const v = entity.vPixel + const size = entity.imageSize + if (!pos) return + const w = Math.abs(Number(size?.x) || 0) + const h = Math.abs(Number(size?.y) || 0) + const ux = Number(u?.x) || 0 + const uy = Number(u?.y) || 0 + const vx = Number(v?.x) || 0 + const vy = Number(v?.y) || 0 + if (w <= 0 || h <= 0 || (!ux && !uy && !vx && !vy)) return + const pts = [ + pos.x, + pos.y, + pos.x + ux * w, + pos.y + uy * w, + pos.x + ux * w + vx * h, + pos.y + uy * w + vy * h, + pos.x + vx * h, + pos.y + vy * h + ] + const label = state.doc.imageNames.get(String(entity.imageDefHandle || '')) || '栅格图像' + const prim: ImagePrim = { + kind: 'image', +...base(entity, em, color, width, dashInfo), + x1: 0, + y1: 0, + x2: 0, + y2: 0, + points: pts, + label + } + const p = bboxTransform(em, bboxFromPoints(pts)) + prim.bbox = p + prim.x1 = p.minX + prim.y1 = p.minY + prim.x2 = p.maxX + prim.y2 = p.maxY + state.prims.push(prim) + return + } + case 'ACAD_TABLE': + case 'TABLE': { + addTable(entity, state, em, color, width, dashInfo) + return + } + case 'TOLERANCE': { + if (!entity.text) return + const fake = { + ...entity, + type: 'MTEXT', + insertionPoint: entity.insertionPoint ?? { x: 0, y: 0, z: 0 }, + textHeight: Number(entity.textHeight) || 2.5, + rotation: 0, + text: entity.text, + rectWidth: 0, + extentsWidth: 0, + attachmentPoint: 1, + lineSpacing: 1, + styleName: entity.styleName + } + addMTextEntity(fake, state, em, color, width, dashInfo) + return + } + case 'OLE2FRAME': { + const a = entity.corner1 + const b = entity.corner2 + if (!a || !b) return + const x1 = Math.min(Number(a.x) || 0, Number(b.x) || 0) + const x2 = Math.max(Number(a.x) || 0, Number(b.x) || 0) + const y1 = Math.min(Number(a.y) || 0, Number(b.y) || 0) + const y2 = Math.max(Number(a.y) || 0, Number(b.y) || 0) + const points = [x1, y1, x2, y1, x2, y2, x1, y2] + const prim: ImagePrim = { + kind: 'image', + ...base(entity, em, color, width, dashInfo), + x1, + y1, + x2, + y2, + points, + label: String(entity.label || 'OLE 对象') + } + prim.bbox = bboxTransform(em, bboxFromPoints(points)) + state.prims.push(prim) + return + } + default: + return + } +} + +function base( + entity: AnyEntity, + mat: Mat, + color: ColorSpec, + width: number, + dash: number[] | undefined, + worldWidth?: number, + ignoreBounds?: boolean +): PrimBase { + return { + layer: entity.layer || '0', + color, + width, + worldWidth, + dash, + bbox: emptyBBox(), + mat, + ignoreBounds, + proxy: entity.proxy === true ? true : undefined + } +} + +function addPoly( + state: BuildState, + entity: AnyEntity, + mat: Mat, + points: number[], + closed: boolean, + fill: boolean, + stroke: boolean, + color: ColorSpec, + width: number, + dash: number[] | undefined, + worldWidth?: number, + ignoreBounds?: boolean +): void { + if (points.length < 4) return + const prim: PolyPrim = { + kind: 'poly', +...base(entity, mat, color, width, dash, worldWidth, ignoreBounds), + points, + closed, + fill, + stroke + } + prim.bbox = bboxTransform(mat, bboxFromPoints(points)) + state.prims.push(prim) +} + +function addTextEntity( + entity: AnyEntity, + state: BuildState, + mat: Mat, + color: ColorSpec, + width: number, + dash: number[] | undefined +): void { + const data = { + text: entity.text, + startPoint: entity.startPoint, + endPoint: entity.endPoint, + textHeight: entity.textHeight, + rotation: entity.rotation, + xScale: entity.xScale, + halign: entity.halign, + valign: entity.valign, + generationFlag: entity.generationFlag + } + addTextData(data, state, mat, color, width, dash, undefined, entity) +} + +function addTextData( + data: Record, + state: BuildState, + mat: Mat, + color: ColorSpec, + width: number, + dash: number[] | undefined, + _inherit: ColorSpec | undefined, + entity: AnyEntity +): void { + const raw = String(data.text ?? '') + if (!raw) return + const lines = [decodeCadEscapes(raw)].filter((l) => l.length > 0) + if (!lines.length) return + const height = Math.abs(Number(data.textHeight) || 0) + if (height <= 0) return + const halignRaw = Number(data.halign) || 0 + const valignRaw = Number(data.valign) || 0 + const halign: TextPrim['halign'] = + halignRaw === 1 || halignRaw === 4 ? 'center' : halignRaw === 2 ? 'right' : 'left' + const valign: TextPrim['valign'] = + valignRaw === 3 ? 'top' : valignRaw === 2 ? 'middle' : valignRaw === 1 ? 'bottom' : 'baseline' + const hasAlign = halignRaw !== 0 || valignRaw !== 0 + const end = data.endPoint + const hasEnd = + end && (Math.abs(Number(end.x) || 0) > 1e-12 || Math.abs(Number(end.y) || 0) > 1e-12) + const anchor = hasAlign && hasEnd ? end : data.startPoint + if (!anchor) return + const x = Number(anchor.x) || 0 + const y = Number(anchor.y) || 0 + const rotation = Number(data.rotation) || 0 + const widthFactor = Math.abs(Number(data.xScale) || 1) || 1 + const lineHeight = height * 1.28 + const prim: TextPrim = { + kind: 'text', +...base(entity, mat, color, width, dash), + x, + y, + height, + rotation, + lines, + halign, + valign, + lineHeight, + widthFactor, + mirrored: (Number(data.generationFlag) & 2) === 2 + } + prim.bbox = textBBox(prim, mat) + state.prims.push(prim) +} + +function addMTextEntity( + entity: AnyEntity, + state: BuildState, + mat: Mat, + color: ColorSpec, + width: number, + dash: number[] | undefined +): void { + const raw = String(entity.text ?? '') + if (!raw) return + const height = Math.abs(Number(entity.textHeight) || 0) + if (height <= 0) return + const rectWidth = Math.abs(Number(entity.rectWidth) || 0) + const wrapWidth = rectWidth + let lines = parseMText(raw, wrapWidth, height) + if (!lines.length) lines = [decodeCadEscapes(raw)] + lines = lines.filter((line) => line.length > 0) + if (!lines.length) return + const attach = Number(entity.attachmentPoint) || 1 + const halign: TextPrim['halign'] = + attach === 2 || attach === 5 || attach === 8 + ? 'center' + : attach === 3 || attach === 6 || attach === 9 + ? 'right' + : 'left' + const valign: TextPrim['valign'] = + attach === 1 || attach === 2 || attach === 3 + ? 'top' + : attach === 4 || attach === 5 || attach === 6 + ? 'middle' + : 'bottom' + const p = entity.insertionPoint + if (!p) return + let rotation = Number(entity.rotation) || 0 + if (Math.abs(rotation) < 1e-9 && entity.direction) { + const dx = Number(entity.direction.x) || 0 + const dy = Number(entity.direction.y) || 0 + if (dx || dy) rotation = Math.atan2(dy, dx) + } + const lineSpacing = Number(entity.lineSpacing) || 1 + const lineHeight = height * 1.35 * clamp(lineSpacing, 0.3, 3) + const prim: TextPrim = { + kind: 'text', +...base(entity, mat, color, width, dash), + x: Number(p.x) || 0, + y: Number(p.y) || 0, + height, + rotation, + lines, + halign, + valign, + lineHeight, + widthFactor: 1, + mirrored: false + } + prim.bbox = textBBox(prim, mat) + state.prims.push(prim) +} + +function addInsert( + entity: AnyEntity, + state: BuildState, + mat: Mat, + color: ColorSpec, + width: number, + dash: number[] | undefined, + ltscale: number +): void { + const name = String(entity.name || '') + const block = state.doc.blocks.get(name.toUpperCase()) + if (!block) return + if (state.stack.has(block.name) || state.depth > 12) return + const pos = entity.insertionPoint ?? { x: 0, y: 0, z: 0 } + const rotation = Number(entity.rotation) || 0 + const sx = Number(entity.xScale) || 1 + const sy = Number(entity.yScale) || 1 + const rows = clamp(Math.floor(Number(entity.rowCount) || 1), 1, 100) + const cols = clamp(Math.floor(Number(entity.columnCount) || 1), 1, 100) + const rowSpacing = Number(entity.rowSpacing) || 0 + const colSpacing = Number(entity.columnSpacing) || 0 + const baseX = block.baseX || 0 + const baseY = block.baseY || 0 + state.stack.add(block.name) + state.depth++ + for (let row = 0; row < rows; row++) { + for (let col = 0; col < cols; col++) { + let m = matMul(mat, matTranslate(Number(pos.x) || 0, Number(pos.y) || 0)) + m = matMul(m, matRotate(rotation)) + m = matMul(m, matScale(sx, sy)) + if (col || row) m = matMul(m, matTranslate(col * colSpacing, row * rowSpacing)) + m = matMul(m, matTranslate(-baseX, -baseY)) + buildEntities(block.entities, state, m, color, ltscale) + } + } + state.depth-- + state.stack.delete(block.name) + + if (Array.isArray(entity.attribs)) { + for (const attrib of entity.attribs) { + if (!attrib || attrib.isVisible === false) continue + if ((Number(attrib.flags) & 1) === 1) continue + const data = attrib.text ?? attrib + const attrColor = resolveColor(attrib as AnyEntity, state.doc, color) + addTextData(data, state, mat, attrColor, width, dash, color, attrib as AnyEntity) + } + } +} + +function addLeader( + entity: AnyEntity, + state: BuildState, + mat: Mat, + color: ColorSpec, + width: number, + dash: number[] | undefined +): void { + const vertices = Array.isArray(entity.vertices) ? entity.vertices : [] + if (vertices.length < 2) return + const points: number[] = [] + for (const v of vertices) points.push(Number(v.x) || 0, Number(v.y) || 0) + addPoly(state, entity, mat, points, false, false, true, color, width, dash) + if (entity.isArrowheadEnabled !== false) { + const x0 = Number(vertices[0].x) || 0 + const y0 = Number(vertices[0].y) || 0 + const x1 = Number(vertices[1].x) || 0 + const y1 = Number(vertices[1].y) || 0 + const dx = x1 - x0 + const dy = y1 - y0 + const len = Math.hypot(dx, dy) + if (len > 1e-9) { + const size = Math.min(len * 0.18, Math.max(Number(entity.textHeight) || 0, len * 0.08, 1)) + const ux = dx / len + const uy = dy / len + const px = -uy + const py = ux + const pts = [ + x0, + y0, + x0 + ux * size + px * size * 0.42, + y0 + uy * size + py * size * 0.42, + x0 + ux * size - px * size * 0.42, + y0 + uy * size - py * size * 0.42 + ] + addPoly(state, entity, mat, pts, true, true, false, color, width, undefined) + } + } +} + +function addHatch( + entity: AnyEntity, + state: BuildState, + mat: Mat, + color: ColorSpec, + width: number, + dash: number[] | undefined +): void { + const paths: number[][] = [] + const rawPaths = Array.isArray(entity.boundaryPaths) ? entity.boundaryPaths : [] + for (const path of rawPaths) { + const pts = hatchPathPoints(path) + if (pts.length >= 6) paths.push(pts) + } + if (!paths.length) return + const solid = Number(entity.solidFill) === 1 + const angle = normalizeAngle(Number(entity.patternAngle) || 0) + let spacing = 0 + if (Array.isArray(entity.definitionLines) && entity.definitionLines.length) { + const offset = entity.definitionLines[0]?.offset + if (offset) spacing = Math.hypot(Number(offset.x) || 0, Number(offset.y) || 0) + } + if (!spacing || !Number.isFinite(spacing)) { + spacing = Math.max(1, Math.abs(Number(entity.patternScale) || 1) * 3) + } + const prim: HatchPrim = { + kind: 'hatch', +...base(entity, mat, color, solid ? 0 : Math.max(0.55, width * 0.7), dash), + paths, + solid, + patternName: String(entity.patternName || ''), + patternAngle: angle, + patternSpacing: Math.max(0.3, spacing) + } + let bbox = emptyBBox() + for (const p of paths) bbox = bboxUnion(bbox, bboxTransform(mat, bboxFromPoints(p))) + prim.bbox = bbox + state.prims.push(prim) +} + +function hatchPathPoints(path: AnyEntity): number[] { + const out: number[] = [] + if (Array.isArray(path.vertices) && path.vertices.length >= 2) { + const verts = path.vertices + for (let i = 0; i < verts.length; i++) { + const v = verts[i] + const x = Number(v.x) || 0 + const y = Number(v.y) || 0 + if (i > 0) { + const prev = verts[i - 1] + const bulge = Number(prev.bulge) || 0 + if (Math.abs(bulge) > 1e-9) { + const arc = bulgeToArc(Number(prev.x) || 0, Number(prev.y) || 0, x, y, bulge) + if (arc) { + const pts = sampleArcPoints(arc.cx, arc.cy, arc.r, arc.a0, arc.sweep, 80) + for (let j = 2; j < pts.length; j += 2) out.push(pts[j], pts[j + 1]) + continue + } + } + } + out.push(x, y) + } + const last = verts[verts.length - 1] + const first = verts[0] + const bulge = Number(last.bulge) || 0 + if (Math.abs(bulge) > 1e-9) { + const arc = bulgeToArc( + Number(last.x) || 0, + Number(last.y) || 0, + Number(first.x) || 0, + Number(first.y) || 0, + bulge + ) + if (arc) { + const pts = sampleArcPoints(arc.cx, arc.cy, arc.r, arc.a0, arc.sweep, 80) + for (let j = 2; j < pts.length; j += 2) out.push(pts[j], pts[j + 1]) + } + } + return out + } + if (Array.isArray(path.edges)) { + for (const edge of path.edges) { + const type = Number(edge.type) + if (type === 1) { + const s = edge.start + const e = edge.end + if (s && e) out.push(Number(s.x) || 0, Number(s.y) || 0, Number(e.x) || 0, Number(e.y) || 0) + } else if (type === 2) { + const c = edge.center + if (!c) continue + const r = Math.abs(Number(edge.radius) || 0) + const a0 = Number(edge.startAngle) || 0 + const a1 = Number(edge.endAngle) || 0 + let sweep = a1 - a0 + while (sweep <= 0) sweep += Math.PI * 2 + const pts = sampleArcPoints(Number(c.x) || 0, Number(c.y) || 0, r, a0, sweep, 64) + for (let j = 0; j < pts.length; j += 2) out.push(pts[j], pts[j + 1]) + } else if (type === 3) { + const c = edge.center + const ep = edge.end + if (!c || !ep) continue + const mx = (Number(ep.x) || 0) - (Number(c.x) || 0) + const my = (Number(ep.y) || 0) - (Number(c.y) || 0) + const ratio = Math.hypot(mx, my) > 0 ? Math.abs(Number(edge.lengthOfMinorAxis) || 1) / Math.hypot(mx, my) : 1 + const a0 = Number(edge.startAngle) || 0 + const a1 = Number(edge.endAngle) || 0 + let sweep = a1 - a0 + while (sweep <= 0) sweep += Math.PI * 2 + const pts = sampleEllipsePoints(Number(c.x) || 0, Number(c.y) || 0, mx, my, clamp(ratio, 0.001, 1), a0, sweep, 64) + for (let j = 0; j < pts.length; j += 2) out.push(pts[j], pts[j + 1]) + } else if (type === 4) { + const cps = Array.isArray(edge.controlPoints) ? edge.controlPoints : [] + for (const p of cps) out.push(Number(p.x) || 0, Number(p.y) || 0) + } + } + } + return out +} + +function wipeoutPoints(entity: AnyEntity): number[] { + if (Array.isArray(entity.clippingBoundaryPath) && entity.clippingBoundaryPath.length >= 2) { + const pts: number[] = [] + for (const p of entity.clippingBoundaryPath) pts.push(Number(p.x) || 0, Number(p.y) || 0) + return pts + } + const pos = entity.position + const u = entity.uPixel + const v = entity.vPixel + const size = entity.imageSize + if (!pos || !u || !v || !size) return [] + const w = Math.abs(Number(size.x) || 0) + const h = Math.abs(Number(size.y) || 0) + const ux = Number(u.x) || 0 + const uy = Number(u.y) || 0 + const vx = Number(v.x) || 0 + const vy = Number(v.y) || 0 + return [ + pos.x, + pos.y, + pos.x + ux * w, + pos.y + uy * w, + pos.x + ux * w + vx * h, + pos.y + uy * w + vy * h, + pos.x + vx * h, + pos.y + vy * h + ] +} + +function addTable( + entity: AnyEntity, + state: BuildState, + mat: Mat, + color: ColorSpec, + width: number, + dash: number[] | undefined +): void { + const rows = clamp(Math.floor(Number(entity.rowCount) || 0), 0, 500) + const cols = clamp(Math.floor(Number(entity.columnCount) || 0), 0, 200) + const rowHeights: number[] = Array.isArray(entity.rowHeightArr) ? entity.rowHeightArr : [] + const colWidths: number[] = Array.isArray(entity.columnWidthArr) ? entity.columnWidthArr : [] + const cells: AnyEntity[] = Array.isArray(entity.cells) ? entity.cells : [] + const start = entity.startPoint + if (!start || rows <= 0 || cols <= 0) return + let y = Number(start.y) || 0 + for (let r = 0; r < rows; r++) { + const rh = Math.abs(Number(rowHeights[r]) || 0) + let x = Number(start.x) || 0 + for (let c = 0; c < cols; c++) { + const cw = Math.abs(Number(colWidths[c]) || 0) + const cell = cells[r * cols + c] + if (cell) { + if (cell.topBorderVisibility) addPoly(state, entity, mat, [x, y, x + cw, y], false, false, true, color, width, dash) + if (cell.bottomBorderVisibility) addPoly(state, entity, mat, [x, y + rh, x + cw, y + rh], false, false, true, color, width, dash) + if (cell.leftBorderVisibility) addPoly(state, entity, mat, [x, y, x, y + rh], false, false, true, color, width, dash) + if (cell.rightBorderVisibility) addPoly(state, entity, mat, [x + cw, y, x + cw, y + rh], false, false, true, color, width, dash) + const text = String(cell.text ?? '') + if (text) { + const h = Math.abs(Number(cell.textHeight) || 0) + const fake = { + ...entity, + type: 'MTEXT', + insertionPoint: { x: x + cw / 2, y: y + rh / 2, z: 0 }, + textHeight: h, + rotation: 0, + text, + rectWidth: 0, + extentsWidth: 0, + attachmentPoint: 5, + lineSpacing: 1 + } + addMTextEntity(fake, state, mat, color, width, dash) + } + } + x += cw + } + y += rh + } +} + +function resolveColor(entity: AnyEntity, doc: CadDocument, inherit: ColorSpec | undefined): ColorSpec { + const ci = typeof entity.colorIndex === 'number' ? entity.colorIndex : 256 + const trueColor = typeof entity.color === 'number' ? entity.color >>> 0 : undefined + if (trueColor != null && trueColor !== 0xffffff && trueColor !== 0 && (ci === 0 || ci === 256)) { + return { kind: 'rgb', value: trueColor } + } + if (ci === 0) return inherit ?? { kind: 'aci', value: 7 } + if (ci === 256 || !Number.isFinite(ci)) return layerColor(entity.layer, doc) + const index = Math.abs(Math.round(ci)) + if (index >= 1 && index <= 255) return { kind: 'aci', value: index } + return layerColor(entity.layer, doc) +} + +function layerColor(name: string | undefined, doc: CadDocument): ColorSpec { + const key = name || '0' + const layer = doc.layerMap.get(key) ?? doc.layerMap.get(key.toLowerCase()) + if (!layer) return { kind: 'aci', value: 7 } + if (layer.rgb != null) return { kind: 'rgb', value: layer.rgb } + return { kind: 'aci', value: layer.aci || 7 } +} + +function lineWidthOf(entity: AnyEntity, paper: boolean, doc: CadDocument): number { + let lw = Number(entity.lineweight) + if (!Number.isFinite(lw) || lw < 0) { + const layer = findLayer(doc, entity.layer || '0') + if (layer && Number.isFinite(layer.lineWeight) && layer.lineWeight > 0) lw = layer.lineWeight + } + let width: number + if (!Number.isFinite(lw) || lw < 0) width = 1 + else if (lw === 0) width = 0.55 + else width = clamp(0.6 + (lw / 100) * 1.8, 0.6, 4.2) + return paper ? Math.max(0.55, width * 0.88) : width +} + +function resolveDash(entity: AnyEntity, doc: CadDocument, ltscale: number): number[] | undefined { + let name = String(entity.lineType || '').trim() + if (!name || /^bylayer$/i.test(name)) { + const layer = findLayer(doc, entity.layer || '0') + name = layer?.lineType || '' + } + if (!name || /^(byblock|bylayer|continuous)$/i.test(name)) return undefined + const entityScale = Number(entity.lineTypeScale) > 0 ? Number(entity.lineTypeScale) : 1 + const pattern = doc.dashPatterns.get(name) ?? doc.dashPatterns.get(name.toLowerCase()) + let base: number[] | undefined + if (pattern && pattern.length) { + base = pattern + } else { + const upper = name.toUpperCase() + if (upper.includes('DASHDOT') || upper.includes('DASH_DOT')) base = [4, 0.8, 0.15, 0.8] + else if (upper.includes('DASHED') || upper.includes('DASH')) base = [3, 1.2] + else if (upper.includes('HIDDEN')) base = [1.2, 0.7] + else if (upper.includes('CENTER')) base = [5, 0.9, 0.9, 0.9] + else if (upper.includes('DOT')) base = [0.15, 1] + } + if (!base) return undefined + const scale = ltscale * entityScale + const scaled = base.map((v) => Math.max(0.04, v * scale)) + return scaled.some((v) => v > 0.05) ? scaled : undefined +} + +function circleBBox(cx: number, cy: number, r: number, mat: Mat): BBoxLike { + return bboxTransform(mat, { minX: cx - r, minY: cy - r, maxX: cx + r, maxY: cy + r }) +} + +function bulgeBounds(vertices: Array<{ x: number; y: number; bulge: number }>, closed: boolean, mat: Mat): BBoxLike { + let local = emptyBBox() + for (const v of vertices) local = bboxUnion(local, { minX: v.x, minY: v.y, maxX: v.x, maxY: v.y }) + for (let i = 0; i < vertices.length; i++) { + const next = i + 1 < vertices.length ? i + 1 : closed ? 0 : -1 + if (next < 0) break + const a = vertices[i] + const b = vertices[next] + if (Math.abs(a.bulge) < 1e-9) continue + const arc = bulgeToArc(a.x, a.y, b.x, b.y, a.bulge) + if (!arc) continue + local = bboxUnion(local, arcBounds(arc.cx, arc.cy, arc.r, arc.a0, arc.sweep)) + } + return bboxTransform(mat, local) +} + +function arcBounds(cx: number, cy: number, r: number, a0: number, sweep: number): BBoxLike { + let bbox: BBoxLike = { + minX: Number.POSITIVE_INFINITY, + minY: Number.POSITIVE_INFINITY, + maxX: Number.NEGATIVE_INFINITY, + maxY: Number.NEGATIVE_INFINITY + } + bboxAddPoint(bbox, cx + r * Math.cos(a0), cy + r * Math.sin(a0)) + bboxAddPoint(bbox, cx + r * Math.cos(a0 + sweep), cy + r * Math.sin(a0 + sweep)) + const step = Math.PI / 2 + const start = Math.min(a0, a0 + sweep) + const end = Math.max(a0, a0 + sweep) + for (let a = Math.ceil(start / step) * step; a <= end; a += step) { + bboxAddPoint(bbox, cx + r * Math.cos(a), cy + r * Math.sin(a)) + } + return bbox +} + +function textBBox(prim: TextPrim, mat: Mat): BBoxLike { + const lines = prim.lines.length ? prim.lines : [''] + const count = lines.length + const lineHeight = prim.lineHeight + let maxWidth = 0 + for (const line of lines) maxWidth = Math.max(maxWidth, textWidth(line, prim.height)) + maxWidth = Math.max(maxWidth * Math.abs(prim.widthFactor), prim.height * 0.5) + const totalHeight = Math.max(lineHeight * count, prim.height) + let minX = 0 + let maxX = maxWidth + if (prim.halign === 'center') { + minX = -maxWidth / 2 + maxX = maxWidth / 2 + } else if (prim.halign === 'right') { + minX = -maxWidth + maxX = 0 + } + let minY = 0 + let maxY = totalHeight + if (prim.valign === 'top') { + minY = -totalHeight + maxY = 0 + } else if (prim.valign === 'middle') { + minY = -totalHeight / 2 + maxY = totalHeight / 2 + } + const cos = Math.cos(prim.rotation) + const sin = Math.sin(prim.rotation) + const bbox = emptyBBox() + const corners = [ + [minX, minY], + [maxX, minY], + [maxX, maxY], + [minX, maxY] + ] + for (const [lx, ly] of corners) { + const wx = prim.x + lx * cos - ly * sin + const wy = prim.y + lx * sin + ly * cos + const [sx, sy] = applyMat(mat, wx, wy) + bboxAddPoint(bbox, sx, sy) + } + return bbox +} + +function normalizeAngle(value: number): number { + if (Math.abs(value) > Math.PI * 2 + 0.001) return (value * Math.PI) / 180 + return value +} + +function sampleArcPoints( + cx: number, + cy: number, + r: number, + a0: number, + sweep: number, + segments: number +): number[] { + const out: number[] = [] + const n = clamp(segments, 4, 256) + for (let i = 0; i <= n; i++) { + const a = a0 + (sweep * i) / n + out.push(cx + r * Math.cos(a), cy + r * Math.sin(a)) + } + return out +} + +function sampleEllipsePoints( + cx: number, + cy: number, + mx: number, + my: number, + ratio: number, + a0: number, + sweep: number, + segments: number +): number[] { + const nx = -my * ratio + const ny = mx * ratio + const out: number[] = [] + const n = clamp(segments, 4, 256) + for (let i = 0; i <= n; i++) { + const a = a0 + (sweep * i) / n + out.push(cx + mx * Math.cos(a) + nx * Math.sin(a), cy + my * Math.cos(a) + ny * Math.sin(a)) + } + return out +} + +export function findLayer(doc: CadDocument, name: string): LayerInfo | undefined { + return doc.layerMap.get(name) ?? doc.layerMap.get(name.toLowerCase()) +} + +export function spaceCenter(space: CadSpace): [number, number] { + return bboxCenter(space.bbox) +} + +export function padBounds(b: BBoxLike, ratio = 0.02): BBoxLike { + return bboxExpand(b, Math.max(bboxWidth(b) * ratio, 0.001), Math.max(bboxHeight(b) * ratio, 0.001)) +} diff --git a/src/cad/cadViewer.ts b/src/cad/cadViewer.ts new file mode 100644 index 0000000..c66ac73 --- /dev/null +++ b/src/cad/cadViewer.ts @@ -0,0 +1,1067 @@ +import type { CadDocument, CadSpace } from './types' +import { CadRenderer } from './renderer' +import { + bboxCenter, + bboxHeight, + bboxWidth, + clamp, + formatNumber, + screenToWorld, + worldToScreen +} from './geom' +import type { Camera } from './geom' +import { cssColor, cssForAci } from './colors' +import type { ViewerHost } from '../core/viewerHost' +import { clear, h, icon, iconButton } from '../core/dom' +import { getTheme, onThemeChange, toggleTheme } from '../core/theme' +import { toast } from '../core/toast' +import { showAbout } from '../ui/about' + +interface Measurement { + a: [number, number] + b: [number, number] +} + +interface Callbacks { + onBack: () => void +} + +export class CadViewer { + private host: ViewerHost + private doc: CadDocument + private renderer: CadRenderer + private callbacks: Callbacks + private canvas: HTMLCanvasElement + private ctx: CanvasRenderingContext2D + private overlayCanvas: HTMLCanvasElement + private overlayCtx: CanvasRenderingContext2D + private canvasWrap: HTMLElement + private stage: HTMLElement + private tools: HTMLElement + private hint: HTMLElement + private sheetBackdrop: HTMLElement + private sheet: HTMLElement + private sheetList: HTMLElement + private sheetSearch: HTMLInputElement + private tabs: HTMLElement + private themeBtn: HTMLButtonElement + private measureBtn: HTMLButtonElement + private clearBtn: HTMLButtonElement + private proxyBtn!: HTMLButtonElement + private fullscreenBtn: HTMLButtonElement + private proxyVisible = true + private layerVis = new Map() + private cameras = new Map() + private fitScales = new Map() + private measurements = new Map() + private pendingStart = new Map() + private current = 0 + private dpr = 1 + private renderQueued = false + private raf = 0 + private renderCamera: Camera | null = null + private fullRenderTimer = 0 + private previewing = false + private resizeObserver: ResizeObserver | null = null + private themeUnsub: (() => void) | null = null + private measureMode = false + private pointerScreen: [number, number] | null = null + private pointers = new Map() + private gesture: + | { type: 'pan'; lastX: number; lastY: number } + | { + type: 'pinch' + startScale: number + startDist: number + startMid: [number, number] + worldMid: [number, number] + } + | null = null + private tapStart: { x: number; y: number; time: number; moved: boolean } | null = null + private lastTap = { time: 0, x: 0, y: 0 } + private coordTimer = 0 + private hintTimer = 0 + private destroyed = false + + constructor(host: ViewerHost, doc: CadDocument, callbacks: Callbacks) { + this.host = host + this.doc = doc + this.callbacks = callbacks + this.renderer = new CadRenderer(doc) + this.stage = host.stage + this.canvas = h('canvas', { class: 'cad-canvas' }) + this.overlayCanvas = h('canvas', { class: 'cad-overlay-canvas' }) + const ctx = this.canvas.getContext('2d', { alpha: false }) + if (!ctx) throw new Error('无法创建 Canvas 2D 上下文') + this.ctx = ctx + const overlayCtx = this.overlayCanvas.getContext('2d') + if (!overlayCtx) throw new Error('无法创建 Canvas 2D 上下文') + this.overlayCtx = overlayCtx + this.canvasWrap = h('div', { class: 'cad-canvas-wrap' }, this.canvas, this.overlayCanvas) + + for (const layer of doc.layers) this.layerVis.set(layer.name.toLowerCase(), layer.visible) + + host.setFileInfo(doc.fileName, 'DWG 图纸', 'DWG', 'cad', `${doc.spaces.length} 个空间`) + host.setStatus('') + this.tabs = this.buildTabs() + host.setSubbar(this.tabs) + + this.tools = this.buildTools() + this.hint = h('div', { class: 'cad-hint', text: this.hintText() }) + this.sheetSearch = h('input', { + class: 'sheet-search-input', + type: 'search', + placeholder: '搜索图层…', + 'aria-label': '搜索图层' + }) + this.sheetList = h('div', { class: 'sheet-list' }) + this.sheetBackdrop = h('div', { class: 'sheet-backdrop' }) + this.sheet = this.buildSheet() + this.sheetBackdrop.appendChild(this.sheet) + + this.stage.append(this.canvasWrap, this.tools, this.hint, this.sheetBackdrop) + this.buildHeaderActions() + + this.measureBtn = this.tools.querySelector('[data-action="measure"]') as HTMLButtonElement + this.clearBtn = this.tools.querySelector('[data-action="clear-measure"]') as HTMLButtonElement + this.themeBtn = this.tools.querySelector('[data-action="theme"]') as HTMLButtonElement + this.fullscreenBtn = host.actions.querySelector('[data-action="fullscreen"]') as HTMLButtonElement + this.updateThemeButton() + this.updateClearButton() + this.updateProxyButton() + + this.bindEvents() + this.observeResize() + this.themeUnsub = onThemeChange(() => { + this.updateThemeButton() + this.schedule() + }) + this.hintTimer = window.setTimeout(() => this.hideHint(), 5200) + this.updateStatus() + this.schedule() + } + + private get space(): CadSpace { + return this.doc.spaces[this.current] ?? this.doc.model + } + + private get camera(): Camera { + const space = this.space + let camera = this.cameras.get(space.id) + if (!camera) { + camera = this.computeFit(space) + this.cameras.set(space.id, camera) + } + return camera + } + + private setCamera(camera: Camera): void { + this.cameras.set(this.space.id, camera) + } + + private computeFit(space: CadSpace): Camera { + const width = Math.max(1, this.stage.clientWidth) + const height = Math.max(1, this.stage.clientHeight) + if (space.savedView && space.savedView.width > 0 && space.savedView.height > 0) { + const view = space.savedView + const scale = Math.max( + 1e-12, + Math.min((width * 0.92) / view.width, (height * 0.9) / view.height) + ) + this.fitScales.set(space.id, scale) + return { scale, cx: view.cx, cy: view.cy } + } + const box = space.fitBBox ?? space.bbox + const bw = Math.max(bboxWidth(box), 1e-9) + const bh = Math.max(bboxHeight(box), 1e-9) + const scale = Math.max(1e-12, Math.min((width * 0.9) / bw, (height * 0.88) / bh)) + const [cx, cy] = bboxCenter(box) + this.fitScales.set(space.id, scale) + return { scale, cx, cy } + } + + private buildHeaderActions(): void { + const downloadBtn = iconButton('download', '保存当前视图为 PNG', () => this.exportPng()) + const fullscreenBtn = iconButton('maximize', '全屏', () => void this.toggleFullscreen()) + fullscreenBtn.dataset.action = 'fullscreen' + const aboutBtn = iconButton('info', '关于', () => showAbout()) + this.host.actions.append(downloadBtn, fullscreenBtn, aboutBtn) + this.fullscreenBtn = fullscreenBtn + } + + private buildTabs(): HTMLElement { + const tabs = h('div', { class: 'tabs', role: 'tablist' }) + this.doc.spaces.forEach((space, index) => { + const btn = h( + 'button', + { + class: `tab ${index === this.current ? 'active' : ''}`, + type: 'button', + role: 'tab', + 'aria-selected': index === this.current ? 'true' : 'false', + dataset: { index: String(index) } + }, + h('span', { class: 'tab-icon', html: icon(space.kind === 'model' ? 'grid' : 'file-text', 15) }), + h('span', { class: 'tab-text', text: space.name }) + ) + btn.addEventListener('click', () => this.setSpace(index)) + tabs.appendChild(btn) + }) + return tabs + } + + private buildTools(): HTMLElement { + const tools = h('div', { class: 'cad-tools' }) + const add = (name: string, label: string, action: string, onClick: () => void) => { + const btn = iconButton(name, label, (ev) => { + ev.stopPropagation() + onClick() + }) + btn.dataset.action = action + tools.appendChild(btn) + return btn + } + add('plus', '放大', 'zoom-in', () => this.zoomBy(1.32)) + add('minus', '缩小', 'zoom-out', () => this.zoomBy(1 / 1.32)) + add('fit', '适配全图', 'fit', () => this.fitCurrent()) + tools.appendChild(h('div', { class: 'tool-divider' })) + add('layers', '图层', 'layers', () => this.openSheet()) + this.proxyBtn = add('proxy', '显示代理对象', 'proxy', () => this.toggleProxyObjects()) + this.proxyBtn.classList.add('active') + this.measureBtn = add('ruler', '测量距离', 'measure', () => this.toggleMeasure()) + this.clearBtn = add('trash', '清除测量', 'clear-measure', () => this.clearMeasurements()) + this.themeBtn = add('sun', '切换背景', 'theme', () => { + toggleTheme() + this.schedule() + }) + this.clearBtn.classList.add('tool-hidden') + return tools + } + + private buildSheet(): HTMLElement { + const title = h('div', { class: 'sheet-title' }, h('span', { text: '图层' })) + const close = iconButton('x', '关闭', () => this.closeSheet()) + const head = h('div', { class: 'sheet-head' }, title, close) + const actions = h('div', { class: 'sheet-actions' }) + const showAll = h('button', { class: 'chip-btn', type: 'button', text: '全部显示' }) + const hideAll = h('button', { class: 'chip-btn', type: 'button', text: '全部隐藏' }) + const reset = h('button', { class: 'chip-btn', type: 'button', text: '恢复默认' }) + showAll.addEventListener('click', () => this.setAllLayers(true)) + hideAll.addEventListener('click', () => this.setAllLayers(false)) + reset.addEventListener('click', () => { + for (const layer of this.doc.layers) this.setLayerVisible(layer.name, layer.visible) + this.renderSheetRows() + this.schedule() + }) + actions.append(showAll, hideAll, reset) + + this.sheetSearch.addEventListener('input', () => this.filterSheet()) + this.renderSheetRows() + + return h('aside', { class: 'sheet', role: 'dialog', 'aria-label': '图层' }, head, actions, this.sheetSearch, this.sheetList) + } + + private renderSheetRows(): void { + clear(this.sheetList) + const sorted = [...this.doc.layers].sort((a, b) => { + if (a.name === '0') return -1 + if (b.name === '0') return 1 + return a.name.localeCompare(b.name, 'zh-Hans-CN') + }) + for (const layer of sorted) { + const visible = this.isLayerVisible(layer.name) + const row = h('button', { + class: `layer-row ${visible ? 'visible' : 'hidden'}`, + type: 'button', + dataset: { name: layer.name.toLowerCase(), search: layer.name.toLowerCase() } + }) + const swatch = h('span', { class: 'layer-swatch' }) + const theme = getTheme() + swatch.style.background = + layer.rgb != null ? cssColor({ kind: 'rgb', value: layer.rgb }, false, theme) : cssForAci(layer.aci, false, theme) + const info = h( + 'span', + { class: 'layer-info' }, + h('span', { class: 'layer-name', text: layer.name }), + h('span', { + class: 'layer-meta', + text: `${layer.count} 个实体${layer.off ? ' · 已关闭' : ''}${layer.frozen ? ' · 已冻结' : ''}` + }) + ) + const eye = h('span', { class: 'layer-eye', html: icon(visible ? 'eye' : 'eye-off', 18) }) + row.append(swatch, info, eye) + row.addEventListener('click', () => { + this.setLayerVisible(layer.name, !this.isLayerVisible(layer.name)) + this.renderSheetRows() + this.schedule() + }) + this.sheetList.appendChild(row) + } + this.filterSheet() + } + + private bindEvents(): void { + this.canvas.addEventListener('pointerdown', this.onPointerDown) + this.canvas.addEventListener('pointermove', this.onPointerMove) + this.canvas.addEventListener('pointerup', this.onPointerUp) + this.canvas.addEventListener('pointercancel', this.onPointerCancel) + this.canvas.addEventListener('wheel', this.onWheel, { passive: false }) + this.canvas.addEventListener('dblclick', this.onDoubleClick) + this.canvas.addEventListener('contextmenu', (ev) => ev.preventDefault()) + document.addEventListener('keydown', this.onKeyDown) + document.addEventListener('fullscreenchange', this.onFullscreenChange) + this.sheetBackdrop.addEventListener('click', (ev) => { + if (ev.target === this.sheetBackdrop) this.closeSheet() + }) + } + + private observeResize(): void { + this.resizeObserver = new ResizeObserver(() => this.resize()) + this.resizeObserver.observe(this.stage) + window.addEventListener('orientationchange', this.onOrientation) + this.resize() + } + + private onOrientation = () => { + window.setTimeout(() => { + this.resize() + const space = this.space + const camera = this.cameras.get(space.id) + const fit = this.fitScales.get(space.id) ?? 0 + if (!camera || Math.abs(camera.scale - fit) / Math.max(fit, 1e-9) < 0.08) { + this.cameras.set(space.id, this.computeFit(space)) + this.schedule() + } + }, 220) + } + + private resize(): void { + const width = this.stage.clientWidth + const height = this.stage.clientHeight + if (width <= 0 || height <= 0) return + this.dpr = Math.min(window.devicePixelRatio || 1, 2.5) + for (const canvas of [this.canvas, this.overlayCanvas]) { + canvas.width = Math.max(1, Math.round(width * this.dpr)) + canvas.height = Math.max(1, Math.round(height * this.dpr)) + canvas.style.width = `${width}px` + canvas.style.height = `${height}px` + } + const space = this.space + const camera = this.cameras.get(space.id) + const fit = this.fitScales.get(space.id) ?? 0 + if (!camera || fit <= 1e-11 || Math.abs(camera.scale - fit) / Math.max(fit, 1e-9) < 0.08) { + this.cameras.set(space.id, this.computeFit(space)) + } + this.schedule() + } + + private schedule(): void { + if (this.fullRenderTimer) { + window.clearTimeout(this.fullRenderTimer) + this.fullRenderTimer = 0 + } + if (this.destroyed || this.renderQueued) return + this.renderQueued = true + this.raf = requestAnimationFrame(() => { + this.renderQueued = false + this.render() + }) + } + + private scheduleFullSoon(delay = 140): void { + if (this.destroyed) return + if (this.fullRenderTimer) window.clearTimeout(this.fullRenderTimer) + this.fullRenderTimer = window.setTimeout(() => { + this.fullRenderTimer = 0 + this.schedule() + }, delay) + } + + private cancelScheduledRender(): void { + if (this.fullRenderTimer) { + window.clearTimeout(this.fullRenderTimer) + this.fullRenderTimer = 0 + } + if (this.raf) { + cancelAnimationFrame(this.raf) + this.raf = 0 + this.renderQueued = false + } + } + + private applyPreview(): void { + const rendered = this.renderCamera + if (!rendered) { + this.schedule() + return + } + const camera = this.camera + const scale = camera.scale / rendered.scale + const tx = (rendered.cx - camera.cx) * camera.scale + const ty = (camera.cy - rendered.cy) * camera.scale + if ( + Math.abs(scale - 1) < 1e-4 && + Math.abs(tx) < 0.05 && + Math.abs(ty) < 0.05 + ) { + this.canvasWrap.style.transform = '' + this.previewing = false + return + } + this.canvasWrap.style.transformOrigin = '50% 50%' + this.canvasWrap.style.transform = `translate(${tx}px, ${ty}px) scale(${scale})` + this.previewing = true + } + + private render(): void { + if (this.destroyed) return + const width = this.stage.clientWidth + const height = this.stage.clientHeight + if (width <= 0 || height <= 0) return + this.canvasWrap.style.transform = '' + this.previewing = false + const started = performance.now() + const ctx = this.ctx + ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0) + ctx.clearRect(0, 0, width, height) + const camera = this.camera + this.renderer.draw(ctx, this.space, camera, width, height, { + theme: getTheme(), + layerVisible: (name) => this.isLayerVisible(name), + proxyVisible: this.proxyVisible + }) + this.renderCamera = { ...camera } + this.renderOverlay(width, height) + const elapsed = performance.now() - started + if (elapsed > 30) console.info(`[render] ${elapsed.toFixed(1)}ms`) + } + + private renderOverlay(width = this.stage.clientWidth, height = this.stage.clientHeight): void { + if (this.destroyed || this.previewing || width <= 0 || height <= 0) return + const ctx = this.overlayCtx + ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0) + ctx.clearRect(0, 0, width, height) + this.drawOverlay(ctx, width, height) + } + + private drawOverlay(ctx: CanvasRenderingContext2D, width: number, height: number): void { + const camera = this.camera + const space = this.space + const list = this.measurements.get(space.id) + const accent = getTheme() === 'dark' ? '#5b9bff' : '#2563eb' + const textColor = '#ffffff' + const labelFont = '600 12px "Noto Sans SC","PingFang SC","Microsoft YaHei",system-ui,sans-serif' + + const drawLabel = (x: number, y: number, text: string) => { + ctx.save() + ctx.font = labelFont + const w = ctx.measureText(text).width + 16 + const hgt = 24 + const rx = x - w / 2 + const ry = y - hgt - 10 + ctx.beginPath() + if (typeof ctx.roundRect === 'function') ctx.roundRect(rx, ry, w, hgt, 8) + else ctx.rect(rx, ry, w, hgt) + ctx.fillStyle = accent + ctx.shadowColor = 'rgba(0,0,0,0.28)' + ctx.shadowBlur = 6 + ctx.fill() + ctx.shadowBlur = 0 + ctx.fillStyle = textColor + ctx.textAlign = 'center' + ctx.textBaseline = 'middle' + ctx.fillText(text, x, ry + hgt / 2 + 0.5) + ctx.restore() + } + + const drawPoint = (x: number, y: number, color: string) => { + ctx.save() + ctx.strokeStyle = color + ctx.fillStyle = color + ctx.lineWidth = 1.5 + ctx.beginPath() + ctx.arc(x, y, 4.2, 0, Math.PI * 2) + ctx.stroke() + ctx.beginPath() + ctx.arc(x, y, 1.7, 0, Math.PI * 2) + ctx.fill() + ctx.restore() + } + + if (list) { + for (const m of list) { + const a = worldToScreen(camera, width, height, m.a[0], m.a[1]) + const b = worldToScreen(camera, width, height, m.b[0], m.b[1]) + ctx.save() + ctx.strokeStyle = accent + ctx.lineWidth = 1.6 + ctx.setLineDash([7, 5]) + ctx.beginPath() + ctx.moveTo(a[0], a[1]) + ctx.lineTo(b[0], b[1]) + ctx.stroke() + ctx.restore() + drawPoint(a[0], a[1], accent) + drawPoint(b[0], b[1], accent) + const dist = Math.hypot(m.b[0] - m.a[0], m.b[1] - m.a[1]) + drawLabel((a[0] + b[0]) / 2, (a[1] + b[1]) / 2, this.formatMeasurement(dist)) + } + } + + const pending = this.pendingStart.get(space.id) + if (pending) { + const a = worldToScreen(camera, width, height, pending[0], pending[1]) + drawPoint(a[0], a[1], accent) + if (this.pointerScreen) { + const [px, py] = this.pointerScreen + const world = screenToWorld(camera, width, height, px, py) + ctx.save() + ctx.strokeStyle = accent + ctx.lineWidth = 1.3 + ctx.setLineDash([5, 5]) + ctx.beginPath() + ctx.moveTo(a[0], a[1]) + ctx.lineTo(px, py) + ctx.stroke() + ctx.restore() + const dist = Math.hypot(world[0] - pending[0], world[1] - pending[1]) + drawLabel(px, py, this.formatMeasurement(dist)) + } + } + } + + private formatMeasurement(value: number): string { + const unit = this.doc.unitLabel + if (unit === 'mm' && Math.abs(value) >= 1000) return `${(value / 1000).toFixed(3)} m` + if (unit === 'mm') return `${value.toFixed(1)} mm` + if (unit === 'm') return `${value.toFixed(3)} m` + if (unit === 'cm') return `${value.toFixed(2)} cm` + if (unit) return `${value.toFixed(2)} ${unit}` + return formatNumber(value, 2) + } + + private updateStatus(extra?: string): void { + const space = this.space + const camera = this.camera + const fit = this.fitScales.get(space.id) ?? camera.scale + const pct = fit > 0 ? (camera.scale / fit) * 100 : 100 + const pctText = pct >= 1000 ? `${Math.round(pct / 100) * 100}%` : `${Math.round(pct)}%` + const unknown = this.doc.unknownCount > 0 ? ` · 不支持 ${this.doc.unknownCount}` : '' + const measureText = this.measureMode ? ' · 测量模式' : '' + const count = space.entityCount ?? space.entities.length + this.host.setStatus( + extra ?? `${space.name} · ${count} 个实体 · ${pctText}${unknown}${measureText}` + ) + } + + private updateCoordinateStatus(x: number, y: number): void { + const unit = this.doc.unitLabel ? ` ${this.doc.unitLabel}` : '' + this.updateStatus( + `${this.space.name} · X ${formatNumber(x, 2)}${unit} Y ${formatNumber(y, 2)}${unit}` + ) + if (this.coordTimer) window.clearTimeout(this.coordTimer) + this.coordTimer = window.setTimeout(() => this.updateStatus(), 1400) + } + + private isLayerVisible(name: string): boolean { + return this.layerVis.get((name || '0').toLowerCase()) ?? true + } + + private setLayerVisible(name: string, visible: boolean): void { + this.layerVis.set(name.toLowerCase(), visible) + } + + private setAllLayers(visible: boolean): void { + for (const layer of this.doc.layers) this.setLayerVisible(layer.name, visible) + this.renderSheetRows() + this.schedule() + } + + private filterSheet(): void { + const query = this.sheetSearch.value.trim().toLowerCase() + const rows = this.sheetList.querySelectorAll('.layer-row') + rows.forEach((row) => { + const name = row.dataset.search ?? '' + row.hidden = query.length > 0 && !name.includes(query) + }) + } + + private openSheet(): void { + this.sheetBackdrop.classList.add('open') + window.setTimeout(() => this.sheetSearch.focus({ preventScroll: true }), 120) + } + + private closeSheet(): void { + this.sheetBackdrop.classList.remove('open') + } + + private setSpace(index: number): void { + if (index < 0 || index >= this.doc.spaces.length || index === this.current) return + this.current = index + const tabs = this.tabs.querySelectorAll('.tab') + tabs.forEach((tab, i) => { + tab.classList.toggle('active', i === index) + tab.setAttribute('aria-selected', i === index ? 'true' : 'false') + }) + tabs[index]?.scrollIntoView({ behavior: 'smooth', inline: 'nearest', block: 'nearest' }) + const space = this.space + if (!this.cameras.has(space.id)) this.cameras.set(space.id, this.computeFit(space)) + this.pendingStart.delete(space.id) + this.updateClearButton() + this.updateStatus() + this.schedule() + } + + private fitCurrent(): void { + const space = this.space + const camera = this.computeFit(space) + this.cameras.set(space.id, camera) + this.updateStatus() + this.applyPreview() + this.scheduleFullSoon(80) + } + + private zoomBy(factor: number): void { + const width = this.stage.clientWidth + const height = this.stage.clientHeight + this.zoomAt(width / 2, height / 2, factor) + } + + private zoomAt(sx: number, sy: number, factor: number): void { + const width = this.stage.clientWidth + const height = this.stage.clientHeight + const camera = this.camera + const space = this.space + const fit = this.fitScales.get(space.id) ?? camera.scale + const next = clamp(camera.scale * factor, fit * 0.02, fit * 6000) + if (Math.abs(next - camera.scale) / camera.scale < 1e-6) return + const world = screenToWorld(camera, width, height, sx, sy) + this.setCamera({ + scale: next, + cx: world[0] - (sx - width / 2) / next, + cy: world[1] + (sy - height / 2) / next + }) + this.updateStatus() + this.applyPreview() + this.scheduleFullSoon(140) + } + + private onPointerDown = (ev: PointerEvent) => { + if (ev.button != null && ev.button !== 0 && ev.pointerType === 'mouse') return + this.cancelScheduledRender() + this.hideHint() + this.canvas.setPointerCapture(ev.pointerId) + this.pointers.set(ev.pointerId, { x: ev.clientX, y: ev.clientY }) + const rect = this.stage.getBoundingClientRect() + this.tapStart = { + x: ev.clientX - rect.left, + y: ev.clientY - rect.top, + time: performance.now(), + moved: false + } + if (this.pointers.size === 1) { + this.gesture = { + type: 'pan', + lastX: ev.clientX, + lastY: ev.clientY + } + } else if (this.pointers.size === 2) { + const [a, b] = [...this.pointers.values()] + const mid: [number, number] = [((a.x + b.x) / 2 - rect.left), ((a.y + b.y) / 2 - rect.top)] + const dist = Math.hypot(a.x - b.x, a.y - b.y) + const camera = { ...this.camera } + this.gesture = { + type: 'pinch', + startScale: camera.scale, + startDist: Math.max(dist, 1), + startMid: mid, + worldMid: screenToWorld(camera, this.stage.clientWidth, this.stage.clientHeight, mid[0], mid[1]) + } + if (this.tapStart) this.tapStart.moved = true + } + this.updateCursor() + } + + private onPointerMove = (ev: PointerEvent) => { + const rect = this.stage.getBoundingClientRect() + const local: [number, number] = [ev.clientX - rect.left, ev.clientY - rect.top] + this.pointerScreen = local + if (this.pointers.has(ev.pointerId)) { + this.pointers.set(ev.pointerId, { x: ev.clientX, y: ev.clientY }) + } + + if (this.tapStart) { + const dx = local[0] - this.tapStart.x + const dy = local[1] - this.tapStart.y + if (Math.hypot(dx, dy) > 6) this.tapStart.moved = true + } + + if (this.gesture?.type === 'pan' && this.pointers.size === 1) { + const dx = ev.clientX - this.gesture.lastX + const dy = ev.clientY - this.gesture.lastY + this.gesture.lastX = ev.clientX + this.gesture.lastY = ev.clientY + if (dx || dy) { + const camera = this.camera + this.setCamera({ + scale: camera.scale, + cx: camera.cx - dx / camera.scale, + cy: camera.cy + dy / camera.scale + }) + this.applyPreview() + } + } else if (this.gesture?.type === 'pinch' && this.pointers.size >= 2) { + const [a, b] = [...this.pointers.values()] + const mid: [number, number] = [ + (a.x + b.x) / 2 - rect.left, + (a.y + b.y) / 2 - rect.top + ] + const dist = Math.hypot(a.x - b.x, a.y - b.y) + const space = this.space + const fit = this.fitScales.get(space.id) ?? this.gesture.startScale + const next = clamp( + this.gesture.startScale * (dist / this.gesture.startDist), + fit * 0.02, + fit * 6000 + ) + this.setCamera({ + scale: next, + cx: this.gesture.worldMid[0] - (mid[0] - this.stage.clientWidth / 2) / next, + cy: this.gesture.worldMid[1] + (mid[1] - this.stage.clientHeight / 2) / next + }) + this.applyPreview() + this.updateStatus() + } + + if (ev.pointerType === 'mouse' && !this.gesture) { + const world = screenToWorld(this.camera, this.stage.clientWidth, this.stage.clientHeight, local[0], local[1]) + this.updateCoordinateStatus(world[0], world[1]) + } + if (this.pendingStart.has(this.space.id) && this.measureMode) this.renderOverlay() + } + + private onPointerUp = (ev: PointerEvent) => { + const wasPan = this.gesture?.type + this.pointers.delete(ev.pointerId) + const rect = this.stage.getBoundingClientRect() + const x = ev.clientX - rect.left + const y = ev.clientY - rect.top + const singleTap = + this.pointers.size === 0 && + this.tapStart != null && + !this.tapStart.moved && + performance.now() - this.tapStart.time < 600 && + wasPan !== 'pinch' + + if (singleTap && this.tapStart) { + const now = performance.now() + const isDouble = + !this.measureMode && + ev.pointerType !== 'mouse' && + now - this.lastTap.time < 320 && + Math.hypot(x - this.lastTap.x, y - this.lastTap.y) < 26 + if (isDouble) { + this.zoomAt(x, y, 1.85) + this.lastTap = { time: 0, x: 0, y: 0 } + } else { + this.lastTap = { time: now, x, y } + if (this.measureMode) this.handleMeasureTap(x, y) + } + } + + if (this.pointers.size === 0) { + this.gesture = null + this.tapStart = null + } else if (this.pointers.size === 1) { + const remaining = [...this.pointers.values()][0] + this.gesture = { type: 'pan', lastX: remaining.x, lastY: remaining.y } + } + if (ev.pointerType !== 'mouse') this.pointerScreen = null + this.updateStatus() + this.updateCursor() + if (this.pointers.size === 0) { + if (this.previewing) this.scheduleFullSoon(60) + } + } + + private onPointerCancel = (ev: PointerEvent) => { + this.pointers.delete(ev.pointerId) + if (this.pointers.size === 0) { + this.gesture = null + this.tapStart = null + if (this.previewing) this.scheduleFullSoon(60) + } + } + + private onWheel = (ev: WheelEvent) => { + ev.preventDefault() + const rect = this.stage.getBoundingClientRect() + const factor = Math.exp(-ev.deltaY * 0.0016) + this.zoomAt(ev.clientX - rect.left, ev.clientY - rect.top, factor) + this.hideHint() + } + + private onDoubleClick = (ev: MouseEvent) => { + const rect = this.stage.getBoundingClientRect() + this.zoomAt(ev.clientX - rect.left, ev.clientY - rect.top, 1.85) + } + + private handleMeasureTap(x: number, y: number): void { + const width = this.stage.clientWidth + const height = this.stage.clientHeight + const world = screenToWorld(this.camera, width, height, x, y) + const space = this.space + const pending = this.pendingStart.get(space.id) + if (!pending) { + this.pendingStart.set(space.id, world) + this.updateStatus('测量:请点击第二点') + } else { + const dist = Math.hypot(world[0] - pending[0], world[1] - pending[1]) + if (dist > 1e-9) { + const list = this.measurements.get(space.id) ?? [] + list.push({ a: pending, b: world }) + this.measurements.set(space.id, list) + } + this.pendingStart.delete(space.id) + this.updateClearButton() + this.updateStatus() + } + this.renderOverlay() + } + + private toggleMeasure(): void { + this.measureMode = !this.measureMode + this.measureBtn.classList.toggle('active', this.measureMode) + if (!this.measureMode) { + this.pendingStart.delete(this.space.id) + this.pointerScreen = null + } else { + this.pendingStart.delete(this.space.id) + toast('测量模式:点击两点测量距离', 'info', 2200) + } + this.updateClearButton() + this.updateStatus() + this.updateCursor() + this.renderOverlay() + } + + private clearMeasurements(): void { + this.measurements.delete(this.space.id) + this.pendingStart.delete(this.space.id) + this.updateClearButton() + this.updateStatus() + this.renderOverlay() + } + + private updateClearButton(): void { + const has = (this.measurements.get(this.space.id)?.length ?? 0) > 0 || this.pendingStart.has(this.space.id) + this.clearBtn.classList.toggle('tool-hidden', !has && !this.measureMode) + } + + private toggleProxyObjects(): void { + this.proxyVisible = !this.proxyVisible + this.updateProxyButton() + this.schedule() + toast(this.proxyVisible ? '已显示代理对象' : '已隐藏代理对象') + } + + private updateProxyButton(): void { + if (!this.proxyBtn) return + this.proxyBtn.classList.toggle('active', this.proxyVisible) + this.proxyBtn.setAttribute('aria-pressed', this.proxyVisible ? 'true' : 'false') + this.proxyBtn.setAttribute('title', this.proxyVisible ? '隐藏代理对象' : '显示代理对象') + } + + private updateCursor(): void { + this.canvas.classList.toggle('crosshair', this.measureMode) + } + + private updateThemeButton(): void { + if (!this.themeBtn) return + this.themeBtn.innerHTML = icon(getTheme() === 'dark' ? 'sun' : 'moon', 20) + this.themeBtn.setAttribute('title', getTheme() === 'dark' ? '切换为浅色背景' : '切换为深色背景') + } + + private hintText(): string { + const coarse = window.matchMedia?.('(pointer: coarse)').matches + return coarse ? '双指缩放 · 单指拖动 · 点“适配”查看全图' : '滚轮缩放 · 拖动平移 · 点“适配”查看全图' + } + + private hideHint(): void { + if (this.hintTimer) { + window.clearTimeout(this.hintTimer) + this.hintTimer = 0 + } + if (this.hint) { + this.hint.classList.add('hide') + window.setTimeout(() => this.hint?.remove(), 400) + } + } + + private async toggleFullscreen(): Promise { + try { + if (!document.fullscreenElement) { + await this.host.root.requestFullscreen?.() + } else { + await document.exitFullscreen?.() + } + } catch { + toast('当前浏览器不支持全屏', 'error') + } + } + + private onFullscreenChange = () => { + if (!this.fullscreenBtn) return + const active = !!document.fullscreenElement + this.fullscreenBtn.innerHTML = icon(active ? 'minimize' : 'maximize', 20) + this.fullscreenBtn.setAttribute('title', active ? '退出全屏' : '全屏') + window.setTimeout(() => this.resize(), 80) + } + + private exportPng(): void { + this.render() + const output = document.createElement('canvas') + output.width = this.canvas.width + output.height = this.canvas.height + const outputCtx = output.getContext('2d') + if (!outputCtx) { + toast('导出失败', 'error') + return + } + outputCtx.drawImage(this.canvas, 0, 0) + outputCtx.drawImage(this.overlayCanvas, 0, 0) + output.toBlob((blob) => { + if (!blob) { + toast('导出失败', 'error') + return + } + const base = this.doc.fileName.replace(/\.[^.]+$/, '') || 'drawing' + const safeSpace = this.space.name.replace(/[\\/:*?"<>|]+/g, '_') + const fileName = `${base}-${safeSpace}.png` + const bridge = ( + window as unknown as { + AndroidViewer?: { saveBase64?: (name: string, mime: string, data: string) => void } + } + ).AndroidViewer + if (bridge?.saveBase64) { + const reader = new FileReader() + reader.onload = () => { + try { + const result = String(reader.result ?? '') + const data = result.includes(',') ? result.slice(result.indexOf(',') + 1) : result + bridge.saveBase64?.(fileName, 'image/png', data) + toast('已保存到 Android 下载目录', 'success') + } catch { + toast('保存失败', 'error') + } + } + reader.onerror = () => toast('保存失败', 'error') + reader.readAsDataURL(blob) + return + } + const url = URL.createObjectURL(blob) + const a = document.createElement('a') + a.href = url + a.download = fileName + document.body.appendChild(a) + a.click() + a.remove() + window.setTimeout(() => URL.revokeObjectURL(url), 4000) + toast('已保存当前视图', 'success') + }, 'image/png') + } + + private onKeyDown = (ev: KeyboardEvent) => { + if (document.activeElement && /^(input|textarea|select)$/i.test(document.activeElement.tagName)) return + const target = ev.target as HTMLElement | null + if (target && target.closest('.sheet')) return + switch (ev.key) { + case '+': + case '=': + ev.preventDefault() + this.zoomBy(1.3) + break + case '-': + case '_': + ev.preventDefault() + this.zoomBy(1 / 1.3) + break + case '0': + ev.preventDefault() + this.fitCurrent() + break + case 'm': + case 'M': + ev.preventDefault() + this.toggleMeasure() + break + case 'l': + case 'L': + ev.preventDefault() + this.openSheet() + break + case 'Escape': + if (this.sheetBackdrop.classList.contains('open')) { + this.closeSheet() + } else if (this.measureMode) { + this.toggleMeasure() + } + break + case 'ArrowLeft': + this.panByKey(80, 0) + ev.preventDefault() + break + case 'ArrowRight': + this.panByKey(-80, 0) + ev.preventDefault() + break + case 'ArrowUp': + this.panByKey(0, 80) + ev.preventDefault() + break + case 'ArrowDown': + this.panByKey(0, -80) + ev.preventDefault() + break + case 'f': + case 'F': + void this.toggleFullscreen() + break + default: + break + } + } + + private panByKey(dx: number, dy: number): void { + const camera = this.camera + this.setCamera({ + scale: camera.scale, + cx: camera.cx - dx / camera.scale, + cy: camera.cy + dy / camera.scale + }) + this.updateStatus() + this.applyPreview() + this.scheduleFullSoon(140) + } + + destroy(): void { + if (this.destroyed) return + this.destroyed = true + cancelAnimationFrame(this.raf) + this.resizeObserver?.disconnect() + window.removeEventListener('orientationchange', this.onOrientation) + document.removeEventListener('keydown', this.onKeyDown) + document.removeEventListener('fullscreenchange', this.onFullscreenChange) + this.themeUnsub?.() + if (this.coordTimer) window.clearTimeout(this.coordTimer) + if (this.hintTimer) window.clearTimeout(this.hintTimer) + this.canvas.removeEventListener('pointerdown', this.onPointerDown) + this.canvas.removeEventListener('pointermove', this.onPointerMove) + this.canvas.removeEventListener('pointerup', this.onPointerUp) + this.canvas.removeEventListener('pointercancel', this.onPointerCancel) + this.canvas.removeEventListener('wheel', this.onWheel) + this.canvas.removeEventListener('dblclick', this.onDoubleClick) + this.host.destroy() + } +} + diff --git a/src/cad/colors.ts b/src/cad/colors.ts new file mode 100644 index 0000000..2e3e8a1 --- /dev/null +++ b/src/cad/colors.ts @@ -0,0 +1,93 @@ +import type { Theme } from '../core/theme' + +export type ColorSpec = { kind: 'aci'; value: number } | { kind: 'rgb'; value: number } + +export const ACI_COLORS: readonly number[] = [ + 0, 16711680, 16776960, 65280, 65535, 255, 16711935, 16777215, 8421504, 12632256, 16711680, 16744319, + 13369344, 13395558, 10027008, 10046540, 8323072, 8339263, 4980736, 4990502, 16727808, 16752511, + 13382400, 13401958, 10036736, 10051404, 8331008, 8343359, 4985600, 4992806, 16744192, 16760703, + 13395456, 13408614, 10046464, 10056268, 8339200, 8347455, 4990464, 4995366, 16760576, 16768895, + 13408512, 13415014, 10056192, 10061132, 8347392, 8351551, 4995328, 4997670, 16776960, 16777087, + 13421568, 13421670, 10000384, 10000460, 8355584, 8355647, 5000192, 5000230, 12582656, 14679935, + 10079232, 11717734, 7510016, 8755276, 6258432, 7307071, 3755008, 4344870, 8388352, 12582783, + 6736896, 10079334, 5019648, 7510092, 4161280, 6258495, 2509824, 3755046, 4194048, 10485631, + 3394560, 8375398, 2529280, 6264908, 2064128, 5209919, 1264640, 3099686, 65280, 8388479, 52224, + 6736998, 38912, 5019724, 32512, 4161343, 19456, 2509862, 65343, 8388511, 52275, 6737023, 38950, + 5019743, 32543, 4161359, 19475, 2509871, 65407, 8388543, 52326, 6737049, 38988, 5019762, 32575, + 4161375, 19494, 2509881, 65471, 8388575, 52377, 6737074, 39026, 5019781, 32607, 4161391, 19513, + 2509890, 65535, 8388607, 52428, 6737100, 39064, 5019800, 32639, 4161407, 19532, 2509900, 49151, + 8380415, 39372, 6730444, 29336, 5014936, 24447, 4157311, 14668, 2507340, 32767, 8372223, 26316, + 6724044, 19608, 5010072, 16255, 4153215, 9804, 2505036, 16383, 8364031, 13260, 6717388, 9880, + 5005208, 8063, 4149119, 4940, 2502476, 255, 8355839, 204, 6710988, 152, 5000344, 127, 4145023, 76, + 2500172, 4129023, 10452991, 3342540, 8349388, 2490520, 6245528, 2031743, 5193599, 1245260, 3089996, + 8323327, 12550143, 6684876, 10053324, 4980888, 7490712, 4128895, 6242175, 2490444, 3745356, + 12517631, 14647295, 10027212, 11691724, 7471256, 8735896, 6226047, 7290751, 3735628, 4335180, + 16711935, 16744447, 13369548, 13395660, 9961624, 9981080, 8323199, 8339327, 4980812, 4990540, + 16711871, 16744415, 13369497, 13395634, 9961586, 9981061, 8323167, 8339311, 4980793, 4990530, + 16711807, 16744383, 13369446, 13395609, 9961548, 9981042, 8323135, 8339295, 4980774, 4990521, + 16711743, 16744351, 13369395, 13395583, 9961510, 9981023, 8323103, 8339279, 4980755, 4990511, + 3355443, 5987163, 8684676, 11382189, 14079702, 16777215, 0 +] + +export function rgbFromInt(value: number): [number, number, number] { + return [(value >> 16) & 0xff, (value >> 8) & 0xff, value & 0xff] +} + +export function rgbToHex(r: number, g: number, b: number): string { + return `#${((1 << 24) | (Math.round(r) << 16) | (Math.round(g) << 8) | Math.round(b)) + .toString(16) + .slice(1)}` +} + +export function cssColor(spec: ColorSpec, paper: boolean, theme: Theme): string { + if (spec.kind === 'aci') { + const index = Math.max(0, Math.min(255, Math.round(spec.value))) + if (index === 7) return paper ? '#111318' : theme === 'dark' ? '#f4f7fb' : '#111318' + if (index === 0 || index === 256) return paper ? '#111318' : theme === 'dark' ? '#f4f7fb' : '#111318' + const rgb = ACI_COLORS[index] ?? 0xffffff + const [r, g, b] = rgbFromInt(rgb) + return rgbToCss(adjust(r, g, b, paper ? false : theme === 'dark')) + } + const [r, g, b] = rgbFromInt(spec.value) + return rgbToCss(adjustTrueColor(r, g, b, paper ? false : theme === 'dark')) +} + +function rgbToCss([r, g, b]: [number, number, number]): string { + return `rgb(${r},${g},${b})` +} + +function adjust(r: number, g: number, b: number, dark: boolean): [number, number, number] { + const lum = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255 + if (dark) { + if (lum < 0.16) return mix(r, g, b, 255, 0.58) + if (lum < 0.28) return mix(r, g, b, 255, 0.26) + } else { + if (lum > 0.9) return mix(r, g, b, 0, 0.62) + if (lum > 0.8) return mix(r, g, b, 0, 0.22) + } + return [r, g, b] +} + +function adjustTrueColor(r: number, g: number, b: number, dark: boolean): [number, number, number] { + const lum = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255 + if (dark && lum < 0.1) return mix(r, g, b, 255, 0.72) + if (!dark && lum > 0.94) return mix(r, g, b, 0, 0.55) + return [r, g, b] +} + +function mix(r: number, g: number, b: number, target: number, amount: number): [number, number, number] { + return [ + Math.round(r + (target - r) * amount), + Math.round(g + (target - g) * amount), + Math.round(b + (target - b) * amount) + ] +} + +export function cssForAci(index: number, paper: boolean, theme: Theme): string { + return cssColor({ kind: 'aci', value: index }, paper, theme) +} + +export function luminanceOfRgb(value: number): number { + const [r, g, b] = rgbFromInt(value) + return (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255 +} diff --git a/src/cad/dwgWorker.ts b/src/cad/dwgWorker.ts new file mode 100644 index 0000000..655dc0a --- /dev/null +++ b/src/cad/dwgWorker.ts @@ -0,0 +1,72 @@ +import { buildAcadDocument } from './acadAdapter' +import { slimDocument } from './slim' +import type { CadDocument } from './types' + +interface WorkerContext { + onmessage: ((event: MessageEvent) => void) | null + postMessage: (message: unknown, transfer?: Transferable[]) => void +} + +interface LoadMessage { + type: 'load' + file: File + name: string + size: number +} + +type InMessage = { type: 'init' } | LoadMessage + +const ctx = self as unknown as WorkerContext + +let busy = false + +function post(message: unknown): void { + ctx.postMessage(message) +} + +async function handleLoad(message: LoadMessage): Promise { + if (busy) { + post({ type: 'error', code: 'busy', message: '正在解析其他图纸,请稍候。' }) + return + } + busy = true + const started = performance.now() + try { + post({ type: 'progress', message: '正在读取文件…' }) + const readStart = performance.now() + const buffer = await message.file.arrayBuffer() + const readMs = performance.now() - readStart + post({ type: 'progress', message: '正在解析 DWG 图纸…' }) + const buildStart = performance.now() + const doc = buildAcadDocument(buffer, message.name, message.size) + const built = slimDocument(doc) + const buildMs = performance.now() - buildStart + post({ + type: 'done', + doc: built, + timings: { + readMs, + parseMs: buildMs, + buildMs, + totalMs: performance.now() - started + } + }) + } catch (error) { + const detail = error instanceof Error ? error.message : String(error) + post({ type: 'error', code: 'parse', message: detail }) + } finally { + busy = false + } +} + +ctx.onmessage = (event: MessageEvent) => { + const message = event.data as InMessage + if (!message) return + if (message.type === 'init') { + post({ type: 'ready' }) + return + } + if (message.type === 'load') { + void handleLoad(message) + } +} diff --git a/src/cad/geom.ts b/src/cad/geom.ts new file mode 100644 index 0000000..0c2caea --- /dev/null +++ b/src/cad/geom.ts @@ -0,0 +1,399 @@ +export type Mat = readonly [number, number, number, number, number, number] + +export const IDENTITY: Mat = [1, 0, 0, 1, 0, 0] + +export function matMul(a: Mat, b: Mat): Mat { + return [ + a[0] * b[0] + a[2] * b[1], + a[1] * b[0] + a[3] * b[1], + a[0] * b[2] + a[2] * b[3], + a[1] * b[2] + a[3] * b[3], + a[0] * b[4] + a[2] * b[5] + a[4], + a[1] * b[4] + a[3] * b[5] + a[5] + ] +} + +export function matTranslate(tx: number, ty: number): Mat { + return [1, 0, 0, 1, tx, ty] +} + +export function matScale(sx: number, sy: number): Mat { + return [sx, 0, 0, sy, 0, 0] +} + +export function matRotate(rad: number): Mat { + const c = Math.cos(rad) + const s = Math.sin(rad) + return [c, s, -s, c, 0, 0] +} + +export function applyMat(m: Mat, x: number, y: number): [number, number] { + return [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]] +} + +export function applyMatVec(m: Mat, x: number, y: number): [number, number] { + return [m[0] * x + m[2] * y, m[1] * x + m[3] * y] +} + +export function matDet(m: Mat): number { + return m[0] * m[3] - m[1] * m[2] +} + +export function matInvert(m: Mat): Mat | null { + const det = matDet(m) + if (!Number.isFinite(det) || Math.abs(det) < 1e-14) return null + const a = m[3] / det + const b = -m[1] / det + const c = -m[2] / det + const d = m[0] / det + return [a, b, c, d, -(a * m[4] + c * m[5]), -(b * m[4] + d * m[5])] +} + +export function matScaleX(m: Mat): number { + return Math.hypot(m[0], m[1]) +} + +export function matScaleY(m: Mat): number { + return Math.hypot(m[2], m[3]) +} + +export function matScaleAvg(m: Mat): number { + return Math.sqrt(Math.abs(matDet(m))) || matScaleX(m) +} + +export function isSimilarity(m: Mat, eps = 1e-5): boolean { + const sx = matScaleX(m) + const sy = matScaleY(m) + if (Math.abs(sx - sy) > eps * Math.max(1, sx, sy)) return false + const dot = m[0] * m[2] + m[1] * m[3] + return Math.abs(dot) <= eps * Math.max(1, sx * sy) +} + +export interface BBox { + minX: number + minY: number + maxX: number + maxY: number +} + +export function emptyBBox(): BBox { + return { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity } +} + +export function bboxValid(b: BBox): boolean { + return ( + Number.isFinite(b.minX) && + Number.isFinite(b.minY) && + Number.isFinite(b.maxX) && + Number.isFinite(b.maxY) && + b.maxX >= b.minX && + b.maxY >= b.minY + ) +} + +export function bboxAddPoint(b: BBox, x: number, y: number): BBox { + if (!Number.isFinite(x) || !Number.isFinite(y)) return b + if (x < b.minX) b.minX = x + if (y < b.minY) b.minY = y + if (x > b.maxX) b.maxX = x + if (y > b.maxY) b.maxY = y + return b +} + +export function bboxFromPoints(points: ArrayLike, b: BBox = emptyBBox()): BBox { + for (let i = 0; i + 1 < points.length; i += 2) bboxAddPoint(b, points[i], points[i + 1]) + return b +} + +export function bboxUnion(a: BBox, b: BBox): BBox { + if (!bboxValid(a)) return { ...b } + if (!bboxValid(b)) return { ...a } + return { + minX: Math.min(a.minX, b.minX), + minY: Math.min(a.minY, b.minY), + maxX: Math.max(a.maxX, b.maxX), + maxY: Math.max(a.maxY, b.maxY) + } +} + +export function bboxTransform(m: Mat, b: BBox): BBox { + const out = emptyBBox() + bboxAddPoint(out, ...applyMat(m, b.minX, b.minY)) + bboxAddPoint(out, ...applyMat(m, b.maxX, b.minY)) + bboxAddPoint(out, ...applyMat(m, b.minX, b.maxY)) + bboxAddPoint(out, ...applyMat(m, b.maxX, b.maxY)) + return out +} + +export function bboxExpand(b: BBox, dx: number, dy = dx): BBox { + return { minX: b.minX - dx, minY: b.minY - dy, maxX: b.maxX + dx, maxY: b.maxY + dy } +} + +export function bboxWidth(b: BBox): number { + return b.maxX - b.minX +} + +export function bboxHeight(b: BBox): number { + return b.maxY - b.minY +} + +export function bboxCenter(b: BBox): [number, number] { + return [(b.minX + b.maxX) / 2, (b.minY + b.maxY) / 2] +} + +export function bboxIntersects(a: BBox, b: BBox): boolean { + return a.minX <= b.maxX && a.maxX >= b.minX && a.minY <= b.maxY && a.maxY >= b.minY +} + +export interface Camera { + scale: number + cx: number + cy: number +} + +export function cameraMatrix(cam: Camera, width: number, height: number): Mat { + const s = cam.scale + return [s, 0, 0, -s, width / 2 - s * cam.cx, height / 2 + s * cam.cy] +} + +export function worldToScreen( + cam: Camera, + width: number, + height: number, + x: number, + y: number +): [number, number] { + return [width / 2 + (x - cam.cx) * cam.scale, height / 2 - (y - cam.cy) * cam.scale] +} + +export function screenToWorld( + cam: Camera, + width: number, + height: number, + sx: number, + sy: number +): [number, number] { + return [cam.cx + (sx - width / 2) / cam.scale, cam.cy + (height / 2 - sy) / cam.scale] +} + +export function clamp(value: number, min: number, max: number): number { + return value < min ? min : value > max ? max : value +} + +export function arcSegmentCount(radiusScreen: number, sweep: number): number { + const r = Math.max(radiusScreen, 0.35) + const tolerance = 0.22 + const ratio = clamp(1 - tolerance / r, -1, 1) + const maxAngle = 2 * Math.acos(ratio) + const count = Math.ceil(Math.abs(sweep) / Math.max(maxAngle, 0.02)) + return clamp(count, 4, 1600) +} + +export function sampleArc( + cx: number, + cy: number, + r: number, + a0: number, + sweep: number, + radiusScreen: number, + out: number[] = [] +): number[] { + const n = arcSegmentCount(radiusScreen, sweep) + out.push(cx + r * Math.cos(a0), cy + r * Math.sin(a0)) + for (let i = 1; i <= n; i++) { + const a = a0 + (sweep * i) / n + out.push(cx + r * Math.cos(a), cy + r * Math.sin(a)) + } + return out +} + +export function sampleArcToPath( + cx: number, + cy: number, + r: number, + a0: number, + sweep: number, + radiusScreen: number, + moveTo: (x: number, y: number) => void, + lineTo: (x: number, y: number) => void +): void { + const n = arcSegmentCount(radiusScreen, sweep) + moveTo(cx + r * Math.cos(a0), cy + r * Math.sin(a0)) + for (let i = 1; i <= n; i++) { + const a = a0 + (sweep * i) / n + lineTo(cx + r * Math.cos(a), cy + r * Math.sin(a)) + } +} + +export function sampleEllipse( + cx: number, + cy: number, + mx: number, + my: number, + ratio: number, + a0: number, + sweep: number, + radiusScreen: number, + out: number[] = [] +): number[] { + const nx = -my * ratio + const ny = mx * ratio + const n = arcSegmentCount(radiusScreen, sweep) + const c0 = Math.cos(a0) + const s0 = Math.sin(a0) + out.push(cx + mx * c0 + nx * s0, cy + my * c0 + ny * s0) + for (let i = 1; i <= n; i++) { + const a = a0 + (sweep * i) / n + const c = Math.cos(a) + const s = Math.sin(a) + out.push(cx + mx * c + nx * s, cy + my * c + ny * s) + } + return out +} + +export function sampleEllipseToPath( + cx: number, + cy: number, + mx: number, + my: number, + ratio: number, + a0: number, + sweep: number, + radiusScreen: number, + moveTo: (x: number, y: number) => void, + lineTo: (x: number, y: number) => void +): void { + const nx = -my * ratio + const ny = mx * ratio + const n = arcSegmentCount(radiusScreen, sweep) + const c0 = Math.cos(a0) + const s0 = Math.sin(a0) + moveTo(cx + mx * c0 + nx * s0, cy + my * c0 + ny * s0) + for (let i = 1; i <= n; i++) { + const a = a0 + (sweep * i) / n + const c = Math.cos(a) + const s = Math.sin(a) + lineTo(cx + mx * c + nx * s, cy + my * c + ny * s) + } +} + +export interface BulgeArc { + cx: number + cy: number + r: number + a0: number + sweep: number +} + +export function bulgeToArc(x1: number, y1: number, x2: number, y2: number, bulge: number): BulgeArc | null { + if (!Number.isFinite(bulge) || Math.abs(bulge) < 1e-12) return null + const dx = x2 - x1 + const dy = y2 - y1 + const chord = Math.hypot(dx, dy) + if (chord < 1e-12) return null + const theta = 4 * Math.atan(bulge) + const half = Math.abs(theta) / 2 + const r = chord / (2 * Math.sin(half)) + if (!Number.isFinite(r) || r <= 0) return null + const mx = (x1 + x2) / 2 + const my = (y1 + y2) / 2 + const nx = -dy / chord + const ny = dx / chord + const d = chord / 2 / Math.tan(theta / 2) + const cx = mx + nx * d + const cy = my + ny * d + const a0 = Math.atan2(y1 - cy, x1 - cx) + return { cx, cy, r, a0, sweep: theta } +} + +export function splineDomain(knots: number[], degree: number, count: number): [number, number] { + if (knots.length < count + degree + 1 || count <= degree) { + return [0, 1] + } + return [knots[degree], knots[count]] +} + +export function evaluateSpline( + control: number[], + degree: number, + knots: number[], + weights: number[] | undefined, + t: number +): [number, number] { + const count = control.length / 2 + if (count === 0) return [0, 0] + if (count <= degree || knots.length < count + degree + 1) { + const firstX = control[0] + const firstY = control[1] + return [firstX, firstY] + } + let k = degree + for (let i = degree; i < count; i++) { + if (t >= knots[i] && t <= knots[i + 1]) { + k = i + if (t < knots[i + 1]) break + } + } + const pts: Array<[number, number, number]> = [] + for (let j = 0; j <= degree; j++) { + const idx = k - degree + j + const w = weights && weights.length > idx ? weights[idx] : 1 + pts.push([control[idx * 2] * w, control[idx * 2 + 1] * w, w]) + } + for (let r = 1; r <= degree; r++) { + for (let j = degree; j >= r; j--) { + const i = k - degree + j + const denom = knots[i + degree + 1 - r] - knots[i] + const alpha = denom === 0 ? 0 : (t - knots[i]) / denom + const prev = pts[j - 1] + const cur = pts[j] + pts[j] = [ + prev[0] * (1 - alpha) + cur[0] * alpha, + prev[1] * (1 - alpha) + cur[1] * alpha, + prev[2] * (1 - alpha) + cur[2] * alpha + ] + } + } + const result = pts[degree] + return [result[2] === 0 ? 0 : result[0] / result[2], result[2] === 0 ? 0 : result[1] / result[2]] +} + +export function sampleSpline( + control: number[], + degree: number, + knots: number[], + weights: number[] | undefined, + segments: number, + out: number[] = [] +): number[] { + const count = control.length / 2 + if (count === 0) return out + if (count === 1) { + out.push(control[0], control[1]) + return out + } + if (degree < 1 || count <= degree || knots.length < count + degree + 1) { + for (let i = 0; i < control.length; i++) out.push(control[i]) + return out + } + const [start, end] = splineDomain(knots, degree, count) + if (!(end > start)) { + for (let i = 0; i < control.length; i++) out.push(control[i]) + return out + } + const n = clamp(Math.round(segments), 8, 2048) + for (let i = 0; i <= n; i++) { + const t = start + ((end - start) * i) / n + const p = evaluateSpline(control, degree, knots, weights, t) + out.push(p[0], p[1]) + } + return out +} + +export function formatNumber(value: number, maxDecimals = 3): string { + if (!Number.isFinite(value)) return '—' + const abs = Math.abs(value) + if (abs >= 1e7 || (abs > 0 && abs < 1e-4)) return value.toExponential(2) + const fixed = value.toFixed(maxDecimals) + return fixed.replace(/\.?0+$/, '') +} diff --git a/src/cad/loader.ts b/src/cad/loader.ts new file mode 100644 index 0000000..a3bf013 --- /dev/null +++ b/src/cad/loader.ts @@ -0,0 +1,186 @@ +import type { CadDocument } from './types' +import { slimDocument } from './slim' + +interface WorkerDoneMessage { + type: 'done' + doc: CadDocument + timings?: { readMs: number; parseMs: number; buildMs: number; totalMs: number } +} + +interface WorkerMessage { + type: 'progress' | 'ready' | 'done' | 'error' + message?: string + code?: string + doc?: CadDocument + timings?: WorkerDoneMessage['timings'] +} + +interface ActiveLoad { + resolve: (doc: CadDocument) => void + reject: (error: Error) => void + onProgress?: (message: string) => void +} + +let worker: Worker | null = null +let workerDisabled = false +let enginePromise: Promise | null = null +let engineResolve: (() => void) | null = null +let engineReject: ((error: Error) => void) | null = null +let engineTimer = 0 +let activeLoad: ActiveLoad | null = null + +function disableWorker(error: Error): void { + workerDisabled = true + if (engineTimer) { + window.clearTimeout(engineTimer) + engineTimer = 0 + } + if (engineReject) { + engineReject(error) + engineReject = null + engineResolve = null + enginePromise = null + } + if (activeLoad) { + activeLoad.reject(error) + activeLoad = null + } + try { + worker?.terminate() + } catch { + /* ignore */ + } + worker = null +} + +function handleWorkerMessage(event: MessageEvent): void { + const message = event.data as WorkerMessage + if (!message) return + if (message.type === 'progress') { + activeLoad?.onProgress?.(message.message ?? '') + return + } + if (message.type === 'ready') { + if (engineTimer) { + window.clearTimeout(engineTimer) + engineTimer = 0 + } + const resolve = engineResolve + engineResolve = null + engineReject = null + resolve?.() + return + } + if (message.type === 'done' && message.doc) { + if (message.timings) { + console.info( + `[dwg] read ${Math.round(message.timings.readMs)}ms · parse ${Math.round( + message.timings.parseMs + )}ms · build ${Math.round(message.timings.buildMs)}ms · total ${Math.round( + message.timings.totalMs + )}ms` + ) + } + const active = activeLoad + activeLoad = null + active?.resolve(message.doc) + return + } + if (message.type === 'error') { + const error = new Error(message.message || 'DWG 解析失败') + if (message.code === 'engine') { + disableWorker(error) + return + } + const active = activeLoad + activeLoad = null + active?.reject(error) + } +} + +function ensureWorker(): Worker | null { + if (workerDisabled) return null + if (!worker) { + try { + worker = new Worker(new URL('./dwgWorker.ts', import.meta.url), { type: 'module' }) + } catch { + workerDisabled = true + return null + } + worker.onmessage = handleWorkerMessage + worker.onerror = () => { + disableWorker(new Error('DWG 解析 Worker 启动失败')) + } + } + if (!enginePromise) { + enginePromise = new Promise((resolve, reject) => { + engineResolve = resolve + engineReject = reject + engineTimer = window.setTimeout(() => { + disableWorker(new Error('DWG 引擎加载超时')) + }, 60000) + try { + worker!.postMessage({ type: 'init' }) + } catch (error) { + disableWorker(error instanceof Error ? error : new Error(String(error))) + } + }) + } + return worker +} + +export async function preloadDwgEngine(): Promise { + const instance = ensureWorker() + if (!instance || !enginePromise) return + try { + await enginePromise + } catch { + /* main-thread fallback will be used on open */ + } +} + +export async function loadDwg( + file: File, + onProgress?: (message: string) => void +): Promise { + const instance = ensureWorker() + if (!instance || !enginePromise) { + return loadDwgOnMainThread(file, onProgress) + } + try { + await enginePromise + } catch { + return loadDwgOnMainThread(file, onProgress) + } + if (workerDisabled || !worker) { + return loadDwgOnMainThread(file, onProgress) + } + try { + return await new Promise((resolve, reject) => { + activeLoad = { resolve, reject, onProgress } + worker!.postMessage({ + type: 'load', + file, + name: file.name, + size: file.size + }) + }) + } catch (error) { + const failure = error instanceof Error ? error : new Error(String(error)) + disableWorker(failure) + return loadDwgOnMainThread(file, onProgress) + } +} + +async function loadDwgOnMainThread( + file: File, + onProgress?: (message: string) => void +): Promise { + onProgress?.('正在读取文件…') + const buffer = await file.arrayBuffer() + onProgress?.('正在解析 DWG 图纸…') + await new Promise((resolve) => setTimeout(resolve, 20)) + const { buildAcadDocument } = await import('./acadAdapter') + const doc = buildAcadDocument(buffer, file.name, file.size) + return slimDocument(doc) +} diff --git a/src/cad/polyfills.ts b/src/cad/polyfills.ts new file mode 100644 index 0000000..7908d74 --- /dev/null +++ b/src/cad/polyfills.ts @@ -0,0 +1,75 @@ +if (!(Array.prototype as any).at) { + Object.defineProperty(Array.prototype, 'at', { + configurable: true, + writable: true, + value(this: unknown[], index: number) { + const length = this.length + let key = Math.trunc(Number(index)) || 0 + if (key < 0) key += length + if (key < 0 || key >= length) return undefined + return this[key] + } + }) +} + +if (!(String.prototype as any).at) { + Object.defineProperty(String.prototype, 'at', { + configurable: true, + writable: true, + value(this: string, index: number) { + const length = this.length + let key = Math.trunc(Number(index)) || 0 + if (key < 0) key += length + if (key < 0 || key >= length) return undefined + return this.charAt(key) + } + }) +} + +if (!(String.prototype as any).replaceAll) { + Object.defineProperty(String.prototype, 'replaceAll', { + configurable: true, + writable: true, + value(this: string, search: string | RegExp, replacement: string) { + if (search instanceof RegExp) { + if (!search.global) throw new TypeError('replaceAll requires a global RegExp') + return this.replace(search, replacement) + } + return this.split(search).join(replacement) + } + }) +} + +if (!(Object as any).hasOwn) { + Object.hasOwn = (object: object, key: PropertyKey) => + Object.prototype.hasOwnProperty.call(object, key) +} + +const dataView = DataView.prototype as any +if (!dataView.getBigInt64) { + dataView.getBigInt64 = function (this: DataView, byteOffset = 0, littleEndian = false) { + const high = this.getInt32(littleEndian ? byteOffset + 4 : byteOffset, littleEndian) + const low = this.getUint32(littleEndian ? byteOffset : byteOffset + 4, littleEndian) + return high * 4294967296 + low + } +} +if (!dataView.getBigUint64) { + dataView.getBigUint64 = function (this: DataView, byteOffset = 0, littleEndian = false) { + const high = this.getUint32(littleEndian ? byteOffset + 4 : byteOffset, littleEndian) + const low = this.getUint32(littleEndian ? byteOffset : byteOffset + 4, littleEndian) + return high * 4294967296 + low + } +} + +if (typeof crypto !== 'undefined' && !(crypto as any).randomUUID) { + ;(crypto as any).randomUUID = function () { + const bytes = new Uint8Array(16) + crypto.getRandomValues(bytes) + bytes[6] = (bytes[6] & 0x0f) | 0x40 + bytes[8] = (bytes[8] & 0x3f) | 0x80 + const hex = [...bytes].map((value) => value.toString(16).padStart(2, '0')) + return `${hex.slice(0, 4).join('')}-${hex.slice(4, 6).join('')}-${hex.slice(6, 8).join('')}-${hex + .slice(8, 10) + .join('')}-${hex.slice(10).join('')}` + } +} diff --git a/src/cad/renderer.ts b/src/cad/renderer.ts new file mode 100644 index 0000000..1a2459e --- /dev/null +++ b/src/cad/renderer.ts @@ -0,0 +1,643 @@ +import type { DwgViewportEntity } from '@mlightcad/libredwg-web' +import type { Camera, Mat } from './geom' +import { + applyMat, + applyMatVec, + bboxFromPoints, + bboxHeight, + bboxIntersects, + bboxTransform, + bboxUnion, + bboxValid, + bboxWidth, + bulgeToArc, + cameraMatrix, + clamp, + emptyBBox, + matInvert, + matMul, + matRotate, + matScale, + matScaleAvg, + matScaleY, + matTranslate, + sampleArcToPath, + sampleEllipseToPath, + sampleSpline +} from './geom' +import { cssColor } from './colors' +import type { CadDocument, CadSpace, Primitive } from './types' +import type { Theme } from '../core/theme' + +export interface RenderOptions { + layerVisible: (name: string) => boolean + proxyVisible?: boolean + theme: Theme +} + +const FONT_FAMILY = + '"Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif' + +const MODEL_BG = { dark: '#0d1117', light: '#f6f8fc' } +const LAYOUT_BG = { dark: '#121722', light: '#e8edf5' } +const PAGE_COLOR = '#ffffff' + +export class CadRenderer { + private doc: CadDocument + private layerHandleToName = new Map() + + constructor(doc: CadDocument) { + this.doc = doc + for (const layer of doc.layers) { + if (layer.handle) this.layerHandleToName.set(layer.handle, layer.name) + } + } + + draw( + ctx: CanvasRenderingContext2D, + space: CadSpace, + camera: Camera, + width: number, + height: number, + options: RenderOptions + ): void { + const theme = options.theme + const isLayout = space.kind === 'layout' + ctx.save() + ctx.fillStyle = isLayout ? LAYOUT_BG[theme] : MODEL_BG[theme] + ctx.fillRect(0, 0, width, height) + + const cameraMat = cameraMatrix(camera, width, height) + if (isLayout) { + this.drawLayout(ctx, space, camera, cameraMat, width, height, options) + } else { + this.drawPrimitives(ctx, space, cameraMat, camera, false, options) + } + ctx.restore() + } + + private drawLayout( + ctx: CanvasRenderingContext2D, + space: CadSpace, + camera: Camera, + cameraMat: Mat, + _width: number, + _height: number, + options: RenderOptions + ): void { + const page = space.bbox + if (!bboxValid(page)) return + const p0 = applyMat(cameraMat, page.minX, page.minY) + const p1 = applyMat(cameraMat, page.maxX, page.maxY) + const left = Math.min(p0[0], p1[0]) + const top = Math.min(p0[1], p1[1]) + const right = Math.max(p0[0], p1[0]) + const bottom = Math.max(p0[1], p1[1]) + const pageRect = { x: left, y: top, w: right - left, h: bottom - top } + + ctx.save() + ctx.shadowColor = 'rgba(0,0,0,0.38)' + ctx.shadowBlur = 22 + ctx.shadowOffsetY = 8 + ctx.fillStyle = PAGE_COLOR + ctx.fillRect(pageRect.x, pageRect.y, pageRect.w, pageRect.h) + ctx.restore() + + ctx.save() + ctx.beginPath() + ctx.rect(pageRect.x, pageRect.y, pageRect.w, pageRect.h) + ctx.clip() + + for (const vp of space.viewports) { + if (!this.isRenderableViewport(vp)) continue + this.drawViewport(ctx, space, vp, camera, cameraMat, options) + } + + this.drawPrimitives(ctx, space, cameraMat, camera, true, options) + + ctx.restore() + + ctx.strokeStyle = 'rgba(0,0,0,0.16)' + ctx.lineWidth = 1 + ctx.strokeRect(pageRect.x + 0.5, pageRect.y + 0.5, Math.max(0, pageRect.w - 1), Math.max(0, pageRect.h - 1)) + } + + private isRenderableViewport(vp: DwgViewportEntity): boolean { + const width = Math.abs(Number(vp.width) || 0) + const height = Math.abs(Number(vp.height) || 0) + const viewHeight = Math.abs(Number(vp.viewHeight) || 0) + if (width <= 0 || height <= 0 || viewHeight <= 0) return false + const flags = Number(vp.statusBitFlags) || 0 + if (flags & 131072) return false + return true + } + + private drawViewport( + ctx: CanvasRenderingContext2D, + space: CadSpace, + vp: DwgViewportEntity, + camera: Camera, + cameraMat: Mat, + options: RenderOptions + ): void { + const model = this.doc.model + if (!model) return + const width = Math.abs(Number(vp.width) || 0) + const height = Math.abs(Number(vp.height) || 0) + const viewHeight = Math.abs(Number(vp.viewHeight) || 0) + if (width <= 0 || height <= 0 || viewHeight <= 0) return + const center = vp.viewportCenter ?? { x: 0, y: 0 } + const viewCenter = vp.displayCenter ?? { x: 0, y: 0 } + const twist = Number(vp.viewTwistAngle) || 0 + const scale = height / viewHeight + let modelToPaper = matTranslate(Number(center.x) || 0, Number(center.y) || 0) + modelToPaper = matMul(modelToPaper, matRotate(-twist)) + modelToPaper = matMul(modelToPaper, matScale(scale, scale)) + modelToPaper = matMul( + modelToPaper, + matTranslate(-(Number(viewCenter.x) || 0), -(Number(viewCenter.y) || 0)) + ) + const totalMat = matMul(cameraMat, modelToPaper) + + const corners = [ + [Number(center.x) - width / 2, Number(center.y) - height / 2], + [Number(center.x) + width / 2, Number(center.y) - height / 2], + [Number(center.x) + width / 2, Number(center.y) + height / 2], + [Number(center.x) - width / 2, Number(center.y) + height / 2] + ].map(([x, y]) => applyMat(cameraMat, x, y)) + + const frozen = new Set() + if (Array.isArray(vp.frozenLayerIds)) { + for (const handle of vp.frozenLayerIds) { + const name = this.layerHandleToName.get(String(handle)) + if (name) frozen.add(name) + } + } + + ctx.save() + ctx.beginPath() + ctx.moveTo(corners[0][0], corners[0][1]) + for (let i = 1; i < corners.length; i++) ctx.lineTo(corners[i][0], corners[i][1]) + ctx.closePath() + ctx.clip() + this.drawPrimitives( + ctx, + model, + totalMat, + camera, + true, + options, + (prim) => !frozen.has(prim.layer) + ) + ctx.restore() + + if (this.isViewportFrameVisible(vp)) { + const c = corners + const minX = Math.min(...c.map((p) => p[0])) + const maxX = Math.max(...c.map((p) => p[0])) + const minY = Math.min(...c.map((p) => p[1])) + const maxY = Math.max(...c.map((p) => p[1])) + if (maxX - minX > 8 && maxY - minY > 8) { + ctx.save() + ctx.strokeStyle = options.theme === 'dark' ? 'rgba(0,0,0,0.22)' : 'rgba(30,50,90,0.18)' + ctx.lineWidth = 1 + ctx.setLineDash([4, 4]) + ctx.strokeRect(minX + 0.5, minY + 0.5, maxX - minX - 1, maxY - minY - 1) + ctx.restore() + } + } + void camera + } + + private isViewportFrameVisible(vp: DwgViewportEntity): boolean { + const flags = Number(vp.statusBitFlags) || 0 + return (flags & 131072) === 0 + } + + private drawPrimitives( + ctx: CanvasRenderingContext2D, + source: Pick, + totalMat: Mat, + _camera: Camera, + paper: boolean, + options: RenderOptions, + extraFilter?: (prim: Primitive) => boolean + ): void { + const cw = ctx.canvas.clientWidth || ctx.canvas.width + const ch = ctx.canvas.clientHeight || ctx.canvas.height + for (const prim of this.visiblePrimitives(source, totalMat, cw, ch)) { + if (!options.layerVisible(prim.layer)) continue + if (options.proxyVisible === false && prim.proxy) continue + if (extraFilter && !extraFilter(prim)) continue + let sb = null + if (!prim.ignoreBounds) { + sb = bboxTransform(totalMat, prim.bbox) + if (sb.maxX < -32 || sb.minX > cw + 32 || sb.maxY < -32 || sb.minY > ch + 32) { + continue + } + } + if (prim.kind === 'text') { + const size = prim.height * matScaleY(totalMat) + if (size < 2.8) continue + this.drawText(ctx, prim, totalMat, paper, options) + } else { + if (sb) { + const sw = sb.maxX - sb.minX + const sh = sb.maxY - sb.minY + if (Math.max(sw, sh) < 0.55) continue + } + this.drawPrimitive(ctx, prim, totalMat, paper, options) + } + } + } + + private visiblePrimitives( + source: Pick, + mat: Mat, + width: number, + height: number + ): Primitive[] { + const prims = source.prims + const grid = source.grid + const inverse = matInvert(mat) + if (!inverse) return [] + + const corners = [ + applyMat(inverse, -32, -32), + applyMat(inverse, width + 32, -32), + applyMat(inverse, -32, height + 32), + applyMat(inverse, width + 32, height + 32) + ] + let minX = Infinity + let minY = Infinity + let maxX = -Infinity + let maxY = -Infinity + for (const [x, y] of corners) { + if (x < minX) minX = x + if (y < minY) minY = y + if (x > maxX) maxX = x + if (y > maxY) maxY = y + } + const world = { minX, minY, maxX, maxY } + + if (!grid) { + return prims.filter((prim) => prim.ignoreBounds || bboxIntersects(prim.bbox, world)) + } + + const seen = new Uint8Array(prims.length) + const indices: number[] = [] + const add = (index: number) => { + if (seen[index]) return + seen[index] = 1 + const prim = prims[index] + if (prim && (prim.ignoreBounds || bboxIntersects(prim.bbox, world))) indices.push(index) + } + + for (const index of grid.big) add(index) + + const c0 = clamp(Math.floor((minX - grid.minX) / grid.cellW), 0, grid.cols - 1) + const c1 = clamp(Math.floor((maxX - grid.minX) / grid.cellW), 0, grid.cols - 1) + const r0 = clamp(Math.floor((minY - grid.minY) / grid.cellH), 0, grid.rows - 1) + const r1 = clamp(Math.floor((maxY - grid.minY) / grid.cellH), 0, grid.rows - 1) + for (let row = r0; row <= r1; row++) { + const base = row * grid.cols + for (let col = c0; col <= c1; col++) { + const cell = grid.cells[base + col] + if (!cell) continue + for (const index of cell) add(index) + } + } + + return indices.map((index) => prims[index]) + } + + private drawPrimitive( + ctx: CanvasRenderingContext2D, + prim: Exclude, + mat: Mat, + paper: boolean, + options: RenderOptions + ): void { + const scale = matScaleAvg(mat) + const color = cssColor(prim.color, paper, options.theme) + const lineWidth = Math.max(0.35, prim.width) + ctx.save() + ctx.lineWidth = lineWidth + ctx.strokeStyle = color + ctx.fillStyle = color + ctx.lineCap = 'butt' + ctx.lineJoin = 'round' + if (prim.alpha != null && prim.alpha < 1) ctx.globalAlpha = clamp(prim.alpha, 0.05, 1) + const dash = dashInPixels(prim.dash, scale) + if (dash) ctx.setLineDash(dash) + else ctx.setLineDash([]) + + switch (prim.kind) { + case 'poly': { + if (prim.points.length < 4) break + ctx.beginPath() + const p = applyMat(mat, prim.points[0], prim.points[1]) + ctx.moveTo(p[0], p[1]) + for (let i = 2; i < prim.points.length; i += 2) { + const q = applyMat(mat, prim.points[i], prim.points[i + 1]) + ctx.lineTo(q[0], q[1]) + } + if (prim.closed) ctx.closePath() + if (prim.fill) { + ctx.setLineDash([]) + ctx.fillStyle = prim.fillBackground + ? paper + ? PAGE_COLOR + : options.theme === 'dark' + ? MODEL_BG.dark + : MODEL_BG.light + : color + ctx.fill() + } + if (prim.stroke) { + if (prim.worldWidth && prim.worldWidth > 0) { + ctx.lineWidth = clamp(prim.worldWidth * scale, lineWidth, 48) + } + ctx.stroke() + } + break + } + case 'circle': { + const r = Math.max(0.1, prim.r * scale) + if (r < 0.25) break + ctx.beginPath() + sampleArcToPath( + prim.cx, + prim.cy, + prim.r, + 0, + Math.PI * 2, + r, + (x, y) => { + const p = applyMat(mat, x, y) + ctx.moveTo(p[0], p[1]) + }, + (x, y) => { + const p = applyMat(mat, x, y) + ctx.lineTo(p[0], p[1]) + } + ) + ctx.closePath() + if (prim.fill) ctx.fill() + ctx.stroke() + break + } + case 'arc': { + const r = Math.max(0.1, prim.r * scale) + if (r < 0.25) break + ctx.beginPath() + sampleArcToPath( + prim.cx, + prim.cy, + prim.r, + prim.a0, + prim.sweep, + r, + (x, y) => { + const p = applyMat(mat, x, y) + ctx.moveTo(p[0], p[1]) + }, + (x, y) => { + const p = applyMat(mat, x, y) + ctx.lineTo(p[0], p[1]) + } + ) + ctx.stroke() + break + } + case 'ellipse': { + const r = Math.max(0.1, Math.hypot(prim.mx, prim.my) * scale) + if (r < 0.25) break + ctx.beginPath() + sampleEllipseToPath( + prim.cx, + prim.cy, + prim.mx, + prim.my, + prim.ratio, + prim.a0, + prim.sweep, + r, + (x, y) => { + const p = applyMat(mat, x, y) + ctx.moveTo(p[0], p[1]) + }, + (x, y) => { + const p = applyMat(mat, x, y) + ctx.lineTo(p[0], p[1]) + } + ) + if (prim.fill) { + ctx.closePath() + ctx.fill() + } + ctx.stroke() + break + } + case 'bulge': { + if (prim.vertices.length < 2) break + ctx.beginPath() + const first = applyMat(mat, prim.vertices[0].x, prim.vertices[0].y) + ctx.moveTo(first[0], first[1]) + for (let i = 0; i < prim.vertices.length; i++) { + const next = i + 1 < prim.vertices.length ? i + 1 : prim.closed ? 0 : -1 + if (next < 0) break + const a = prim.vertices[i] + const b = prim.vertices[next] + const arc = bulgeToArc(a.x, a.y, b.x, b.y, a.bulge) + if (arc) { + const r = Math.max(0.1, arc.r * scale) + sampleArcToPath( + arc.cx, + arc.cy, + arc.r, + arc.a0, + arc.sweep, + r, + () => {}, + (x, y) => { + const p = applyMat(mat, x, y) + ctx.lineTo(p[0], p[1]) + } + ) + } else { + const p = applyMat(mat, b.x, b.y) + ctx.lineTo(p[0], p[1]) + } + } + if (prim.closed) ctx.closePath() + if (prim.worldWidth && prim.worldWidth > 0) ctx.lineWidth = clamp(prim.worldWidth * scale, lineWidth, 48) + ctx.stroke() + break + } + case 'spline': { + const local = bboxFromPoints(prim.control) + const extent = Math.max(bboxWidth(local), bboxHeight(local)) * scale + const spans = Math.max(1, prim.control.length / 2 - prim.degree) + const segments = clamp(Math.ceil(extent / 2.5) + spans * 6, 32, 1400) + const pts = sampleSpline(prim.control, prim.degree, prim.knots, prim.weights, segments) + if (pts.length < 4) break + ctx.beginPath() + const p0 = applyMat(mat, pts[0], pts[1]) + ctx.moveTo(p0[0], p0[1]) + for (let i = 2; i < pts.length; i += 2) { + const p = applyMat(mat, pts[i], pts[i + 1]) + ctx.lineTo(p[0], p[1]) + } + if (prim.closed) ctx.closePath() + ctx.stroke() + break + } + case 'hatch': { + ctx.beginPath() + for (const path of prim.paths) { + if (path.length < 6) continue + const p0 = applyMat(mat, path[0], path[1]) + ctx.moveTo(p0[0], p0[1]) + for (let i = 2; i < path.length; i += 2) { + const p = applyMat(mat, path[i], path[i + 1]) + ctx.lineTo(p[0], p[1]) + } + ctx.closePath() + } + if (prim.solid) { + ctx.setLineDash([]) + ctx.fill('evenodd') + break + } + const sb = bboxTransform(mat, prim.bbox) + if (!bboxValid(sb)) break + if (prim.patternSpacing * scale < 1.4) break + ctx.save() + ctx.clip('evenodd') + let spacing = Math.max(2, prim.patternSpacing * scale) + const angle = -prim.patternAngle + const dx = Math.cos(angle) + const dy = Math.sin(angle) + const nx = -dy + const ny = dx + const cx = (sb.minX + sb.maxX) / 2 + const cy = (sb.minY + sb.maxY) / 2 + const diagonal = Math.hypot(bboxWidth(sb), bboxHeight(sb)) + if ((diagonal * 2) / spacing > 12000) spacing = (diagonal * 2) / 12000 + ctx.beginPath() + const limit = diagonal + spacing + for (let offset = -limit; offset <= limit; offset += spacing) { + const ox = cx + nx * offset + const oy = cy + ny * offset + ctx.moveTo(ox - dx * limit, oy - dy * limit) + ctx.lineTo(ox + dx * limit, oy + dy * limit) + } + ctx.lineWidth = 0.7 + ctx.strokeStyle = color + ctx.setLineDash([]) + ctx.stroke() + ctx.restore() + break + } + case 'point': { + const p = applyMat(mat, prim.x, prim.y) + ctx.beginPath() + ctx.arc(p[0], p[1], 1.8, 0, Math.PI * 2) + ctx.fill() + ctx.strokeStyle = color + ctx.lineWidth = 1 + ctx.beginPath() + ctx.moveTo(p[0] - 3, p[1]) + ctx.lineTo(p[0] + 3, p[1]) + ctx.moveTo(p[0], p[1] - 3) + ctx.lineTo(p[0], p[1] + 3) + ctx.stroke() + break + } + case 'image': { + ctx.beginPath() + if (prim.points && prim.points.length >= 6) { + const p0 = applyMat(mat, prim.points[0], prim.points[1]) + ctx.moveTo(p0[0], p0[1]) + for (let i = 2; i < prim.points.length; i += 2) { + const p = applyMat(mat, prim.points[i], prim.points[i + 1]) + ctx.lineTo(p[0], p[1]) + } + ctx.closePath() + } else { + const a = applyMat(mat, prim.x1, prim.y1) + const b = applyMat(mat, prim.x2, prim.y2) + ctx.rect(a[0], a[1], b[0] - a[0], b[1] - a[1]) + } + ctx.globalAlpha = 0.16 + ctx.fillStyle = color + ctx.fill() + ctx.globalAlpha = 1 + ctx.setLineDash([5, 4]) + ctx.strokeStyle = color + ctx.lineWidth = 1 + ctx.stroke() + break + } + } + ctx.restore() + } + + private drawText( + ctx: CanvasRenderingContext2D, + prim: Extract, + mat: Mat, + paper: boolean, + options: RenderOptions + ): void { + if (!prim.lines.length) return + const anchor = applyMat(mat, prim.x, prim.y) + const yScale = Math.hypot(mat[2], mat[3]) + const size = prim.height * yScale + if (!Number.isFinite(size) || size < 2.4) return + if (size > 2600) return + const cos = Math.cos(prim.rotation) + const sin = Math.sin(prim.rotation) + const axis = applyMatVec(mat, cos, sin) + const angle = Math.atan2(axis[1], axis[0]) + const color = cssColor(prim.color, paper, options.theme) + const lineHeightPx = Math.max(size * 1.1, prim.lineHeight * yScale) + const totalHeight = lineHeightPx * prim.lines.length + + ctx.save() + ctx.translate(anchor[0], anchor[1]) + ctx.rotate(angle) + ctx.scale(prim.widthFactor * (prim.mirrored ? -1 : 1), 1) + ctx.font = `${Math.min(size, 2600)}px ${FONT_FAMILY}` + ctx.fillStyle = color + ctx.textAlign = prim.halign + ctx.setLineDash([]) + + if (prim.lines.length === 1 && (prim.valign === 'baseline' || prim.valign === 'bottom')) { + ctx.textBaseline = prim.valign === 'baseline' ? 'alphabetic' : 'bottom' + ctx.fillText(prim.lines[0], 0, 0) + } else { + ctx.textBaseline = 'top' + let y0 = 0 + if (prim.valign === 'middle') y0 = -totalHeight / 2 + else if (prim.valign === 'bottom') y0 = -totalHeight + for (let i = 0; i < prim.lines.length; i++) { + ctx.fillText(prim.lines[i], 0, y0 + i * lineHeightPx) + } + } + ctx.restore() + } +} + +function dashInPixels(dash: number[] | undefined, scale: number): number[] | null { + if (!dash || !dash.length) return null + let meaningful = false + const out: number[] = [] + for (const value of dash) { + const px = Math.max(0.3, value * scale) + if (px > 0.6) meaningful = true + out.push(Math.min(px, 400)) + } + return meaningful ? out : null +} diff --git a/src/cad/slim.ts b/src/cad/slim.ts new file mode 100644 index 0000000..706674d --- /dev/null +++ b/src/cad/slim.ts @@ -0,0 +1,21 @@ +import type { DwgDatabase } from '@mlightcad/libredwg-web' +import type { CadDocument, CadSpace } from './types' + +export function slimDocument(doc: CadDocument): CadDocument { + const spaces: CadSpace[] = doc.spaces.map((space) => ({ + ...space, + entities: [], + entityCount: space.entityCount ?? space.entities.length + })) + const model = spaces.find((space) => space.kind === 'model') ?? spaces[0] + return { + ...doc, + db: undefined as unknown as DwgDatabase, + blocks: new Map(), + blockByHandle: new Map(), + dashPatterns: new Map(), + imageNames: new Map(), + spaces, + model + } +} diff --git a/src/cad/text.ts b/src/cad/text.ts new file mode 100644 index 0000000..52d2a9e --- /dev/null +++ b/src/cad/text.ts @@ -0,0 +1,118 @@ +export function decodeCadEscapes(text: string): string { + if (!text) return '' + let out = text + out = out.replace(/\\U\+([0-9a-fA-F]{4})/g, (_m, hex: string) => String.fromCharCode(parseInt(hex, 16))) + out = out.replace(/%%([dDpPcC%])/g, (_m, code: string) => { + switch (code.toLowerCase()) { + case 'd': + return '°' + case 'p': + return '±' + case 'c': + return 'Ø' + case '%': + return '%' + default: + return '' + } + }) + out = out.replace(/\\P/gi, '\n') + out = out.replace(/\\~/g, ' ') + out = out.replace(/\\\\/g, '\\') + out = out.replace(/\\\{/g, '{').replace(/\\\}/g, '}') + out = out.replace(/[{}]/g, '') + out = out.replace(/\r/g, '') + return out +} + +export function parseMText(raw: string, width: number, height: number): string[] { + if (!raw) return [] + let text = raw + text = text.replace(/\\U\+([0-9a-fA-F]{4})/g, (_m, hex: string) => String.fromCharCode(parseInt(hex, 16))) + text = text.replace(/\\P/gi, '\n') + text = text.replace(/\\~/g, ' ') + text = text.replace(/\\S([^;]*);/g, (_m, stacked: string) => stacked.replace(/[\^#]/g, '/')) + text = text.replace(/\\[AaCcFfHhQqTtWwXx][^;\\]*;/g, '') + text = text.replace(/\\[LlOoKkNn]/g, '') + text = text.replace(/\\[a-zA-Z][^;\\]*;?/g, '') + text = text.replace(/%%([dDpPcC%])/g, (_m, code: string) => { + switch (code.toLowerCase()) { + case 'd': + return '°' + case 'p': + return '±' + case 'c': + return 'Ø' + case '%': + return '%' + default: + return '' + } + }) + text = text.replace(/\\\\/g, '\\') + text = text.replace(/\\\{/g, '{').replace(/\\\}/g, '}') + text = text.replace(/[{}]/g, '') + text = text.replace(/\r/g, '') + const explicit = text.split('\n') + const result: string[] = [] + for (const line of explicit) { + if (width > 0) { + result.push(...wrapLine(line, width, height)) + } else { + result.push(line.replace(/\s+$/, '')) + } + } + return result.filter((line, index, arr) => line.length > 0 || (index > 0 && index < arr.length - 1)) +} + +function charWidth(ch: string, height: number): number { + const code = ch.codePointAt(0) ?? 32 + if (code >= 0x2e80) return height + if (ch === ' ') return height * 0.32 + if (/[ilI1.,'`:;|!]/.test(ch)) return height * 0.28 + if (/[mwMW@%&]/.test(ch)) return height * 0.85 + if (/[A-Z]/.test(ch)) return height * 0.66 + if (/[0-9]/.test(ch)) return height * 0.58 + return height * 0.54 +} + +export function textWidth(text: string, height: number): number { + let width = 0 + for (const ch of text) width += charWidth(ch, height) + return width +} + +export function wrapLine(line: string, width: number, height: number): string[] { + const trimmed = line.trim() + if (!trimmed) return [''] + if (width <= 0 || textWidth(trimmed, height) <= width) return [trimmed] + const lines: string[] = [] + let current = '' + let currentWidth = 0 + let lastBreak = -1 + const chars = Array.from(trimmed) + for (let i = 0; i < chars.length; i++) { + const ch = chars[i] + const w = charWidth(ch, height) + if (currentWidth + w > width && current.length > 0) { + if (lastBreak > 0 && /[A-Za-z0-9]/.test(chars[i - 1] ?? '')) { + const head = current.slice(0, lastBreak) + const tail = current.slice(lastBreak).trimStart() + lines.push(head.trimEnd()) + current = tail + currentWidth = textWidth(current, height) + lastBreak = -1 + } else { + lines.push(current.trimEnd()) + current = '' + currentWidth = 0 + lastBreak = -1 + } + } + current += ch + currentWidth += w + if (ch === ' ' || ch === '-' || ch === '/') lastBreak = current.length + } + if (current.trim()) lines.push(current.trimEnd()) + return lines.length ? lines : [''] +} diff --git a/src/cad/types.ts b/src/cad/types.ts new file mode 100644 index 0000000..29d7588 --- /dev/null +++ b/src/cad/types.ts @@ -0,0 +1,196 @@ +import type { + DwgBlockRecordTableEntry, + DwgDatabase, + DwgEntity, + DwgLayoutObject, + DwgViewportEntity +} from '@mlightcad/libredwg-web' +import type { BBox, Mat } from './geom' +import type { ColorSpec } from './colors' + +export interface LayerInfo { + name: string + handle: string + aci: number + rgb?: number + visible: boolean + off: boolean + frozen: boolean + count: number + lineType: string + lineWeight: number +} + +export interface CadBlockInfo { + name: string + handle: string + layoutHandle: string + baseX: number + baseY: number + entities: DwgEntity[] +} + +export interface PrimBase { + layer: string + color: ColorSpec + width: number + worldWidth?: number + dash?: number[] + alpha?: number + bbox: BBox + mat: Mat + ignoreBounds?: boolean + proxy?: boolean +} + +export interface PolyPrim extends PrimBase { + kind: 'poly' + points: number[] + closed: boolean + fill: boolean + fillBackground?: boolean + stroke: boolean +} + +export interface BulgePrim extends PrimBase { + kind: 'bulge' + vertices: Array<{ x: number; y: number; bulge: number }> + closed: boolean +} + +export interface CirclePrim extends PrimBase { + kind: 'circle' + cx: number + cy: number + r: number + fill: boolean +} + +export interface ArcPrim extends PrimBase { + kind: 'arc' + cx: number + cy: number + r: number + a0: number + sweep: number +} + +export interface EllipsePrim extends PrimBase { + kind: 'ellipse' + cx: number + cy: number + mx: number + my: number + ratio: number + a0: number + sweep: number + fill: boolean +} + +export interface SplinePrim extends PrimBase { + kind: 'spline' + control: number[] + degree: number + knots: number[] + weights?: number[] + closed: boolean +} + +export interface TextPrim extends PrimBase { + kind: 'text' + x: number + y: number + height: number + rotation: number + lines: string[] + halign: 'left' | 'center' | 'right' + valign: 'baseline' | 'bottom' | 'middle' | 'top' + lineHeight: number + widthFactor: number + mirrored: boolean +} + +export interface HatchPrim extends PrimBase { + kind: 'hatch' + paths: number[][] + solid: boolean + patternName?: string + patternAngle: number + patternSpacing: number +} + +export interface PointPrim extends PrimBase { + kind: 'point' + x: number + y: number +} + +export interface ImagePrim extends PrimBase { + kind: 'image' + x1: number + y1: number + x2: number + y2: number + points?: number[] + label: string +} + +export type Primitive = + | PolyPrim + | BulgePrim + | CirclePrim + | ArcPrim + | EllipsePrim + | SplinePrim + | TextPrim + | HatchPrim + | PointPrim + | ImagePrim + +export interface SpaceGrid { + minX: number + minY: number + cellW: number + cellH: number + cols: number + rows: number + cells: number[][] + big: number[] +} + +export interface CadSpace { + id: string + name: string + kind: 'model' | 'layout' + blockHandle: string + entities: DwgEntity[] + entityCount: number + prims: Primitive[] + grid?: SpaceGrid + bbox: BBox + fitBBox?: BBox + savedView?: { cx: number; cy: number; width: number; height: number } + viewports: DwgViewportEntity[] + layout?: DwgLayoutObject +} + +export interface CadDocument { + db: DwgDatabase + fileName: string + fileSize: number + layers: LayerInfo[] + layerMap: Map + blocks: Map + blockByHandle: Map + dashPatterns: Map + imageNames: Map + spaces: CadSpace[] + model: CadSpace + units: string + unitLabel: string + version: string + unknownCount: number + warnings: string[] +} + +export type BlockRecord = DwgBlockRecordTableEntry diff --git a/src/core/app.ts b/src/core/app.ts new file mode 100644 index 0000000..820c98f --- /dev/null +++ b/src/core/app.ts @@ -0,0 +1,408 @@ +import { clear, h, icon, LOGO_SVG } from './dom' +import { initTheme } from './theme' +import { + formatBytes, + formatTimeAgo, + detectKind, + kindMeta, + mimeForKind, + readHead, + SUPPORTED_ACCEPT, + viewerFor, + type FileKind +} from './files' +import { clearRecent, deleteRecent, listRecent, loadRecentFile, saveRecent, type RecentItem } from './recent' +import { createViewerHost, type ViewerHost } from './viewerHost' +import { toast } from './toast' +import { confirmDialog, modalMessage } from '../ui/modal' +import { showGuide } from '../ui/guide' + +interface ActiveViewer { + destroy: () => void +} + +let host: ViewerHost | null = null +let activeViewer: ActiveViewer | null = null +let busy = false +let recentItems: RecentItem[] = [] +let dropDepth = 0 +let openToken = 0 + +let homeEl: HTMLElement +let viewerRoot: HTMLElement +let recentWrap: HTMLElement +let recentSection: HTMLElement +let fileInput: HTMLInputElement +let dropOverlay: HTMLElement + +export function initApp(): void { + initTheme() + const app = document.getElementById('app') + if (!app) throw new Error('app root missing') + + homeEl = buildHome() + viewerRoot = h('div', { class: 'viewer-root', hidden: true }) + app.append(homeEl, viewerRoot) + + fileInput = h('input', { + type: 'file', + accept: SUPPORTED_ACCEPT, + class: 'hidden-input', + 'aria-hidden': 'true', + tabindex: '-1' + }) + fileInput.addEventListener('change', () => { + const file = fileInput.files?.[0] + fileInput.value = '' + if (file) void openFile(file) + }) + document.body.appendChild(fileInput) + + dropOverlay = h( + 'div', + { class: 'drop-overlay' }, + h('div', { class: 'drop-box' }, h('span', { class: 'drop-icon', html: icon('folder-open', 40) }), h('strong', { text: '松开以打开文件' }), h('span', { text: 'DWG · PDF · EPUB · XPS · CBZ · 图片' })) + ) + document.body.appendChild(dropOverlay) + + bindGlobalEvents() + void refreshRecent() + handleLaunchQueue() + window.setTimeout(() => { + void import('../cad/loader') + .then((module) => module.preloadDwgEngine()) + .catch(() => {}) + }, 300) + ;(window as unknown as { __phoneViewerBack?: () => boolean }).__phoneViewerBack = () => { + const modalClose = document.querySelector('.modal-backdrop.show .modal-close') + if (modalClose) { + modalClose.click() + return true + } + const sheet = document.querySelector('.sheet-backdrop.open') + if (sheet) { + sheet.classList.remove('open') + return true + } + const menu = document.querySelector('.doc-menu.open') + if (menu) { + menu.classList.remove('open') + return true + } + const searchClose = document.querySelector( + '.doc-search button[aria-label="关闭查找"]' + ) + if (searchClose) { + searchClose.click() + return true + } + if (activeViewer) { + closeActiveViewer() + return true + } + return false + } + ;(window as unknown as { __phoneViewerOpenFile?: (file: File) => void }).__phoneViewerOpenFile = ( + file: File + ) => { + if (file) void openFile(file) + } +} + +function buildHome(): HTMLElement { + const guideBtn = h( + 'button', + { class: 'guide-btn', type: 'button', 'aria-label': '使用指南' }, + h('span', { html: icon('book-open', 18) }), + h('span', { text: '使用指南' }) + ) + guideBtn.addEventListener('click', () => showGuide()) + + const brand = h( + 'div', + { class: 'home-brand' }, + h('div', { class: 'brand-mark', html: LOGO_SVG }), + h('div', { class: 'brand-text' }, h('div', { class: 'brand-name', text: '万能看图' })) + ) + + const top = h( + 'header', + { class: 'home-top simple-top' }, + brand, + h('div', { class: 'home-actions' }, guideBtn) + ) + + const openBtn = h( + 'button', + { class: 'open-file-card', type: 'button' }, + h('span', { class: 'open-file-icon', html: icon('folder-open', 24) }), + h('span', { class: 'open-file-text' }, h('strong', { text: '打开图纸' })), + h('span', { class: 'open-file-arrow', html: icon('chevron-right', 20) }) + ) + openBtn.addEventListener('click', () => fileInput.click()) + + recentWrap = h('div', { class: 'recent-grid simple-recent-grid' }) + const clearBtn = h('button', { + class: 'btn btn-ghost btn-sm recent-clear', + type: 'button', + text: '清空记录', + hidden: true + }) + clearBtn.addEventListener('click', () => void clearAllRecent()) + + recentSection = h( + 'section', + { class: 'recent-section simple-recent' }, + h('div', { class: 'section-head' }, h('h2', { text: '最近打开' }), clearBtn), + recentWrap + ) + + return h( + 'div', + { class: 'home home-simple' }, + h('div', { class: 'home-inner simple-inner' }, top, openBtn, recentSection) + ) +} + +async function refreshRecent(): Promise { + recentItems = await listRecent() + renderRecent() +} + +function renderRecent(): void { + if (!recentWrap) return + clear(recentWrap) + const clearBtn = recentSection.querySelector('.recent-clear') + if (clearBtn) clearBtn.hidden = recentItems.length === 0 + if (!recentItems.length) { + recentWrap.appendChild( + h( + 'div', + { class: 'recent-empty' }, + h('span', { class: 'recent-empty-icon', html: icon('file', 26) }), + h('strong', { text: '还没有最近文件' }), + h('span', { text: '打开过的文件会显示在这里。' }) + ) + ) + return + } + for (const item of recentItems) { + const meta = kindMeta(item.kind) + const card = h('div', { + class: 'recent-card', + role: 'button', + tabindex: '0', + 'aria-label': `打开 ${item.name}` + }) + const iconEl = h('span', { class: `recent-icon tone-${meta.tone}`, html: icon(meta.icon, 22) }) + const info = h( + 'span', + { class: 'recent-info' }, + h('span', { class: 'recent-name', text: item.name, title: item.name }), + h('span', { + class: 'recent-meta', + text: `${meta.label} · ${formatBytes(item.size)} · ${formatTimeAgo(item.lastOpened)}${item.hasBlob ? '' : ' · 内容未保存'}` + }) + ) + const del = h('button', { class: 'recent-del', type: 'button', 'aria-label': `删除 ${item.name}` }) + del.innerHTML = icon('trash', 16) + del.addEventListener('click', (ev) => { + ev.stopPropagation() + void removeRecent(item) + }) + card.append(iconEl, info, del) + const activate = () => void openRecent(item) + card.addEventListener('click', activate) + card.addEventListener('keydown', (ev) => { + if (ev.key === 'Enter' || ev.key === ' ') { + ev.preventDefault() + activate() + } + }) + recentWrap.appendChild(card) + } +} + +async function openRecent(item: RecentItem): Promise { + const file = await loadRecentFile(item.id, item.name) + if (!file) { + toast('文件内容没有被浏览器保存,请重新选择文件', 'info', 3800) + fileInput.click() + return + } + await openFile(file) +} + +async function removeRecent(item: RecentItem): Promise { + await deleteRecent(item.id) + await refreshRecent() + toast('已从最近记录移除', 'success', 1600) +} + +async function clearAllRecent(): Promise { + const ok = await confirmDialog('清空最近记录?', '所有最近打开的文件内容将从本机浏览器中删除。', '清空', { + danger: true + }) + if (!ok) return + await clearRecent() + await refreshRecent() + toast('最近记录已清空', 'success', 1600) +} + +async function openFile(file: File): Promise { + if (busy) { + toast('正在打开文件,请稍候…', 'info', 1600) + return + } + if (!file.size) { + toast('文件为空', 'error') + return + } + let kind: FileKind + try { + const head = await readHead(file) + kind = detectKind(file.name, file.type, head) + } catch { + kind = detectKind(file.name, file.type) + } + const target = viewerFor(kind) + if (!target) { + toast('暂不支持这种文件类型', 'error', 3200) + return + } + + busy = true + closeActiveViewer() + const token = ++openToken + host = createViewerHost(() => closeActiveViewer()) + host.setFileInfo(file.name, kindMeta(kind).label, kindMeta(kind).short, kindMeta(kind).tone, formatBytes(file.size)) + host.showLoader('正在准备…', file.name) + viewerRoot.appendChild(host.root) + viewerRoot.hidden = false + homeEl.hidden = true + document.title = `${file.name} · 万能看图` + await new Promise((resolve) => requestAnimationFrame(() => resolve())) + + let createdViewer: ActiveViewer | null = null + try { + if (target === 'cad') { + const { loadDwg } = await import('../cad/loader') + const doc = await loadDwg(file, (message) => host?.setLoaderMessage(message, file.name)) + if (token !== openToken) return + const { CadViewer } = await import('../cad/cadViewer') + createdViewer = new CadViewer(host!, doc, { onBack: () => closeActiveViewer() }) + activeViewer = createdViewer + host?.hideLoader() + if (doc.warnings.length) toast(doc.warnings[0], 'info', 5000) + } else { + const [{ loadMuPDF }, { DocViewer }] = await Promise.all([ + import('../doc/mupdfLoader'), + import('../doc/docViewer') + ]) + const mupdf = await loadMuPDF() + host?.setLoaderMessage('正在读取文件…', file.name) + const bytes = new Uint8Array(await file.arrayBuffer()) + const magic = + kind === 'xps' && /\.oxps$/i.test(file.name) + ? 'application/oxps' + : mimeForKind(kind, file.type) + const viewer = new DocViewer(host!, mupdf, bytes, file.name, file.size, kind, magic) + await viewer.init() + if (token !== openToken) { + viewer.destroy() + return + } + createdViewer = viewer + activeViewer = viewer + } + void saveRecent(file, kind) + .catch(() => {}) + .then(() => refreshRecent()) + .catch(() => {}) + } catch (error) { + if (createdViewer) { + createdViewer.destroy() + } else { + host?.destroy() + } + host = null + activeViewer = null + viewerRoot.hidden = true + homeEl.hidden = false + document.title = '万能看图 · DWG/PDF 浏览器' + const message = error instanceof Error ? error.message : String(error) + console.error(error) + modalMessage( + '无法打开文件', + message, + kind === 'dwg' ? '提示:DWG 需要由 AutoCAD 2000 及之后的版本保存;过旧或加密的图纸可能暂时无法解析。' : undefined + ) + } finally { + busy = false + } +} + +function closeActiveViewer(): void { + openToken++ + const viewer = activeViewer + const previousHost = host + activeViewer = null + host = null + if (viewer) { + viewer.destroy() + } else if (previousHost) { + previousHost.destroy() + } + viewerRoot.innerHTML = '' + viewerRoot.hidden = true + homeEl.hidden = false + document.title = '万能看图 · DWG/PDF 浏览器' + void refreshRecent() +} + +function bindGlobalEvents(): void { + window.addEventListener('dragenter', (ev) => { + if (!ev.dataTransfer?.types.includes('Files')) return + ev.preventDefault() + dropDepth++ + dropOverlay.classList.add('show') + }) + window.addEventListener('dragover', (ev) => { + if (!ev.dataTransfer?.types.includes('Files')) return + ev.preventDefault() + ev.dataTransfer.dropEffect = 'copy' + }) + window.addEventListener('dragleave', (ev) => { + if (!ev.dataTransfer?.types.includes('Files')) return + dropDepth = Math.max(0, dropDepth - 1) + if (dropDepth === 0) dropOverlay.classList.remove('show') + }) + window.addEventListener('drop', (ev) => { + if (!ev.dataTransfer?.files?.length) return + ev.preventDefault() + dropDepth = 0 + dropOverlay.classList.remove('show') + const file = ev.dataTransfer.files[0] + if (file) void openFile(file) + }) + window.addEventListener('paste', (ev) => { + const file = ev.clipboardData?.files?.[0] + if (file) { + ev.preventDefault() + void openFile(file) + } + }) +} + +function handleLaunchQueue(): void { + const launchQueue = (window as unknown as { launchQueue?: { setConsumer: (cb: (params: { files: Array<{ getFile: () => Promise }> }) => void) => void } }).launchQueue + if (!launchQueue) return + launchQueue.setConsumer((params) => { + const first = params.files?.[0] + if (!first) return + void first + .getFile() + .then((file) => openFile(file)) + .catch(() => toast('无法读取系统传入的文件', 'error')) + }) +} diff --git a/src/core/dom.ts b/src/core/dom.ts new file mode 100644 index 0000000..134fa14 --- /dev/null +++ b/src/core/dom.ts @@ -0,0 +1,176 @@ +export type Child = Node | string | number | null | undefined | false + +type Props = Record + +export function h( + tag: K, + props: Props = {}, + ...children: Child[] +): HTMLElementTagNameMap[K] { + const el = document.createElement(tag) + for (const [key, value] of Object.entries(props)) { + if (value == null || value === false) continue + if (key === 'class' || key === 'className') { + el.className = String(value) + } else if (key === 'text') { + el.textContent = String(value) + } else if (key === 'html') { + el.innerHTML = String(value) + } else if (key === 'style' && typeof value === 'object') { + Object.assign(el.style, value as Record) + } else if (key === 'dataset' && typeof value === 'object') { + Object.assign(el.dataset, value as Record) + } else if (key.startsWith('on') && typeof value === 'function') { + el.addEventListener(key.slice(2).toLowerCase(), value as EventListener) + } else if (value === true) { + el.setAttribute(key, '') + } else { + el.setAttribute(key, String(value)) + } + } + append(el, children) + return el +} + +export function append(parent: Node, children: Child[]): void { + for (const child of children) { + if (child == null || child === false) continue + parent.appendChild(child instanceof Node ? child : document.createTextNode(String(child))) + } +} + +export function clear(node: Element): void { + while (node.firstChild) node.removeChild(node.firstChild) +} + +export function iconButton( + iconName: string, + label: string, + onClick: (ev: MouseEvent) => void, + opts: { className?: string; size?: number; tooltip?: boolean } = {} +): HTMLButtonElement { + const btn = h('button', { + class: `icon-btn ${opts.className ?? ''}`.trim(), + type: 'button', + 'aria-label': label, + title: opts.tooltip === false ? undefined : label, + html: icon(iconName, opts.size ?? 20) + }) + btn.addEventListener('click', onClick) + return btn +} + +export function icon(name: string, size = 20, className = ''): string { + const body = ICONS[name] ?? ICONS.file + return `` +} + +export const LOGO_SVG = ` +` + +export const ICONS: Record = { + 'arrow-left': '', + 'arrow-right': '', + 'chevron-left': '', + 'chevron-right': '', + 'chevron-down': '', + 'folder-open': + '', + file: '', + 'file-text': + '', + 'file-cad': + '', + 'file-pdf': + '', + 'file-img': + '', + layers: + '', + proxy: + '', + fit: '', + maximize: '', + minimize: '', + ruler: + '', + sun: '', + moon: '', + plus: '', + minus: '', + 'rotate-cw': '', + search: '', + list: '', + x: '', + download: '', + info: '', + eye: '', + 'eye-off': + '', + trash: '', + home: '', + more: '', + 'more-vertical': '', + 'book-open': '', + check: '', + refresh: '', + grid: '', + 'alert-triangle': '', + lock: '', + unlink: '', + 'zoom-in': '', + 'zoom-out': '', + 'panel-left': '', + 'install': '', + 'hard-drive': '', + 'crosshair': '', + 'rotate-ccw': '', + 'chevron-up': '', + 'corner-up-left': '' +} + +export function debounce void>(fn: T, wait: number): (...args: Parameters) => void { + let timer: ReturnType | null = null + return (...args: Parameters) => { + if (timer) clearTimeout(timer) + timer = setTimeout(() => { + timer = null + fn(...args) + }, wait) + } +} + +export function nextFrame(): Promise { + return new Promise((resolve) => requestAnimationFrame(() => resolve())) +} + +export function twoFrames(): Promise { + return new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve()))) +} + +export function escapeHtml(value: string): string { + return value + .replaceAll('&', '&') + .replaceAll('<', '<') + .replaceAll('>', '>') + .replaceAll('"', '"') + .replaceAll("'", ''') +} diff --git a/src/core/files.ts b/src/core/files.ts new file mode 100644 index 0000000..7d4a292 --- /dev/null +++ b/src/core/files.ts @@ -0,0 +1,127 @@ +export type FileKind = 'dwg' | 'pdf' | 'epub' | 'xps' | 'cbz' | 'image' | 'fb2' | 'unknown' + +export const SUPPORTED_ACCEPT = + '.dwg,.pdf,.epub,.fb2,.xps,.oxps,.cbz,.png,.jpg,.jpeg,.gif,.bmp' + +const IMAGE_EXT = new Set(['png', 'jpg', 'jpeg', 'gif', 'bmp', 'jfif']) +const IMAGE_MIME = new Set([ + 'image/png', + 'image/jpeg', + 'image/jpg', + 'image/gif', + 'image/bmp', + 'image/x-ms-bmp' +]) + +export function extensionOf(name: string): string { + const idx = name.lastIndexOf('.') + return idx >= 0 ? name.slice(idx + 1).toLowerCase() : '' +} + +export function viewerFor(kind: FileKind): 'cad' | 'doc' | null { + if (kind === 'dwg') return 'cad' + if (kind === 'unknown') return null + return 'doc' +} + +export function detectKind(name: string, mime: string, head?: Uint8Array): FileKind { + const ext = extensionOf(name) + const lowerMime = (mime || '').toLowerCase() + + if (head && head.length >= 4) { + if (head[0] === 0x41 && head[1] === 0x43 && head[2] === 0x31 && head[3] === 0x30) return 'dwg' + if (head[0] === 0x25 && head[1] === 0x50 && head[2] === 0x44 && head[3] === 0x46) return 'pdf' + } + + if (ext === 'dwg') return 'dwg' + if (ext === 'pdf' || lowerMime === 'application/pdf') return 'pdf' + if (ext === 'epub') return 'epub' + if (ext === 'xps' || ext === 'oxps') return 'xps' + if (ext === 'cbz') return 'cbz' + if (ext === 'fb2') return 'fb2' + if (ext === 'svg' || lowerMime === 'image/svg+xml') return 'unknown' + if (IMAGE_EXT.has(ext) || IMAGE_MIME.has(lowerMime)) return 'image' + if (lowerMime.startsWith('image/')) return 'unknown' + + if (head) { + const prefix = new TextDecoder('utf-8', { fatal: false }).decode(head.slice(0, 256)).toLowerCase() + if (prefix.includes(' { + return new Uint8Array(await file.slice(0, bytes).arrayBuffer()) +} + +export function formatBytes(size: number): string { + if (!Number.isFinite(size) || size <= 0) return '0 B' + const units = ['B', 'KB', 'MB', 'GB'] + let value = size + let unit = 0 + while (value >= 1024 && unit < units.length - 1) { + value /= 1024 + unit++ + } + return `${value >= 10 || unit === 0 ? Math.round(value) : value.toFixed(1)} ${units[unit]}` +} + +export function formatTimeAgo(timestamp: number): string { + const diff = Date.now() - timestamp + if (!Number.isFinite(diff) || diff < 0) return '刚刚' + const minute = 60_000 + const hour = 60 * minute + const day = 24 * hour + if (diff < minute) return '刚刚' + if (diff < hour) return `${Math.floor(diff / minute)} 分钟前` + if (diff < day) return `${Math.floor(diff / hour)} 小时前` + if (diff < 7 * day) return `${Math.floor(diff / day)} 天前` + const date = new Date(timestamp) + const now = new Date() + if (date.getFullYear() === now.getFullYear()) { + return `${date.getMonth() + 1} 月 ${date.getDate()} 日` + } + return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}` +} diff --git a/src/core/recent.ts b/src/core/recent.ts new file mode 100644 index 0000000..80be4f1 --- /dev/null +++ b/src/core/recent.ts @@ -0,0 +1,215 @@ +import type { FileKind } from './files' + +export interface RecentItem { + id: string + name: string + size: number + type: string + kind: FileKind + lastOpened: number + hasBlob: boolean +} + +interface StoredRecord extends RecentItem { + blob?: Blob +} + +const DB_NAME = 'phone-viewer' +const STORE = 'recent' +const DB_VERSION = 1 +const MAX_ITEMS = 15 +const MAX_FILE_BYTES = 48 * 1024 * 1024 +const MAX_TOTAL_BYTES = 180 * 1024 * 1024 + +let dbPromise: Promise | null = null + +function getDb(): Promise { + if (dbPromise) return dbPromise + dbPromise = new Promise((resolve) => { + if (typeof indexedDB === 'undefined') { + resolve(null) + return + } + let request: IDBOpenDBRequest + try { + request = indexedDB.open(DB_NAME, DB_VERSION) + } catch { + resolve(null) + return + } + request.onupgradeneeded = () => { + const db = request.result + if (!db.objectStoreNames.contains(STORE)) { + const store = db.createObjectStore(STORE, { keyPath: 'id' }) + store.createIndex('lastOpened', 'lastOpened') + } + } + request.onsuccess = () => resolve(request.result) + request.onerror = () => resolve(null) + request.onblocked = () => resolve(null) + }) + return dbPromise +} + +function txDone(tx: IDBTransaction): Promise { + return new Promise((resolve, reject) => { + tx.oncomplete = () => resolve() + tx.onerror = () => reject(tx.error ?? new Error('IndexedDB transaction failed')) + tx.onabort = () => reject(tx.error ?? new Error('IndexedDB transaction aborted')) + }) +} + +function requestResult(request: IDBRequest): Promise { + return new Promise((resolve, reject) => { + request.onsuccess = () => resolve(request.result) + request.onerror = () => reject(request.error) + }) +} + +const LS_KEY = 'viewer.recent.meta' + +function lsRead(): StoredRecord[] { + try { + const raw = localStorage.getItem(LS_KEY) + if (!raw) return [] + const parsed = JSON.parse(raw) as StoredRecord[] + return Array.isArray(parsed) ? parsed : [] + } catch { + return [] + } +} + +function lsWrite(items: StoredRecord[]): void { + try { + localStorage.setItem( + LS_KEY, + JSON.stringify(items.map(({ blob: _blob, ...rest }) => rest)) + ) + } catch { + /* ignore */ + } +} + +export async function listRecent(): Promise { + const db = await getDb() + if (!db) return lsRead().map(({ blob: _blob, ...rest }) => rest).sort((a, b) => b.lastOpened - a.lastOpened) + try { + const tx = db.transaction(STORE, 'readonly') + const all = await requestResult(tx.objectStore(STORE).getAll() as IDBRequest) + return all + .map(({ blob: _blob, ...rest }) => rest) + .sort((a, b) => b.lastOpened - a.lastOpened) + .slice(0, MAX_ITEMS) + } catch { + return [] + } +} + +export async function saveRecent(file: File, kind: FileKind): Promise { + const id = `${file.name}|${file.size}` + const record: StoredRecord = { + id, + name: file.name, + size: file.size, + type: file.type, + kind, + lastOpened: Date.now(), + hasBlob: file.size <= MAX_FILE_BYTES, + blob: file.size <= MAX_FILE_BYTES ? file : undefined + } + const db = await getDb() + if (!db) { + const items = lsRead().filter((item) => item.id !== id) + items.unshift({ ...record, blob: undefined, hasBlob: false }) + lsWrite(items.slice(0, MAX_ITEMS)) + return + } + try { + const tx = db.transaction(STORE, 'readwrite') + tx.objectStore(STORE).put(record) + await txDone(tx) + } catch { + try { + const tx = db.transaction(STORE, 'readwrite') + tx.objectStore(STORE).put({ ...record, blob: undefined, hasBlob: false }) + await txDone(tx) + } catch { + /* storage full or unavailable */ + } + } + void enforceLimits(db) + try { + void navigator.storage?.persist?.() + } catch { + /* ignore */ + } +} + +async function enforceLimits(db: IDBDatabase): Promise { + try { + const tx = db.transaction(STORE, 'readwrite') + const store = tx.objectStore(STORE) + const all = await requestResult(store.getAll() as IDBRequest) + all.sort((a, b) => b.lastOpened - a.lastOpened) + for (const item of all.slice(MAX_ITEMS)) { + store.delete(item.id) + } + let total = 0 + for (const item of all.slice(0, MAX_ITEMS)) { + if (!item.blob) continue + total += item.blob.size + if (total > MAX_TOTAL_BYTES) { + store.put({ ...item, blob: undefined, hasBlob: false }) + } + } + await txDone(tx) + } catch { + /* ignore */ + } +} + +export async function loadRecentFile(id: string, fallbackName?: string): Promise { + const db = await getDb() + if (!db) return null + try { + const tx = db.transaction(STORE, 'readonly') + const record = await requestResult(tx.objectStore(STORE).get(id) as IDBRequest) + if (!record?.blob) return null + return new File([record.blob], record.name || fallbackName || 'file', { + type: record.type, + lastModified: record.lastOpened + }) + } catch { + return null + } +} + +export async function deleteRecent(id: string): Promise { + const db = await getDb() + if (!db) { + lsWrite(lsRead().filter((item) => item.id !== id)) + return + } + try { + const tx = db.transaction(STORE, 'readwrite') + tx.objectStore(STORE).delete(id) + await txDone(tx) + } catch { + /* ignore */ + } +} + +export async function clearRecent(): Promise { + const db = await getDb() + if (!db) { + lsWrite([]) + return + } + try { + const tx = db.transaction(STORE, 'readwrite') + tx.objectStore(STORE).clear() + await txDone(tx) + } catch { + /* ignore */ + } +} diff --git a/src/core/theme.ts b/src/core/theme.ts new file mode 100644 index 0000000..71f2d54 --- /dev/null +++ b/src/core/theme.ts @@ -0,0 +1,56 @@ +export type Theme = 'dark' | 'light' + +const STORAGE_KEY = 'viewer.theme' +const listeners = new Set<(theme: Theme) => void>() + +export function initTheme(): Theme { + const isAndroidShell = + typeof (window as unknown as { AndroidViewer?: unknown }).AndroidViewer !== 'undefined' + let theme: Theme = 'dark' + try { + const stored = localStorage.getItem(STORAGE_KEY) + if (stored === 'light' || stored === 'dark') { + theme = stored + } else if (!isAndroidShell && window.matchMedia?.('(prefers-color-scheme: light)').matches) { + theme = 'light' + } + } catch { + /* ignore */ + } + applyTheme(theme, false) + return theme +} + +export function getTheme(): Theme { + return document.documentElement.dataset.theme === 'light' ? 'light' : 'dark' +} + +export function setTheme(theme: Theme): void { + applyTheme(theme, true) +} + +export function toggleTheme(): Theme { + const next: Theme = getTheme() === 'dark' ? 'light' : 'dark' + setTheme(next) + return next +} + +function applyTheme(theme: Theme, persist: boolean): void { + document.documentElement.dataset.theme = theme + document.documentElement.style.colorScheme = theme + const meta = document.querySelector('meta[name="theme-color"]') + if (meta) meta.setAttribute('content', theme === 'dark' ? '#0b0e14' : '#f2f5fa') + if (persist) { + try { + localStorage.setItem(STORAGE_KEY, theme) + } catch { + /* ignore */ + } + } + for (const listener of listeners) listener(theme) +} + +export function onThemeChange(listener: (theme: Theme) => void): () => void { + listeners.add(listener) + return () => listeners.delete(listener) +} diff --git a/src/core/toast.ts b/src/core/toast.ts new file mode 100644 index 0000000..9569e8b --- /dev/null +++ b/src/core/toast.ts @@ -0,0 +1,25 @@ +import { h, icon } from './dom' + +let seq = 0 + +export function toast(message: string, type: 'info' | 'success' | 'error' = 'info', duration = 3200): void { + const root = document.getElementById('toasts') + if (!root) return + const id = ++seq + const iconName = type === 'success' ? 'check' : type === 'error' ? 'alert-triangle' : 'info' + const el = h( + 'div', + { class: `toast toast-${type}`, role: 'status', dataset: { id: String(id) } }, + h('span', { class: 'toast-icon', html: icon(iconName, 18) }), + h('span', { class: 'toast-text', text: message }) + ) + root.appendChild(el) + requestAnimationFrame(() => el.classList.add('show')) + const remove = () => { + el.classList.remove('show') + el.addEventListener('transitionend', () => el.remove(), { once: true }) + window.setTimeout(() => el.remove(), 400) + } + window.setTimeout(remove, Math.max(1200, duration)) + el.addEventListener('click', remove) +} diff --git a/src/core/viewerHost.ts b/src/core/viewerHost.ts new file mode 100644 index 0000000..ab4cb78 --- /dev/null +++ b/src/core/viewerHost.ts @@ -0,0 +1,98 @@ +import { clear, h, icon } from './dom' + +export interface ViewerHost { + root: HTMLElement + header: HTMLElement + actions: HTMLElement + subbar: HTMLElement + stage: HTMLElement + status: HTMLElement + setFileInfo: (name: string, kindLabel: string, badge: string, tone: string, meta?: string) => void + setSubbar: (content: Node | null) => void + setStatus: (text: string, title?: string) => void + showLoader: (message: string, detail?: string) => void + setLoaderMessage: (message: string, detail?: string) => void + hideLoader: () => void + destroy: () => void +} + +export function createViewerHost(onBack: () => void): ViewerHost { + const backBtn = h('button', { + class: 'icon-btn back-btn', + type: 'button', + 'aria-label': '返回', + html: icon('arrow-left', 21) + }) + backBtn.addEventListener('click', onBack) + + const badge = h('span', { class: 'file-badge' }) + const name = h('div', { class: 'file-name' }) + const meta = h('div', { class: 'file-meta' }) + const titleBox = h('div', { class: 'file-titles' }, name, meta) + const fileBox = h('div', { class: 'file-box' }, badge, titleBox) + const actions = h('div', { class: 'viewer-actions' }) + const header = h('header', { class: 'viewer-header' }, backBtn, fileBox, actions) + const subbar = h('div', { class: 'viewer-subbar', hidden: true }) + const status = h('div', { class: 'viewer-status', hidden: true }) + const stage = h('div', { class: 'viewer-stage' }, status) + const body = h('div', { class: 'viewer-body' }, stage) + const loaderText = h('div', { class: 'loader-text', text: '正在打开…' }) + const loaderDetail = h('div', { class: 'loader-detail' }) + const loader = h( + 'div', + { class: 'viewer-loader', hidden: true }, + h('div', { class: 'loader-card' }, h('div', { class: 'spinner' }), loaderText, loaderDetail) + ) + const root = h('section', { class: 'viewer' }, header, subbar, body, loader) + + const setSubbar = (content: Node | null) => { + clear(subbar) + if (content) { + subbar.hidden = false + subbar.appendChild(content) + } else { + subbar.hidden = true + } + } + + return { + root, + header, + actions, + subbar, + stage, + status, + setFileInfo: (fileName, kindLabel, badgeText, tone, metaText) => { + name.textContent = fileName + name.title = fileName + meta.textContent = metaText ? `${kindLabel} · ${metaText}` : kindLabel + badge.textContent = badgeText + badge.className = `file-badge tone-${tone}` + }, + setSubbar, + setStatus: (text, title) => { + if (!text) { + status.hidden = true + return + } + status.hidden = false + status.textContent = text + status.title = title ?? text + }, + showLoader: (message, detail) => { + loader.hidden = false + loaderText.textContent = message + loaderDetail.textContent = detail ?? '' + }, + setLoaderMessage: (message, detail) => { + loaderText.textContent = message + loaderDetail.textContent = detail ?? '' + }, + hideLoader: () => { + loader.hidden = true + }, + destroy: () => { + root.remove() + } + } +} diff --git a/src/doc/docViewer.ts b/src/doc/docViewer.ts new file mode 100644 index 0000000..05e41ff --- /dev/null +++ b/src/doc/docViewer.ts @@ -0,0 +1,1265 @@ +import type { MuPDFModule } from './mupdfLoader' +import type { ViewerHost } from '../core/viewerHost' +import { clear, h, icon, iconButton } from '../core/dom' +import { toast } from '../core/toast' +import { openModal } from '../ui/modal' +import { showAbout } from '../ui/about' +import { formatBytes, kindMeta, type FileKind } from '../core/files' + +interface PageSlot { + index: number + el: HTMLElement + canvas: HTMLCanvasElement + ctx: CanvasRenderingContext2D + renderedKey: string +} + +interface OutlineItem { + title?: string + uri?: string + page?: number + down?: OutlineItem[] +} + +interface SearchHit { + hitIndex: number + page: number + quads: number[][] +} + +interface Size { + w: number + h: number +} + +const INVERT_KEY = 'viewer.docInvert' +const PAGE_GAP = 18 + +export class DocViewer { + private host: ViewerHost + private mupdf: MuPDFModule + private bytes: Uint8Array + private fileName: string + private fileSize: number + private kind: FileKind + private magic?: string + private doc: any = null + private scroller: HTMLElement + private pagesEl: HTMLElement + private slots: PageSlot[] = [] + private pageSizes = new Map() + private defaultSize: Size = { w: 612, h: 792 } + private pageCount = 0 + private currentPage = 0 + private zoom = 1 + private rotate = 0 + private invert = false + private reflowable = false + private fitMode: 'width' | 'page' | 'custom' = 'width' + private epoch = 0 + private renderQueue: Promise = Promise.resolve() + private pendingRenders = new Set() + private visiblePages = new Set() + private intersectionObserver: IntersectionObserver | null = null + private resizeObserver: ResizeObserver | null = null + private resizeTimer = 0 + private scrollRaf = 0 + private searchToken = 0 + private searchQuery = '' + private searchHits: SearchHit[] = [] + private currentHit = -1 + private searchVisible = false + private lastReflowWidth = 0 + private lastReflowHeight = 0 + private pinch: + | { + startDist: number + startZoom: number + startScrollTop: number + startScrollLeft: number + midX: number + midY: number + } + | null = null + private destroyed = false + private pageInput: HTMLInputElement + private pageTotal: HTMLElement + private zoomLabel: HTMLButtonElement + private searchBar: HTMLElement + private searchInput: HTMLInputElement + private searchCount: HTMLElement + private searchPrev: HTMLButtonElement + private searchNext: HTMLButtonElement + private outlineBackdrop: HTMLElement + private outlineList: HTMLElement + private menu: HTMLElement + private menuButtons: Record = {} + private fullscreenBtn: HTMLButtonElement | null = null + private firstRenderDone = false + private onDocumentPointerDown: ((ev: PointerEvent) => void) | null = null + + constructor( + host: ViewerHost, + mupdf: MuPDFModule, + bytes: Uint8Array, + fileName: string, + fileSize: number, + kind: FileKind, + magic?: string + ) { + this.host = host + this.mupdf = mupdf + this.bytes = bytes + this.fileName = fileName + this.fileSize = fileSize + this.kind = kind + this.magic = magic + try { + this.invert = localStorage.getItem(INVERT_KEY) === '1' + } catch { + this.invert = false + } + + const meta = kindMeta(kind) + host.setFileInfo(fileName, meta.label, meta.short, meta.tone, formatBytes(fileSize)) + host.setStatus('') + + this.scroller = h('div', { class: 'doc-scroll' }) + this.pagesEl = h('div', { class: 'doc-pages' }) + this.pagesEl.classList.toggle('inverted', this.invert) + this.scroller.appendChild(this.pagesEl) + host.stage.appendChild(this.scroller) + + this.pageInput = h('input', { + class: 'page-input', + type: 'number', + min: '1', + inputMode: 'numeric', + 'aria-label': '页码' + }) + this.pageTotal = h('span', { class: 'page-total', text: '/ 1' }) + const prev = iconButton('chevron-left', '上一页', () => this.goToPage(this.currentPage - 1), { + className: 'doc-btn' + }) + const next = iconButton('chevron-right', '下一页', () => this.goToPage(this.currentPage + 1), { + className: 'doc-btn' + }) + const pageGroup = h('div', { class: 'doc-group' }, prev, this.pageInput, this.pageTotal, next) + + const zoomOut = iconButton('zoom-out', '缩小', () => this.zoomTo(this.zoom / 1.2), { + className: 'doc-btn' + }) + const zoomIn = iconButton('zoom-in', '放大', () => this.zoomTo(this.zoom * 1.2), { + className: 'doc-btn' + }) + this.zoomLabel = h('button', { class: 'zoom-label', type: 'button', text: '100%', title: '适合宽度' }) + this.zoomLabel.addEventListener('click', () => this.fitWidth()) + const zoomGroup = h('div', { class: 'doc-group' }, zoomOut, this.zoomLabel, zoomIn) + + const fitBtn = iconButton('fit', '适合宽度', () => this.fitWidth(), { className: 'doc-btn' }) + const moreBtn = iconButton('more', '更多', () => this.toggleMenu(), { className: 'doc-btn' }) + moreBtn.dataset.action = 'more' + const actionGroup = h('div', { class: 'doc-group' }, fitBtn, moreBtn) + + const bottom = h('div', { class: 'doc-bottom' }, pageGroup, zoomGroup, actionGroup) + host.stage.appendChild(bottom) + + this.menu = this.buildMenu() + host.stage.appendChild(this.menu) + + this.searchInput = h('input', { + class: 'doc-search-input', + type: 'search', + placeholder: '在文档中查找…', + 'aria-label': '查找' + }) + this.searchCount = h('span', { class: 'doc-search-count', text: '' }) + this.searchPrev = iconButton('chevron-up', '上一个结果', () => this.prevHit(), { className: 'doc-btn' }) + this.searchNext = iconButton('chevron-down', '下一个结果', () => this.nextHit(), { className: 'doc-btn' }) + const searchClose = iconButton('x', '关闭查找', () => this.closeSearch(), { className: 'doc-btn' }) + this.searchBar = h( + 'div', + { class: 'doc-search' }, + h('span', { class: 'doc-search-icon', html: icon('search', 18) }), + this.searchInput, + this.searchCount, + this.searchPrev, + this.searchNext, + searchClose + ) + host.stage.appendChild(this.searchBar) + + this.outlineList = h('div', { class: 'outline-list' }) + this.outlineBackdrop = h('div', { class: 'sheet-backdrop sheet-left' }) + const outlineClose = iconButton('x', '关闭', () => this.closeOutline()) + const outlineSheet = h( + 'aside', + { class: 'sheet sheet-outline', role: 'dialog', 'aria-label': '目录' }, + h('div', { class: 'sheet-head' }, h('div', { class: 'sheet-title' }, h('span', { text: '目录' })), outlineClose), + this.outlineList + ) + this.outlineBackdrop.appendChild(outlineSheet) + this.outlineBackdrop.addEventListener('click', (ev) => { + if (ev.target === this.outlineBackdrop) this.closeOutline() + }) + host.stage.appendChild(this.outlineBackdrop) + + this.buildHeaderActions() + + this.pageInput.addEventListener('change', () => { + const value = Number(this.pageInput.value) + if (Number.isFinite(value)) this.goToPage(value - 1) + }) + this.pageInput.addEventListener('keydown', (ev) => { + if (ev.key === 'Enter') { + ev.preventDefault() + this.pageInput.blur() + const value = Number(this.pageInput.value) + if (Number.isFinite(value)) this.goToPage(value - 1) + } + }) + this.searchInput.addEventListener('keydown', (ev) => { + if (ev.key === 'Enter') { + ev.preventDefault() + const q = this.searchInput.value.trim() + if (!q) return + if (q === this.searchQuery && this.searchHits.length) { + if (ev.shiftKey) this.prevHit() + else this.nextHit() + } else { + void this.runSearch(q) + } + } else if (ev.key === 'Escape') { + this.closeSearch() + } + }) + + this.onDocumentPointerDown = (ev) => { + if (!this.menu.classList.contains('open')) return + const target = ev.target as Element | null + if (target?.closest('[data-action="more"]')) return + if (!this.menu.contains(ev.target as Node)) this.closeMenu() + } + document.addEventListener('pointerdown', this.onDocumentPointerDown) + + this.zoomLabel.textContent = '100%' + this.applyInvertUi() + this.updateMenuUi() + } + + async init(): Promise { + this.host.showLoader('正在打开文档…', this.fileName) + await this.waitForStage() + try { + this.doc = this.mupdf.Document.openDocument(this.bytes, this.magic) + await this.unlockIfNeeded() + this.reflowable = this.kind === 'epub' || this.kind === 'fb2' + try { + const reflow = (this.doc as { isReflowable?: () => unknown }).isReflowable?.() + if (reflow === true) this.reflowable = true + } catch { + /* ignore */ + } + if (this.reflowable) this.layoutReflow() + this.pageCount = this.doc.countPages() + if (!this.pageCount) throw new Error('文档中没有可显示的页面') + this.measureFirstPage() + this.buildPages() + this.buildOutline() + this.pageTotal.textContent = `/ ${this.pageCount}` + this.pageInput.max = String(this.pageCount) + this.pageInput.value = '1' + this.zoom = this.computeFitWidth() + this.applyZoomLabel() + this.layoutPageSizes() + this.bindEvents() + this.observe() + this.scroller.scrollTop = 0 + this.updateCurrentPage() + this.renderVisible() + this.host.setLoaderMessage('正在渲染页面…') + window.setTimeout(() => { + if (!this.firstRenderDone) this.host.hideLoader() + }, 4000) + } catch (error) { + this.host.hideLoader() + this.doc?.destroy?.() + this.doc = null + throw error + } + } + + private buildHeaderActions(): void { + const searchBtn = iconButton('search', '查找', () => this.toggleSearch()) + const outlineBtn = iconButton('list', '目录', () => this.openOutline()) + const infoBtn = iconButton('info', '关于', () => showAbout()) + this.host.actions.append(searchBtn, outlineBtn, infoBtn) + } + + private buildMenu(): HTMLElement { + const menu = h('div', { class: 'doc-menu', role: 'menu' }) + const add = (key: string, iconName: string, label: string, onClick: () => void) => { + const btn = h('button', { class: 'menu-item', type: 'button', role: 'menuitem' }) + const iconEl = h('span', { class: 'menu-icon', html: icon(iconName, 18) }) + const textEl = h('span', { class: 'menu-text', text: label }) + btn.append(iconEl, textEl) + btn.addEventListener('click', () => { + this.closeMenu() + onClick() + }) + menu.appendChild(btn) + this.menuButtons[key] = btn + return btn + } + add('fit-page', 'fit', '适合页面', () => this.fitPage()) + add('rotate', 'rotate-cw', '旋转 90°', () => this.rotatePage()) + add('invert', 'moon', '反色阅读', () => this.toggleInvert()) + this.fullscreenBtn = add('fullscreen', 'maximize', '全屏', () => void this.toggleFullscreen()) + add('about', 'info', '关于万能看图', () => showAbout()) + return menu + } + + private updateMenuUi(): void { + const invertBtn = this.menuButtons.invert + if (invertBtn) { + const iconEl = invertBtn.querySelector('.menu-icon') + const textEl = invertBtn.querySelector('.menu-text') + if (iconEl) iconEl.innerHTML = icon(this.invert ? 'sun' : 'moon', 18) + if (textEl) textEl.textContent = this.invert ? '关闭反色' : '反色阅读' + invertBtn.classList.toggle('active', this.invert) + } + if (this.fullscreenBtn) { + const active = !!document.fullscreenElement + const iconEl = this.fullscreenBtn.querySelector('.menu-icon') + const textEl = this.fullscreenBtn.querySelector('.menu-text') + if (iconEl) iconEl.innerHTML = icon(active ? 'minimize' : 'maximize', 18) + if (textEl) textEl.textContent = active ? '退出全屏' : '全屏' + } + } + + private waitForStage(): Promise { + if (this.host.stage.clientWidth > 0 && this.host.stage.clientHeight > 0) return Promise.resolve() + return new Promise((resolve) => { + const ro = new ResizeObserver(() => { + if (this.host.stage.clientWidth > 0 && this.host.stage.clientHeight > 0) { + ro.disconnect() + resolve() + } + }) + ro.observe(this.host.stage) + }) + } + + private async unlockIfNeeded(): Promise { + let attempts = 0 + while (this.doc.needsPassword()) { + if (attempts >= 4) throw new Error('密码尝试次数过多') + attempts++ + const password = await this.promptPassword(attempts > 1) + if (password == null) throw new Error('文档已加密,需要密码才能打开') + try { + this.doc.authenticatePassword(password) + } catch { + /* ignore */ + } + if (this.doc.needsPassword()) toast('密码不正确,请重试', 'error') + } + } + + private promptPassword(retry: boolean): Promise { + return new Promise((resolve) => { + let done = false + const finish = (value: string | null) => { + if (done) return + done = true + resolve(value) + modal.close() + } + const input = h('input', { + class: 'text-input', + type: 'password', + placeholder: '请输入文档密码', + autocomplete: 'current-password' + }) + const form = h( + 'form', + { class: 'password-form' }, + h('p', { class: 'modal-text', text: '此文档受密码保护,请输入密码继续。' }), + retry ? h('p', { class: 'form-error', text: '密码不正确,请重试。' }) : null, + input + ) + form.addEventListener('submit', (ev) => { + ev.preventDefault() + finish(input.value) + }) + const cancel = h('button', { class: 'btn btn-ghost', type: 'button', text: '取消' }) + cancel.addEventListener('click', () => finish(null)) + const unlock = h('button', { class: 'btn btn-primary', type: 'submit', text: '解锁' }) + unlock.addEventListener('click', (ev) => { + ev.preventDefault() + finish(input.value) + }) + const modal = openModal({ + title: '加密文档', + subtitle: this.fileName, + content: form, + actions: [cancel, unlock], + size: 'sm', + onClose: () => { + if (!done) { + done = true + resolve(null) + } + } + }) + window.setTimeout(() => input.focus({ preventScroll: true }), 80) + }) + } + + private layoutReflow(): void { + const width = (this.scroller.clientWidth - 32) * (72 / 96) + const height = Math.max(400, (this.scroller.clientHeight - 90) * (72 / 96)) + this.lastReflowWidth = this.scroller.clientWidth + this.lastReflowHeight = this.scroller.clientHeight + try { + this.doc.layout(Math.max(200, width), Math.max(400, height), 12) + } catch { + /* ignore */ + } + } + + private measureFirstPage(): void { + const page = this.doc.loadPage(0) + try { + const b = page.getBounds() + const size = { w: Math.max(1, b[2] - b[0]), h: Math.max(1, b[3] - b[1]) } + this.defaultSize = size + this.pageSizes.set(0, size) + } finally { + page.destroy() + } + } + + private buildPages(): void { + clear(this.pagesEl) + this.slots = [] + this.visiblePages.clear() + this.pendingRenders.clear() + for (let i = 0; i < this.pageCount; i++) { + const canvas = h('canvas', { class: 'doc-page-canvas' }) + const ctx = canvas.getContext('2d', { alpha: false }) + if (!ctx) throw new Error('无法创建 Canvas 2D 上下文') + const el = h( + 'div', + { + class: 'doc-page', + dataset: { page: String(i + 1) }, + 'aria-label': `第 ${i + 1} 页` + }, + canvas + ) + const slot: PageSlot = { index: i, el, canvas, ctx, renderedKey: '' } + this.slots.push(slot) + this.pagesEl.appendChild(el) + } + this.epoch++ + } + + private pageSize(index: number): Size { + return this.pageSizes.get(index) ?? this.defaultSize + } + + private displaySize(index: number): Size { + const size = this.pageSize(index) + return this.rotate % 180 === 0 ? size : { w: size.h, h: size.w } + } + + private applySlotSize(slot: PageSlot): void { + const size = this.displaySize(slot.index) + const w = Math.max(24, size.w * this.zoom) + const hgt = Math.max(24, size.h * this.zoom) + slot.el.style.width = `${w}px` + slot.el.style.height = `${hgt}px` + } + + private layoutPageSizes(): void { + for (const slot of this.slots) this.applySlotSize(slot) + } + + private computeFitWidth(): number { + const size = this.displaySize(this.currentPage) + const available = Math.max(120, this.scroller.clientWidth - 32) + return Math.max(0.03, Math.min(16, available / Math.max(1, size.w))) + } + + private computeFitPage(): number { + const size = this.displaySize(this.currentPage) + const availableW = Math.max(120, this.scroller.clientWidth - 32) + const availableH = Math.max(180, this.scroller.clientHeight - 110) + return Math.max(0.03, Math.min(16, Math.min(availableW / size.w, availableH / size.h))) + } + + private fitWidth(): void { + this.fitMode = 'width' + const z = this.computeFitWidth() + this.zoomTo(z) + this.scroller.scrollTop = Math.min( + this.scroller.scrollTop, + Math.max(0, this.scroller.scrollHeight - this.scroller.clientHeight) + ) + } + + private fitPage(): void { + this.fitMode = 'page' + this.zoomTo(this.computeFitPage()) + } + + private zoomTo(nextZoom: number, anchorY?: number, final = true, anchorX?: number): void { + const z = Math.max(0.02, Math.min(20, nextZoom)) + if (Math.abs(z - this.zoom) / this.zoom < 1e-4) { + this.applyZoomLabel() + return + } + const old = this.zoom + const localY = anchorY ?? this.scroller.clientHeight / 2 + const localX = anchorX ?? this.scroller.clientWidth / 2 + const contentY = this.scroller.scrollTop + localY + const contentX = this.scroller.scrollLeft + localX + this.zoom = z + this.layoutPageSizes() + const ratio = z / old + const maxScroll = Math.max(0, this.scroller.scrollHeight - this.scroller.clientHeight) + const maxScrollX = Math.max(0, this.scroller.scrollWidth - this.scroller.clientWidth) + this.scroller.scrollTop = Math.max(0, Math.min(maxScroll, contentY * ratio - localY)) + this.scroller.scrollLeft = Math.max(0, Math.min(maxScrollX, contentX * ratio - localX)) + this.applyZoomLabel() + if (final) { + this.epoch++ + this.renderVisible() + } + if (this.fitMode !== 'custom' && Math.abs(z - (this.fitMode === 'page' ? this.computeFitPage() : this.computeFitWidth())) > 0.001) { + this.fitMode = 'custom' + } + this.updateCurrentPage() + } + + private applyZoomLabel(): void { + this.zoomLabel.textContent = `${Math.round(this.zoom * 100)}%` + } + + private buildOutline(): void { + clear(this.outlineList) + let outline: OutlineItem[] | null = null + try { + outline = this.doc.loadOutline() as OutlineItem[] | null + } catch { + outline = null + } + if (!outline || outline.length === 0) { + this.outlineList.appendChild( + h('p', { class: 'outline-empty', text: '此文档没有书签或目录。' }) + ) + return + } + const addItems = (items: OutlineItem[], depth: number): void => { + if (depth > 8) return + for (const item of items) { + const title = (item.title || '').trim() || '(无标题)' + let page = typeof item.page === 'number' ? item.page : undefined + if (page == null && item.uri) { + try { + const resolved = this.doc.resolveLink(item.uri) + if (typeof resolved === 'number' && resolved >= 0) page = resolved + } catch { + /* ignore */ + } + } + const row = h('button', { + class: `outline-item ${page != null ? '' : 'no-page'}`, + type: 'button' + }) + row.style.paddingLeft = `${14 + depth * 16}px` + row.append(h('span', { class: 'outline-text', text: title })) + if (page != null) { + row.append(h('span', { class: 'outline-page', text: String(page + 1) })) + } + row.addEventListener('click', () => { + if (page != null) { + this.goToPage(page, false) + this.closeOutline() + } + }) + this.outlineList.appendChild(row) + if (item.down && item.down.length) addItems(item.down, depth + 1) + } + } + addItems(outline, 0) + } + + private bindEvents(): void { + this.scroller.addEventListener('scroll', this.onScroll, { passive: true }) + this.scroller.addEventListener('dblclick', this.onDoubleClick) + this.scroller.addEventListener('wheel', this.onWheel, { passive: false }) + this.scroller.addEventListener('touchstart', this.onTouchStart, { passive: false }) + this.scroller.addEventListener('touchmove', this.onTouchMove, { passive: false }) + this.scroller.addEventListener('touchend', this.onTouchEnd, { passive: true }) + this.scroller.addEventListener('touchcancel', this.onTouchEnd, { passive: true }) + document.addEventListener('keydown', this.onKeyDown) + document.addEventListener('fullscreenchange', this.onFullscreenChange) + window.addEventListener('resize', this.onWindowResize) + } + + private observe(): void { + this.disconnectObservers() + this.resizeObserver = new ResizeObserver(() => { + if (this.destroyed) return + if (this.resizeTimer) window.clearTimeout(this.resizeTimer) + this.resizeTimer = window.setTimeout(() => this.handleResize(), 320) + }) + this.resizeObserver.observe(this.host.stage) + + this.intersectionObserver = new IntersectionObserver( + (entries) => { + for (const entry of entries) { + const index = Number((entry.target as HTMLElement).dataset.index) + if (!Number.isFinite(index)) continue + if (entry.isIntersecting) { + this.visiblePages.add(index) + this.queueRender(index) + } else { + this.visiblePages.delete(index) + } + } + this.trimCanvases() + }, + { root: this.scroller, rootMargin: '900px 0px', threshold: 0 } + ) + for (const slot of this.slots) { + slot.el.dataset.index = String(slot.index) + this.intersectionObserver.observe(slot.el) + } + } + + private disconnectObservers(): void { + this.intersectionObserver?.disconnect() + this.intersectionObserver = null + this.resizeObserver?.disconnect() + this.resizeObserver = null + } + + private handleResize(): void { + if (this.destroyed) return + let reflowChanged = false + if (this.reflowable) { + const width = this.scroller.clientWidth + const height = this.scroller.clientHeight + const changed = + Math.abs(width - this.lastReflowWidth) > 2 || Math.abs(height - this.lastReflowHeight) > 2 + reflowChanged = changed + if (changed) { + const page = this.currentPage + this.layoutReflow() + this.pageCount = this.doc.countPages() + this.pageTotal.textContent = `/ ${this.pageCount}` + this.pageInput.max = String(this.pageCount) + this.pageSizes.clear() + this.measureFirstPage() + this.buildPages() + this.buildOutline() + this.observe() + this.currentPage = Math.min(page, Math.max(0, this.pageCount - 1)) + if (this.searchHits.length) { + this.searchHits = [] + this.currentHit = -1 + this.searchCount.textContent = '' + } + } + } + if (this.fitMode === 'width') this.zoom = this.computeFitWidth() + else if (this.fitMode === 'page') this.zoom = this.computeFitPage() + this.applyZoomLabel() + this.layoutPageSizes() + this.epoch++ + this.renderVisible() + if (this.reflowable && reflowChanged && this.slots.length) this.goToPage(this.currentPage, false) + } + + private onWindowResize = () => { + if (this.resizeTimer) window.clearTimeout(this.resizeTimer) + this.resizeTimer = window.setTimeout(() => this.handleResize(), 320) + } + + private onScroll = () => { + if (this.scrollRaf) return + this.scrollRaf = requestAnimationFrame(() => { + this.scrollRaf = 0 + this.updateCurrentPage() + this.renderNear() + }) + } + + private updateCurrentPage(): void { + if (!this.slots.length) return + const mid = this.scroller.scrollTop + this.scroller.clientHeight / 2 + let best = this.currentPage + let bestDist = Infinity + for (const slot of this.slots) { + const center = slot.el.offsetTop + slot.el.offsetHeight / 2 + const dist = Math.abs(center - mid) + if (dist < bestDist) { + bestDist = dist + best = slot.index + } + } + if (best !== this.currentPage) this.currentPage = best + if (document.activeElement !== this.pageInput) { + this.pageInput.value = String(this.currentPage + 1) + } + this.applySlotSize(this.slots[this.currentPage]) + } + + private goToPage(index: number, smooth = true): void { + const target = Math.max(0, Math.min(this.pageCount - 1, index)) + this.currentPage = target + const slot = this.slots[target] + if (!slot) return + const top = Math.max(0, slot.el.offsetTop - 10) + this.scroller.scrollTo({ top, behavior: smooth ? 'smooth' : 'auto' }) + this.pageInput.value = String(target + 1) + this.queueRender(target) + this.renderNear() + } + + private renderNear(): void { + const top = this.scroller.scrollTop - 900 + const bottom = this.scroller.scrollTop + this.scroller.clientHeight + 900 + for (const slot of this.slots) { + const slotTop = slot.el.offsetTop + const slotBottom = slotTop + slot.el.offsetHeight + if (slotBottom >= top && slotTop <= bottom) this.queueRender(slot.index) + } + } + + private renderVisible(): void { + this.renderNear() + } + + private pageKey(): string { + return `${this.epoch}:${this.zoom.toFixed(3)}:${this.rotate}:${this.invert ? 1 : 0}` + } + + private queueRender(index: number): void { + const slot = this.slots[index] + if (!slot || this.destroyed) return + const key = this.pageKey() + if (slot.renderedKey === key) return + if (this.pendingRenders.has(index)) return + this.pendingRenders.add(index) + this.renderQueue = this.renderQueue + .then(async () => { + if (this.destroyed) return + this.pendingRenders.delete(index) + await this.renderPage(index) + }) + .catch((error: unknown) => { + this.pendingRenders.delete(index) + console.warn('page render failed', error) + if (!this.firstRenderDone) { + this.firstRenderDone = true + this.host.hideLoader() + toast('页面渲染失败,文档可能不受支持', 'error') + } + }) + } + + private async renderPage(index: number): Promise { + const slot = this.slots[index] + if (!slot || this.destroyed) return + const key = this.pageKey() + if (slot.renderedKey === key) return + let page: any = null + let pixmap: any = null + try { + page = this.doc.loadPage(index) + const bounds = page.getBounds() + const bw = Math.max(1, bounds[2] - bounds[0]) + const bh = Math.max(1, bounds[3] - bounds[1]) + const size = { w: bw, h: bh } + const known = this.pageSizes.get(index) + if (!known || Math.abs(known.w - bw) > 0.5 || Math.abs(known.h - bh) > 0.5) { + this.pageSizes.set(index, size) + this.applySlotSize(slot) + } + + const dpr = Math.min(window.devicePixelRatio || 1, 3) + let z = this.zoom * dpr + let pixels = bw * z * bh * z + const MAX_PIXELS = 6_000_000 + if (pixels > MAX_PIXELS) { + z *= Math.sqrt(MAX_PIXELS / pixels) + pixels = bw * z * bh * z + } + let matrix = this.mupdf.Matrix.scale(z, z) + if (this.rotate) matrix = this.mupdf.Matrix.concat(matrix, this.mupdf.Matrix.rotate(this.rotate)) + pixmap = page.toPixmap(matrix, this.mupdf.ColorSpace.DeviceRGB, false, true) + if (this.invert) pixmap.invert() + const pw = pixmap.getWidth() + const ph = pixmap.getHeight() + if (!pw || !ph) throw new Error('页面渲染为空') + slot.canvas.width = pw + slot.canvas.height = ph + const imageData = this.pixmapToImageData(pixmap, pw, ph) + slot.ctx.setTransform(1, 0, 0, 1, 0, 0) + slot.ctx.putImageData(imageData, 0, 0) + this.drawSearchHighlights(slot.ctx, matrix, pixmap, index) + slot.el.classList.add('rendered') + slot.renderedKey = key + if (!this.firstRenderDone) { + this.firstRenderDone = true + this.host.hideLoader() + } + this.trimCanvases() + } finally { + try { + pixmap?.destroy?.() + } catch { + /* ignore */ + } + try { + page?.destroy?.() + } catch { + /* ignore */ + } + } + } + + private pixmapToImageData(pixmap: any, width: number, height: number): ImageData { + const components = pixmap.getNumberOfComponents() + const stride = pixmap.getStride() + const src: Uint8ClampedArray = pixmap.getPixels() + const image = new ImageData(width, height) + const dst = image.data + if (components === 4) { + for (let y = 0; y < height; y++) { + const start = y * stride + dst.set(src.subarray(start, start + width * 4), y * width * 4) + } + } else if (components === 3) { + for (let y = 0; y < height; y++) { + const start = y * stride + let d = y * width * 4 + for (let x = 0; x < width; x++) { + const s = start + x * 3 + dst[d++] = src[s] + dst[d++] = src[s + 1] + dst[d++] = src[s + 2] + dst[d++] = 255 + } + } + } else if (components === 1) { + for (let y = 0; y < height; y++) { + const start = y * stride + let d = y * width * 4 + for (let x = 0; x < width; x++) { + const v = src[start + x] + dst[d++] = v + dst[d++] = v + dst[d++] = v + dst[d++] = 255 + } + } + } else { + throw new Error(`不支持的像素格式(${components} 通道)`) + } + return image + } + + private drawSearchHighlights( + ctx: CanvasRenderingContext2D, + matrix: number[], + pixmap: any, + pageIndex: number + ): void { + if (!this.searchHits.length) return + const hits = this.searchHits.filter((hit) => hit.page === pageIndex) + if (!hits.length) return + const originX = pixmap.getX?.() ?? 0 + const originY = pixmap.getY?.() ?? 0 + ctx.save() + for (const hit of hits) { + const active = hit.hitIndex === this.currentHit + ctx.fillStyle = active ? 'rgba(255,140,0,0.46)' : 'rgba(255,210,40,0.28)' + ctx.strokeStyle = active ? 'rgba(255,110,0,0.95)' : 'rgba(230,170,0,0.5)' + ctx.lineWidth = active ? 2 : 1 + for (const quad of hit.quads) { + let minX = Infinity + let minY = Infinity + let maxX = -Infinity + let maxY = -Infinity + for (let i = 0; i + 1 < quad.length; i += 2) { + const x = quad[i] + const y = quad[i + 1] + const tx = matrix[0] * x + matrix[2] * y + matrix[4] - originX + const ty = matrix[1] * x + matrix[3] * y + matrix[5] - originY + if (tx < minX) minX = tx + if (ty < minY) minY = ty + if (tx > maxX) maxX = tx + if (ty > maxY) maxY = ty + } + if (!Number.isFinite(minX)) continue + const w = Math.max(2, maxX - minX) + const hgt = Math.max(2, maxY - minY) + ctx.fillRect(minX, minY, w, hgt) + ctx.strokeRect(minX + 0.5, minY + 0.5, w - 1, hgt - 1) + } + } + ctx.restore() + } + + private trimCanvases(): void { + const keep = new Set(this.visiblePages) + keep.add(this.currentPage) + const rendered = this.slots.filter((slot) => slot.renderedKey) + if (rendered.length <= 6) return + const removable = rendered + .filter((slot) => !keep.has(slot.index)) + .sort((a, b) => Math.abs(b.index - this.currentPage) - Math.abs(a.index - this.currentPage)) + while (rendered.length > 6 && removable.length) { + const slot = removable.shift()! + slot.canvas.width = 0 + slot.canvas.height = 0 + slot.renderedKey = '' + slot.el.classList.remove('rendered') + rendered.splice(rendered.indexOf(slot), 1) + } + } + + private toggleSearch(): void { + if (this.searchVisible) { + this.closeSearch() + } else { + this.searchVisible = true + this.searchBar.classList.add('open') + window.setTimeout(() => this.searchInput.focus({ preventScroll: true }), 100) + this.searchInput.select() + } + } + + private closeSearch(): void { + this.searchVisible = false + this.searchInput.blur() + this.searchBar.classList.remove('open') + this.host.stage.scrollTop = 0 + this.host.stage.scrollLeft = 0 + this.searchToken++ + this.searchQuery = '' + this.searchHits = [] + this.currentHit = -1 + this.searchCount.textContent = '' + this.epoch++ + this.renderVisible() + } + + private async runSearch(query: string): Promise { + const token = ++this.searchToken + this.searchVisible = true + this.searchBar.classList.add('open') + this.searchQuery = query + this.searchHits = [] + this.currentHit = -1 + this.searchCount.textContent = '搜索中…' + const startPage = this.currentPage + let total = 0 + for (let pass = 0; pass < 2; pass++) { + const begin = pass === 0 ? startPage : 0 + const end = pass === 0 ? this.pageCount : startPage + for (let i = begin; i < end; i++) { + if (token !== this.searchToken || this.destroyed) return + let page: any = null + try { + page = this.doc.loadPage(i) + const results = page.search(query, {}) as number[][][] + let pageHit = 0 + for (const quads of results) { + if (!Array.isArray(quads) || !quads.length) continue + const flat: number[][] = [] + for (const quad of quads) { + if (Array.isArray(quad) && quad.length >= 4) flat.push(quad as number[]) + } + if (!flat.length) continue + this.searchHits.push({ hitIndex: total, page: i, quads: flat }) + total++ + pageHit++ + if (total >= 4000) break + } + if (pageHit && i % 5 === 0) { + this.searchCount.textContent = `已找到 ${total} 处…` + } + } catch { + /* skip page */ + } finally { + try { + page?.destroy?.() + } catch { + /* ignore */ + } + } + if (total >= 4000) break + if (i % 4 === 3) await new Promise((resolve) => setTimeout(resolve, 0)) + } + if (total >= 4000) break + if (this.searchHits.length) break + } + if (token !== this.searchToken) return + if (!this.searchHits.length) { + this.searchCount.textContent = '无结果' + this.epoch++ + this.renderVisible() + return + } + this.currentHit = 0 + this.updateSearchCount() + this.epoch++ + this.gotoHit(0) + } + + private updateSearchCount(): void { + if (!this.searchHits.length) { + this.searchCount.textContent = this.searchQuery ? '无结果' : '' + return + } + this.searchCount.textContent = `${this.currentHit + 1} / ${this.searchHits.length}` + } + + private gotoHit(index: number): void { + if (!this.searchHits.length) return + const clamped = ((index % this.searchHits.length) + this.searchHits.length) % this.searchHits.length + this.currentHit = clamped + const hit = this.searchHits[clamped] + this.updateSearchCount() + this.epoch++ + const target = this.slots[hit.page] + if (target) { + const top = Math.max(0, target.el.offsetTop - 10) + this.scroller.scrollTo({ top, behavior: 'auto' }) + this.currentPage = hit.page + this.pageInput.value = String(hit.page + 1) + } + this.renderVisible() + } + + private nextHit(): void { + if (!this.searchHits.length) { + if (this.searchInput.value.trim()) void this.runSearch(this.searchInput.value.trim()) + return + } + this.gotoHit(this.currentHit + 1) + } + + private prevHit(): void { + if (!this.searchHits.length) return + this.gotoHit(this.currentHit - 1) + } + + private openOutline(): void { + this.closeMenu() + this.outlineBackdrop.classList.add('open') + } + + private closeOutline(): void { + this.outlineBackdrop.classList.remove('open') + } + + private toggleMenu(): void { + this.menu.classList.toggle('open') + } + + private closeMenu(): void { + this.menu.classList.remove('open') + } + + private rotatePage(): void { + this.rotate = (this.rotate + 90) % 360 + if (this.fitMode === 'width') this.zoom = this.computeFitWidth() + else if (this.fitMode === 'page') this.zoom = this.computeFitPage() + this.applyZoomLabel() + this.layoutPageSizes() + this.epoch++ + this.renderVisible() + toast('已旋转 90°', 'info', 1500) + } + + private toggleInvert(): void { + this.invert = !this.invert + try { + localStorage.setItem(INVERT_KEY, this.invert ? '1' : '0') + } catch { + /* ignore */ + } + this.pagesEl.classList.toggle('inverted', this.invert) + this.applyInvertUi() + this.epoch++ + this.renderVisible() + } + + private applyInvertUi(): void { + this.updateMenuUi() + } + + private async toggleFullscreen(): Promise { + try { + if (!document.fullscreenElement) await this.host.root.requestFullscreen?.() + else await document.exitFullscreen?.() + } catch { + toast('当前浏览器不支持全屏', 'error') + } + } + + private onFullscreenChange = () => { + this.updateMenuUi() + window.setTimeout(() => this.handleResize(), 100) + } + + private onDoubleClick = (ev: MouseEvent) => { + const rect = this.scroller.getBoundingClientRect() + const y = ev.clientY - rect.top + const x = ev.clientX - rect.left + const fit = this.computeFitWidth() + if (this.zoom < fit * 1.8) this.zoomTo(fit * 2, y, true, x) + else this.fitWidth() + } + + private onWheel = (ev: WheelEvent) => { + if (!ev.ctrlKey && !ev.metaKey) return + ev.preventDefault() + const rect = this.scroller.getBoundingClientRect() + const localY = ev.clientY - rect.top + const localX = ev.clientX - rect.left + const factor = Math.exp(-ev.deltaY * 0.002) + this.zoomTo(this.zoom * factor, localY, true, localX) + } + + private onTouchStart = (ev: TouchEvent) => { + if (ev.touches.length !== 2) return + ev.preventDefault() + const [a, b] = [ev.touches[0], ev.touches[1]] + const rect = this.scroller.getBoundingClientRect() + const midY = (a.clientY + b.clientY) / 2 - rect.top + const midX = (a.clientX + b.clientX) / 2 - rect.left + this.pinch = { + startDist: Math.max(1, Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY)), + startZoom: this.zoom, + startScrollTop: this.scroller.scrollTop, + startScrollLeft: this.scroller.scrollLeft, + midX, + midY + } + } + + private onTouchMove = (ev: TouchEvent) => { + if (!this.pinch || ev.touches.length !== 2) return + ev.preventDefault() + const [a, b] = [ev.touches[0], ev.touches[1]] + const rect = this.scroller.getBoundingClientRect() + const dist = Math.max(1, Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY)) + const midY = (a.clientY + b.clientY) / 2 - rect.top + const midX = (a.clientX + b.clientX) / 2 - rect.left + const next = Math.max(0.02, Math.min(20, this.pinch.startZoom * (dist / this.pinch.startDist))) + const ratio = next / this.pinch.startZoom + const contentY = this.pinch.startScrollTop + this.pinch.midY + const contentX = this.pinch.startScrollLeft + this.pinch.midX + this.zoom = next + this.layoutPageSizes() + const maxScroll = Math.max(0, this.scroller.scrollHeight - this.scroller.clientHeight) + const maxScrollX = Math.max(0, this.scroller.scrollWidth - this.scroller.clientWidth) + this.scroller.scrollTop = Math.max(0, Math.min(maxScroll, contentY * ratio - midY)) + this.scroller.scrollLeft = Math.max(0, Math.min(maxScrollX, contentX * ratio - midX)) + this.applyZoomLabel() + this.fitMode = 'custom' + } + + private onTouchEnd = (ev: TouchEvent) => { + if (!this.pinch) return + if (ev.touches.length < 2) { + this.pinch = null + this.epoch++ + this.renderVisible() + this.updateCurrentPage() + } + } + + private onKeyDown = (ev: KeyboardEvent) => { + const active = document.activeElement + if (active && /^(input|textarea|select)$/i.test(active.tagName)) { + if (ev.key === 'Escape') (active as HTMLElement).blur() + return + } + switch (ev.key) { + case '+': + case '=': + ev.preventDefault() + this.zoomTo(this.zoom * 1.2) + break + case '-': + case '_': + ev.preventDefault() + this.zoomTo(this.zoom / 1.2) + break + case '0': + ev.preventDefault() + this.fitWidth() + break + case '/': + if (ev.ctrlKey || ev.metaKey) { + ev.preventDefault() + this.toggleSearch() + } + break + case 'f': + case 'F': + if (ev.ctrlKey || ev.metaKey) { + ev.preventDefault() + this.toggleSearch() + } + break + case 'Escape': + if (this.outlineBackdrop.classList.contains('open')) this.closeOutline() + else if (this.menu.classList.contains('open')) this.closeMenu() + else if (this.searchVisible) this.closeSearch() + break + default: + break + } + } + + destroy(): void { + if (this.destroyed) return + this.destroyed = true + this.searchToken++ + this.disconnectObservers() + if (this.resizeTimer) window.clearTimeout(this.resizeTimer) + if (this.scrollRaf) cancelAnimationFrame(this.scrollRaf) + this.scroller.removeEventListener('scroll', this.onScroll) + this.scroller.removeEventListener('dblclick', this.onDoubleClick) + this.scroller.removeEventListener('wheel', this.onWheel) + this.scroller.removeEventListener('touchstart', this.onTouchStart) + this.scroller.removeEventListener('touchmove', this.onTouchMove) + this.scroller.removeEventListener('touchend', this.onTouchEnd) + this.scroller.removeEventListener('touchcancel', this.onTouchEnd) + document.removeEventListener('keydown', this.onKeyDown) + document.removeEventListener('fullscreenchange', this.onFullscreenChange) + window.removeEventListener('resize', this.onWindowResize) + if (this.onDocumentPointerDown) document.removeEventListener('pointerdown', this.onDocumentPointerDown) + for (const slot of this.slots) { + slot.canvas.width = 0 + slot.canvas.height = 0 + } + try { + this.doc?.destroy?.() + } catch { + /* ignore */ + } + this.doc = null + this.host.destroy() + } +} diff --git a/src/doc/mupdfLoader.ts b/src/doc/mupdfLoader.ts new file mode 100644 index 0000000..277240c --- /dev/null +++ b/src/doc/mupdfLoader.ts @@ -0,0 +1,16 @@ +export type MuPDFModule = typeof import('mupdf') + +let promise: Promise | null = null + +export function loadMuPDF(): Promise { + if (promise) return promise + const url = new URL('vendor/mupdf/mupdf.js', document.baseURI).href + promise = import(/* @vite-ignore */ url) + .then((mod) => mod as unknown as MuPDFModule) + .catch((error: unknown) => { + promise = null + const detail = error instanceof Error ? error.message : String(error) + throw new Error(`文档引擎加载失败:${detail}`) + }) + return promise +} diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..5c8f79d --- /dev/null +++ b/src/main.ts @@ -0,0 +1,7 @@ +import './styles.css' +import { registerSW } from 'virtual:pwa-register' +import { initApp } from './core/app' + +const isAndroidShell = typeof (window as unknown as { AndroidViewer?: unknown }).AndroidViewer !== 'undefined' +if (!isAndroidShell) registerSW({ immediate: true }) +initApp() diff --git a/src/styles.css b/src/styles.css new file mode 100644 index 0000000..fbd4f64 --- /dev/null +++ b/src/styles.css @@ -0,0 +1,2361 @@ +:root { + --safe-bottom: env(safe-area-inset-bottom, 0px); + --safe-top: env(safe-area-inset-top, 0px); + --radius-sm: 10px; + --radius: 14px; + --radius-lg: 20px; + --font: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif; +} + +:root[data-theme='dark'] { + --bg: #0b0e14; + --bg-2: #0f141c; + --bg-3: #151b25; + --panel: rgba(20, 26, 36, 0.78); + --panel-solid: #141a24; + --text: #e9eef7; + --muted: #8b98ab; + --faint: #5f6b7e; + --line: rgba(255, 255, 255, 0.08); + --line-strong: rgba(255, 255, 255, 0.15); + --accent: #4f8cff; + --accent-2: #62e6c5; + --accent-soft: rgba(79, 140, 255, 0.16); + --danger: #ff5c6c; + --shadow: 0 26px 70px rgba(0, 0, 0, 0.5); + --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.32); + --glass: rgba(15, 20, 28, 0.74); + --glass-2: rgba(17, 23, 32, 0.92); + --page-bg: #151a22; +} + +:root[data-theme='light'] { + --bg: #f2f5fa; + --bg-2: #e9eef6; + --bg-3: #ffffff; + --panel: rgba(255, 255, 255, 0.84); + --panel-solid: #ffffff; + --text: #111827; + --muted: #5c6a7d; + --faint: #8c98a8; + --line: rgba(15, 23, 42, 0.08); + --line-strong: rgba(15, 23, 42, 0.16); + --accent: #2563eb; + --accent-2: #0ea88a; + --accent-soft: rgba(37, 99, 235, 0.11); + --danger: #dc2626; + --shadow: 0 26px 70px rgba(30, 50, 90, 0.2); + --shadow-soft: 0 10px 30px rgba(30, 50, 90, 0.14); + --glass: rgba(255, 255, 255, 0.78); + --glass-2: rgba(255, 255, 255, 0.95); + --page-bg: #dfe6f1; +} + +* { + box-sizing: border-box; + -webkit-tap-highlight-color: transparent; +} + +html, +body, +#app { + height: 100%; + margin: 0; +} + +html { + background: var(--bg); +} + +body { + font-family: var(--font); + color: var(--text); + background: var(--bg); + overflow: hidden; + -webkit-font-smoothing: antialiased; + text-rendering: optimizeLegibility; +} + +[hidden] { + display: none !important; +} + +button, +input, +select, +textarea { + font: inherit; + color: inherit; +} + +button { + background: none; + border: 0; + padding: 0; + cursor: pointer; +} + +a { + color: var(--accent); +} + +::selection { + background: var(--accent-soft); +} + +:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; +} + +.icon-btn { + width: 40px; + height: 40px; + border-radius: 12px; + display: inline-grid; + place-items: center; + color: var(--muted); + transition: background 0.15s, color 0.15s, transform 0.1s; + flex: none; +} + +.icon-btn:hover { + background: var(--accent-soft); + color: var(--text); +} + +.icon-btn:active { + transform: scale(0.94); +} + +.icon-btn.active { + background: var(--accent-soft); + color: var(--accent); +} + +.btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 8px; + padding: 10px 16px; + border-radius: 12px; + border: 1px solid transparent; + font-weight: 600; + font-size: 14px; + line-height: 1.2; + transition: transform 0.12s, box-shadow 0.2s, background 0.2s, border-color 0.2s; + white-space: nowrap; +} + +.btn:active { + transform: translateY(1px) scale(0.99); +} + +.btn-primary { + color: #fff; + background: linear-gradient(135deg, #5b9bff, #2f6fe4); + box-shadow: 0 10px 24px rgba(47, 111, 228, 0.38); +} + +.btn-primary:hover { + box-shadow: 0 14px 30px rgba(47, 111, 228, 0.46); +} + +.btn-ghost { + color: var(--text); + border-color: var(--line-strong); + background: transparent; +} + +.btn-ghost:hover { + background: var(--accent-soft); +} + +.btn-danger { + color: #fff; + background: linear-gradient(135deg, #ff6b7b, #d92d40); + box-shadow: 0 10px 24px rgba(217, 45, 64, 0.3); +} + +.btn-sm { + padding: 7px 12px; + font-size: 12.5px; + border-radius: 10px; +} + +.btn-lg { + padding: 14px 24px; + font-size: 16px; + border-radius: 14px; +} + +.text-link { + color: var(--accent); + font-weight: 600; + font-size: 13px; + padding: 2px 3px; + border-radius: 6px; +} + +.text-link:hover { + text-decoration: underline; +} + +.chip-btn { + border: 1px solid var(--line); + background: var(--bg-3); + color: var(--muted); + border-radius: 999px; + padding: 6px 11px; + font-size: 12px; + transition: background 0.15s, color 0.15s; +} + +.chip-btn:hover { + background: var(--accent-soft); + color: var(--text); +} + +.home { + height: 100%; + overflow-y: auto; + overflow-x: hidden; + background: + radial-gradient(1100px 600px at 15% -10%, rgba(79, 140, 255, 0.18), transparent 60%), + radial-gradient(900px 500px at 95% 5%, rgba(98, 230, 197, 0.1), transparent 55%), + var(--bg); + scrollbar-width: thin; +} + +.home-inner { + width: min(1180px, 100%); + margin: 0 auto; + padding: calc(22px + var(--safe-top)) 24px calc(36px + var(--safe-bottom)); +} + +.home-top { + display: flex; + align-items: center; + justify-content: space-between; + gap: 16px; +} + +.home-brand { + display: flex; + align-items: center; + gap: 12px; + min-width: 0; +} + +.brand-mark { + width: 46px; + height: 46px; + flex: none; + filter: drop-shadow(0 8px 18px rgba(47, 111, 228, 0.36)); +} + +.brand-mark svg { + width: 100%; + height: 100%; + display: block; +} + +.brand-name { + font-size: 18px; + font-weight: 750; + letter-spacing: -0.3px; +} + +.brand-sub { + font-size: 11.5px; + color: var(--muted); + margin-top: 2px; +} + +.home-actions { + display: flex; + align-items: center; + gap: 6px; +} + +.home-install { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 8px 13px; + border-radius: 999px; + border: 1px solid rgba(79, 140, 255, 0.4); + background: var(--accent-soft); + color: var(--accent); + font-size: 12.5px; + font-weight: 650; +} + +.home-install:hover { + background: rgba(79, 140, 255, 0.24); +} + +.hero { + position: relative; + margin-top: 30px; + border-radius: 30px; + border: 1px solid var(--line); + background: + radial-gradient(700px 340px at 85% 10%, rgba(98, 230, 197, 0.12), transparent 60%), + linear-gradient(150deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.01)), + var(--bg-3); + box-shadow: var(--shadow-soft); + padding: 38px 40px; + display: grid; + grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr); + gap: 30px; + overflow: hidden; +} + +:root[data-theme='light'] .hero { + background: + radial-gradient(700px 340px at 85% 10%, rgba(14, 168, 138, 0.1), transparent 60%), + linear-gradient(150deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.5)), + var(--bg-3); +} + +.hero::before { + content: ''; + position: absolute; + inset: -40% -20% auto auto; + width: 60%; + height: 70%; + background: radial-gradient(closest-side, rgba(79, 140, 255, 0.18), transparent); + pointer-events: none; +} + +.hero-copy { + position: relative; + z-index: 1; + min-width: 0; +} + +.eyebrow { + display: inline-flex; + align-items: center; + gap: 8px; + font-size: 12px; + font-weight: 600; + letter-spacing: 0.3px; + color: var(--muted); + background: var(--accent-soft); + border: 1px solid rgba(79, 140, 255, 0.22); + padding: 6px 12px; + border-radius: 999px; +} + +.eyebrow-dot { + width: 7px; + height: 7px; + border-radius: 50%; + background: var(--accent-2); + box-shadow: 0 0 0 4px rgba(98, 230, 197, 0.14); +} + +.hero h1 { + margin: 18px 0 0; + font-size: clamp(30px, 4.6vw, 50px); + line-height: 1.12; + letter-spacing: -1.4px; + font-weight: 800; +} + +.grad-text { + background: linear-gradient(100deg, #6aa5ff 0%, #4f8cff 40%, #62e6c5 100%); + -webkit-background-clip: text; + background-clip: text; + color: transparent; +} + +.hero-sub { + margin: 18px 0 0; + max-width: 660px; + color: var(--muted); + font-size: 14.5px; + line-height: 1.72; +} + +.hero-actions { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 18px; + margin-top: 26px; +} + +.sample-links { + display: flex; + align-items: center; + gap: 7px; + font-size: 12.5px; + color: var(--faint); + flex-wrap: wrap; +} + +.dot-sep { + color: var(--faint); +} + +.format-chips { + display: flex; + flex-wrap: wrap; + gap: 8px; + margin-top: 24px; +} + +.format-chip { + font-size: 11.5px; + color: var(--muted); + border: 1px solid var(--line); + background: rgba(255, 255, 255, 0.03); + padding: 5px 10px; + border-radius: 999px; +} + +:root[data-theme='light'] .format-chip { + background: rgba(255, 255, 255, 0.7); +} + +.hero-art { + display: flex; + align-items: center; + justify-content: center; + color: var(--text); + min-height: 250px; +} + +.hero-art svg { + width: 100%; + max-width: 480px; + height: auto; + filter: drop-shadow(0 24px 50px rgba(0, 0, 0, 0.3)); +} + +:root[data-theme='light'] .hero-art svg { + filter: drop-shadow(0 24px 50px rgba(30, 50, 90, 0.16)); +} + +.feature-grid { + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: 14px; + margin-top: 20px; +} + +.feature-card { + border: 1px solid var(--line); + background: var(--panel); + backdrop-filter: blur(12px); + border-radius: 18px; + padding: 18px; + transition: transform 0.2s, border-color 0.2s; +} + +.feature-card:hover { + transform: translateY(-2px); + border-color: var(--line-strong); +} + +.feature-icon { + width: 42px; + height: 42px; + border-radius: 12px; + display: grid; + place-items: center; + background: var(--accent-soft); + color: var(--accent); + margin-bottom: 12px; +} + +.feature-card h3 { + margin: 0; + font-size: 14.5px; + font-weight: 700; +} + +.feature-card p { + margin: 8px 0 0; + color: var(--muted); + font-size: 12.5px; + line-height: 1.65; +} + +.recent-section { + margin-top: 34px; +} + +.section-head { + display: flex; + align-items: flex-end; + justify-content: space-between; + gap: 16px; +} + +.section-head h2 { + margin: 0; + font-size: 18px; + letter-spacing: -0.3px; +} + +.section-head p { + margin: 5px 0 0; + color: var(--faint); + font-size: 12px; +} + +.recent-grid { + display: grid; + grid-template-columns: repeat(3, minmax(0, 1fr)); + gap: 12px; + margin-top: 14px; +} + +.recent-card { + display: flex; + align-items: center; + gap: 12px; + padding: 13px; + border: 1px solid var(--line); + background: var(--panel); + border-radius: 16px; + cursor: pointer; + transition: border-color 0.18s, transform 0.18s, background 0.18s; + min-width: 0; +} + +.recent-card:hover { + border-color: rgba(79, 140, 255, 0.45); + transform: translateY(-1px); +} + +.recent-card:focus-visible { + outline-offset: 1px; +} + +.recent-icon { + width: 44px; + height: 44px; + border-radius: 12px; + display: grid; + place-items: center; + flex: none; +} + +.recent-info { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + gap: 4px; +} + +.recent-name { + font-size: 13.5px; + font-weight: 650; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.recent-meta { + font-size: 11px; + color: var(--muted); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.recent-del { + width: 30px; + height: 30px; + border-radius: 9px; + display: grid; + place-items: center; + color: var(--faint); + flex: none; + opacity: 0.6; + transition: color 0.15s, background 0.15s, opacity 0.15s; +} + +.recent-del:hover { + color: var(--danger); + background: rgba(255, 92, 108, 0.12); + opacity: 1; +} + +.recent-empty { + grid-column: 1 / -1; + display: flex; + flex-direction: column; + align-items: center; + gap: 7px; + padding: 34px 20px; + border: 1px dashed var(--line-strong); + border-radius: 18px; + color: var(--muted); + text-align: center; +} + +.recent-empty strong { + color: var(--text); + font-size: 14px; +} + +.recent-empty span:last-child { + font-size: 12px; + max-width: 440px; + line-height: 1.6; +} + +.recent-empty-icon { + color: var(--faint); + margin-bottom: 4px; +} + +.home-footer { + display: flex; + align-items: center; + justify-content: center; + flex-wrap: wrap; + gap: 8px; + margin-top: 42px; + padding-top: 20px; + border-top: 1px solid var(--line); + color: var(--faint); + font-size: 11.5px; + text-align: center; +} + +.footer-dot { + opacity: 0.6; +} + +.tone-cad { + background: rgba(79, 140, 255, 0.16); + color: #8db8ff; +} + +.tone-pdf { + background: rgba(255, 92, 92, 0.14); + color: #ff8d8d; +} + +.tone-book { + background: rgba(98, 230, 197, 0.14); + color: #62e6c5; +} + +.tone-doc { + background: rgba(167, 139, 250, 0.14); + color: #b9a6ff; +} + +.tone-comic { + background: rgba(255, 209, 102, 0.14); + color: #ffd166; +} + +.tone-image { + background: rgba(244, 114, 182, 0.14); + color: #f472b6; +} + +:root[data-theme='light'] .tone-cad { + color: #2f6fe4; +} +:root[data-theme='light'] .tone-pdf { + color: #d92d40; +} +:root[data-theme='light'] .tone-book { + color: #0e8a72; +} +:root[data-theme='light'] .tone-doc { + color: #6d4bd8; +} +:root[data-theme='light'] .tone-comic { + color: #b47b00; +} +:root[data-theme='light'] .tone-image { + color: #c02876; +} + +/* ---------------------------- Viewer ---------------------------- */ + +.viewer-root { + position: absolute; + inset: 0; + z-index: 5; +} + +.viewer { + height: 100%; + display: flex; + flex-direction: column; + background: var(--bg); + overflow: hidden; +} + +.viewer-header { + display: flex; + align-items: center; + gap: 6px; + padding: calc(8px + var(--safe-top)) 10px 8px; + min-height: 58px; + background: var(--glass-2); + border-bottom: 1px solid var(--line); + backdrop-filter: blur(16px); + z-index: 20; + flex: none; +} + +.back-btn { + margin-right: 2px; +} + +.file-box { + display: flex; + align-items: center; + gap: 9px; + flex: 1; + min-width: 0; +} + +.file-badge { + flex: none; + font-size: 10px; + font-weight: 800; + letter-spacing: 0.4px; + padding: 5px 7px; + border-radius: 7px; + line-height: 1; +} + +.file-titles { + min-width: 0; + display: flex; + flex-direction: column; + gap: 2px; +} + +.file-name { + font-size: 13.5px; + font-weight: 650; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.file-meta { + font-size: 10.5px; + color: var(--muted); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.viewer-actions { + display: flex; + align-items: center; + gap: 1px; + flex: none; +} + +.viewer-subbar { + display: flex; + align-items: center; + padding: 7px 10px; + border-bottom: 1px solid var(--line); + background: var(--bg-2); + overflow-x: auto; + overflow-y: hidden; + flex: none; + scrollbar-width: none; +} + +.viewer-subbar::-webkit-scrollbar { + display: none; +} + +.viewer-body { + position: relative; + flex: 1; + min-height: 0; + overflow: hidden; + overflow: clip; +} + +.viewer-stage { + position: absolute; + inset: 0; + overflow: hidden; + overflow: clip; + background: var(--bg); +} + +.viewer-status { + position: absolute; + left: 12px; + bottom: calc(12px + var(--safe-bottom)); + z-index: 15; + max-width: calc(100% - 110px); + padding: 6px 12px; + border-radius: 999px; + background: var(--glass); + border: 1px solid var(--line); + backdrop-filter: blur(12px); + color: var(--muted); + font-size: 11.5px; + line-height: 1.3; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + pointer-events: none; +} + +.viewer-loader { + position: absolute; + inset: 0; + z-index: 80; + display: grid; + place-items: center; + background: rgba(8, 11, 17, 0.72); + backdrop-filter: blur(8px); + padding: 20px; +} + +.loader-card { + display: flex; + flex-direction: column; + align-items: center; + gap: 12px; + min-width: 220px; + max-width: min(420px, 90vw); + padding: 26px 30px; + border-radius: 20px; + border: 1px solid var(--line-strong); + background: var(--panel-solid); + box-shadow: var(--shadow); + text-align: center; +} + +.spinner { + width: 34px; + height: 34px; + border-radius: 50%; + border: 3px solid var(--line-strong); + border-top-color: var(--accent); + animation: spin 0.8s linear infinite; +} + +@keyframes spin { + to { + transform: rotate(360deg); + } +} + +.loader-text { + font-size: 14px; + font-weight: 650; +} + +.loader-detail { + font-size: 11.5px; + color: var(--muted); + max-width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.hidden-input { + position: fixed; + left: -9999px; + top: 0; + width: 1px; + height: 1px; + opacity: 0; + pointer-events: none; +} + +.tabs { + display: flex; + align-items: center; + gap: 5px; + min-width: max-content; +} + +.tab { + display: inline-flex; + align-items: center; + gap: 6px; + height: 31px; + padding: 0 12px; + border-radius: 9px; + border: 1px solid transparent; + color: var(--muted); + font-size: 12.5px; + white-space: nowrap; + transition: background 0.15s, color 0.15s, border-color 0.15s; +} + +.tab:hover { + background: var(--bg-3); + color: var(--text); +} + +.tab.active { + background: var(--accent-soft); + border-color: rgba(79, 140, 255, 0.3); + color: var(--accent); + font-weight: 650; +} + +.tab-icon { + display: flex; + opacity: 0.85; +} + +/* ---------------------------- CAD ---------------------------- */ + +.cad-canvas { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + display: block; + touch-action: none; + cursor: grab; + user-select: none; + -webkit-user-select: none; +} + +.cad-canvas:active { + cursor: grabbing; +} + +.cad-canvas.crosshair, +.cad-canvas.crosshair:active { + cursor: crosshair; +} + +.cad-tools { + position: absolute; + right: 12px; + bottom: calc(60px + var(--safe-bottom)); + z-index: 16; + display: flex; + flex-direction: column; + gap: 5px; + padding: 6px; + border-radius: 16px; + border: 1px solid var(--line); + background: var(--glass); + backdrop-filter: blur(14px); + box-shadow: var(--shadow-soft); +} + +.cad-tools .icon-btn { + width: 40px; + height: 40px; + border-radius: 11px; +} + +.cad-tools .icon-btn.active { + color: var(--accent); + background: var(--accent-soft); +} + +.tool-divider { + height: 1px; + margin: 3px 7px; + background: var(--line); +} + +.tool-hidden { + display: none !important; +} + +.cad-hint { + position: absolute; + top: 14px; + left: 50%; + transform: translateX(-50%); + z-index: 14; + padding: 8px 14px; + border-radius: 999px; + border: 1px solid var(--line); + background: var(--glass-2); + color: var(--muted); + font-size: 11.5px; + white-space: nowrap; + box-shadow: var(--shadow-soft); + pointer-events: none; + transition: opacity 0.35s, transform 0.35s; +} + +.cad-hint.hide { + opacity: 0; + transform: translate(-50%, -8px); +} + +.sheet-backdrop { + position: absolute; + inset: 0; + z-index: 40; + background: rgba(0, 0, 0, 0.45); + backdrop-filter: blur(3px); + opacity: 0; + pointer-events: none; + transition: opacity 0.22s; +} + +.sheet-backdrop.open { + opacity: 1; + pointer-events: auto; +} + +.sheet { + position: absolute; + top: 0; + right: 0; + height: 100%; + width: min(380px, 92vw); + background: var(--panel-solid); + border-left: 1px solid var(--line); + box-shadow: var(--shadow); + display: flex; + flex-direction: column; + transform: translateX(102%); + transition: transform 0.24s cubic-bezier(0.2, 0.8, 0.2, 1); +} + +.sheet-backdrop.open .sheet { + transform: none; +} + +.sheet.sheet-left { + left: 0; + right: auto; + border-left: 0; + border-right: 1px solid var(--line); + transform: translateX(-102%); +} + +.sheet-backdrop.open .sheet.sheet-left { + transform: none; +} + +.sheet-head { + display: flex; + align-items: center; + justify-content: space-between; + padding: 15px 14px 10px; + flex: none; +} + +.sheet-title { + font-size: 15px; + font-weight: 700; + display: flex; + align-items: center; + gap: 8px; +} + +.sheet-actions { + display: flex; + flex-wrap: wrap; + gap: 6px; + padding: 0 14px 12px; + flex: none; +} + +.sheet-search-input { + margin: 0 14px 10px; + padding: 10px 12px; + border-radius: 10px; + border: 1px solid var(--line); + background: var(--bg-2); + color: var(--text); + font-size: 13px; + outline: none; + flex: none; +} + +.sheet-search-input:focus { + border-color: var(--accent); + box-shadow: 0 0 0 3px var(--accent-soft); +} + +.sheet-list { + flex: 1; + overflow-y: auto; + padding: 0 8px calc(18px + var(--safe-bottom)); + overscroll-behavior: contain; +} + +.layer-row { + width: 100%; + display: flex; + align-items: center; + gap: 10px; + padding: 9px 10px; + border-radius: 10px; + text-align: left; + color: var(--text); + transition: background 0.15s; +} + +.layer-row:hover { + background: var(--bg-2); +} + +.layer-row.hidden { + opacity: 0.48; +} + +.layer-swatch { + width: 14px; + height: 14px; + border-radius: 4px; + border: 1px solid rgba(0, 0, 0, 0.24); + flex: none; +} + +.layer-info { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + gap: 2px; +} + +.layer-name { + font-size: 13px; + font-weight: 550; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.layer-meta { + font-size: 10.5px; + color: var(--muted); +} + +.layer-eye { + color: var(--muted); + display: flex; + flex: none; +} + +.outline-list { + flex: 1; + overflow-y: auto; + padding: 2px 8px calc(18px + var(--safe-bottom)); + overscroll-behavior: contain; +} + +.outline-item { + width: 100%; + display: flex; + align-items: center; + gap: 8px; + padding: 9px 12px; + border-radius: 8px; + text-align: left; + color: var(--text); + font-size: 13px; + transition: background 0.15s; +} + +.outline-item:hover { + background: var(--bg-2); +} + +.outline-item.no-page { + opacity: 0.65; +} + +.outline-text { + flex: 1; + min-width: 0; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.outline-page { + color: var(--muted); + font-size: 10.5px; + flex: none; +} + +.outline-empty { + padding: 26px 16px; + text-align: center; + color: var(--muted); + font-size: 12.5px; + line-height: 1.6; +} + +/* ---------------------------- Documents ---------------------------- */ + +.doc-scroll { + position: absolute; + inset: 0; + overflow-y: auto; + overflow-x: auto; + padding: 10px 0 calc(94px + var(--safe-bottom)); + background: + radial-gradient(900px 500px at 50% -10%, rgba(79, 140, 255, 0.08), transparent 60%), + var(--bg-2); + touch-action: pan-x pan-y; + overscroll-behavior: contain; + scroll-behavior: auto; + -webkit-overflow-scrolling: touch; + scrollbar-width: thin; +} + +.doc-scroll::-webkit-scrollbar { + width: 8px; +} + +.doc-scroll::-webkit-scrollbar-thumb { + background: var(--line-strong); + border-radius: 8px; +} + +.doc-pages { + display: flex; + flex-direction: column; + align-items: center; + gap: 18px; + width: max-content; + min-width: 100%; + min-height: 100%; + margin: 0 auto; + padding: 8px 16px 20px; +} + +.doc-page { + position: relative; + flex: none; + background: #ffffff; + border-radius: 3px; + box-shadow: + 0 1px 2px rgba(0, 0, 0, 0.14), + 0 14px 34px rgba(0, 0, 0, 0.24); + overflow: hidden; + min-width: 24px; + min-height: 24px; +} + +:root[data-theme='light'] .doc-page { + box-shadow: + 0 1px 2px rgba(30, 50, 90, 0.12), + 0 16px 38px rgba(30, 50, 90, 0.16); +} + +.doc-page-canvas { + display: block; + width: 100%; + height: 100%; +} + +.doc-pages.inverted .doc-page { + background: var(--page-bg); +} + +.doc-bottom { + position: absolute; + left: 50%; + bottom: calc(10px + var(--safe-bottom)); + transform: translateX(-50%); + z-index: 22; + display: flex; + align-items: center; + gap: 4px; + max-width: calc(100% - 14px); + padding: 5px 8px; + border-radius: 16px; + border: 1px solid var(--line); + background: var(--glass-2); + backdrop-filter: blur(16px); + box-shadow: var(--shadow-soft); + overflow-x: auto; + scrollbar-width: none; +} + +.doc-bottom::-webkit-scrollbar { + display: none; +} + +.doc-group { + display: flex; + align-items: center; + gap: 1px; + padding: 0 5px; + border-right: 1px solid var(--line); + flex: none; +} + +.doc-group:last-child { + border-right: 0; + padding-right: 1px; +} + +.doc-btn { + width: 34px; + height: 34px; + border-radius: 9px; +} + +.page-input { + width: 44px; + height: 30px; + padding: 0 2px; + border-radius: 8px; + border: 1px solid var(--line); + background: var(--bg-2); + color: var(--text); + font-size: 12px; + text-align: center; + outline: none; + -moz-appearance: textfield; + appearance: textfield; +} + +.page-input::-webkit-outer-spin-button, +.page-input::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; +} + +.page-input:focus { + border-color: var(--accent); + box-shadow: 0 0 0 3px var(--accent-soft); +} + +.page-total { + font-size: 11.5px; + color: var(--muted); + min-width: 38px; + text-align: left; +} + +.zoom-label { + min-width: 54px; + height: 30px; + padding: 0 8px; + border-radius: 8px; + border: 1px solid var(--line); + background: var(--bg-2); + color: var(--text); + font-size: 11.5px; + font-weight: 650; + transition: background 0.15s; +} + +.zoom-label:hover { + background: var(--accent-soft); +} + +.doc-search { + position: absolute; + top: 10px; + left: 50%; + transform: translate(-50%, -150%); + z-index: 26; + display: flex; + align-items: center; + gap: 5px; + width: min(560px, calc(100% - 20px)); + padding: 6px 7px 6px 11px; + border-radius: 14px; + border: 1px solid var(--line); + background: var(--glass-2); + backdrop-filter: blur(16px); + box-shadow: var(--shadow-soft); + opacity: 0; + pointer-events: none; + transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s; +} + +.doc-search.open { + transform: translate(-50%, 0); + opacity: 1; + pointer-events: auto; +} + +.doc-search-icon { + color: var(--muted); + display: flex; + flex: none; +} + +.doc-search-input { + flex: 1; + min-width: 40px; + border: 0; + background: transparent; + color: var(--text); + outline: none; + font-size: 14px; + padding: 6px 2px; +} + +.doc-search-input::-webkit-search-cancel-button { + -webkit-appearance: none; + appearance: none; +} + +.doc-search-count { + font-size: 10.5px; + color: var(--muted); + white-space: nowrap; + max-width: 110px; + overflow: hidden; + text-overflow: ellipsis; +} + +.doc-menu { + position: absolute; + right: 12px; + bottom: calc(66px + var(--safe-bottom)); + z-index: 30; + min-width: 200px; + padding: 6px; + border-radius: 14px; + border: 1px solid var(--line); + background: var(--panel-solid); + box-shadow: var(--shadow); + display: flex; + flex-direction: column; + gap: 1px; + opacity: 0; + transform: translateY(8px) scale(0.98); + transform-origin: bottom right; + pointer-events: none; + transition: opacity 0.16s, transform 0.16s; +} + +.doc-menu.open { + opacity: 1; + transform: none; + pointer-events: auto; +} + +.menu-item { + display: flex; + align-items: center; + gap: 10px; + width: 100%; + padding: 10px 11px; + border-radius: 9px; + text-align: left; + color: var(--text); + font-size: 13px; + transition: background 0.14s, color 0.14s; +} + +.menu-item:hover { + background: var(--bg-2); +} + +.menu-item.active { + color: var(--accent); + background: var(--accent-soft); +} + +.menu-icon { + width: 19px; + display: flex; + color: var(--muted); +} + +.menu-item.active .menu-icon { + color: var(--accent); +} + +.form-error { + margin: 0; + color: var(--danger); + font-size: 12px; +} + +.password-form { + display: flex; + flex-direction: column; + gap: 10px; +} + +.text-input { + width: 100%; + padding: 11px 12px; + border-radius: 10px; + border: 1px solid var(--line); + background: var(--bg-2); + color: var(--text); + font-size: 14px; + outline: none; +} + +.text-input:focus { + border-color: var(--accent); + box-shadow: 0 0 0 3px var(--accent-soft); +} + +/* ---------------------------- Modal ---------------------------- */ + +.modal-backdrop { + position: fixed; + inset: 0; + z-index: 100; + display: grid; + place-items: center; + padding: 20px; + background: rgba(4, 7, 12, 0.58); + backdrop-filter: blur(7px); + opacity: 0; + transition: opacity 0.18s; +} + +.modal-backdrop.show { + opacity: 1; +} + +.modal { + width: min(100%, 560px); + max-height: min(86vh, 760px); + display: flex; + flex-direction: column; + background: var(--panel-solid); + border: 1px solid var(--line-strong); + border-radius: 20px; + box-shadow: var(--shadow); + transform: translateY(10px) scale(0.98); + transition: transform 0.18s; + overflow: hidden; +} + +.modal-backdrop.show .modal { + transform: none; +} + +.modal-sm { + max-width: 410px; +} + +.modal-lg { + max-width: 760px; +} + +.modal-head { + display: flex; + align-items: flex-start; + justify-content: space-between; + gap: 12px; + padding: 20px 20px 8px; + flex: none; +} + +.modal-titles { + min-width: 0; +} + +.modal-title { + margin: 0; + font-size: 17px; + font-weight: 750; + letter-spacing: -0.2px; +} + +.modal-subtitle { + margin: 4px 0 0; + color: var(--muted); + font-size: 11.5px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.modal-close { + margin: -6px -6px 0 0; +} + +.modal-body { + padding: 6px 20px 18px; + overflow-y: auto; + font-size: 13.5px; + line-height: 1.7; + color: var(--text); +} + +.modal-text { + margin: 0 0 10px; + color: var(--muted); + line-height: 1.7; +} + +.modal-details { + margin: 10px 0 0; + padding: 10px 12px; + border-radius: 10px; + background: var(--bg-2); + border: 1px solid var(--line); + color: var(--muted); + font-size: 11px; + line-height: 1.55; + white-space: pre-wrap; + word-break: break-word; + max-height: 160px; + overflow: auto; +} + +.modal-actions { + display: flex; + justify-content: flex-end; + flex-wrap: wrap; + gap: 8px; + padding: 0 20px 20px; + flex: none; +} + +.about h3 { + margin: 16px 0 6px; + font-size: 13px; + font-weight: 700; +} + +.about-list { + margin: 0; + padding: 0; + list-style: none; + color: var(--muted); + font-size: 12.5px; +} + +.about-list li { + margin: 4px 0; + line-height: 1.6; +} + +.about-list strong { + color: var(--text); + font-weight: 650; +} + +.about-version { + margin: 18px 0 0; + color: var(--faint); + font-size: 11px; +} + +/* ---------------------------- Toast ---------------------------- */ + +#toasts { + position: fixed; + left: 50%; + bottom: calc(24px + var(--safe-bottom)); + transform: translateX(-50%); + z-index: 200; + display: flex; + flex-direction: column; + align-items: center; + gap: 8px; + width: max-content; + max-width: min(520px, calc(100vw - 24px)); + pointer-events: none; +} + +.toast { + display: flex; + align-items: center; + gap: 8px; + max-width: 100%; + padding: 10px 14px; + border-radius: 12px; + border: 1px solid var(--line-strong); + background: var(--glass-2); + backdrop-filter: blur(14px); + box-shadow: var(--shadow-soft); + color: var(--text); + font-size: 12.5px; + opacity: 0; + transform: translateY(8px); + transition: opacity 0.2s, transform 0.2s; + pointer-events: auto; + cursor: pointer; +} + +.toast.show { + opacity: 1; + transform: none; +} + +.toast-icon { + display: flex; + color: var(--accent); + flex: none; +} + +.toast-error .toast-icon { + color: var(--danger); +} + +.toast-success .toast-icon { + color: var(--accent-2); +} + +.toast-text { + min-width: 0; + line-height: 1.45; +} + +/* ---------------------------- Drop ---------------------------- */ + +.drop-overlay { + position: fixed; + inset: 0; + z-index: 300; + display: grid; + place-items: center; + background: rgba(4, 7, 12, 0.74); + backdrop-filter: blur(9px); + opacity: 0; + pointer-events: none; + transition: opacity 0.2s; + padding: 24px; +} + +.drop-overlay.show { + opacity: 1; + pointer-events: auto; +} + +.drop-box { + display: flex; + flex-direction: column; + align-items: center; + gap: 8px; + padding: 46px 56px; + border: 2px dashed var(--accent); + border-radius: 24px; + background: rgba(79, 140, 255, 0.08); + color: var(--text); + text-align: center; +} + +.drop-icon { + color: var(--accent); + margin-bottom: 6px; +} + +.drop-box strong { + font-size: 18px; +} + +.drop-box span:last-child { + color: var(--muted); + font-size: 12.5px; +} + +/* ---------------------------- Responsive ---------------------------- */ + +@media (max-width: 980px) { + .hero { + grid-template-columns: 1fr; + padding: 30px; + } + + .hero-art { + min-height: 0; + max-width: 520px; + width: 100%; + margin: 0 auto; + } + + .feature-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } + + .recent-grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + } +} + +@media (max-width: 720px) { + .home-inner { + padding: calc(16px + var(--safe-top)) 14px calc(28px + var(--safe-bottom)); + } + + .hero { + padding: 24px 18px; + border-radius: 24px; + margin-top: 20px; + } + + .hero h1 { + font-size: clamp(27px, 8.4vw, 40px); + letter-spacing: -0.9px; + } + + .hero-sub { + font-size: 13.5px; + } + + .hero-actions { + gap: 14px; + } + + .btn-lg { + padding: 13px 20px; + } + + .brand-sub { + display: none; + } + + .home-install span:last-child { + display: none; + } + + .home-install { + padding: 9px; + border-radius: 12px; + } + + .feature-grid { + grid-template-columns: 1fr; + gap: 10px; + } + + .recent-grid { + grid-template-columns: 1fr; + } + + .section-head { + align-items: flex-start; + } + + .viewer-header { + padding: calc(6px + var(--safe-top)) 6px 6px; + min-height: 54px; + } + + .viewer-actions .icon-btn { + width: 36px; + height: 36px; + } + + .back-btn { + width: 38px; + height: 38px; + } + + .file-meta { + display: none; + } + + .viewer-subbar { + padding: 6px 8px; + } + + .cad-tools { + right: 8px; + bottom: calc(54px + var(--safe-bottom)); + padding: 5px; + border-radius: 15px; + } + + .cad-tools .icon-btn { + width: 38px; + height: 38px; + } + + .viewer-status { + left: 8px; + bottom: calc(8px + var(--safe-bottom)); + font-size: 10.5px; + max-width: calc(100% - 78px); + padding: 5px 10px; + } + + .cad-hint { + font-size: 10.5px; + padding: 7px 12px; + max-width: calc(100% - 24px); + overflow: hidden; + text-overflow: ellipsis; + } + + .sheet { + top: auto; + bottom: 0; + left: 0; + right: 0; + width: 100%; + height: min(74vh, 640px); + border-left: 0; + border-top: 1px solid var(--line); + border-radius: 20px 20px 0 0; + transform: translateY(102%); + } + + .sheet.sheet-left { + left: 0; + right: 0; + border-right: 0; + transform: translateY(102%); + } + + .sheet-backdrop.open .sheet, + .sheet-backdrop.open .sheet.sheet-left { + transform: none; + } + + .doc-scroll { + padding-bottom: calc(88px + var(--safe-bottom)); + } + + .doc-pages { + padding: 6px 10px 16px; + gap: 14px; + } + + .doc-bottom { + bottom: calc(7px + var(--safe-bottom)); + padding: 4px 5px; + border-radius: 14px; + gap: 1px; + } + + .doc-group { + padding: 0 3px; + } + + .doc-btn { + width: 33px; + height: 33px; + } + + .page-input { + width: 38px; + height: 29px; + } + + .page-total { + min-width: 32px; + font-size: 10.5px; + } + + .zoom-label { + min-width: 46px; + height: 29px; + font-size: 10.5px; + padding: 0 5px; + } + + .doc-menu { + right: 8px; + bottom: calc(62px + var(--safe-bottom)); + } + + .doc-search { + top: 7px; + width: calc(100% - 14px); + padding: 5px 6px 5px 10px; + } + + .doc-search-count { + max-width: 74px; + } + + .modal-backdrop { + padding: 12px; + } + + .modal { + border-radius: 18px; + } + + .drop-box { + padding: 34px 24px; + } +} + +@media (max-width: 420px) { + .hero-art { + display: none; + } + + .format-chips { + gap: 6px; + } + + .format-chip { + font-size: 10.5px; + padding: 4px 8px; + } + + .sample-links { + font-size: 11.5px; + } + + .viewer-actions { + gap: 0; + } + + .doc-group { + padding: 0 2px; + } + + .doc-btn { + width: 32px; + height: 32px; + } +} + +@media (max-height: 520px) and (orientation: landscape) { + .viewer-header { + min-height: 46px; + padding-top: calc(3px + var(--safe-top)); + padding-bottom: 3px; + } + + .viewer-subbar { + padding: 4px 8px; + } + + .tab { + height: 28px; + } + + .cad-tools { + bottom: calc(44px + var(--safe-bottom)); + } + + .doc-scroll { + padding-bottom: calc(74px + var(--safe-bottom)); + } + + .doc-bottom { + bottom: calc(5px + var(--safe-bottom)); + } +} + +@media (prefers-reduced-motion: reduce) { + *, + *::before, + *::after { + animation-duration: 0.001ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.001ms !important; + scroll-behavior: auto !important; + } +} + +/* ---------------------------- Simple home ---------------------------- */ + +.home-simple { + background: var(--bg); +} + +.simple-inner { + width: min(820px, 100%); +} + +.simple-top { + margin-bottom: 26px; +} + +.simple-main { + display: flex; + flex-direction: column; + gap: 14px; +} + +.open-file-card { + width: 100%; + display: flex; + align-items: center; + gap: 16px; + padding: 20px 22px; + border: 1px solid var(--line); + border-radius: 18px; + background: var(--panel); + text-align: left; + transition: border-color 0.18s, background 0.18s, transform 0.18s; +} + +.open-file-card:hover { + border-color: rgba(79, 140, 255, 0.48); + background: var(--accent-soft); +} + +.open-file-card:active { + transform: scale(0.995); +} + +.open-file-icon { + width: 52px; + height: 52px; + border-radius: 15px; + display: grid; + place-items: center; + flex: none; + color: #fff; + background: linear-gradient(135deg, #5b9bff, #2f6fe4); + box-shadow: 0 10px 22px rgba(47, 111, 228, 0.3); +} + +.open-file-text { + flex: 1; + min-width: 0; + display: flex; + flex-direction: column; + gap: 5px; +} + +.open-file-text strong { + font-size: 19px; + font-weight: 750; + letter-spacing: -0.3px; +} + +.open-file-text span { + font-size: 12.5px; + color: var(--muted); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} + +.open-file-arrow { + color: var(--faint); + display: flex; + flex: none; +} + +.sample-row { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 8px; + padding: 0 4px; + color: var(--faint); + font-size: 12px; +} + +.sample-row .text-link { + font-size: 12px; +} + +.simple-recent { + margin-top: 14px; +} + +.simple-recent-grid { + grid-template-columns: 1fr; +} + +.simple-footer { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 8px; + margin-top: 34px; + padding-top: 15px; + border-top: 1px solid var(--line); + color: var(--faint); + font-size: 11.5px; +} + +.simple-footer .text-link { + font-size: 11.5px; +} + +.guide-section { + margin-top: 16px; +} + +.guide-section h3 { + margin: 0 0 6px; + font-size: 13.5px; + font-weight: 700; +} + +.guide-list { + margin: 0; + padding-left: 18px; + color: var(--muted); + font-size: 12.5px; + line-height: 1.72; +} + +.guide-list li { + margin: 3px 0; +} + +.guide-text { + margin: 5px 0; + color: var(--muted); + font-size: 12.5px; + line-height: 1.7; +} + +.guide kbd { + display: inline-block; + padding: 0 5px; + border-radius: 4px; + border: 1px solid var(--line-strong); + background: var(--bg-2); + color: var(--text); + font-family: ui-monospace, SFMono-Regular, Consolas, monospace; + font-size: 11px; + line-height: 1.6; +} + +.guide-actions { + margin-top: 18px; +} + +@media (max-width: 720px) { + .simple-top { + margin-bottom: 18px; + } + + .open-file-card { + padding: 16px; + gap: 13px; + border-radius: 16px; + } + + .open-file-icon { + width: 46px; + height: 46px; + border-radius: 13px; + } + + .open-file-text strong { + font-size: 17px; + } + + .open-file-text span { + font-size: 11.5px; + } + + .simple-recent { + margin-top: 10px; + } + + .simple-footer { + margin-top: 24px; + } +} + +/* Home must fit one screen; only the recent list scrolls. */ +.home-simple { + height: 100%; + overflow: hidden; + display: flex; +} + +.home-simple .home-inner { + height: 100%; + min-height: 0; + display: flex; + flex-direction: column; +} + +.simple-top { + flex: none; + margin-bottom: 20px; +} + +.open-file-card { + flex: none; +} + +.simple-recent { + flex: 1; + min-height: 0; + display: flex; + flex-direction: column; + margin-top: 18px; +} + +.simple-recent .section-head { + flex: none; +} + +.simple-recent-grid { + flex: 1; + min-height: 0; + overflow-y: auto; + align-content: start; + padding-right: 4px; + overscroll-behavior: contain; +} + +.guide-btn { + display: inline-flex; + align-items: center; + gap: 7px; + height: 38px; + padding: 0 13px; + border-radius: 11px; + border: 1px solid var(--line); + background: var(--panel); + color: var(--muted); + font-size: 12.5px; + font-weight: 600; + flex: none; + transition: color 0.15s, border-color 0.15s, background 0.15s; +} + +.guide-btn:hover { + color: var(--text); + border-color: var(--line-strong); + background: var(--accent-soft); +} + +.guide-btn span { + display: flex; +} + +@media (max-width: 720px) { + .simple-top { + margin-bottom: 16px; + } + + .guide-btn { + height: 36px; + padding: 0 10px; + font-size: 12px; + } + + .simple-recent { + margin-top: 14px; + } +} + +.cad-canvas-wrap { + position: absolute; + inset: 0; + transform-origin: 50% 50%; + will-change: transform; +} + +.cad-overlay-canvas { + position: absolute; + inset: 0; + display: block; + pointer-events: none; +} diff --git a/src/ui/about.ts b/src/ui/about.ts new file mode 100644 index 0000000..5b5d1ca --- /dev/null +++ b/src/ui/about.ts @@ -0,0 +1,51 @@ +import { h } from '../core/dom' +import { openModal } from './modal' + +const VERSION = '0.4.1' + +export function showAbout(): void { + const body = h( + 'div', + { class: 'about' }, + h( + 'p', + { class: 'modal-text' }, + '万能看图是一个完全在本地运行的手机 / 平板图纸与文档浏览器。文件只在本机解析,不会上传到任何服务器。' + ), + h('h3', { text: '支持的格式' }), + h( + 'ul', + { class: 'about-list' }, + h('li', {}, h('strong', { text: 'DWG' }), ' — 模型空间 + 全部布局空间 / 视口、图层、块、文字、填充、样条、测量'), + h('li', {}, h('strong', { text: 'PDF / XPS / OXPS' }), ' — 连续翻页、大纲、全文搜索、缩放、旋转、反色'), + h('li', {}, h('strong', { text: 'EPUB / FB2' }), ' — 电子书阅读,自动重排'), + h('li', {}, h('strong', { text: 'CBZ' }), ' — 漫画压缩包'), + h('li', {}, h('strong', { text: 'PNG / JPEG / GIF / BMP' }), ' — 图片浏览') + ), + h('h3', { text: '安装为 App' }), + h( + 'p', + { class: 'modal-text' }, + '在浏览器菜单中选择“安装应用”或“添加到主屏幕”,即可像原生 App 一样全屏使用,并支持离线打开已缓存的引擎与示例。' + ), + h('h3', { text: '开源组件与许可' }), + h( + 'ul', + { class: 'about-list' }, + h('li', {}, 'DWG 解析:@node-projects/acad-ts — MIT'), + h('li', {}, '文档渲染:MuPDF.js(SumatraPDF 同源渲染内核家族)— AGPL-3.0'), + h('li', {}, '本应用以 AGPL-3.0 发布;完整许可文本见项目 LICENSE 文件。') + ), + h('p', { class: 'about-version', text: `万能看图 v${VERSION} · PWA · 本地解析` }) + ) + + const close = h('button', { class: 'btn btn-primary', type: 'button', text: '关闭' }) + const modal = openModal({ + title: '关于万能看图', + subtitle: '手机 / 平板上的 DWG 图纸 & 文档浏览器', + content: body, + actions: [close], + size: 'md' + }) + close.addEventListener('click', modal.close) +} diff --git a/src/ui/guide.ts b/src/ui/guide.ts new file mode 100644 index 0000000..3d9e77f --- /dev/null +++ b/src/ui/guide.ts @@ -0,0 +1,123 @@ +import { h } from '../core/dom' +import { openModal } from './modal' +import { showAbout } from './about' + +export function showGuide(): void { + const list = (...items: string[]) => + h('ul', { class: 'guide-list' }, ...items.map((text) => h('li', { text }))) + const section = (title: string, ...children: (Node | string)[]) => + h('section', { class: 'guide-section' }, h('h3', { text: title }), ...children) + + const body = h( + 'div', + { class: 'guide' }, + h( + 'p', + { class: 'modal-text' }, + '万能看图把 DWG 图纸浏览和文档阅读放在同一个本地 App 里。文件只在本机解析,不会上传到服务器。' + ), + section( + '支持格式', + list( + 'DWG:模型空间 + 全部布局空间、视口、图层、块、文字、标注、填充、样条、圆弧、椭圆等常见 2D 实体。', + 'PDF / EPUB / FB2 / XPS / OXPS / CBZ。', + 'PNG / JPEG / GIF / BMP 图片。' + ) + ), + section( + '打开文件', + list( + '点首页的“打开图纸”,或把文件拖进窗口(桌面端)。', + 'Android 上可以从文件管理器、QQ、微信等选择“用其他应用打开”,直接进入本 App。', + '支持格式:DWG、PDF、EPUB、FB2、XPS/OXPS、CBZ、PNG/JPEG/GIF/BMP。' + ) + ), + section( + 'DWG 图纸', + list( + '顶部 Tab 切换模型空间和各个布局空间。', + '右侧图层按钮:按图层显示/隐藏,支持全部显示、全部隐藏、恢复默认。', + '尺子按钮:点两点测量距离;清除按钮清空当前空间的测量线。', + '立方体按钮:显示/隐藏第三方代理对象,默认显示。', + '适配按钮:一键显示全图;背景按钮切换深色/浅色图纸背景。', + '保存按钮:把当前视图导出为 PNG。', + '布局空间会按纸张和视口显示,模型内容自动裁剪到视口内。' + ) + ), + section( + 'PDF / 文档', + list( + '连续翻页、页码跳转、缩放、旋转、反色阅读、适合宽度 / 适合页面。', + '目录按钮打开书签;搜索按钮全文查找并高亮结果。', + '加密 PDF 会提示输入密码。' + ) + ), + section( + '手势与快捷键', + h( + 'p', + { class: 'guide-text' }, + '单指拖动平移,双指缩放;双击放大。桌面端滚轮缩放,拖动平移。' + ), + h( + 'p', + { class: 'guide-text' }, + '快捷键:', + h('kbd', { text: '+' }), + ' / ', + h('kbd', { text: '-' }), + ' 缩放,', + h('kbd', { text: '0' }), + ' 适配全图,', + h('kbd', { text: 'M' }), + ' 测量,', + h('kbd', { text: 'L' }), + ' 图层,', + h('kbd', { text: 'F' }), + ' 全屏,', + h('kbd', { text: 'Esc' }), + ' 退出当前工具。' + ) + ), + section( + '安装与离线', + list( + 'Android:直接安装 APK;APK 已经把 DWG/PDF 引擎一起打包,离线可用。', + '浏览器 / PWA:在浏览器菜单中选择“安装应用”或“添加到主屏幕”。', + 'PWA 首次打开 DWG 或文档时会下载对应引擎,之后由缓存离线使用。', + '文件和最近记录都保存在本机;最近记录可在首页清空。' + ) + ), + section( + '性能与限制', + list( + '大图纸的解析时间和首次绘制时间取决于图纸复杂度与设备性能。', + 'DWG 的 3DSOLID、MULTILEADER、MLINE、OLE/代理对象等复杂实体可能不显示,解析结果会在状态栏提示不支持数量。', + '当前 DWG/PDF 引擎是本地 WASM 实现,不是原生桌面 CAD 内核。' + ) + ), + section( + '开源组件与许可', + list( + 'DWG 解析:LibreDWG / libredwg-web — GPL-3.0(WASM 初始内存已调整)。', + '文档渲染:MuPDF.js(SumatraPDF 同源渲染内核家族)— AGPL-3.0。', + '本应用以 AGPL-3.0 发布;完整许可文本见项目 LICENSE 文件。' + ) + ), + h( + 'div', + { class: 'guide-actions' }, + h('button', { class: 'text-link', type: 'button', text: '关于与完整许可', onclick: () => showAbout() }) + ) + ) + + const close = h('button', { class: 'btn btn-primary', type: 'button', text: '知道了' }) + const modal = openModal({ + title: '使用指南', + subtitle: '手机 / 平板上的 DWG 与文档浏览器', + content: body, + actions: [close], + size: 'lg' + }) + close.addEventListener('click', () => modal.close()) +} diff --git a/src/ui/modal.ts b/src/ui/modal.ts new file mode 100644 index 0000000..b887bbd --- /dev/null +++ b/src/ui/modal.ts @@ -0,0 +1,156 @@ +import { append, h, icon } from '../core/dom' + +export interface ModalOptions { + title: string + subtitle?: string + content: Node | string + actions?: Node[] + size?: 'sm' | 'md' | 'lg' + dismissible?: boolean + onClose?: () => void +} + +interface ModalHandle { + el: HTMLElement + close: () => void +} + +const stack: ModalHandle[] = [] +let escBound = false + +export function openModal(options: ModalOptions): ModalHandle { + const root = document.getElementById('modal-root') + if (!root) throw new Error('modal root missing') + const dismissible = options.dismissible !== false + const priorFocus = document.activeElement as HTMLElement | null + + const closeBtn = h('button', { + class: 'icon-btn modal-close', + type: 'button', + 'aria-label': '关闭', + html: icon('x', 20) + }) + + const contentEl = h('div', { class: 'modal-body' }) + append(contentEl, [options.content]) + const actionsEl = h('div', { class: 'modal-actions' }) + append(actionsEl, options.actions ?? []) + + const dialog = h( + 'div', + { + class: `modal modal-${options.size ?? 'md'}`, + role: 'dialog', + 'aria-modal': 'true', + 'aria-label': options.title + }, + h( + 'div', + { class: 'modal-head' }, + h( + 'div', + { class: 'modal-titles' }, + h('h2', { class: 'modal-title', text: options.title }), + options.subtitle ? h('p', { class: 'modal-subtitle', text: options.subtitle }) : null + ), + dismissible ? closeBtn : null + ), + contentEl, + actionsEl.childNodes.length ? actionsEl : null + ) + + const backdrop = h('div', { class: 'modal-backdrop' }, dialog) + root.appendChild(backdrop) + requestAnimationFrame(() => backdrop.classList.add('show')) + + let closed = false + const close = () => { + if (closed) return + closed = true + const idx = stack.findIndex((m) => m.el === backdrop) + if (idx >= 0) stack.splice(idx, 1) + backdrop.classList.remove('show') + window.setTimeout(() => { + backdrop.remove() + options.onClose?.() + if (priorFocus && document.contains(priorFocus)) priorFocus.focus({ preventScroll: true }) + }, 180) + } + + closeBtn.addEventListener('click', close) + backdrop.addEventListener('click', (ev) => { + if (dismissible && ev.target === backdrop) close() + }) + + bindEscape() + stack.push({ el: backdrop, close }) + + window.setTimeout(() => { + const focusable = dialog.querySelector( + 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])' + ) + focusable?.focus({ preventScroll: true }) + }, 20) + + const handle: ModalHandle = { el: backdrop, close } + ;(backdrop as HTMLElement & { __modal?: ModalHandle }).__modal = handle + return handle +} + +function bindEscape(): void { + if (escBound) return + escBound = true + document.addEventListener('keydown', (ev) => { + if (ev.key !== 'Escape') return + const top = stack[stack.length - 1] + if (top) { + ev.stopPropagation() + top.close() + } + }) +} + +export function confirmDialog( + title: string, + message: string, + confirmText = '确定', + opts: { danger?: boolean; cancelText?: string } = {} +): Promise { + return new Promise((resolve) => { + let decided = false + const finish = (value: boolean) => { + if (decided) return + decided = true + resolve(value) + modal.close() + } + const cancel = h('button', { class: 'btn btn-ghost', type: 'button', text: opts.cancelText ?? '取消' }) + cancel.addEventListener('click', () => finish(false)) + const confirm = h('button', { + class: `btn ${opts.danger ? 'btn-danger' : 'btn-primary'}`, + type: 'button', + text: confirmText + }) + confirm.addEventListener('click', () => finish(true)) + const modal = openModal({ + title, + content: h('p', { class: 'modal-text', text: message }), + actions: [cancel, confirm], + size: 'sm', + onClose: () => { + if (!decided) { + decided = true + resolve(false) + } + } + }) + }) +} + +export function modalMessage(title: string, message: string, details?: string): void { + const body = h('div', {}, h('p', { class: 'modal-text', text: message })) + if (details) body.appendChild(h('pre', { class: 'modal-details', text: details })) + const ok = h('button', { class: 'btn btn-primary', type: 'button', text: '知道了' }) + const modal = openModal({ title, content: body, actions: [ok], size: 'sm' }) + ok.addEventListener('click', modal.close) +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..42d82c7 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2022", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": false, + "resolveJsonModule": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + "strict": true, + "noUnusedLocals": false, + "noUnusedParameters": false, + "noFallthroughCasesInSwitch": true, + "types": ["vite/client", "vite-plugin-pwa/client"] + }, + "include": ["src", "vite.config.ts"] +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..1388abb --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,85 @@ +import { defineConfig } from 'vite' +import { VitePWA } from 'vite-plugin-pwa' + +export default defineConfig({ + base: './', + build: { + target: 'es2020', + chunkSizeWarningLimit: 4000 + }, + optimizeDeps: { + exclude: ['mupdf'] + }, + plugins: [ + VitePWA({ + registerType: 'autoUpdate', + injectRegister: false, + includeAssets: ['icons/favicon.svg', 'icons/apple-touch-icon.png'], + manifest: { + name: '万能看图 · DWG/PDF 浏览', + short_name: '涓囪兘鐪嬪浘', + description: + '手机与平板上的 DWG 图纸浏览器,支持模型空间与布局空间、图层控制、测量,以及 PDF / EPUB / XPS / CBZ / 图片阅读。', + lang: 'zh-CN', + dir: 'ltr', + start_url: './', + scope: './', + display: 'standalone', + display_override: ['window-controls-overlay', 'standalone', 'minimal-ui'], + orientation: 'any', + background_color: '#0b0e14', + theme_color: '#0b0e14', + categories: ['productivity', 'utilities', 'graphics'], + icons: [ + { src: 'icons/icon-192.png', sizes: '192x192', type: 'image/png', purpose: 'any' }, + { src: 'icons/icon-512.png', sizes: '512x512', type: 'image/png', purpose: 'any' }, + { src: 'icons/icon-maskable-512.png', sizes: '512x512', type: 'image/png', purpose: 'maskable' } + ], + file_handlers: [ + { + action: './', + accept: { + 'application/pdf': ['.pdf'], + 'image/vnd.dwg': ['.dwg'], + 'application/acad': ['.dwg'], + 'application/epub+zip': ['.epub'], + 'application/vnd.ms-xpsdocument': ['.xps'], + 'application/oxps': ['.oxps'], + 'application/vnd.comicbook+zip': ['.cbz'], + 'image/png': ['.png'], + 'image/jpeg': ['.jpg', '.jpeg'], + 'image/gif': ['.gif'], + 'image/bmp': ['.bmp'] + } + } + ] + }, + workbox: { + globPatterns: ['**/*.{js,css,html,svg,png,ico,woff2}'], + globIgnores: ['**/vendor/**', '**/samples/**'], + maximumFileSizeToCacheInBytes: 4 * 1024 * 1024, + navigateFallback: 'index.html', + cleanupOutdatedCaches: true, + runtimeCaching: [ + { + urlPattern: /\/vendor\/(?:libredwg|mupdf)\//, + handler: 'CacheFirst', + options: { + cacheName: 'viewer-engines-v1', + expiration: { maxEntries: 12, maxAgeSeconds: 60 * 60 * 24 * 365 } + } + }, + { + urlPattern: /\/samples\//, + handler: 'CacheFirst', + options: { + cacheName: 'viewer-samples-v1', + expiration: { maxEntries: 12, maxAgeSeconds: 60 * 60 * 24 * 365 } + } + } + ] + } + }) + ] +}) +