diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..29ebfa54 --- /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 +. \ No newline at end of file diff --git a/apps/blog/.gitattributes b/apps/blog/.gitattributes new file mode 100644 index 00000000..df3ddcba --- /dev/null +++ b/apps/blog/.gitattributes @@ -0,0 +1 @@ +*.json linguist-language=JSON-with-Comments \ No newline at end of file diff --git a/apps/blog/enums/themeFromEnum.ts b/apps/blog/enums/themeFromEnum.ts new file mode 100644 index 00000000..d012f8e8 --- /dev/null +++ b/apps/blog/enums/themeFromEnum.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +/** + * 主题来源 + * + * @author terwer + * @since 0.0.1 + */ +enum ThemeFromEnum { + ThemeFrom_Blog = "zhi-theme-blog", + ThemeFrom_Siyuan = "zhi-theme-siyuan", +} + +export default ThemeFromEnum diff --git a/apps/blog/package.json b/apps/blog/package.json index 8c29f318..d1e2091e 100644 --- a/apps/blog/package.json +++ b/apps/blog/package.json @@ -17,9 +17,6 @@ "lintcss:fix": "stylelint *.styl --fix", "prettier": "prettier --write ." }, - "dependencies": { - "zhi-log": "^1.5.5" - }, "devDependencies": { "@nuxtjs/eslint-config-typescript": "^12.0.0", "eslint": "^8.36.0", @@ -35,6 +32,9 @@ "vite-plugin-eslint": "^1.8.1", "vue-tsc": "^1.2.0" }, + "dependencies": { + "zhi-sdk": "^1.0.8" + }, "keywords": [ "zhi", "blog" diff --git a/apps/blog/pages/index.vue b/apps/blog/pages/index.vue index 82d7d2bf..ed764807 100644 --- a/apps/blog/pages/index.vue +++ b/apps/blog/pages/index.vue @@ -4,3 +4,19 @@ + + diff --git a/apps/blog/pnpm-lock.yaml b/apps/blog/pnpm-lock.yaml index 9b7e9983..126b1465 100644 --- a/apps/blog/pnpm-lock.yaml +++ b/apps/blog/pnpm-lock.yaml @@ -14,10 +14,10 @@ specifiers: typescript: ^4.9.5 vite-plugin-eslint: ^1.8.1 vue-tsc: ^1.2.0 - zhi-log: ^1.5.5 + zhi-sdk: ^1.0.8 dependencies: - zhi-log: 1.5.5 + zhi-sdk: 1.0.8 devDependencies: '@nuxtjs/eslint-config-typescript': 12.0.0_vgl77cfdswitgr47lm5swmv43m @@ -2700,6 +2700,10 @@ packages: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} dev: true + /compare-versions/6.0.0-rc.1: + resolution: {integrity: sha512-cFhkjbGY1jLFWIV7KegECbfuyYPxSGvgGkdkfM+ibboQDoPwg2FRHm5BSNTOApiauRBzJIQH7qvOJs2sW5ueKQ==} + dev: false + /compress-commons/4.1.1: resolution: {integrity: sha512-QLdDLCKNV2dtoTorqgxngQCMA+gWXkM/Nwu7FpeBhk/RdkzimqC3jueb/FDmaZeXh+uby1jkBqE3xArsLBE5wQ==} engines: {node: '>= 10'} @@ -6555,6 +6559,10 @@ packages: resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} dev: true + /siyuan/0.3.12: + resolution: {integrity: sha512-Hcjn7Ujisayi9SW5o0DBtV2Jj/B8PKEXlIksJfbyeTYAtTBpgy++Fhy3nO0Pz1rJazadLt/dxKZ1X8JvlDgFHw==} + dev: false + /slash/3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -7771,6 +7779,14 @@ packages: zhi-env: 1.8.2 dev: false + /zhi-sdk/1.0.8: + resolution: {integrity: sha512-LZGDBvhsNtR1zZCCrFeu7bJhpADLIr1wD2m/EVhQ7Q286NS5ojkRdenzJxHc3Uz/ynpLf+sNKLyCYZdCnP2qpQ==} + dependencies: + compare-versions: 6.0.0-rc.1 + siyuan: 0.3.12 + zhi-log: 1.5.5 + dev: false + /zip-stream/4.1.0: resolution: {integrity: sha512-zshzwQW7gG7hjpBlgeQP9RuyPGNxvJdzR8SUM3QhxCnLjWN2E7j3dOvpeDcQoETfHx0urRS7EtmVToql7YpU4A==} engines: {node: '>= 10'} diff --git a/apps/blog/utils/Config.ts b/apps/blog/utils/Config.ts new file mode 100644 index 00000000..585b13d8 --- /dev/null +++ b/apps/blog/utils/Config.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +/** + * zhi 主题通用常量配置 + * + * @author terwer + * @since 1.0.0 + */ +class Config {} +export default Config diff --git a/apps/blog/utils/ZhiUtil.ts b/apps/blog/utils/ZhiUtil.ts new file mode 100644 index 00000000..34705aad --- /dev/null +++ b/apps/blog/utils/ZhiUtil.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import ZhiSdk from "zhi-sdk" +import Env from "zhi-env" + +/** + * 工具类统一入口 + * + * @author terwer + * @since 1.0.0 + */ +class ZhiUtil { + private static zhiSdkObj: ZhiSdk + public static zhiSdk() { + if (!ZhiUtil.zhiSdkObj) { + const env = new Env(import.meta.env) + ZhiUtil.zhiSdkObj = new ZhiSdk(env) + const logger = ZhiUtil.zhiSdkObj.getLogger() + const common = ZhiUtil.zhiSdkObj.common + logger.info(common.strUtil.f("ZhiSdk inited, components are available now,like logger, env and so on.")) + } + return ZhiUtil.zhiSdkObj + } +} + +export default ZhiUtil diff --git a/apps/theme/.eslintrc.cjs b/apps/theme/.eslintrc.cjs index 4f78c8db..55f5f2c7 100644 --- a/apps/theme/.eslintrc.cjs +++ b/apps/theme/.eslintrc.cjs @@ -7,7 +7,7 @@ module.exports = { es2021: true, }, - parser: "@typescript-eslint/parser", + parser: "vue-eslint-parser", parserOptions: { ecmaVersion: 12, @@ -20,16 +20,13 @@ module.exports = { plugins: ["@typescript-eslint", "prettier"], - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/recommended", - "prettier", - ], + extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"], rules: { // Note: you must disable the base rule as it can report incorrect errors semi: "off", quotes: "off", - "prettier/prettier": "error" + "@typescript-eslint/no-this-alias": "off", + "prettier/prettier": "error", }, -} +} \ No newline at end of file diff --git a/apps/theme/.gitattributes b/apps/theme/.gitattributes new file mode 100644 index 00000000..df3ddcba --- /dev/null +++ b/apps/theme/.gitattributes @@ -0,0 +1 @@ +*.json linguist-language=JSON-with-Comments \ No newline at end of file diff --git a/apps/theme/.stylelintrc.json b/apps/theme/.stylelintrc.json index e51e31c6..da2f7b67 100644 --- a/apps/theme/.stylelintrc.json +++ b/apps/theme/.stylelintrc.json @@ -4,7 +4,7 @@ "import-notation": "string", "string-quotes": "double", "selector-combinator-space-after": "always", - "custom-property-no-missing-var-function": false, + "custom-property-no-missing-var-function": null, "color-function-notation": "legacy", "value-list-comma-space-before": "never", "value-list-comma-space-after": "always", diff --git a/apps/theme/build.mts b/apps/theme/build.mts index cf38ca81..4c5c9341 100644 --- a/apps/theme/build.mts +++ b/apps/theme/build.mts @@ -1,7 +1,7 @@ // https://github.com/vitejs/vite/discussions/1736#discussioncomment-3229793 import { build, InlineConfig } from "vite" -import path from "path" +import path from "path"; /** * zhi 主题构建 @@ -31,6 +31,7 @@ class ZhiBuild { }, ], }, + plugins: [], build: { outDir: "../../", lib: { diff --git a/apps/theme/coverage/base.css b/apps/theme/coverage/base.css new file mode 100644 index 00000000..f418035b --- /dev/null +++ b/apps/theme/coverage/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/apps/theme/coverage/block-navigation.js b/apps/theme/coverage/block-navigation.js new file mode 100644 index 00000000..cc121302 --- /dev/null +++ b/apps/theme/coverage/block-navigation.js @@ -0,0 +1,87 @@ +/* eslint-disable */ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selecter that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/apps/theme/coverage/clover.xml b/apps/theme/coverage/clover.xml new file mode 100644 index 00000000..1dfe5db9 --- /dev/null +++ b/apps/theme/coverage/clover.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/apps/theme/coverage/coverage-final.json b/apps/theme/coverage/coverage-final.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/apps/theme/coverage/coverage-final.json @@ -0,0 +1 @@ +{} diff --git a/apps/theme/coverage/favicon.png b/apps/theme/coverage/favicon.png new file mode 100644 index 00000000..c1525b81 Binary files /dev/null and b/apps/theme/coverage/favicon.png differ diff --git a/apps/theme/coverage/index.html b/apps/theme/coverage/index.html new file mode 100644 index 00000000..206055b2 --- /dev/null +++ b/apps/theme/coverage/index.html @@ -0,0 +1,101 @@ + + + + + + Code coverage report for All files + + + + + + + + + +
+
+

All files

+
+ +
+ Unknown% + Statements + 0/0 +
+ + +
+ Unknown% + Branches + 0/0 +
+ + +
+ Unknown% + Functions + 0/0 +
+ + +
+ Unknown% + Lines + 0/0 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/apps/theme/coverage/prettify.css b/apps/theme/coverage/prettify.css new file mode 100644 index 00000000..b317a7cd --- /dev/null +++ b/apps/theme/coverage/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/apps/theme/coverage/prettify.js b/apps/theme/coverage/prettify.js new file mode 100644 index 00000000..b3225238 --- /dev/null +++ b/apps/theme/coverage/prettify.js @@ -0,0 +1,2 @@ +/* eslint-disable */ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/apps/theme/coverage/sort-arrow-sprite.png b/apps/theme/coverage/sort-arrow-sprite.png new file mode 100644 index 00000000..6ed68316 Binary files /dev/null and b/apps/theme/coverage/sort-arrow-sprite.png differ diff --git a/apps/theme/coverage/sorter.js b/apps/theme/coverage/sorter.js new file mode 100644 index 00000000..2bb296a8 --- /dev/null +++ b/apps/theme/coverage/sorter.js @@ -0,0 +1,196 @@ +/* eslint-disable */ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + if ( + row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()) + ) { + row.style.display = ''; + } else { + row.style.display = 'none'; + } + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/apps/theme/package.json b/apps/theme/package.json index 7d711f65..8e07a569 100644 --- a/apps/theme/package.json +++ b/apps/theme/package.json @@ -20,15 +20,23 @@ "watch:css": "stylus --watch theme.styl --out ../../theme.css", "build": "pnpm build:css && pnpm build:js", "build:css": "stylus --compress theme.styl --out ../../theme.css", - "build:js": "node --experimental-specifier-resolution=node --loader ts-node/esm build.mts" + "build:js": "node --experimental-specifier-resolution=node --loader ts-node/esm build.mts", + "lint": "eslint --ext .ts .", + "lint:fix": "eslint --fix --ext .ts .", + "lintcss": "stylelint *.styl --fix", + "lintcss:fix": "stylelint *.styl --fix", + "prettier": "prettier --write .", + "test": "vitest", + "coverage": "vitest run --coverage" }, "dependencies": { - "zhi-log": "^1.5.5" + "zhi-sdk": "^1.0.8" }, "devDependencies": { "@types/node": "16.11.7", "@typescript-eslint/eslint-plugin": "^5.54.1", "@typescript-eslint/parser": "^5.54.1", + "@vitest/coverage-c8": "^0.29.2", "eslint": "^8.36.0", "eslint-config-prettier": "^8.7.0", "eslint-plugin-prettier": "^4.2.1", @@ -40,7 +48,9 @@ "ts-node": "^10.9.1", "typescript": "^4.9.5", "vite": "^4.1.4", - "vite-plugin-eslint": "^1.8.1" + "vite-plugin-eslint": "^1.8.1", + "vitest": "^0.29.2", + "vue-eslint-parser": "^9.1.0" }, "keywords": [ "zhi", diff --git a/apps/theme/pnpm-lock.yaml b/apps/theme/pnpm-lock.yaml index f2b49698..5fd0e226 100644 --- a/apps/theme/pnpm-lock.yaml +++ b/apps/theme/pnpm-lock.yaml @@ -4,6 +4,7 @@ specifiers: '@types/node': 16.11.7 '@typescript-eslint/eslint-plugin': ^5.54.1 '@typescript-eslint/parser': ^5.54.1 + '@vitest/coverage-c8': ^0.29.2 eslint: ^8.36.0 eslint-config-prettier: ^8.7.0 eslint-plugin-prettier: ^4.2.1 @@ -16,15 +17,18 @@ specifiers: typescript: ^4.9.5 vite: ^4.1.4 vite-plugin-eslint: ^1.8.1 - zhi-log: ^1.5.5 + vitest: ^0.29.2 + vue-eslint-parser: ^9.1.0 + zhi-sdk: ^1.0.8 dependencies: - zhi-log: 1.5.5 + zhi-sdk: 1.0.8 devDependencies: '@types/node': 16.11.7 '@typescript-eslint/eslint-plugin': 5.54.1_4rfaf6mlw2mmutqjcopwvbftpu '@typescript-eslint/parser': 5.54.1_vgl77cfdswitgr47lm5swmv43m + '@vitest/coverage-c8': 0.29.2_vitest@0.29.2 eslint: 8.36.0 eslint-config-prettier: 8.7.0_eslint@8.36.0 eslint-plugin-prettier: 4.2.1_eqzx3hpkgx5nnvxls3azrcc7dm @@ -37,6 +41,8 @@ devDependencies: typescript: 4.9.5 vite: 4.1.4_y7fcyppcuzjteyaahq7ch36z2q vite-plugin-eslint: 1.8.1_eslint@8.36.0+vite@4.1.4 + vitest: 0.29.2_stylus@0.59.0 + vue-eslint-parser: 9.1.0_eslint@8.36.0 packages: @@ -65,6 +71,10 @@ packages: js-tokens: 4.0.0 dev: true + /@bcoe/v8-coverage/0.2.3: + resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} + dev: true + /@cspotcode/source-map-support/0.8.1: resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} engines: {node: '>=12'} @@ -363,6 +373,11 @@ packages: resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} dev: true + /@istanbuljs/schema/0.1.3: + resolution: {integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==} + engines: {node: '>=8'} + dev: true + /@jridgewell/resolve-uri/3.1.0: resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==} engines: {node: '>=6.0.0'} @@ -372,6 +387,13 @@ packages: resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} dev: true + /@jridgewell/trace-mapping/0.3.17: + resolution: {integrity: sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==} + dependencies: + '@jridgewell/resolve-uri': 3.1.0 + '@jridgewell/sourcemap-codec': 1.4.14 + dev: true + /@jridgewell/trace-mapping/0.3.9: resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} dependencies: @@ -424,6 +446,16 @@ packages: resolution: {integrity: sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ==} dev: true + /@types/chai-subset/1.3.3: + resolution: {integrity: sha512-frBecisrNGz+F4T6bcc+NLeolfiojh5FxW2klu669+8BARtyQv2C/GkNW6FUodVe4BroGMP/wER/YDGc7rEllw==} + dependencies: + '@types/chai': 4.3.4 + dev: true + + /@types/chai/4.3.4: + resolution: {integrity: sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==} + dev: true + /@types/eslint/8.21.1: resolution: {integrity: sha512-rc9K8ZpVjNcLs8Fp0dkozd5Pt2Apk1glO4Vgz8ix1u6yFByxfqo5Yavpy65o+93TAe24jr7v+eSBtFLvOQtCRQ==} dependencies: @@ -435,6 +467,10 @@ packages: resolution: {integrity: sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==} dev: true + /@types/istanbul-lib-coverage/2.0.4: + resolution: {integrity: sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==} + dev: true + /@types/json-schema/7.0.11: resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==} dev: true @@ -585,6 +621,49 @@ packages: eslint-visitor-keys: 3.3.0 dev: true + /@vitest/coverage-c8/0.29.2_vitest@0.29.2: + resolution: {integrity: sha512-NmD3WirQCeQjjKfHu4iEq18DVOBFbLn9TKVdMpyi5YW2EtnS+K22/WE+9/wRrepOhyeTxuEFgxUVkCAE1GhbnQ==} + peerDependencies: + vitest: '>=0.29.0 <1' + dependencies: + c8: 7.13.0 + picocolors: 1.0.0 + std-env: 3.3.2 + vitest: 0.29.2_stylus@0.59.0 + dev: true + + /@vitest/expect/0.29.2: + resolution: {integrity: sha512-wjrdHB2ANTch3XKRhjWZN0UueFocH0cQbi2tR5Jtq60Nb3YOSmakjdAvUa2JFBu/o8Vjhj5cYbcMXkZxn1NzmA==} + dependencies: + '@vitest/spy': 0.29.2 + '@vitest/utils': 0.29.2 + chai: 4.3.7 + dev: true + + /@vitest/runner/0.29.2: + resolution: {integrity: sha512-A1P65f5+6ru36AyHWORhuQBJrOOcmDuhzl5RsaMNFe2jEkoj0faEszQS4CtPU/LxUYVIazlUtZTY0OEZmyZBnA==} + dependencies: + '@vitest/utils': 0.29.2 + p-limit: 4.0.0 + pathe: 1.1.0 + dev: true + + /@vitest/spy/0.29.2: + resolution: {integrity: sha512-Hc44ft5kaAytlGL2PyFwdAsufjbdOvHklwjNy/gy/saRbg9Kfkxfh+PklLm1H2Ib/p586RkQeNFKYuJInUssyw==} + dependencies: + tinyspy: 1.1.1 + dev: true + + /@vitest/utils/0.29.2: + resolution: {integrity: sha512-F14/Uc+vCdclStS2KEoXJlOLAEyqRhnw0gM27iXw9bMTcyKRPJrQ+rlC6XZ125GIPvvKYMPpVxNhiou6PsEeYQ==} + dependencies: + cli-truncate: 3.1.0 + diff: 5.1.0 + loupe: 2.3.6 + picocolors: 1.0.0 + pretty-format: 27.5.1 + dev: true + /acorn-jsx/5.3.2_acorn@8.8.2: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -627,6 +706,11 @@ packages: engines: {node: '>=8'} dev: true + /ansi-regex/6.0.1: + resolution: {integrity: sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==} + engines: {node: '>=12'} + dev: true + /ansi-styles/3.2.1: resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} engines: {node: '>=4'} @@ -641,6 +725,16 @@ packages: color-convert: 2.0.1 dev: true + /ansi-styles/5.2.0: + resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} + engines: {node: '>=10'} + dev: true + + /ansi-styles/6.2.1: + resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} + engines: {node: '>=12'} + dev: true + /arg/4.1.3: resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} dev: true @@ -659,6 +753,10 @@ packages: engines: {node: '>=0.10.0'} dev: true + /assertion-error/1.1.0: + resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} + dev: true + /astral-regex/2.0.0: resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} engines: {node: '>=8'} @@ -692,6 +790,30 @@ packages: fill-range: 7.0.1 dev: true + /c8/7.13.0: + resolution: {integrity: sha512-/NL4hQTv1gBL6J6ei80zu3IiTrmePDKXKXOTLpHvcIWZTVYQlDhVWjjWvkhICylE8EwwnMVzDZugCvdx0/DIIA==} + engines: {node: '>=10.12.0'} + hasBin: true + dependencies: + '@bcoe/v8-coverage': 0.2.3 + '@istanbuljs/schema': 0.1.3 + find-up: 5.0.0 + foreground-child: 2.0.0 + istanbul-lib-coverage: 3.2.0 + istanbul-lib-report: 3.0.0 + istanbul-reports: 3.1.5 + rimraf: 3.0.2 + test-exclude: 6.0.0 + v8-to-istanbul: 9.1.0 + yargs: 16.2.0 + yargs-parser: 20.2.9 + dev: true + + /cac/6.7.14: + resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} + engines: {node: '>=8'} + dev: true + /callsites/3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} @@ -716,6 +838,19 @@ packages: engines: {node: '>=6'} dev: true + /chai/4.3.7: + resolution: {integrity: sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==} + engines: {node: '>=4'} + dependencies: + assertion-error: 1.1.0 + check-error: 1.0.2 + deep-eql: 4.1.3 + get-func-name: 2.0.0 + loupe: 2.3.6 + pathval: 1.1.1 + type-detect: 4.0.8 + dev: true + /chalk/2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -733,6 +868,26 @@ packages: supports-color: 7.2.0 dev: true + /check-error/1.0.2: + resolution: {integrity: sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==} + dev: true + + /cli-truncate/3.1.0: + resolution: {integrity: sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + slice-ansi: 5.0.0 + string-width: 5.1.2 + dev: true + + /cliui/7.0.4: + resolution: {integrity: sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==} + dependencies: + string-width: 4.2.3 + strip-ansi: 6.0.1 + wrap-ansi: 7.0.0 + dev: true + /color-convert/1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} dependencies: @@ -758,10 +913,18 @@ packages: resolution: {integrity: sha512-jeC1axXpnb0/2nn/Y1LPuLdgXBLH7aDcHu4KEKfqw3CUhX7ZpfBSlPKyqXE6btIgEzfWtrX3/tyBCaCvXvMkOw==} dev: true + /compare-versions/6.0.0-rc.1: + resolution: {integrity: sha512-cFhkjbGY1jLFWIV7KegECbfuyYPxSGvgGkdkfM+ibboQDoPwg2FRHm5BSNTOApiauRBzJIQH7qvOJs2sW5ueKQ==} + dev: false + /concat-map/0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} dev: true + /convert-source-map/1.9.0: + resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} + dev: true + /cosmiconfig/8.1.0: resolution: {integrity: sha512-0tLZ9URlPGU7JsKq0DQOQ3FoRsYX8xDZ7xMiATQfaiGMz7EHowNkbU9u1coAOmnh9p/1ySpm0RB3JNWRXM5GCg==} engines: {node: '>=14'} @@ -842,6 +1005,13 @@ packages: engines: {node: '>=0.10'} dev: true + /deep-eql/4.1.3: + resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==} + engines: {node: '>=6'} + dependencies: + type-detect: 4.0.8 + dev: true + /deep-is/0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} dev: true @@ -851,6 +1021,11 @@ packages: engines: {node: '>=0.3.1'} dev: true + /diff/5.1.0: + resolution: {integrity: sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==} + engines: {node: '>=0.3.1'} + dev: true + /dir-glob/3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -892,10 +1067,18 @@ packages: domhandler: 5.0.3 dev: true + /eastasianwidth/0.2.0: + resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} + dev: true + /emoji-regex/8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true + /emoji-regex/9.2.2: + resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} + dev: true + /entities/4.4.0: resolution: {integrity: sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==} engines: {node: '>=0.12'} @@ -937,6 +1120,11 @@ packages: '@esbuild/win32-x64': 0.16.17 dev: true + /escalade/3.1.1: + resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} + engines: {node: '>=6'} + dev: true + /escape-string-regexp/1.0.5: resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} engines: {node: '>=0.8.0'} @@ -1180,6 +1368,14 @@ packages: resolution: {integrity: sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==} dev: true + /foreground-child/2.0.0: + resolution: {integrity: sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==} + engines: {node: '>=8.0.0'} + dependencies: + cross-spawn: 7.0.3 + signal-exit: 3.0.7 + dev: true + /fs.realpath/1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} dev: true @@ -1196,6 +1392,15 @@ packages: resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} dev: true + /get-caller-file/2.0.5: + resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} + engines: {node: 6.* || 8.* || >= 10.*} + dev: true + + /get-func-name/2.0.0: + resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==} + dev: true + /glob-parent/5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -1297,6 +1502,10 @@ packages: lru-cache: 6.0.0 dev: true + /html-escaper/2.0.2: + resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} + dev: true + /html-tags/3.2.0: resolution: {integrity: sha512-vy7ClnArOZwCnqZgvv+ddgHgJiAFXe3Ge9ML5/mBctVJoUoYPCdxVucOywjDARn6CVoh3dRSFdPHy2sX80L0Wg==} engines: {node: '>=8'} @@ -1374,6 +1583,11 @@ packages: engines: {node: '>=8'} dev: true + /is-fullwidth-code-point/4.0.0: + resolution: {integrity: sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==} + engines: {node: '>=12'} + dev: true + /is-glob/4.0.3: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} @@ -1405,6 +1619,28 @@ packages: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true + /istanbul-lib-coverage/3.2.0: + resolution: {integrity: sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==} + engines: {node: '>=8'} + dev: true + + /istanbul-lib-report/3.0.0: + resolution: {integrity: sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==} + engines: {node: '>=8'} + dependencies: + istanbul-lib-coverage: 3.2.0 + make-dir: 3.1.0 + supports-color: 7.2.0 + dev: true + + /istanbul-reports/3.1.5: + resolution: {integrity: sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==} + engines: {node: '>=8'} + dependencies: + html-escaper: 2.0.2 + istanbul-lib-report: 3.0.0 + dev: true + /js-sdsl/4.3.0: resolution: {integrity: sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ==} dev: true @@ -1440,6 +1676,10 @@ packages: resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} dev: true + /jsonc-parser/3.2.0: + resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} + dev: true + /kind-of/6.0.3: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} @@ -1461,6 +1701,11 @@ packages: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} dev: true + /local-pkg/0.4.3: + resolution: {integrity: sha512-SFppqq5p42fe2qcZQqqEOiVRXl+WCP1MdT6k7BDEW1j++sp5fIY+/fdRQitvKgB5BrBcmrs5m/L0v2FrU5MY1g==} + engines: {node: '>=14'} + dev: true + /locate-path/5.0.0: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} engines: {node: '>=8'} @@ -1500,6 +1745,12 @@ packages: engines: {node: '>= 0.6.0'} dev: false + /loupe/2.3.6: + resolution: {integrity: sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==} + dependencies: + get-func-name: 2.0.0 + dev: true + /lru-cache/6.0.0: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} engines: {node: '>=10'} @@ -1507,6 +1758,13 @@ packages: yallist: 4.0.0 dev: true + /make-dir/3.1.0: + resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} + engines: {node: '>=8'} + dependencies: + semver: 6.3.0 + dev: true + /make-error/1.3.6: resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} dev: true @@ -1580,6 +1838,15 @@ packages: kind-of: 6.0.3 dev: true + /mlly/1.2.0: + resolution: {integrity: sha512-+c7A3CV0KGdKcylsI6khWyts/CYrGTrRVo4R/I7u/cUsy0Conxa6LUhiEzVKIw14lc2L5aiO4+SeVe4TeGRKww==} + dependencies: + acorn: 8.8.2 + pathe: 1.1.0 + pkg-types: 1.0.2 + ufo: 1.1.1 + dev: true + /ms/2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} dev: true @@ -1654,6 +1921,13 @@ packages: yocto-queue: 0.1.0 dev: true + /p-limit/4.0.0: + resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + yocto-queue: 1.0.0 + dev: true + /p-locate/4.1.0: resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} engines: {node: '>=8'} @@ -1714,6 +1988,14 @@ packages: engines: {node: '>=8'} dev: true + /pathe/1.1.0: + resolution: {integrity: sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==} + dev: true + + /pathval/1.1.1: + resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} + dev: true + /picocolors/1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} dev: true @@ -1723,6 +2005,14 @@ packages: engines: {node: '>=8.6'} dev: true + /pkg-types/1.0.2: + resolution: {integrity: sha512-hM58GKXOcj8WTqUXnsQyJYXdeAPbythQgEF3nTcEo+nkD49chjQ9IKm/QJy9xf6JakXptz86h7ecP2024rrLaQ==} + dependencies: + jsonc-parser: 3.2.0 + mlly: 1.2.0 + pathe: 1.1.0 + dev: true + /postcss-html/1.5.0: resolution: {integrity: sha512-kCMRWJRHKicpA166kc2lAVUGxDZL324bkj/pVOb6RhjB0Z5Krl7mN0AsVkBhVIRZZirY0lyQXG38HCVaoKVNoA==} engines: {node: ^12 || >=14} @@ -1802,6 +2092,15 @@ packages: hasBin: true dev: true + /pretty-format/27.5.1: + resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==} + engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} + dependencies: + ansi-regex: 5.0.1 + ansi-styles: 5.2.0 + react-is: 17.0.2 + dev: true + /punycode/2.3.0: resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} engines: {node: '>=6'} @@ -1816,6 +2115,10 @@ packages: engines: {node: '>=8'} dev: true + /react-is/17.0.2: + resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==} + dev: true + /read-pkg-up/7.0.1: resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} engines: {node: '>=8'} @@ -1848,6 +2151,11 @@ packages: engines: {node: '>=8'} dev: true + /require-directory/2.1.1: + resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} + engines: {node: '>=0.10.0'} + dev: true + /require-from-string/2.0.2: resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} engines: {node: '>=0.10.0'} @@ -1919,6 +2227,11 @@ packages: hasBin: true dev: true + /semver/6.3.0: + resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==} + hasBin: true + dev: true + /semver/7.3.8: resolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==} engines: {node: '>=10'} @@ -1939,10 +2252,18 @@ packages: engines: {node: '>=8'} dev: true + /siginfo/2.0.0: + resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} + dev: true + /signal-exit/3.0.7: resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} dev: true + /siyuan/0.3.12: + resolution: {integrity: sha512-Hcjn7Ujisayi9SW5o0DBtV2Jj/B8PKEXlIksJfbyeTYAtTBpgy++Fhy3nO0Pz1rJazadLt/dxKZ1X8JvlDgFHw==} + dev: false + /slash/3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -1957,6 +2278,14 @@ packages: is-fullwidth-code-point: 3.0.0 dev: true + /slice-ansi/5.0.0: + resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==} + engines: {node: '>=12'} + dependencies: + ansi-styles: 6.2.1 + is-fullwidth-code-point: 4.0.0 + dev: true + /source-map-js/1.0.2: resolution: {integrity: sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==} engines: {node: '>=0.10.0'} @@ -2002,6 +2331,14 @@ packages: resolution: {integrity: sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w==} dev: true + /stackback/0.0.2: + resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + dev: true + + /std-env/3.3.2: + resolution: {integrity: sha512-uUZI65yrV2Qva5gqE0+A7uVAvO40iPo6jGhs7s8keRfHCmtg+uB2X6EiLGCI9IgL1J17xGhvoOqSz79lzICPTA==} + dev: true + /string-width/4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -2011,6 +2348,15 @@ packages: strip-ansi: 6.0.1 dev: true + /string-width/5.1.2: + resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==} + engines: {node: '>=12'} + dependencies: + eastasianwidth: 0.2.0 + emoji-regex: 9.2.2 + strip-ansi: 7.0.1 + dev: true + /strip-ansi/6.0.1: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} @@ -2018,6 +2364,13 @@ packages: ansi-regex: 5.0.1 dev: true + /strip-ansi/7.0.1: + resolution: {integrity: sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==} + engines: {node: '>=12'} + dependencies: + ansi-regex: 6.0.1 + dev: true + /strip-indent/3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} @@ -2030,6 +2383,12 @@ packages: engines: {node: '>=8'} dev: true + /strip-literal/1.0.1: + resolution: {integrity: sha512-QZTsipNpa2Ppr6v1AmJHESqJ3Uz247MUS0OjrnnZjFAvEoWqxuyFuXn2xLgMtRnijJShAa1HL0gtJyUs7u7n3Q==} + dependencies: + acorn: 8.8.2 + dev: true + /style-search/0.1.0: resolution: {integrity: sha512-Dj1Okke1C3uKKwQcetra4jSuk0DqbzbYtXipzFlFMZtowbF1x7BKJwB9AayVMyFARvU8EDrZdcax4At/452cAg==} dev: true @@ -2207,10 +2566,33 @@ packages: strip-ansi: 6.0.1 dev: true + /test-exclude/6.0.0: + resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} + engines: {node: '>=8'} + dependencies: + '@istanbuljs/schema': 0.1.3 + glob: 7.2.3 + minimatch: 3.1.2 + dev: true + /text-table/0.2.0: resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} dev: true + /tinybench/2.4.0: + resolution: {integrity: sha512-iyziEiyFxX4kyxSp+MtY1oCH/lvjH3PxFN8PGCDeqcZWAJ/i+9y+nL85w99PxVzrIvew/GSkSbDYtiGVa85Afg==} + dev: true + + /tinypool/0.3.1: + resolution: {integrity: sha512-zLA1ZXlstbU2rlpA4CIeVaqvWq41MTWqLY3FfsAXgC8+f7Pk7zroaJQxDgxn1xNudKW6Kmj4808rPFShUlIRmQ==} + engines: {node: '>=14.0.0'} + dev: true + + /tinyspy/1.1.1: + resolution: {integrity: sha512-UVq5AXt/gQlti7oxoIg5oi/9r0WpF7DGEVwXgqWSMmyN16+e3tl5lIvTaOpJ3TAtu5xFzWccFRM4R5NaWHF+4g==} + engines: {node: '>=14.0.0'} + dev: true + /to-regex-range/5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -2275,6 +2657,11 @@ packages: prelude-ls: 1.2.1 dev: true + /type-detect/4.0.8: + resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} + engines: {node: '>=4'} + dev: true + /type-fest/0.18.1: resolution: {integrity: sha512-OIAYXk8+ISY+qTOwkHtKqzAuxchoMiD9Udx+FSGQDuiRR+PJKJHc2NJAXlbhkGwTt/4/nKZxELY1w3ReWOL8mw==} engines: {node: '>=10'} @@ -2301,6 +2688,10 @@ packages: hasBin: true dev: true + /ufo/1.1.1: + resolution: {integrity: sha512-MvlCc4GHrmZdAllBc0iUDowff36Q9Ndw/UzqmEKyrfSzokTd9ZCy1i+IIk5hrYKkjoYVQyNbrw7/F8XJ2rEwTg==} + dev: true + /uri-js/4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: @@ -2319,6 +2710,15 @@ packages: resolution: {integrity: sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==} dev: true + /v8-to-istanbul/9.1.0: + resolution: {integrity: sha512-6z3GW9x8G1gd+JIIgQQQxXuiJtCXeAjp6RaPEPLv62mH3iPHPxV6W3robxtCzNErRo6ZwTmzWhsbNvjyEBKzKA==} + engines: {node: '>=10.12.0'} + dependencies: + '@jridgewell/trace-mapping': 0.3.17 + '@types/istanbul-lib-coverage': 2.0.4 + convert-source-map: 1.9.0 + dev: true + /validate-npm-package-license/3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} dependencies: @@ -2326,6 +2726,27 @@ packages: spdx-expression-parse: 3.0.1 dev: true + /vite-node/0.29.2_y7fcyppcuzjteyaahq7ch36z2q: + resolution: {integrity: sha512-5oe1z6wzI3gkvc4yOBbDBbgpiWiApvuN4P55E8OI131JGrSuo4X3SOZrNmZYo4R8Zkze/dhi572blX0zc+6SdA==} + engines: {node: '>=v14.16.0'} + hasBin: true + dependencies: + cac: 6.7.14 + debug: 4.3.4 + mlly: 1.2.0 + pathe: 1.1.0 + picocolors: 1.0.0 + vite: 4.1.4_y7fcyppcuzjteyaahq7ch36z2q + transitivePeerDependencies: + - '@types/node' + - less + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + /vite-plugin-eslint/1.8.1_eslint@8.36.0+vite@4.1.4: resolution: {integrity: sha512-PqdMf3Y2fLO9FsNPmMX+//2BF5SF8nEWspZdgl4kSt7UvHDRHVVfHvxsD7ULYzZrJDGRxR81Nq7TOFgwMnUang==} peerDependencies: @@ -2374,6 +2795,79 @@ packages: fsevents: 2.3.2 dev: true + /vitest/0.29.2_stylus@0.59.0: + resolution: {integrity: sha512-ydK9IGbAvoY8wkg29DQ4ivcVviCaUi3ivuPKfZEVddMTenFHUfB8EEDXQV8+RasEk1ACFLgMUqAaDuQ/Nk+mQA==} + engines: {node: '>=v14.16.0'} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@vitest/browser': '*' + '@vitest/ui': '*' + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@vitest/browser': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + dependencies: + '@types/chai': 4.3.4 + '@types/chai-subset': 1.3.3 + '@types/node': 16.11.7 + '@vitest/expect': 0.29.2 + '@vitest/runner': 0.29.2 + '@vitest/spy': 0.29.2 + '@vitest/utils': 0.29.2 + acorn: 8.8.2 + acorn-walk: 8.2.0 + cac: 6.7.14 + chai: 4.3.7 + debug: 4.3.4 + local-pkg: 0.4.3 + pathe: 1.1.0 + picocolors: 1.0.0 + source-map: 0.6.1 + std-env: 3.3.2 + strip-literal: 1.0.1 + tinybench: 2.4.0 + tinypool: 0.3.1 + tinyspy: 1.1.1 + vite: 4.1.4_y7fcyppcuzjteyaahq7ch36z2q + vite-node: 0.29.2_y7fcyppcuzjteyaahq7ch36z2q + why-is-node-running: 2.2.2 + transitivePeerDependencies: + - less + - sass + - stylus + - sugarss + - supports-color + - terser + dev: true + + /vue-eslint-parser/9.1.0_eslint@8.36.0: + resolution: {integrity: sha512-NGn/iQy8/Wb7RrRa4aRkokyCZfOUWk19OP5HP6JEozQFX5AoS/t+Z0ZN7FY4LlmWc4FNI922V7cvX28zctN8dQ==} + engines: {node: ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: '>=6.0.0' + dependencies: + debug: 4.3.4 + eslint: 8.36.0 + eslint-scope: 7.1.1 + eslint-visitor-keys: 3.3.0 + espree: 9.5.0 + esquery: 1.5.0 + lodash: 4.17.21 + semver: 7.3.8 + transitivePeerDependencies: + - supports-color + dev: true + /which/1.3.1: resolution: {integrity: sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==} hasBin: true @@ -2389,11 +2883,29 @@ packages: isexe: 2.0.0 dev: true + /why-is-node-running/2.2.2: + resolution: {integrity: sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==} + engines: {node: '>=8'} + hasBin: true + dependencies: + siginfo: 2.0.0 + stackback: 0.0.2 + dev: true + /word-wrap/1.2.3: resolution: {integrity: sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==} engines: {node: '>=0.10.0'} dev: true + /wrap-ansi/7.0.0: + resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} + engines: {node: '>=10'} + dependencies: + ansi-styles: 4.3.0 + string-width: 4.2.3 + strip-ansi: 6.0.1 + dev: true + /wrappy/1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: true @@ -2406,6 +2918,11 @@ packages: signal-exit: 3.0.7 dev: true + /y18n/5.0.8: + resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} + engines: {node: '>=10'} + dev: true + /yallist/4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} dev: true @@ -2415,6 +2932,19 @@ packages: engines: {node: '>=10'} dev: true + /yargs/16.2.0: + resolution: {integrity: sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==} + engines: {node: '>=10'} + dependencies: + cliui: 7.0.4 + escalade: 3.1.1 + get-caller-file: 2.0.5 + require-directory: 2.1.1 + string-width: 4.2.3 + y18n: 5.0.8 + yargs-parser: 20.2.9 + dev: true + /yn/3.1.1: resolution: {integrity: sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==} engines: {node: '>=6'} @@ -2425,6 +2955,11 @@ packages: engines: {node: '>=10'} dev: true + /yocto-queue/1.0.0: + resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} + engines: {node: '>=12.20'} + dev: true + /zhi-env/1.8.2: resolution: {integrity: sha512-oMQX540mRNUa7w5IfvZSn06GLsNSK+2WcCBedpHRiA13k755L+1HlL9rAOReWg1xx2n4/2JelpQmiXIv/oHAKg==} dev: false @@ -2437,3 +2972,11 @@ packages: loglevel-plugin-prefix: 0.8.4 zhi-env: 1.8.2 dev: false + + /zhi-sdk/1.0.8: + resolution: {integrity: sha512-LZGDBvhsNtR1zZCCrFeu7bJhpADLIr1wD2m/EVhQ7Q286NS5ojkRdenzJxHc3Uz/ynpLf+sNKLyCYZdCnP2qpQ==} + dependencies: + compare-versions: 6.0.0-rc.1 + siyuan: 0.3.12 + zhi-log: 1.5.5 + dev: false diff --git a/apps/theme/src/Lifecycle.ts b/apps/theme/src/Lifecycle.ts new file mode 100644 index 00000000..89770512 --- /dev/null +++ b/apps/theme/src/Lifecycle.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import DependencyItem from "~/src/models/DependencyItem" +import pluginSystem from "~/src/plugin-system" + +/** + * zhi主题统一生命周期管理 + * + * @author terwer + * @since 1.0.0 + */ +class Lifecycle { + private _dynamicImports = [] + + get dynamicImports(): DependencyItem[] { + return this._dynamicImports + } + + public load() { + const allImports = [] + + const pluginSystemImports = this.loadPluginSystem() + const widgetsImports = this.loadWidgets() + const vendorImports = this.loadVendors() + + this._dynamicImports = allImports.concat(pluginSystemImports).concat(widgetsImports).concat(vendorImports) + } + + /** + * SiYuanPluginSystem + * + * @private + */ + private loadPluginSystem(): DependencyItem[] { + return pluginSystem.initPluginSystem() + } + + /** + * 加载挂件 + * + * @private + */ + private loadWidgets(): DependencyItem[] { + return [] + } + + /** + * 加载第三方库 + * + * @private + */ + private loadVendors(): DependencyItem[] { + return [] + } +} + +export default Lifecycle diff --git a/apps/theme/src/bootstrap.ts b/apps/theme/src/bootstrap.ts new file mode 100644 index 00000000..4f08035c --- /dev/null +++ b/apps/theme/src/bootstrap.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import Lifecycle from "~/src/Lifecycle" +import DependencyItem from "~/src/models/DependencyItem" + +/** + * zhi主题唯一激活入口 + * + * @author terwer + * @since 1.0.0 + */ +class Bootstrap { + private static lifecycle: Lifecycle + + static { + Bootstrap.lifecycle = new Lifecycle() + } + + /** + * 主题激活 + */ + public static async start(): Promise { + Bootstrap.lifecycle.load() + return Promise.resolve(Bootstrap.lifecycle.dynamicImports) + } +} + +export default Bootstrap diff --git a/apps/theme/src/enums/themeFromEnum.ts b/apps/theme/src/enums/themeFromEnum.ts new file mode 100644 index 00000000..d012f8e8 --- /dev/null +++ b/apps/theme/src/enums/themeFromEnum.ts @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +/** + * 主题来源 + * + * @author terwer + * @since 0.0.1 + */ +enum ThemeFromEnum { + ThemeFrom_Blog = "zhi-theme-blog", + ThemeFrom_Siyuan = "zhi-theme-siyuan", +} + +export default ThemeFromEnum diff --git a/apps/theme/src/index.ts b/apps/theme/src/index.ts index 359795f1..7da2c782 100644 --- a/apps/theme/src/index.ts +++ b/apps/theme/src/index.ts @@ -1,3 +1,32 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import ZhiUtil from "~/src/utils/ZhiUtil" +import Zhi from "~/src/zhi" +import path from "path" + /** * 主题通用类(由theme.js动态调用,除了单元测试之外请勿主动调用) * @@ -6,13 +35,64 @@ * @since 1.0.0 */ class Theme { + private readonly logger + private readonly common + private readonly siyuanApi + private readonly zhiTheme + + constructor() { + const zhiSdk = ZhiUtil.zhiSdk() + + this.logger = zhiSdk.getLogger() + this.common = zhiSdk.common + this.siyuanApi = zhiSdk.siyuanApi + this.zhiTheme = new Zhi() + } + /** * 主流程加载 * * @param runAs 运行模式 */ public async init(runAs?: any): Promise { - console.log("Theme inited.") + try { + // 初始化第三方依赖 + const dynamicImports = await this.zhiTheme.main([]) + for (const item of dynamicImports) { + const libpath = item.libpath + // 类型校验 + if (item.format !== "cjs" || !libpath.includes(".cjs")) { + this.logger.warn("Only cjs supported, skip this lib!", libpath) + continue + } + + // 运行环境校验 + if (runAs) { + if (runAs !== item.runAs) { + this.logger.warn( + this.common.strUtil.f("This lib can only run at {0}, skip!Lib is=>{1}", item.runAs, item.libpath) + ) + continue + } + } + + this.logger.info("Loading dependency=>", libpath) + + let lib + if (this.common.browserUtil.isInBrowser) { + const importPath = path.join(this.siyuanApi.siyuanUtil.ZHI_THEME_DIST_PATH(), libpath) + lib = this.siyuanApi.siyuanUtil.requireLib(importPath) + } + + // 如果有初始化方法,进行初始化 + if (lib && lib.init) { + await lib.init() + } + } + this.logger.info("Theme inited.") + } catch (e) { + this.logger.error("Theme load error=>", e) + } } } diff --git a/apps/theme/src/models/DependencyItem.ts b/apps/theme/src/models/DependencyItem.ts new file mode 100644 index 00000000..02912b6f --- /dev/null +++ b/apps/theme/src/models/DependencyItem.ts @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +/** + * 依赖项类型定义 + * + * @author terwer + * @since 1.0.0 + */ +class DependencyItem { + libpath: string + format: "cjs" | "esm" | "js" + importType: "require" | "import" + runAs: "browser" | "node" | "electron" | "both" + + constructor() { + this.libpath = "" + this.format = "cjs" + this.importType = "require" + this.runAs = "both" + } +} + +export default DependencyItem diff --git a/apps/theme/src/plugin-system/index.ts b/apps/theme/src/plugin-system/index.ts new file mode 100644 index 00000000..08753df7 --- /dev/null +++ b/apps/theme/src/plugin-system/index.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import DependencyItem from "~/src/models/DependencyItem" + +/** + * 插件系统注册 + * + * @author terwer + * @since 1.0.0 + */ +const initPluginSystem = (): DependencyItem[] => { + return [ + { + libpath: "/plugin-system/plugin-system-hook.cjs", + format: "cjs", + importType: "require", + runAs: "electron", + }, + ] +} + +const pluginSystem = { + initPluginSystem, +} + +export default pluginSystem diff --git a/apps/theme/src/plugin-system/plugin-system-hook.ts b/apps/theme/src/plugin-system/plugin-system-hook.ts new file mode 100644 index 00000000..6ba695a4 --- /dev/null +++ b/apps/theme/src/plugin-system/plugin-system-hook.ts @@ -0,0 +1,205 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import ZhiUtil from "~/src/utils/ZhiUtil" +import HackPluginSystem from "~/src/plugin-system/pluginSystemUtil" + +/** + * 插件系统入口(由theme.js动态调用,请勿主动调用) + * vite构建配置:config/vite.cjs.config.plugin.system.hook + * + * @author terwer + * @since 1.0.0 + */ +class PluginSystemHook { + private readonly logger + private readonly common + private readonly siyuanApi + + private readonly fs + private readonly path + + private readonly hack + + constructor() { + const zhiSdk = ZhiUtil.zhiSdk() + + this.logger = zhiSdk.getLogger() + this.common = zhiSdk.common + this.siyuanApi = zhiSdk.siyuanApi + + this.fs = this.common.cjsUtil.safeRequire("fs") + this.path = this.common.cjsUtil.safeRequire("path") + + this.hack = new HackPluginSystem() + } + + /** + * 获取插件同步信息 + * + * @param p 插件系统对象 + * @param zhiPlugin 插件对象 + */ + getOldPluginInfo(p: any, zhiPlugin: any) { + let isSynced = false + let isUpdate = false + let oldVersion = this.hack.OLD_VERSION_ZERO + + const plugins = p.pslm.storageMangager.thirdPartyPlugins + for (const item of plugins) { + // this.logger.debug("Plugin=>", item) + // 不是当前插件跳过 + if (zhiPlugin.name !== item.name) { + continue + } + + // 当前插件有新版本 + if (this.common.versionUtil.greater(zhiPlugin.version, item.version)) { + isUpdate = true + } + + oldVersion = item.version + isSynced = true + } + + return { isSynced, oldVersion, isUpdate } + } + + async syncZhiPlugins(p: any) { + this.logger.info("Start syncing zhi plugins ...") + + // 主题插件目录 + const zhiPluginsPath = this.path.join(this.siyuanApi.siyuanUtil.ZHI_THEME_PATH(), this.hack.ZHI_PLUGIN_FOLDER) + this.logger.debug("Zhi plugins folder=>", zhiPluginsPath) + + // 插件系统默认目录 + const pluginsPath = this.path.join(this.siyuanApi.siyuanUtil.SIYUAN_DATA_PATH(), this.hack.PLUGIN_FOLDER) + this.logger.debug("Plugins folder=>", pluginsPath) + + let syncedCount = 0 + let zhiPlugins: any = [] + // 未找到主题差距,不同步 + if (!this.fs.existsSync(zhiPluginsPath)) { + this.logger.warn("No zhi plugins found, stop!") + } else { + // 扫描插件并同步 + zhiPlugins = await this.hack.scanPlugins(zhiPluginsPath) + // this.logger.debug("zhiPlugins=>", zhiPlugins) + for (const item of zhiPlugins) { + const pluginBasename = this.path.basename(item) + const from = item + const to = this.path.join(pluginsPath, pluginBasename) + this.logger.debug(this.common.strUtil.f("Try syncing zhi plugin {0}", pluginBasename)) + + const manifest = await this.hack.getManifest(this.path.join(item, this.hack.MANIFEST)) + // this.logger.debug("ZhiPlugin=>", manifest) + + const oldPluginInfo = this.getOldPluginInfo(p, manifest) + const oldVersion = oldPluginInfo.oldVersion + this.logger.info( + this.common.strUtil.f( + "Plugin status : [{0}] isSynced=>{1}, isUpdate=>{2}, forceUpdate=>{3}, version Info: {4} -> {5}", + pluginBasename, + oldPluginInfo.isSynced, + oldPluginInfo.isUpdate, + manifest.forceUpdate, + oldVersion, + manifest.version + ) + ) + + // 同步需满足下面条件 + // 1. 未同步过或者有新版本 + // 2. 新旧插件注册信息目录均保持一致 + if (!oldPluginInfo.isSynced) { + // 未同步过,但是目标目录已存在 + if (this.fs.existsSync(to)) { + throw new Error(this.common.strUtil.f("Expected forder already exists=>{0}", to)) + } + + this.common.strUtil.f("Do syncing, please wait...") + this.common.nodeUtil.copyFolderSync(from, to) + syncedCount++ + } else if (oldPluginInfo.isSynced && oldPluginInfo.isUpdate) { + // 新插件目录不一致,但是有版本号 + if (!this.fs.existsSync(to)) { + throw new Error( + this.common.strUtil.f( + "Conflict plugin exists, manifest exists but dest folder is not correct with original, please fix plugin folder name.Expected forder is=>{0}", + to + ) + ) + } + + this.common.strUtil.f("Do syncing, please wait...") + this.common.nodeUtil.copyFolderSync(from, to) + syncedCount++ + } else if (manifest.forceUpdate) { + this.logger.warn( + this.common.strUtil.f( + "Find forceUpdate flag in manifest.json, try forcing update plugin, [{0}] {1}.This flag is development only, before publish plugin, you should remove this flag from manifest.json!", + pluginBasename, + manifest.version + ) + ) + + this.common.nodeUtil.rmFolder(to) + this.common.nodeUtil.copyFolderSync(from, to) + syncedCount++ + } else { + this.logger.debug( + this.common.strUtil.f("Already synced and the latest version [{0}] {1}", pluginBasename, manifest.version) + ) + } + } + } + + this.logger.info( + this.common.strUtil.f( + "Zhi theme plugins Synced.Scaned {0}, synced {1} plugin(s).", + zhiPlugins.length, + syncedCount + ) + ) + + if (syncedCount > 0) { + this.logger.warn( + this.common.strUtil.f("Synced {0} zhi plugins, you need to reload siyuan to take effect.", syncedCount) + ) + } + } + + async init() { + await this.hack.initPluginSystem() + + const sys = await this.hack.getPluginSystem() + await this.syncZhiPlugins(sys) + + this.logger.info("PluginSystemHook inited.") + } +} + +const pluginSystemHook = new PluginSystemHook() +export default pluginSystemHook diff --git a/apps/theme/src/plugin-system/pluginSystemUtil.ts b/apps/theme/src/plugin-system/pluginSystemUtil.ts new file mode 100644 index 00000000..55750dce --- /dev/null +++ b/apps/theme/src/plugin-system/pluginSystemUtil.ts @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +// 警告⚠️:请勿在非思源笔记Electron环境调用此文件中的任何方法 + +import ZhiUtil from "~/src/utils/ZhiUtil" + +/** + * hack插件系统的某些功能 + * + * @author terwer + * @since 1.0.0 + */ +class HackPluginSystem { + private readonly logger + private readonly common + private readonly siyuanApi + + private readonly fs + private readonly path + + public readonly ZHI_PLUGIN_FOLDER = "zhi-plugins" + public readonly PLUGIN_FOLDER = "plugins" + public readonly MANIFEST = "manifest.json" + private readonly SCRIPT = "main.js" + + public SIYUAN_ZHI_THEME_PLUGIN_PATH + + public OLD_VERSION_ZERO = "0.0.0" + + constructor() { + const zhiSdk = ZhiUtil.zhiSdk() + + this.logger = zhiSdk.getLogger() + this.common = zhiSdk.common + this.siyuanApi = zhiSdk.siyuanApi + + this.fs = this.common.cjsUtil.safeRequire("fs") + this.path = this.common.cjsUtil.safeRequire("path") + + this.SIYUAN_ZHI_THEME_PLUGIN_PATH = this.path.join( + this.path.join(this.siyuanApi.siyuanUtil.SIYUAN_DATA_PATH(), "dist-cjs") + ) + } + public getPluginSystem = () => { + return this.siyuanApi.siyuanUtil.syWin().pluginSystem + } + public getPluginSystemVersion = () => { + return this.siyuanApi.siyuanUtil.syWin().pluginSystemVersion + } + + isDir(p: any) { + return this.fs.statSync(p).isDirectory() + } + + isExists(p: any) { + try { + this.fs.statSync(p) + return true + } catch (e) { + return false + } + } + + getFileContent = async (f: any) => { + const that = this + return new Promise((resolve, reject) => { + that.fs.readFile(f, (err: any, data: any) => { + if (err) { + reject(err) + return + } + return resolve(data.toString("utf8")) + }) + }) + } + + getManifest = async (manifest: any) => { + const content: any = await this.getFileContent(manifest) + try { + return JSON.parse(content) + } catch (e) { + this.logger.error("Lading manifest: " + manifest, e) + return null + } + } + + async scanPlugins(pluginFolder: string) { + const that = this + + return new Promise((resolve, reject) => { + that.fs.readdir(pluginFolder, (err: any, files: any) => { + if (err) { + that.logger.error(err) + resolve([]) + return + } + resolve( + files + .filter((f: any) => { + return ( + this.isDir(that.path.join(pluginFolder, f)) && + this.isExists(that.path.join(pluginFolder, f, that.MANIFEST)) && + this.isExists(that.path.join(pluginFolder, f, that.SCRIPT)) + ) + }) + ?.map((g: any) => that.path.resolve(pluginFolder, g)) || [] + ) + }) + }) + } + + public async initPluginSystem() { + const pluginSystem = await this.getPluginSystem() + if (pluginSystem) { + this.logger.warn("Plugin system already loaded by snapshots, ignore initiation.") + this.logger.warn("Loaded plugin system version is ", this.getPluginSystemVersion()) + return + } + + try { + this.logger.info("Undetected plugin system,initiating plugin system...") + + const data = this.fs.readFileSync( + this.path.join(this.siyuanApi.siyuanUtil.getCrossPlatformAppDataFolder(), ".siyuan", "plugin.js") + ) + const script = data.toString("utf8") + this.logger.info("Local plugin system found, loading...") + eval(script) + } catch (e) { + this.logger.info("Local plugin system not found, load online", e) + return fetch("https://gitee.com/zuoez02/siyuan-plugin-system/raw/main/main.js", { cache: "no-cache" }) + .then((res) => res.text()) + .then((sc) => { + this.siyuanApi.siyuanUtil.syWin().siyuanPluginScript = sc + eval(sc) + }) + } + + const sysv = this.getPluginSystemVersion() + this.logger.info(this.common.strUtil.f("Plugin system initiation finished=>{0}.", sysv)) + } +} + +export default HackPluginSystem diff --git a/apps/theme/src/utils/Config.ts b/apps/theme/src/utils/Config.ts new file mode 100644 index 00000000..585b13d8 --- /dev/null +++ b/apps/theme/src/utils/Config.ts @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +/** + * zhi 主题通用常量配置 + * + * @author terwer + * @since 1.0.0 + */ +class Config {} +export default Config diff --git a/apps/theme/src/utils/ZhiUtil.ts b/apps/theme/src/utils/ZhiUtil.ts new file mode 100644 index 00000000..34705aad --- /dev/null +++ b/apps/theme/src/utils/ZhiUtil.ts @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import ZhiSdk from "zhi-sdk" +import Env from "zhi-env" + +/** + * 工具类统一入口 + * + * @author terwer + * @since 1.0.0 + */ +class ZhiUtil { + private static zhiSdkObj: ZhiSdk + public static zhiSdk() { + if (!ZhiUtil.zhiSdkObj) { + const env = new Env(import.meta.env) + ZhiUtil.zhiSdkObj = new ZhiSdk(env) + const logger = ZhiUtil.zhiSdkObj.getLogger() + const common = ZhiUtil.zhiSdkObj.common + logger.info(common.strUtil.f("ZhiSdk inited, components are available now,like logger, env and so on.")) + } + return ZhiUtil.zhiSdkObj + } +} + +export default ZhiUtil diff --git a/apps/theme/src/zhi-plugins/zhi-blog-plugin/manifest.json b/apps/theme/src/zhi-plugins/zhi-blog-plugin/manifest.json new file mode 100644 index 00000000..17da4be6 --- /dev/null +++ b/apps/theme/src/zhi-plugins/zhi-blog-plugin/manifest.json @@ -0,0 +1,7 @@ +{ + "name": "zhiBlogPlugin", + "author": "terwer", + "url": "https://github.com/terwer/zhi", + "version": "1.0.0", + "forceUpdate": true +} diff --git a/apps/theme/src/zhi-plugins/zhi-blog-plugin/zhi-blog-plugin.ts b/apps/theme/src/zhi-plugins/zhi-blog-plugin/zhi-blog-plugin.ts new file mode 100644 index 00000000..57927da0 --- /dev/null +++ b/apps/theme/src/zhi-plugins/zhi-blog-plugin/zhi-blog-plugin.ts @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import siyuan from "siyuan" +import { IPluginCommand } from "siyuan/types" +import ZhiUtil from "~/src/utils/ZhiUtil" + +const Plugin = siyuan.Plugin + +class ZhiBlogBlogPlugin extends Plugin { + private logger + private el!: HTMLElement + + constructor() { + super() + this.logger = ZhiUtil.zhiSdk().getLogger() + } + + onload() { + this.el = document.createElement("button") + this.el.innerText = "ZhiBlog" + siyuan.clientApi.addToolbarRight(this.el) + this.logger.info("ZhiBlogPlugin load") + } + + onunload() { + this.logger.info("ZhiBlogPlugin unload") + } + + registerCommand(command: IPluginCommand) { + this.logger.info("ZhiBlogPlugin registerCommand", command) + } +} + +export default ZhiBlogBlogPlugin diff --git a/apps/theme/src/zhi.ts b/apps/theme/src/zhi.ts new file mode 100644 index 00000000..d3d46c1c --- /dev/null +++ b/apps/theme/src/zhi.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import { version } from "~/package.json" +import ThemeFromEnum from "~/src/enums/themeFromEnum" +import DependencyItem from "~/src/models/DependencyItem" +import ZhiUtil from "~/src/utils/ZhiUtil" +import Bootstrap from "~/src/bootstrap" + +/** + * 主题入口 + * + * @author terwer + * @since 1.0.0 + */ +class Zhi { + private readonly logger + private readonly common + + constructor() { + const zhiSdk = ZhiUtil.zhiSdk() + + this.logger = zhiSdk.getLogger() + this.common = zhiSdk.common + } + + public async main(args: string[]): Promise { + this.logger.debug(this.common.strUtil.f("Parsing args <{0}>", args)) + this.hello(ThemeFromEnum.ThemeFrom_Siyuan) + return await Bootstrap.start() + } + + public hello(from: string): void { + this.logger.info(this.common.strUtil.f("Hello, {0} {1} v{2}! You are from {3}", "zhi", "theme", version, from)) + } +} + +// 默认支持esm +export default Zhi diff --git a/apps/theme/test/theme.test.ts b/apps/theme/test/theme.test.ts new file mode 100644 index 00000000..1488375d --- /dev/null +++ b/apps/theme/test/theme.test.ts @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import { describe, it } from "vitest" +import Theme from "~/src" + +describe("test theme", () => { + it("test main", async () => { + const theme = new Theme() + await theme.init("node") + }) +}) diff --git a/apps/theme/tsdoc.json b/apps/theme/tsdoc.json new file mode 100644 index 00000000..aa5a0b40 --- /dev/null +++ b/apps/theme/tsdoc.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + + // Include the definitions that are required for API Extractor + "extends": ["@microsoft/api-extractor/extends/tsdoc-base.json"], + + // noStandardTags: false, + + "tagDefinitions": [ + // Define a custom tag and specify how it should be parsed + { + "tagName": "@author", + "syntaxKind": "block", + "allowMultiple": false + }, + { + "tagName": "@since", + "syntaxKind": "block", + "allowMultiple": false + }, + { + "tagName": "@private", + "syntaxKind": "block", + "allowMultiple": false + }, + { + "tagName": "@protected", + "syntaxKind": "block", + "allowMultiple": false + } + ], + + "supportForTags": { + // Indicate that the custom tag is supported by your tooling. (Without this, warnings may + // be reported saying that the tag is unsupported.) + "@author": true, + "@since": true, + "@private": true, + "@protected": true + } +} diff --git a/apps/theme/vite-env.d.ts b/apps/theme/vite-env.d.ts new file mode 100644 index 00000000..332221aa --- /dev/null +++ b/apps/theme/vite-env.d.ts @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +/// + +/** + * 预定义的环境变量 + * + * @author terwer + * @since 1.0.0 + */ +interface ImportMetaEnv { + VITE_LOG_STACK_SIZE: number +} + +/** + * 环境变量定义 + */ +interface ImportMeta { + readonly env: ImportMetaEnv +} diff --git a/apps/theme/vite.config.ts b/apps/theme/vite.config.ts new file mode 100644 index 00000000..2f80f397 --- /dev/null +++ b/apps/theme/vite.config.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2023, Terwer . All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Terwer designates this + * particular file as subject to the "Classpath" exception as provided + * by Terwer in the LICENSE file that accompanied this code. + * + * This code 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 General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com + * or visit www.terwer.space if you need additional information or have any + * questions. + */ + +import path from "path" +import { defineConfig } from "vite" + +// 警告⚠️:此文件仅用于单元测试,项目构建统一使用 build.mts + +export default defineConfig({ + resolve: { + alias: [ + { + find: "~", + replacement: path.resolve(__dirname, ""), + }, + ], + }, +}) diff --git a/theme.js b/theme.js index 5fd56090..5f40c236 100644 --- a/theme.js +++ b/theme.js @@ -1,12 +1,937 @@ "use strict"; +var __defProp = Object.defineProperty; +var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; +var __publicField = (obj, key, value) => { + __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); + return value; +}; +const _ = require("path"); +const I = require("fs"); +var __getOwnPropNames = Object.getOwnPropertyNames; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var J = Object.defineProperty; +var Q = (n, e, t) => e in n ? J(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t; +var g = (n, e, t) => (Q(n, typeof e != "symbol" ? e + "" : e, t), t); +var ee = Object.defineProperty; +var te = (n, e, t) => e in n ? ee(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t; +var b = (n, e, t) => (te(n, typeof e != "symbol" ? e + "" : e, t), t); +var $ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; +var N = {}; +var ne = { + get exports() { + return N; + }, + set exports(n) { + N = n; + } +}; +(function(n) { + (function(e, t) { + n.exports ? n.exports = t() : e.log = t(); + })($, function() { + var e = function() { + }, t = "undefined", r = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), s = ["trace", "debug", "info", "warn", "error"]; + function o(a, m) { + var v = a[m]; + if (typeof v.bind == "function") + return v.bind(a); + try { + return Function.prototype.bind.call(v, a); + } catch { + return function() { + return Function.prototype.apply.apply(v, [a, arguments]); + }; + } + } + function i() { + console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace(); + } + function d(a) { + return a === "debug" && (a = "log"), typeof console === t ? false : a === "trace" && r ? i : console[a] !== void 0 ? o(console, a) : console.log !== void 0 ? o(console, "log") : e; + } + function E(a, m) { + for (var v = 0; v < s.length; v++) { + var u = s[v]; + this[u] = v < a ? e : this.methodFactory(u, a, m); + } + this.log = this.debug; + } + function w(a, m, v) { + return function() { + typeof console !== t && (E.call(this, m, v), this[a].apply(this, arguments)); + }; + } + function l(a, m, v) { + return d(a) || w.apply(this, arguments); + } + function f(a, m, v) { + var u = this, x; + m = m ?? "WARN"; + var h = "loglevel"; + typeof a == "string" ? h += ":" + a : typeof a == "symbol" && (h = void 0); + function D(c) { + var S = (s[c] || "silent").toUpperCase(); + if (!(typeof window === t || !h)) { + try { + window.localStorage[h] = S; + return; + } catch { + } + try { + window.document.cookie = encodeURIComponent(h) + "=" + S + ";"; + } catch { + } + } + } + function U() { + var c; + if (!(typeof window === t || !h)) { + try { + c = window.localStorage[h]; + } catch { + } + if (typeof c === t) + try { + var S = window.document.cookie, A = S.indexOf(encodeURIComponent(h) + "="); + A !== -1 && (c = /^([^;]+)/.exec(S.slice(A))[1]); + } catch { + } + return u.levels[c] === void 0 && (c = void 0), c; + } + } + function V() { + if (!(typeof window === t || !h)) { + try { + window.localStorage.removeItem(h); + return; + } catch { + } + try { + window.document.cookie = encodeURIComponent(h) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC"; + } catch { + } + } + } + u.name = a, u.levels = { + TRACE: 0, + DEBUG: 1, + INFO: 2, + WARN: 3, + ERROR: 4, + SILENT: 5 + }, u.methodFactory = v || l, u.getLevel = function() { + return x; + }, u.setLevel = function(c, S) { + if (typeof c == "string" && u.levels[c.toUpperCase()] !== void 0 && (c = u.levels[c.toUpperCase()]), typeof c == "number" && c >= 0 && c <= u.levels.SILENT) { + if (x = c, S !== false && D(c), E.call(u, c, a), typeof console === t && c < u.levels.SILENT) + return "No console available for logging"; + } else + throw "log.setLevel() called with invalid level: " + c; + }, u.setDefaultLevel = function(c) { + m = c, U() || u.setLevel(c, false); + }, u.resetLevel = function() { + u.setLevel(m, false), V(); + }, u.enableAll = function(c) { + u.setLevel(u.levels.TRACE, c); + }, u.disableAll = function(c) { + u.setLevel(u.levels.SILENT, c); + }; + var L = U(); + L == null && (L = m), u.setLevel(L, false); + } + var p = new f(), y = {}; + p.getLogger = function(a) { + if (typeof a != "symbol" && typeof a != "string" || a === "") + throw new TypeError("You must supply a name when creating a logger."); + var m = y[a]; + return m || (m = y[a] = new f(a, p.getLevel(), p.methodFactory)), m; + }; + var R = typeof window !== t ? window.log : void 0; + return p.noConflict = function() { + return typeof window !== t && window.log === p && (window.log = R), p; + }, p.getLoggers = function() { + return y; + }, p.default = p, p; + }); +})(ne); +var P = {}; +var re = { + get exports() { + return P; + }, + set exports(n) { + P = n; + } +}; +(function(n) { + (function(e, t) { + n.exports ? n.exports = t() : e.prefix = t(e); + })($, function(e) { + var t = function(l) { + for (var f = 1, p = arguments.length, y; f < p; f++) + for (y in arguments[f]) + Object.prototype.hasOwnProperty.call(arguments[f], y) && (l[y] = arguments[f][y]); + return l; + }, r = { + template: "[%t] %l:", + levelFormatter: function(l) { + return l.toUpperCase(); + }, + nameFormatter: function(l) { + return l || "root"; + }, + timestampFormatter: function(l) { + return l.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1"); + }, + format: void 0 + }, s, o = {}, i = function(l) { + if (!l || !l.getLogger) + throw new TypeError("Argument is not a root logger"); + s = l; + }, d = function(l, f) { + if (!l || !l.setLevel) + throw new TypeError("Argument is not a logger"); + var p = l.methodFactory, y = l.name || "", R = o[y] || o[""] || r; + function a(m, v, u) { + var x = p(m, v, u), h = o[u] || o[""], D = h.template.indexOf("%t") !== -1, U = h.template.indexOf("%l") !== -1, V = h.template.indexOf("%n") !== -1; + return function() { + for (var L = "", c = arguments.length, S = Array(c), A = 0; A < c; A++) + S[A] = arguments[A]; + if (y || !o[u]) { + var k = h.timestampFormatter(new Date()), j = h.levelFormatter(m), Z = h.nameFormatter(u); + h.format ? L += h.format(j, Z, k) : (L += h.template, D && (L = L.replace(/%t/, k)), U && (L = L.replace(/%l/, j)), V && (L = L.replace(/%n/, Z))), S.length && typeof S[0] == "string" ? S[0] = L + " " + S[0] : S.unshift(L); + } + x.apply(void 0, S); + }; + } + return o[y] || (l.methodFactory = a), f = f || {}, f.template && (f.format = void 0), o[y] = t({}, R, f), l.setLevel(l.getLevel()), s || l.warn( + "It is necessary to call the function reg() of loglevel-plugin-prefix before calling apply. From the next release, it will throw an error. See more: https://github.com/kutuluk/loglevel-plugin-prefix/blob/master/README.md" + ), l; + }, E = { + reg: i, + apply: d + }, w; + return e && (w = e.prefix, E.noConflict = function() { + return e.prefix === E && (e.prefix = w), E; + }), E; + }); +})(re); +var C = class { +}; +b(C, "LOG_LEVEL_KEY", "VITE_LOG_LEVEL"), b(C, "LOG_PREFIX_KEY", "VITE_LOG_PREFIX"); +var T = /* @__PURE__ */ ((n) => (n.LOG_LEVEL_DEBUG = "DEBUG", n.LOG_LEVEL_INFO = "INFO", n.LOG_LEVEL_WARN = "WARN", n.LOG_LEVEL_ERROR = "ERROR", n))(T || {}); +function oe() { + const n = Error.prepareStackTrace; + Error.prepareStackTrace = (t, r) => r; + const e = new Error().stack.slice(1); + return Error.prepareStackTrace = n, e; +} +var F = class { + /** + * 解析日志级别为枚举 + * + * @param enumObj 枚举对象 + * @param value 配置的值 + */ + static stringToEnumValue(e, t) { + return e[Object.keys(e).filter((r) => e[r].toString() === t)[0]]; + } + /** + * 获取配置的日志级别 + */ + static getEnvLevel(e) { + if (!e) + return; + const t = e.getEnvOrDefault(C.LOG_LEVEL_KEY, T.LOG_LEVEL_INFO), r = F.stringToEnumValue(T, t.toUpperCase()); + return r || console.warn( + "[zhi-log] LOG_LEVEL is invalid in you .env file.Must be either debug, info, warn or error, fallback to default info level" + ), r; + } + /** + * 获取默认日志 + */ + static getEnvLogger(e) { + if (e) + return e.getEnv(C.LOG_PREFIX_KEY); + } +}; +var ie = class { + constructor(e, t, r) { + b(this, "consoleLogger", "console"), b(this, "stackSize", 1), b(this, "getLogger", (i) => { + let d; + if (i) + d = i; + else { + const E = oe(), w = []; + for (let l = 0; l < E.length; l++) { + const f = E[l], p = f.getFileName() ?? "none"; + if (!p.includes(".ts") && !p.includes(".js") && !p.includes(".cjs") && !p.includes(".mjs") && !p.includes(".vue") && !p.includes(".tsx")) + continue; + if (l > this.stackSize - 1) + break; + const y = p + "-" + f.getLineNumber() + ":" + f.getColumnNumber(); + w.push(y); + } + E.length > 0 && (d = w.join(" -> ")); + } + return (!d || d.trim().length === 0) && (d = this.consoleLogger), N.getLogger(d); + }), this.stackSize = 1; + let s; + e ? s = e : s = F.getEnvLevel(r), s = s ?? T.LOG_LEVEL_INFO, N.setLevel(s); + const o = { + gray: (i) => i.toString(), + green: (i) => i.toString(), + yellow: (i) => i.toString(), + red: (i) => i.toString() + }; + P.reg(N), P.apply(N, { + format(i, d, E) { + const w = ["[" + (t ?? F.getEnvLogger(r) ?? "zhi") + "]"]; + switch (w.push(o.gray("[") + o.green(E).toString() + o.gray("]")), i) { + case T.LOG_LEVEL_DEBUG: + w.push(o.gray(i.toUpperCase().toString())); + break; + case T.LOG_LEVEL_INFO: + w.push(o.green(i.toUpperCase().toString())); + break; + case T.LOG_LEVEL_WARN: + w.push(o.yellow(i.toUpperCase().toString())); + break; + case T.LOG_LEVEL_ERROR: + w.push(o.red(i.toUpperCase().toString())); + break; + } + return w.push(o.green(d).toString()), w.push(o.gray(":")), w.join(" "); + } + }); + } + /** + * 设置输出栈的深度,默认1 + * + * @param stackSize 栈的深度 + */ + setStackSize(e) { + this.stackSize = e ?? 1; + } +}; +var se = class { + /** + * 默认日志级别 + * + * @param level - 可选,未设置默认INFO + * @param sign - 可选前缀,默认zhi + * @param env - 可选环境变量实例 + */ + constructor(e, t, r) { + b(this, "logger"), this.logger = new ie(e, t, r); + } + /** + * 获取日志记录器 + * + * @param loggerName - 日志记录器名称 + * @param stackSize - 打印栈的深度 + * @protected + */ + getLogger(e, t) { + return this.logger.setStackSize(t), this.logger.getLogger(e); + } +}; +var M = class extends se { + constructor(e, t, r) { + super(e, t, r); + } + /** + * 获取默认的日志记录器 + * + * @param loggerName - 日志记录器名称 + * @param stackSize - 打印栈的深度 + */ + getLogger(e, t) { + return super.getLogger(e, t); + } +}; +var G = class { + /** + * 默认日志记录器 + * + * @param stackSize 栈的深度 + * @param env - 环境变量实例 + */ + static defaultLogger(e, t) { + return G.customLogFactory(void 0, void 0, e).getLogger(void 0, t); + } + /** + * 自定义日志工厂 + */ + static customLogFactory(e, t, r) { + return new M(e, t, r); + } + /** + * 自定义日志工厂,自定义前缀 + */ + static customSignLogFactory(e, t) { + return new M(void 0, e, t); + } +}; +var X = class { +}; +g(X, "LOG_STACK_SIZE", 1); +var le = class { + constructor() { + g(this, "VERSION"); + this.VERSION = "1.0.0"; + } +}; +var ae = class { + constructor() { + g(this, "VERSION"); + this.VERSION = "1.0.0"; + } +}; +var H = class { + /** + * 检测是否运行在Chrome插件中 + */ + static isInChromeExtension() { + return H.isInBrowser ? window.location.href.indexOf("chrome-extension://") > -1 : false; + } +}; +var O = H; +g(O, "isInBrowser", typeof window < "u"); +var q = class { + constructor() { + g(this, "isInSiyuanOrSiyuanNewWin", () => O.isInBrowser); + g( + this, + "isInSiyuanWidget", + () => window.frameElement != null && window.frameElement.parentElement != null && window.frameElement.parentElement.parentElement != null && window.frameElement.parentElement.parentElement.getAttribute("data-node-id") !== "" + ); + g(this, "isInSiyuanNewWin", () => typeof window.terwer < "u"); + g(this, "requireLib", (e) => { + const t = this.syWin(); + if (!this.syWin()) + throw new Error("Not in siyuan env"); + return t.require(e); + }); + g(this, "getCrossPlatformAppDataFolder", () => { + var t, r, s, o, i, d; + let e; + return ((t = this.syProcess()) == null ? void 0 : t.platform) === "darwin" ? e = _.join((r = this.syProcess()) == null ? void 0 : r.env.HOME, "/Library/Application Support") : ((s = this.syProcess()) == null ? void 0 : s.platform) === "win32" ? e = (o = this.syProcess()) == null ? void 0 : o.env.APPDATA : ((i = this.syProcess()) == null ? void 0 : i.platform) === "linux" && (e = (d = this.syProcess()) == null ? void 0 : d.env.HOME), e; + }); + } + /** + * 思源笔记 window 对象 + */ + syWin() { + let e; + return this.isInSiyuanWidget() ? e = parent.window : (this.isInSiyuanNewWin() && (e = window), e = window), e ?? void 0; + } + /** + * 思源笔记 process 对象 + */ + syProcess() { + return O.isInBrowser ? window.process : process; + } + /** + * 思源笔记 conf 目录 + */ + SIYUAN_CONF_PATH() { + var e; + if (!this.syWin()) + throw new Error("Not in siyuan env"); + return (e = this.syWin()) == null ? void 0 : e.siyuan.config.system.confDir; + } + /** + * 思源笔记 data 目录 + */ + SIYUAN_DATA_PATH() { + var e; + if (!this.syWin()) + throw new Error("Not in siyuan env"); + return (e = this.syWin()) == null ? void 0 : e.siyuan.config.system.dataDir; + } + /** + * 思源笔记 appearance 目录 + */ + SIYUAN_APPEARANCE_PATH() { + return _.join(this.SIYUAN_CONF_PATH(), "appearance"); + } + /** + * 思源笔记 themes 目录 + */ + SIYUAN_THEME_PATH() { + return _.join(this.SIYUAN_APPEARANCE_PATH(), "themes"); + } + /** + * zhi 主题目录 + */ + ZHI_THEME_PATH() { + return _.join(this.SIYUAN_THEME_PATH(), "zhi"); + } + /** + * zhi 主题构建目录 + */ + ZHI_THEME_DIST_PATH() { + return _.join(this.ZHI_THEME_PATH(), "apps", "theme", "dist"); + } + /** + * zhi 博客构建目录 + */ + ZHI_BLOG_DIST_PATH() { + return _.join(this.SIYUAN_THEME_PATH(), "apps", "blog", "dist"); + } +}; +var ce = class { + constructor() { + g(this, "serverApi"); + g(this, "clientApi"); + g(this, "siyuanUtil"); + this.serverApi = new le(), this.clientApi = new ae(), this.siyuanUtil = new q(); + } +}; +var ue = class { + constructor() { + g(this, "VERSION"); + this.VERSION = "1.0.0"; + } +}; +var ge = class { + /** + * 格式化字符串 + * + * @param str - 字符串,可用占位符,例如:test\{0\}str + * @param args - 按占位符顺序排列的参数 + * @author terwer + * @since 0.0.1 + */ + f(e, ...t) { + let r = e; + for (let s = 0; s < t.length; s++) { + const o = t[s]; + typeof o == "string" ? r = r.replace(`{${s}}`, o) : r = r.replace(`{${s}}`, o.toString()); + } + return r; + } +}; +var pe = class { + /** + * + * 可以使用Node.js内置的fs模块中的`copyFileSync`或者`copyFile`方法来复制文件夹。不过需要注意,这两个方法只能复制单个文件,如果想要复制整个文件夹,需要自己编写递归函数实现。 + * 本方法用于复制一个文件夹以及其中所有子文件和子文件夹 + * + * @param source - 源文件 + * @param target - 目标文件 + * @author terwer + * @since 1.0.0 + */ + copyFolderSync(e, t) { + const r = this; + I.existsSync(t) || I.mkdirSync(t), I.lstatSync(e).isDirectory() && I.readdirSync(e).forEach(function(o) { + const i = _.join(e, o); + I.lstatSync(i).isDirectory() ? r.copyFolderSync(i, _.join(t, o)) : I.copyFileSync(i, _.join(t, o)); + }); + } + /** + * 删除文件夹 + * + * @param folder - 文件夹 + */ + rmFolder(e) { + I.existsSync(e) && I.rmdirSync(e, { recursive: true }); + } + /** + * 路径拼接 + * + * @param paths - 路径数组 + */ + joinPath(...e) { + return _.join(...e); + } + /** + * 获取相对路径 + * + * @param pathname - 路径名称 + */ + dirname(e) { + return _.dirname(e); + } + /** + * 获取绝对路径 + * + * @param pathname - 路径名称 + */ + absPath(e) { + const t = this.dirname(e); + return _.resolve(_.dirname(t), e); + } +}; +var fe = class { + constructor() { + g(this, "TIME_SPLIT", " "); + g(this, "formatIsoToZhDate", (e, t, r) => { + if (!e) + return ""; + let s = e; + const o = /(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(.\d{3})Z$/gm, i = s.match(o); + if (i == null) + return e; + for (let d = 0; d < i.length; d++) { + const E = i[d]; + let w = E; + t && (w = this.addHoursToDate(new Date(E), 8).toISOString()); + const l = w.split("T"), f = l[0], p = l[1].split(".")[0]; + let y = f + this.TIME_SPLIT + p; + r && (y = f), s = s.replace(E, y); + } + return s; + }); + } + /** + * 给日期添加小时 + * + * @param date - Date + * @param numOfHours - 数字 + * @author terwer + * @since 1.0.0 + */ + addHoursToDate(e, t) { + return e.setTime(e.getTime() + t * 60 * 60 * 1e3), e; + } + /** + * 当前日期时间完整格式,格式:2023-03-10 02:03:43 + */ + nowZh() { + return this.formatIsoToZhDate(new Date().toISOString()); + } + /** + * 当前日期,格式:2023-03-10 + */ + nowDateZh() { + return this.formatIsoToZhDate(new Date().toISOString(), true, true); + } + /** + * 当前时间,格式:02:03:43 + */ + nowTimeZh() { + return this.formatIsoToZhDate(new Date().toISOString(), true).split(this.TIME_SPLIT)[1]; + } +}; +var W = (n, e) => { + const t = z(n), r = z(e), s = t.pop(), o = r.pop(), i = K(t, r); + return i !== 0 ? i : s && o ? K(s.split("."), o.split(".")) : s || o ? s ? -1 : 1 : 0; +}; +var he = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i; +var z = (n) => { + if (typeof n != "string") + throw new TypeError("Invalid argument expected string"); + const e = n.match(he); + if (!e) + throw new Error(`Invalid argument not valid semver ('${n}' received)`); + return e.shift(), e; +}; +var Y = (n) => n === "*" || n === "x" || n === "X"; +var B = (n) => { + const e = parseInt(n, 10); + return isNaN(e) ? n : e; +}; +var de = (n, e) => typeof n != typeof e ? [String(n), String(e)] : [n, e]; +var we = (n, e) => { + if (Y(n) || Y(e)) + return 0; + const [t, r] = de(B(n), B(e)); + return t > r ? 1 : t < r ? -1 : 0; +}; +var K = (n, e) => { + for (let t = 0; t < Math.max(n.length, e.length); t++) { + const r = we(n[t] || "0", e[t] || "0"); + if (r !== 0) + return r; + } + return 0; +}; +var me = class { + /** + * Compare [semver](https://semver.org/) version strings + * This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`. + * + * @param v1 - First version to compare + * @param v2 - Second version to compare + * @returns boolean true if v1 is higher than v2 + */ + greater(e, t) { + return W(e, t) > 0; + } + /** + * Compare [semver](https://semver.org/) version strings + * This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`. + * + * @param v1 - First version to compare + * @param v2 - Second version to compare + * @returns boolean true if v1 is equal to v2 + */ + equal(e, t) { + return W(e, t) === 0; + } + /** + * Compare [semver](https://semver.org/) version strings + * This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`. + * + * @param v1 - First version to compare + * @param v2 - Second version to compare + * @returns boolean true if v1 is lesser than v2 + */ + lesser(e, t) { + return W(e, t) < 0; + } +}; +var Ee = class { + /** + * 获取当前设备 + */ + static getDevice() { + const e = new q(); + return e.isInSiyuanWidget() ? "Siyuan_Widget" : e.isInSiyuanOrSiyuanNewWin() ? "Siyuan_NewWin" : O.isInChromeExtension() ? "Chrome_Extension" : "Chrome_Browser"; + } +}; +var ve = class { + constructor() { + g(this, "strUtil"); + g(this, "dateUtil"); + g(this, "nodeUtil"); + g(this, "browserUtil"); + g(this, "versionUtil"); + g(this, "deviceUtil"); + this.strUtil = new ge(), this.dateUtil = new fe(), this.nodeUtil = new pe(), this.browserUtil = O, this.versionUtil = new me(), this.deviceUtil = Ee; + } +}; +var Ie = class { + /** + * 构造 zhi-sdk 对象 + * @param env - 可选,环境变量对象 + */ + constructor(e) { + g(this, "env"); + g(this, "logger"); + g(this, "siyuanApi"); + g(this, "blogApi"); + g(this, "common"); + this.env = e, this.logger = G.defaultLogger(this.env, X.LOG_STACK_SIZE), this.siyuanApi = new ce(), this.blogApi = new ue(), this.common = new ve(); + } + /** + * 获取配置环境变量 + */ + getEnv() { + if (!this.env) + throw new Error("env is not initiated, please use new ZhiSdk(env) create ZhiSdk object!"); + return this.env; + } + /** + * 获取日志操作对象 + */ + getLogger() { + return this.logger; + } +}; +var require_lib = __commonJS({ + "node_modules/.pnpm/zhi-env@1.8.2/node_modules/zhi-env/lib/index.js"(exports) { + var i = Object.defineProperty; + var v = (n, e, t) => e in n ? i(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t; + var s = (n, e, t) => (v(n, typeof e != "symbol" ? e + "" : e, t), t); + Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); + var r = class { + }; + s(r, "NODE_ENV_KEY", "NODE_ENV"), s(r, "VITE_DEBUG_MODE_KEY", "VITE_DEBUG_MODE"); + var o = class { + constructor(e) { + s(this, "envMeta"); + this.envMeta = e; + } + isNodeDev() { + return this.getEnv(r.NODE_ENV_KEY) === "development"; + } + isDev() { + return this.isNodeDev() || this.getBooleanEnv(r.VITE_DEBUG_MODE_KEY); + } + getEnv(e) { + let t; + try { + this.envMeta[e] && (t = this.envMeta[e]); + } catch (E) { + console.error(E); + } + return t; + } + getStringEnv(e) { + return this.getEnv(e) ?? ""; + } + getBooleanEnv(e) { + let t = false; + return this.getEnv(e) && (t = this.getStringEnv(e).toLowerCase() === "true"), t; + } + getEnvOrDefault(e, t) { + const E = this.getStringEnv(e); + return E.trim().length == 0 ? t : E; + } + }; + exports.EnvConstants = r; + exports.default = o; + } +}); +const __vite__cjsImport1_zhiEnv = require_lib(); +const Env = __vite__cjsImport1_zhiEnv.__esModule ? __vite__cjsImport1_zhiEnv.default : __vite__cjsImport1_zhiEnv; +const _ZhiUtil = class { + static zhiSdk() { + if (!_ZhiUtil.zhiSdkObj) { + const env = new Env({ "BASE_URL": "/", "MODE": "production", "DEV": false, "PROD": true, "SSR": false }); + _ZhiUtil.zhiSdkObj = new Ie(env); + const logger = _ZhiUtil.zhiSdkObj.getLogger(); + const common = _ZhiUtil.zhiSdkObj.common; + logger.info(common.strUtil.f("ZhiSdk inited, components are available now,like logger, env and so on.")); + } + return _ZhiUtil.zhiSdkObj; + } +}; +let ZhiUtil = _ZhiUtil; +__publicField(ZhiUtil, "zhiSdkObj"); +const version = "1.0.0"; +var ThemeFromEnum = /* @__PURE__ */ ((ThemeFromEnum2) => { + ThemeFromEnum2["ThemeFrom_Blog"] = "zhi-theme-blog"; + ThemeFromEnum2["ThemeFrom_Siyuan"] = "zhi-theme-siyuan"; + return ThemeFromEnum2; +})(ThemeFromEnum || {}); +const initPluginSystem = () => { + return [ + { + libpath: "/plugin-system/plugin-system-hook.cjs", + format: "cjs", + importType: "require", + runAs: "electron" + } + ]; +}; +const pluginSystem = { + initPluginSystem +}; +class Lifecycle { + constructor() { + __publicField(this, "_dynamicImports", []); + } + get dynamicImports() { + return this._dynamicImports; + } + load() { + const allImports = []; + const pluginSystemImports = this.loadPluginSystem(); + const widgetsImports = this.loadWidgets(); + const vendorImports = this.loadVendors(); + this._dynamicImports = allImports.concat(pluginSystemImports).concat(widgetsImports).concat(vendorImports); + } + /** + * SiYuanPluginSystem + * + * @private + */ + loadPluginSystem() { + return pluginSystem.initPluginSystem(); + } + /** + * 加载挂件 + * + * @private + */ + loadWidgets() { + return []; + } + /** + * 加载第三方库 + * + * @private + */ + loadVendors() { + return []; + } +} +const _Bootstrap = class { + /** + * 主题激活 + */ + static async start() { + _Bootstrap.lifecycle.load(); + return Promise.resolve(_Bootstrap.lifecycle.dynamicImports); + } +}; +let Bootstrap = _Bootstrap; +__publicField(Bootstrap, "lifecycle"); +(() => { + _Bootstrap.lifecycle = new Lifecycle(); +})(); +class Zhi { + constructor() { + __publicField(this, "logger"); + __publicField(this, "common"); + const zhiSdk = ZhiUtil.zhiSdk(); + this.logger = zhiSdk.getLogger(); + this.common = zhiSdk.common; + } + async main(args) { + this.logger.debug(this.common.strUtil.f("Parsing args <{0}>", args)); + this.hello(ThemeFromEnum.ThemeFrom_Siyuan); + return await Bootstrap.start(); + } + hello(from) { + this.logger.info(this.common.strUtil.f("Hello, {0} {1} v{2}! You are from {3}", "zhi", "theme", version, from)); + } +} class Theme { + constructor() { + __publicField(this, "logger"); + __publicField(this, "common"); + __publicField(this, "siyuanApi"); + __publicField(this, "zhiTheme"); + const zhiSdk = ZhiUtil.zhiSdk(); + this.logger = zhiSdk.getLogger(); + this.common = zhiSdk.common; + this.siyuanApi = zhiSdk.siyuanApi; + this.zhiTheme = new Zhi(); + } /** * 主流程加载 * * @param runAs 运行模式 */ async init(runAs) { - console.log("Theme inited."); + try { + const dynamicImports = await this.zhiTheme.main([]); + for (const item of dynamicImports) { + const libpath = item.libpath; + if (item.format !== "cjs" || !libpath.includes(".cjs")) { + this.logger.warn("Only cjs supported, skip this lib!", libpath); + continue; + } + if (runAs) { + if (runAs !== item.runAs) { + this.logger.warn( + this.common.strUtil.f("This lib can only run at {0}, skip!Lib is=>{1}", item.runAs, item.libpath) + ); + continue; + } + } + this.logger.info("Loading dependency=>", libpath); + let lib; + if (this.common.browserUtil.isInBrowser) { + const importPath = _.join(this.siyuanApi.siyuanUtil.ZHI_THEME_DIST_PATH(), libpath); + lib = this.siyuanApi.siyuanUtil.requireLib(importPath); + } + if (lib && lib.init) { + await lib.init(); + } + } + this.logger.info("Theme inited."); + } catch (e) { + this.logger.error("Theme load error=>", e); + } } } (async () => {