diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ec58ab --- /dev/null +++ b/.gitignore @@ -0,0 +1,160 @@ + +# ignore any files that start with '.secret' +.secret.* + +.state/ + +# Docker .env files are generated from a Gradle task +.env + +.idea/ +!.idea/icon.svg + +node_modules/ + +*.hprof + +# Created by https://www.toptal.com/developers/gitignore/api/windows,macos,linux,gradle,intellij,visualstudiocode,kotlin +# Edit at https://www.toptal.com/developers/gitignore?templates=windows,macos,linux,gradle,intellij,visualstudiocode,kotlin + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# File-based project format +*.iws +*.iml +*.ipr + +out/ + +### Kotlin ### +# Compiled class file +*.class + +# Log file +*.log + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Ignore all local history of files +.history +.ionide + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### Gradle ### +.gradle +build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +### Gradle Patch ### +**/build/ + +# Eclipse Gradle plugin generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +# End of https://www.toptal.com/developers/gitignore/api/windows,macos,linux,gradle,intellij,visualstudiocode,kotlin diff --git a/LICENSE b/LICENSE index cf5096f..f288702 100644 --- a/LICENSE +++ b/LICENSE @@ -1,232 +1,674 @@ -GNU GENERAL PUBLIC LICENSE -Version 3, 29 June 2007 - -Copyright © 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 General Public License is a free, copyleft license for software and other kinds of works. - -The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is 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. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. - -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. - -To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. - -For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. - -Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. - -For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. - -Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. - -Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. - -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 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. Use with the GNU Affero General Public License. -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 Affero 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 special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. - -14. Revised Versions of this License. -The Free Software Foundation may publish revised and/or new versions of the GNU 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 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 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 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. - - Kafkatorio - Copyright (C) 2026 lazzexus - - This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License along with this program. If not, see . + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 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 General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is 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. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + 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. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + 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 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. Use with the GNU Affero General Public License. + + 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 Affero 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 special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 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 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 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 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. -If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: - Kafkatorio Copyright (C) 2026 lazzexus - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. -The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". -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 GPL, see . + 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 GPL, see +. -The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md index 7883f9f..646a4eb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,67 @@ +[![Mod Portal](https://img.shields.io/badge/dynamic/json?label=Mod%20Portal&query=%24.releases%5B-1%3A%5D.version&url=https%3A%2F%2Fmods.factorio.com%2Fapi%2Fmods%2Fkafkatorio-events&style=flat-square&color=%23600401)](https://mods.factorio.com/mod/kafkatorio-events) +[![Factorio Version](https://img.shields.io/badge/dynamic/json?label=Factorio%20Version&query=%24.releases%5B-1%3A%5D.info_json.factorio_version&url=https%3A%2F%2Fmods.factorio.com%2Fapi%2Fmods%2Fkafkatorio-events&style=flat-square&color=%23d7cdf6)](https://mods.factorio.com/mod/kafkatorio-events) + # Kafkatorio +[Kafkatorio](https://github.com/adamko-dev/kafkatorio) is a platform used for creating +[Factorio](https://www.factorio.com/) mods that require communication with an external server. + +Development is ongoing. + +At present Kafkatorio is used to create a [live-view web map](https://factorio.adamko.dev), that +shows the current status of a Factorio server, and any connected players. + +However, Kafkatorio can be used for more than this. It has the potential to export metrics, and +allow for inter-server communication. + +Kafkatorio was created to explore the possibilities of using +[Apache Kafka](https://kafka.apache.org/) to process updates from a Factorio server. + +### Running + +[Instructions for running a Kafkatorio instance are available in the docs](./docs/guide.md). + +### Overview + +This is a brief overview of how Kafkatorio gathers data, processes it, and uses it to create the +live web-map. + +Kafkatorio receives updates from a Factorio server, processes them, and exposes them over a REST +and WebSocket APIs. + +1. The Kafkatorio game mod, [`events-mod`](./modules/events-mod), collects event data, de-bouncing + and grouping events, and converts them to JSON packets +2. `events-mod` prints the packets to the Factorio game server logs +3. The Factorio logs are forwarded to a Kafka cluster, either using + * [syslog](https://docs.docker.com/config/containers/logging/syslog/) (using Docker logging + plugin) + * or [Kafka Pipe](./modules/infra-kafka-pipe) (a script that reads the server logs and forwards + them to a Kafka topic) +4. The packets are consumed by [`events-server`](./modules/events-server), which processes the + packets using Kafka Streams, creating and hosting map tiles. + + `events-server` serves the map tiles via a REST API, and produces WebSocket messages regarding + updates (for example, when a player's location has changed). +5. The `web-map` uses Leaflet/JS to display the map, using the tiles and WebSocket messages from + `events-server` + +```mermaid +sequenceDiagram + +Factorio multiplayer server->>events-mod: in-game events +Note over events-mod: converts events to packets +events-mod->>logs processor: packets logged to console +logs processor->>Kafka: publishes packets
(Requires API key!) + +Kafka->>events-server: + +Note over events-server: Packets are processed + +events-server->>web-map: Web map tiles (REST API) +events-server-)web-map: WebSocket updates
(e.g. player movement) +``` + +## License + +Because I care about sharing improvements, Kafkatorio is licensed under the +[**GNU General Public License v3.0**](https://choosealicense.com/licenses/gpl-3.0/). diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..9cb7b6b --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,57 @@ +import java.time.LocalDate +import kafkatorio.extensions.excludeGeneratedGradleDsl +import kafkatorio.extensions.initIdeProjectLogo + +plugins { + idea + base + id("kafkatorio.conventions.base") +// `project-report` +// `build-dashboard` +} + +group = "dev.adamko.kafkatorio" +version = "0.10.1" + +val licenseFile: RegularFile by extra(layout.projectDirectory.file("LICENSE")) + +val projectTokens: MapProperty by extra { + objects.mapProperty().apply { + put("project.version", provider { "${project.version}" }) + put("rootProject.name", provider { rootProject.name }) + put("date.year", provider { "${LocalDate.now().year}" }) + put("author.email", "adam@adamko.dev") + } +} + +idea { + module { + isDownloadSources = true + isDownloadJavadoc = true + excludeGeneratedGradleDsl(layout) + excludeDirs = excludeDirs + layout.files( + ".idea", + "gradle/kotlin-js-store", + "gradle/wrapper", + ) + } +} + +tasks.wrapper { + gradleVersion = "7.6" + distributionType = Wrapper.DistributionType.BIN +} + +val runKafkatorio by tasks.registering { + group = rootProject.name + + dependsOn( + ":modules:infra-factorio-client:processRestart", + ":modules:infra-factorio-server:processRestart", + ":modules:infra-kafka-pipe:dockerUp", + ) +} + +apply(from = "$projectDir/kt52647.gradle.kts") + +initIdeProjectLogo() diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..304fee0 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,119 @@ +import kafkatorio.conventions.overrideKotlinLanguageVersion +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("kafkatorio.conventions.kotlin-dsl") + id("kafkatorio.conventions.kotlin-serialization") +// idea +// `kotlin-dsl` +// kotlin("jvm") //version "1.7.20" // embeddedKotlinVersion +// kotlin("plugin.serialization") // version embeddedKotlinVersion +// kotlin("plugin.serialization") version "1.7.20" +} + +//val gradleJvmTarget = "11" +//val gradleKotlinTarget = "1.6" + + +dependencies { + implementation(platform(libs.kotlin.bom)) + implementation("org.jetbrains.kotlin:kotlin-serialization:${libs.versions.kotlin.get()}") + implementation("org.jetbrains.kotlin:kotlin-reflect:${libs.versions.kotlin.get()}") + implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${libs.versions.kotlin.get()}") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.get()}") + + implementation(platform(libs.kotlinx.coroutines.bom)) + implementation(libs.kotlinx.coroutines.core) + + implementation(platform(libs.kotlinxSerialization.bom)) + implementation(libs.kotlinxSerialization.core) + implementation(libs.kotlinxSerialization.json) +// implementation("com.charleskorn.kaml:kaml:0.37.0") + + implementation("com.github.node-gradle:gradle-node-plugin:${libs.versions.gradleNodePlugin.get()}") + + implementation(platform(libs.kotest.bom)) + implementation("io.kotest:kotest-framework-multiplatform-plugin-gradle") + + implementation("io.kvision:io.kvision.gradle.plugin:${libs.versions.kvision.get()}") + + implementation("net.swiftzer.semver:semver:${libs.versions.semver.get()}") + + implementation(platform(libs.okio.bom)) + implementation(libs.okio.core) + + implementation(gradleKotlinDsl()) + + implementation(libs.kotlinx.cli) + + implementation(platform(libs.ktor.bom)) + implementation(libs.ktorClient.auth) + implementation(libs.ktorClient.contentNegotiation) + implementation(libs.ktorClient.core) + implementation(libs.ktorClient.encoding) + implementation(libs.ktorClient.logging) + implementation(libs.ktorClient.cio) + implementation(libs.ktorClient.resources) + implementation(libs.ktorSerialization.kotlinxJson) + + // https://github.com/avast/gradle-docker-compose-plugin +// implementation("com.avast.gradle:gradle-docker-compose-plugin:${Versions.gradleDockerComposePlugin}") + + // https://github.com/gradle/gradle/issues/15383#issuecomment-779893192 + // https://youtrack.jetbrains.com/issue/IDEA-262280#focus=Comments-27-5397040.0-0 +// implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) +} + + +//tasks.compileKotlin { +// kotlinOptions { +// // needed by IntelliJ? Even though below does the same? +// languageVersion = "1.6" +// } +//} + +tasks.withType().configureEach { + + kotlinOptions { +// jvmTarget = gradleJvmTarget +// apiVersion = gradleKotlinTarget +// languageVersion = gradleKotlinTarget + } + + kotlinOptions.freeCompilerArgs += listOf( +// "-Xcontext-receivers", + "-opt-in=kotlin.RequiresOptIn", + "-opt-in=kotlin.ExperimentalStdlibApi", + "-opt-in=kotlin.time.ExperimentalTime", +// "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", + ) +} + + +overrideKotlinLanguageVersion("1.6") +//afterEvaluate { +// tasks.withType().configureEach { +// kotlinOptions { +// apiVersion = gradleKotlinTarget +// languageVersion = gradleKotlinTarget +// } +// } +//} + +//kotlin { +// jvmToolchain { +// (this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget)) +// } +//} +// +//kotlinDslPluginOptions { +// jvmTarget.set(gradleJvmTarget) +//} + +//idea { +// module { +// isDownloadSources = true +// isDownloadJavadoc = true +// } +//} diff --git a/buildSrc/repositories.settings.gradle.kts b/buildSrc/repositories.settings.gradle.kts new file mode 100644 index 0000000..4e357c1 --- /dev/null +++ b/buildSrc/repositories.settings.gradle.kts @@ -0,0 +1,84 @@ +@Suppress("UnstableApiUsage") // Central declaration of repositories is an incubating feature +dependencyResolutionManagement { + + // https://github.com/gradle/gradle/issues/15754#issuecomment-763614651 + // https://github.com/gradle/gradle/blob/09fcaacc9848f09aa584b4119be9271bee6916e6/build-logic/build-logic-base/settings-plugin/src/main/kotlin/gradlebuild.repositories.settings.gradle.kts#L68 + + // Cannot use 'FAIL_ON_PROJECT_REPOS' because + // - the 'gradle-guides-plugin' adds a repo (which it should not do) + // - the 'kotlin-gradle-plugin' adds a repo (and removes it afterwards) to download NodeJS +// repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) + + repositories { + myMavenLocal() + mavenCentral() +// maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") { +// mavenContent { snapshotsOnly() } +// } + jitpack() + gradlePluginPortal() + + // Declare the Node.js download repository + ivy("https://nodejs.org/dist/") { + name = "Node Distributions at $url" + patternLayout { artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]") } + metadataSources { artifact() } + content { includeModule("org.nodejs", "node") } + } + ivy("https://github.com/yarnpkg/yarn/releases/download") { + name = "Yarn Distributions at $url" + patternLayout { artifact("v[revision]/[artifact](-v[revision]).[ext]") } + metadataSources { artifact() } + content { includeModule("com.yarnpkg", "yarn") } + } + + maven("https://raw.githubusercontent.com/adamko-dev/kotka-streams/artifacts/m2") { + content { includeGroup("dev.adamko.kotka") } + } + + maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") { + content { includeGroup("org.jetbrains.kotlinx") } + } + + sonatypeSnapshot() + } + + pluginManagement { + repositories { + myMavenLocal() + gradlePluginPortal() + mavenCentral() + jitpack() + sonatypeSnapshot() + } + } +} + + +fun RepositoryHandler.jitpack() { + maven("https://jitpack.io") +} + + +fun RepositoryHandler.myMavenLocal(enabled: Boolean = true) { + if (enabled) { + logger.lifecycle("Maven local is enabled") + mavenLocal { + content { +// includeGroup("dev.adamko") +// includeGroup("dev.adamko.kxtsgen") + includeGroup("io.kotest") + } + } + } +} + + +fun RepositoryHandler.sonatypeSnapshot() { + maven("https://oss.sonatype.org/content/repositories/snapshots") { + mavenContent { + snapshotsOnly() + includeGroup("io.kotest") + } + } +} diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 0000000..903a987 --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,12 @@ +rootProject.name = "buildSrc" + +apply(from = "./repositories.settings.gradle.kts") + +@Suppress("UnstableApiUsage") // Central declaration of repositories is an incubating feature +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../gradle/libs.versions.toml")) + } + } +} diff --git a/buildSrc/src/main/kotlin/extensions.kt b/buildSrc/src/main/kotlin/extensions.kt new file mode 100644 index 0000000..961642c --- /dev/null +++ b/buildSrc/src/main/kotlin/extensions.kt @@ -0,0 +1,28 @@ +import org.gradle.api.Task +import org.gradle.api.artifacts.Configuration +import org.gradle.api.tasks.TaskCollection + +// to be moved into gradle-plugins/builder-plugins... + + +fun Configuration.asProvider() { + isVisible = false + isCanBeResolved = false + isCanBeConsumed = true +} + + +fun Configuration.asConsumer() { + isVisible = false + isCanBeResolved = true + isCanBeConsumed = false +} +// +//fun Configuration.typescriptAttributes(objects: ObjectFactory): Configuration = +// attributes { +// attribute(Usage.USAGE_ATTRIBUTE, objects.named("dev.adamko.gradle.factorio.typescriptFiles")) +// } + + +fun TaskCollection.withName(name: String): TaskCollection = + matching { it.name == name } diff --git a/docs/guide.md b/docs/guide.md new file mode 100644 index 0000000..8fd2a94 --- /dev/null +++ b/docs/guide.md @@ -0,0 +1,52 @@ +# Running Kafkatorio + +### Building the project + +#### Requirements + +* Docker +* Docker Compose +* Java 11 + +Kafkatorio uses [Gradle](https://docs.gradle.org/current/userguide/getting_started.html) to +build the project, and Docker Compose to create images. + +* `./gradlew build` - build and test the project +* `./gradlew runKafkatorio` - run locally (if Docker is running, a Kafka instance will start) +* `./gradlew dockerComposeBuild` - build, test, and create Kafkatorio Docker images + +### Server set up + +> See [./kafkatorio-platform/docker-compose.yml](kafkatorio-platform/docker-compose.yml) for a +> complete example + +1. Copy the [kafkatorio-platform](./kafkatorio-platform) directory to your computer +2. Rename + [`example.secret.kafkatorio-config.yml`](./kafkatorio-platform/example.secret.kafkatorio-config.yml) + to `.secret.kafkatorio-config.yml` + + In it, define both + * a JWT secret password (a long alphanumeric string is best, you won't need to type this + password manually) + * a Factorio server, with a short-ID and a description. +3. Rename [`example.env`](./kafkatorio-platform/example.env) to `.env` +4. Create a JWT for your Factorio server, by going to https://jwt.io/ + + * In 'PAYLOAD: DATA', set `sub` to your Factorio server's short ID. + ```json + { + "sub": "", + "iat": ... + } + ``` + (`iat`, 'issued-at-time', should update automatically to be the current time.) + * Replace `your-256-bit-secret` with your JWT secret password + + Copy the 'Encoded' token (it should start with `ey`). + + In the `.env` file, set `KAFKATORIO_TOKEN` to equal the token. +5. In `kafkatorio-platform`, start the docker containers + + ```terminal + docker-compose up -d; docker-compose logs -f + ``` diff --git a/docs/kafkatorio-platform/config/kafka-server.properties b/docs/kafkatorio-platform/config/kafka-server.properties new file mode 100644 index 0000000..dd3de1f --- /dev/null +++ b/docs/kafkatorio-platform/config/kafka-server.properties @@ -0,0 +1,130 @@ +# This configuration file is intended for use in KRaft mode, where +# Apache ZooKeeper is not present. See config/kraft/README.md for details. + +############################# Server Basics ############################# + +# The role of this server. Setting this puts us in KRaft mode +process.roles=broker,controller + +# The node id associated with this instance's roles +node.id=1 + +# The connect string for the controller quorum +controller.quorum.voters=1@localhost:9093 + +############################# Socket Server Settings ############################# + +# The address the socket server listens on. It will get the value returned from +# java.net.InetAddress.getCanonicalHostName() if not configured. +# FORMAT: +# listeners = listener_name://host_name:port +# EXAMPLE: +# listeners = PLAINTEXT://your.host.name:9092 +#listeners=PLAINTEXT://:9092,CONTROLLER://:9093 +#listeners=PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092,CONTROLLER://localhost:9093 +listeners=PLAINTEXT://:29092,PLAINTEXT_HOST://:9092,CONTROLLER://:9093 + +inter.broker.listener.name=PLAINTEXT +#KAFKA_INTER_BROKER_LISTENER_NAME: "PLAINTEXT" + +# Hostname and port the broker will advertise to producers and consumers. If not set, +# it uses the value for "listeners" if configured. Otherwise, it will use the value +# returned from java.net.InetAddress.getCanonicalHostName(). +#advertised.listeners=PLAINTEXT://localhost:9092 +advertised.listeners=PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092 + +# Listener, host name, and port for the controller to advertise to the brokers. If +# this server is a controller, this listener must be configured. +controller.listener.names=CONTROLLER + +# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details +#listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL +listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT +# ,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL + +# The number of threads that the server uses for receiving requests from the network and sending responses to the network +num.network.threads=3 + +# The number of threads that the server uses for processing requests, which may include disk I/O +num.io.threads=8 + +# The send buffer (SO_SNDBUF) used by the socket server +socket.send.buffer.bytes=102400 + +# The receive buffer (SO_RCVBUF) used by the socket server +socket.receive.buffer.bytes=102400 + +# The maximum size of a request that the socket server will accept (protection against OOM) +socket.request.max.bytes=104857600 + + +############################# Log Basics ############################# + +# A comma separated list of directories under which to store log files +log.dirs=/tmp/kraft-combined-logs + +# The default number of log partitions per topic. More partitions allow greater +# parallelism for consumption, but this will also result in more files across +# the brokers. +num.partitions=3 + +# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown. +# This value is recommended to be increased for installations with data dirs located in RAID array. +num.recovery.threads.per.data.dir=1 + +############################# Internal Topic Settings ############################# +# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state" +# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3. +offsets.topic.replication.factor=1 +transaction.state.log.replication.factor=1 +transaction.state.log.min.isr=1 + +############################# Log Flush Policy ############################# + +# Messages are immediately written to the filesystem but by default we only fsync() to sync +# the OS cache lazily. The following configurations control the flush of data to disk. +# There are a few important trade-offs here: +# 1. Durability: Unflushed data may be lost if you are not using replication. +# 2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush. +# 3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks. +# The settings below allow one to configure the flush policy to flush data after a period of time or +# every N messages (or both). This can be done globally and overridden on a per-topic basis. + +# The number of messages to accept before forcing a flush of data to disk +#log.flush.interval.messages=10000 + +# The maximum amount of time a message can sit in a log before we force a flush +#log.flush.interval.ms=1000 + +############################# Log Retention Policy ############################# + +# The following configurations control the disposal of log segments. The policy can +# be set to delete segments after a period of time, or after a given size has accumulated. +# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens +# from the end of the log. + +# The minimum age of a log file to be eligible for deletion due to age +log.retention.hours=168 + +# A size-based retention policy for logs. Segments are pruned from the log unless the remaining +# segments drop below log.retention.bytes. Functions independently of log.retention.hours. +#log.retention.bytes=1073741824 + +# The maximum size of a log segment file. When this size is reached a new log segment will be created. +log.segment.bytes=1073741824 + +# The interval at which log segments are checked to see if they can be deleted according +# to the retention policies +log.retention.check.interval.ms=300000 + +### Compression ### +#compression.type=snappy +#linger.ms=5 + + +### record size ### +message.max.bytes=10485760 +replica.fetch.max.bytes=10485760 + +#log.cleanup.policy=compact +#auto.create.topics.enable=false diff --git a/docs/kafkatorio-platform/docker-compose.yml b/docs/kafkatorio-platform/docker-compose.yml new file mode 100644 index 0000000..5826700 --- /dev/null +++ b/docs/kafkatorio-platform/docker-compose.yml @@ -0,0 +1,140 @@ +version: "3.9" + +services: + + ## Factorio game server that players will connect to + factorio-server: + image: factoriotools/factorio:${FACTORIO_VERSION} + container_name: "factorio-server" + restart: unless-stopped + profiles: [ "factorio", "kafkatorio" ] + networks: + - kafkatorio-infra-nw + ports: + - "34198:34197/udp" # factorio + - "27016:27015/tcp" # rcon + volumes: + - "./factorio-server:/factorio" + logging: + # set up syslog, so logs can be forwarded to Kafkatorio + driver: syslog + options: + syslog-address: ${SYSLOG_ADDRESS} + syslog-format: "rfc5424" + # set the tag to be a JWT, containing the server short-ID + tag: ${KAFKATORIO_TOKEN} + + + ## Kafkatorio Web Map host + web-map: + image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/web-map:${KAFKATORIO_VERSION} + container_name: web-map + profiles: [ "infra", "kafkatorio" ] + restart: unless-stopped + networks: + - kafkatorio-infra-nw + + + ## Process Kafkatorio events + events-processors: + image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/events-processors:${KAFKATORIO_VERSION} + container_name: events-processors + restart: unless-stopped + profiles: [ "infra", "kafkatorio" ] + environment: + KAFKA_BOOTSTRAP_SERVERS: "kafka:29092" + networks: + - kafkatorio-infra-nw + depends_on: + - infra-kafka + secrets: + - source: kafkatorio_config + target: /.secret.config.yml + + + ## Receives packets from the Factorio Server, forwarded via Docker syslog-plugin + events-server-syslog: + image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/events-server-syslog:${KAFKATORIO_VERSION} + container_name: events-server-syslog + restart: unless-stopped + profiles: [ "infra", "kafkatorio" ] + environment: + KAFKA_BOOTSTRAP_SERVERS: "kafka:29092" + SOCKET_SERVER_HOST: "0.0.0.0" + SOCKET_SERVER_PORT: "9002" + ports: + - "12035:9002" # syslog socket + networks: + - kafkatorio-infra-nw + depends_on: + - infra-kafka + - events-processors + secrets: + - source: kafkatorio_config + target: /.secret.config.yml + + + ## Hosts map-tiles and forwards websocket messages to the web-map browsers + events-server-web: + image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/events-server-web:${KAFKATORIO_VERSION} + container_name: events-server-web + restart: unless-stopped + profiles: [ "infra", "kafkatorio" ] + environment: + KAFKA_BOOTSTRAP_SERVERS: "kafka:29092" + WEB_SERVER_PORT: "80" + ports: + - "12080:80" # http and ws + networks: + - kafkatorio-infra-nw + depends_on: + - infra-kafka + - events-processors + secrets: + - source: kafkatorio_config + target: /.secret.config.yml + + + ## An instance of Kafka + infra-kafka: + image: ${REGISTRY_HOST}/dev.adamko.kafkatorio/kafka-kraft:${KAFKATORIO_VERSION} + container_name: infra-kafka + restart: unless-stopped + profiles: [ "infra", "kafka" ] + networks: + kafkatorio-infra-nw: + aliases: [ kafka ] + volumes: + - "./config/kafka-server.properties:/kafka/server.properties" + ports: + # note: other Docker containers should use 29092 + - "9092:9092" + - "9093:9093" + + + ## web-based GUI for Kafka + infra-kafka-ui: + image: provectuslabs/kafka-ui:v0.4.0 + container_name: infra-kafka-ui + restart: unless-stopped + profiles: [ "infra", "kafka" ] + networks: + - kafkatorio-infra-nw + ports: + - "18090:8080" + depends_on: + - infra-kafka + environment: + KAFKA_CLUSTERS_0_NAME: "${COMPOSE_PROJECT_NAME}" + KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: "kafka:29092" + + + +secrets: + kafkatorio_config: + file: ./.secret.kafkatorio-config.yml + + +networks: + kafkatorio-infra-nw: + kafkatorio-game-nw: diff --git a/docs/kafkatorio-platform/example.env b/docs/kafkatorio-platform/example.env new file mode 100644 index 0000000..4339796 --- /dev/null +++ b/docs/kafkatorio-platform/example.env @@ -0,0 +1,10 @@ +# Docker Compose containers config + +COMPOSE_PROJECT_NAME=Kafkatorio + +KAFKATORIO_TOKEN= +KAFKATORIO_VERSION=0.9.15 + +REGISTRY_HOST=localhost + +SYSLOG_ADDRESS=tcp://www.my-website.com:12345 diff --git a/docs/kafkatorio-platform/example.secret.kafkatorio-config.yml b/docs/kafkatorio-platform/example.secret.kafkatorio-config.yml new file mode 100644 index 0000000..4e5237b --- /dev/null +++ b/docs/kafkatorio-platform/example.secret.kafkatorio-config.yml @@ -0,0 +1,10 @@ +# Kafkatorio server config + +jwt-secret: "correct horse battery staple" + +# Define the servers that have the Kafkatorio Mod installed. +kafkatorio-servers: + # The key is the short ID, used to uniquely identify a server (used in URLs). + # The value is a description. + short-id-123: "Name of server" + another-id-456: "Name of another server" diff --git a/docs/media/img/kafkatorio-logo.png b/docs/media/img/kafkatorio-logo.png new file mode 100644 index 0000000..a37200e Binary files /dev/null and b/docs/media/img/kafkatorio-logo.png differ diff --git a/docs/media/img/kafkatorio-logo.svg b/docs/media/img/kafkatorio-logo.svg new file mode 100644 index 0000000..1bd35cd --- /dev/null +++ b/docs/media/img/kafkatorio-logo.svg @@ -0,0 +1,71 @@ + + diff --git a/gradle-plugins/builder-plugins/build.gradle.kts b/gradle-plugins/builder-plugins/build.gradle.kts new file mode 100644 index 0000000..ee54055 --- /dev/null +++ b/gradle-plugins/builder-plugins/build.gradle.kts @@ -0,0 +1,43 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("kafkatorio.conventions.kotlin-dsl") +} + +dependencies { + implementation(platform(libs.kotlin.bom)) + implementation("org.jetbrains.kotlin:kotlin-serialization") + implementation("org.jetbrains.kotlin:kotlin-reflect") + implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.get()}") + + implementation(platform(libs.kotlinx.coroutines.bom)) + implementation(libs.kotlinx.coroutines.core) + + implementation(platform(libs.kotlinxSerialization.bom)) + implementation(libs.kotlinxSerialization.core) + implementation(libs.kotlinxSerialization.json) + + implementation("com.github.node-gradle:gradle-node-plugin:${libs.versions.gradleNodePlugin.get()}") + + implementation(platform(libs.kotest.bom)) + implementation("io.kotest:kotest-framework-multiplatform-plugin-gradle") + + implementation(libs.gradlePlugin.kvision) + + implementation(libs.semver) + + implementation(platform(libs.okio.bom)) + implementation(libs.okio.core) + + implementation(libs.kotlinx.cli) +} + + +tasks.withType().configureEach { + kotlinOptions.freeCompilerArgs += listOf( + "-opt-in=kotlin.ExperimentalStdlibApi", + "-opt-in=kotlin.time.ExperimentalTime", + "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", + ) +} diff --git a/gradle-plugins/builder-plugins/modules/common-lib/build.gradle.kts b/gradle-plugins/builder-plugins/modules/common-lib/build.gradle.kts new file mode 100644 index 0000000..b74bf1d --- /dev/null +++ b/gradle-plugins/builder-plugins/modules/common-lib/build.gradle.kts @@ -0,0 +1,24 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + kotlin("jvm") +} + +val gradleJvmTarget = "11" + +dependencies { + implementation(platform(kotlin("bom"))) + implementation(gradleApi()) +} + +kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget)) + } +} + +tasks.withType().configureEach { + kotlinOptions { + jvmTarget = gradleJvmTarget + } +} diff --git a/gradle-plugins/builder-plugins/modules/common-lib/src/main/kotlin/kafkatorio/common/distributions.kt b/gradle-plugins/builder-plugins/modules/common-lib/src/main/kotlin/kafkatorio/common/distributions.kt new file mode 100644 index 0000000..d1ab91f --- /dev/null +++ b/gradle-plugins/builder-plugins/modules/common-lib/src/main/kotlin/kafkatorio/common/distributions.kt @@ -0,0 +1,17 @@ +package kafkatorio.common + +import org.gradle.api.artifacts.Configuration + + +fun Configuration.asProvider() { + isVisible = false + isCanBeResolved = false + isCanBeConsumed = true +} + + +fun Configuration.asConsumer() { + isVisible = false + isCanBeResolved = true + isCanBeConsumed = false +} diff --git a/gradle-plugins/builder-plugins/settings.gradle.kts b/gradle-plugins/builder-plugins/settings.gradle.kts new file mode 100644 index 0000000..eefa4b4 --- /dev/null +++ b/gradle-plugins/builder-plugins/settings.gradle.kts @@ -0,0 +1,31 @@ +rootProject.name = "builder-plugins" + +pluginManagement { + @Suppress("UnstableApiUsage") + includeBuild("../settings-plugins/") +} + +plugins { + id("kafkatorio.conventions.settings.repositories") +} + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../../gradle/libs.versions.toml")) + } + } +} + +include( + ":modules:common-lib", + + ":modules:build-conventions", + + ":modules:docker-compose", + ":modules:factorio-mod", + ":modules:typescript-to-lua", +) + + +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/base.gradle.kts b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/base.gradle.kts new file mode 100644 index 0000000..4171242 --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/base.gradle.kts @@ -0,0 +1,27 @@ +package kafkatorio.conventions + + +plugins { + base + idea +} + + +group = rootProject.group +version = rootProject.version + + +tasks.withType().configureEach { + encoding = Charsets.UTF_8.name() + comment = " Do not edit manually. This file was created with task '$name'" +} + + +tasks.withType().configureEach { + exclude( + "**/.secret.*", + "**/.env", + ) + isPreserveFileTimestamps = false + isReproducibleFileOrder = true +} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/common.kt b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/common.kt new file mode 100644 index 0000000..7956955 --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/common.kt @@ -0,0 +1,37 @@ +package kafkatorio.conventions + +import io.kvision.gradle.KVisionExtension +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.findByType +import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension + + +object Versions { + const val node = "14.19.1" +} + + +/** + * `kotlin-js` adds a directory in the root-dir for the Yarn lock. + * That's a bit annoying. It's a little neater if it's in the + * gradle dir, next to the version-catalog. + */ +fun Project.relocateKotlinJsStore() { + + afterEvaluate { + rootProject.extensions.configure { + lockFileDirectory = project.rootDir.resolve("gradle/kotlin-js-store") + } + } + +// rootProject.plugins.withType(YarnPlugin::class) { +// rootProject.the().lockFileDirectory = +// project.rootDir.resolve("gradle/kotlin-js-store") +// } + + // KVision tries to be clever too + project.extensions.findByType()?.apply { + enableHiddenKotlinJsStore.set(false) + } +} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/infra/docker-compose.gradle.kts b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/infra/docker-compose.gradle.kts new file mode 100644 index 0000000..3088121 --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/infra/docker-compose.gradle.kts @@ -0,0 +1,63 @@ +package kafkatorio.conventions.infra + +//import kafkatorio.tasks.DockerEnvUpdateTask +//import kafkatorio.extensions.DOCKER_COMPOSE_TASK_GROUP +//import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs +// +//plugins { +// base +// id("kafkatorio.conventions.infra.process-runner") +//} +// +// +//val dockerComposeProjectName: String by extra(rootProject.name) +//val dockerSrcDir: Directory by extra(layout.projectDirectory.dir("src")) +// +// +//val dockerUp by tasks.registering(Exec::class) { +// group = DOCKER_COMPOSE_TASK_GROUP +// +// dependsOn(tasks.assemble) +// logging.captureStandardOutput(LogLevel.LIFECYCLE) +// +// workingDir = dockerSrcDir.asFile +// commandLine = parseSpaceSeparatedArgs(""" docker-compose up -d """) +//} +// +// +//val dockerDown by tasks.registering(Exec::class) { +// group = DOCKER_COMPOSE_TASK_GROUP +// +// logging.captureStandardOutput(LogLevel.LIFECYCLE) +// +// workingDir = dockerSrcDir.asFile +// commandLine = parseSpaceSeparatedArgs(""" docker-compose down """) +//} +// +// +//val dockerRemove by tasks.registering(Exec::class) { +// group = DOCKER_COMPOSE_TASK_GROUP +// +// logging.captureStandardOutput(LogLevel.LIFECYCLE) +// +// workingDir = dockerSrcDir.asFile +// commandLine = parseSpaceSeparatedArgs(""" docker-compose rm --stop -v -f """) +//} +// +// +//tasks.matching { it.name == "processRun" }.configureEach { dependsOn(dockerUp, dockerEnvUpdate) } +//tasks.matching { it.name == "processKill" }.configureEach { dependsOn(dockerDown) } +// +// +//val dockerEnvUpdate by tasks.registering(DockerEnvUpdateTask::class) { +// dotEnvFile.set(dockerSrcDir.file(".env")) +// +// properties( +// "COMPOSE_PROJECT_NAME" to dockerComposeProjectName, +// "KAFKATORIO_VERSION" to project.version, +// "REGISTRY_HOST" to providers.gradleProperty("dockerContainerRegistryHost"), +// ) +//} +// +// +//tasks.assemble { dependsOn(dockerEnvUpdate) } diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/infra/process-runner.gradle.kts b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/infra/process-runner.gradle.kts new file mode 100644 index 0000000..5b5b04a --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/infra/process-runner.gradle.kts @@ -0,0 +1,25 @@ +package kafkatorio.conventions.infra + +import org.gradle.kotlin.dsl.extra +import org.gradle.kotlin.dsl.registering + +plugins { + id("kafkatorio.conventions.base") +} + +val processRunnerTaskGroup: String by extra("processes") + +val processRun by tasks.registering(Task::class) { + group = processRunnerTaskGroup +} + +val processKill by tasks.registering(Task::class) { + group = processRunnerTaskGroup +} + +val processRestart by tasks.registering { + group = processRunnerTaskGroup + + dependsOn(processKill) + finalizedBy(processRun) +} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/kotlin-js.gradle.kts b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/kotlin-js.gradle.kts new file mode 100644 index 0000000..f84a3cb --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/kotlin-js.gradle.kts @@ -0,0 +1,70 @@ +package kafkatorio.conventions.lang + +//import dev.adamko.kafkatorio.Versions +import kafkatorio.conventions.relocateKotlinJsStore +//import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension +//import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin +//import org.jetbrains.kotlin.gradle.targets.js.npm.NpmProject +//import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension + +//import org.jetbrains.kotlin.gradle.targets.js.npm.tasks.RootPackageJsonTask + + +plugins { + kotlin("js") + id("kafkatorio.conventions.base") +} + +//dependencies { +// implementation( +// project.dependencies.platform( +// "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${Versions.kotlinWrappers}" +// ) +// ) +//} + +//val rootPackageJson by rootProject.tasks.getting(RootPackageJsonTask::class) + +//fun NpmTask.setNodeModulesPath(path: String): Unit = +// environment.put("NODE_PATH", path) +// +//fun NpmTask.setNodeModulesPath(folder: File): Unit = +// setNodeModulesPath(folder.normalize().absolutePath) + +// https://github.com/node-gradle/gradle-node-plugin/issues/150 +// https://github.com/lamba92/kotlingram/blob/master/examples/js-bot/build.gradle.kts + +//val nodePath: Directory by extra { +// val file = rootPackageJson.rootPackageJson.parentFile.normalize() +// logger.info("Kotlin/JS NODE_PATH: $file") +// project.layout.dir(project.provider { file }).get() +//} + +//val nodeModulesDir: Directory by extra { +// val file = nodePath.dir(NpmProject.NODE_MODULES) +// logger.info("Kotlin/JS NODE_MODULES: $file") +// file +//} + + +relocateKotlinJsStore() + + +//plugins.withType { +// configure { +// nodeVersion = "16.0.0" +// } +//} + + +//afterEvaluate { +// rootProject.extensions.configure { +// // https://github.com/rjaros/kvision/issues/410 +// versions.webpackCli.version = "4.10.0" +// versions.webpackDevServer.version = "4.9.2" +// } +// +// rootProject.extensions.configure { +// resolution("http-proxy-middleware", "^2.0.6") +// } +//} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/kotlin-jvm.gradle.kts b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/kotlin-jvm.gradle.kts new file mode 100644 index 0000000..1393be0 --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/kotlin-jvm.gradle.kts @@ -0,0 +1,66 @@ +package kafkatorio.conventions.lang + +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("kafkatorio.conventions.base") + kotlin("jvm") +} + +val projectKotlinTarget = "1.7" +val projectJvmTarget = "11" + + +dependencies { + testImplementation("org.junit.jupiter:junit-jupiter") + + testImplementation("io.kotest:kotest-runner-junit5") + testImplementation("io.kotest:kotest-assertions-core") + testImplementation("io.kotest:kotest-property") + testImplementation("io.kotest:kotest-assertions-json") + + testImplementation("io.mockk:mockk") +} + + +tasks.withType().configureEach { + + kotlinOptions { + jvmTarget = projectJvmTarget + apiVersion = projectKotlinTarget + languageVersion = projectKotlinTarget + } + + kotlinOptions.freeCompilerArgs += listOf( +// "-Xcontext-receivers", + "-opt-in=kotlin.RequiresOptIn", + "-opt-in=kotlin.ExperimentalStdlibApi", + "-opt-in=kotlin.time.ExperimentalTime", +// "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", +// "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", + ) +} + + +tasks.compileTestKotlin { + kotlinOptions.freeCompilerArgs += "-opt-in=io.kotest.common.ExperimentalKotest" +} + + +kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(projectJvmTarget)) + } +} + + +tasks.withType().configureEach { + useJUnitPlatform() +} + + +plugins.withType().configureEach { + project.extensions.getByType().apply { + applicationDefaultJvmArgs += listOf("-Dkotlinx.coroutines.debug") + } +} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/kotlin-multiplatform.gradle.kts b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/kotlin-multiplatform.gradle.kts new file mode 100644 index 0000000..3b90834 --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/kotlin-multiplatform.gradle.kts @@ -0,0 +1,37 @@ +package kafkatorio.conventions.lang + +import kafkatorio.conventions.relocateKotlinJsStore +//import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension +//import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin +//import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension + + +plugins { + id("kafkatorio.conventions.base") +// id("dev.adamko.kafkatorio.lang.node") + kotlin("multiplatform") +// id("io.kotest.multiplatform") // disabled because of https://github.com/kotest/kotest/issues/3141 +} + + +relocateKotlinJsStore() + + +//plugins.withType { +// configure { +// nodeVersion = "16.0.0" +// } +//} +// +// +//afterEvaluate { +// rootProject.extensions.configure { +// // https://github.com/rjaros/kvision/issues/410 +// versions.webpackCli.version = "4.10.0" +// versions.webpackDevServer.version = "4.9.2" +// } +// +// rootProject.extensions.configure { +// resolution("http-proxy-middleware", "^2.0.6") +// } +//} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/node.gradle.kts b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/node.gradle.kts new file mode 100644 index 0000000..f9128c8 --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/conventions/lang/node.gradle.kts @@ -0,0 +1,64 @@ +package kafkatorio.conventions.lang + +import com.github.gradle.node.npm.task.NpmInstallTask +import kafkatorio.conventions.Versions +import kafkatorio.tasks.UpdatePackageJson +import kotlinx.serialization.json.put + + +plugins { + id("com.github.node-gradle.node") + id("kafkatorio.conventions.base") +} + + +node { + download.set(true) + version.set(Versions.node) + + distBaseUrl.set(null as String?) // set by dependencyResolutionManagement +} + +val projectVersion: Provider = providers.provider { "${project.version}" } + +val updatePackageJson by tasks.registering(UpdatePackageJson::class) { +// group = NodePlugin.NODE_GROUP +// description = "Read the package.json file and update the version and name, based on the project." + + inputs.property("projectVersion", projectVersion) +// propertiesToCheck.put("version", projectVersion) + + updateExpectedJson { + put("version", projectVersion.get()) + } + + // check to see if the properties are already up-to-date +// outputs.upToDateWhen(areJsonPropertiesUpToDate(packageJsonFile, propertiesToCheck)) +// onlyIf(!areJsonPropertiesUpToDate(packageJsonFile, propertiesToCheck)) + +// doLast { +// val packageJsonContent = packageJsonFile.get().asFile.readText() +// val packageJson = jsonMapper.parseToJsonElement(packageJsonContent).jsonObject +// +// val newJsonProps = propertiesToCheck.get().mapValues { (_, newVal) -> JsonPrimitive(newVal) } +// +// val packageJsonUpdate = JsonObject(packageJson + newJsonProps) +// val packageJsonContentUpdated = +// jsonMapper +// .encodeToString(packageJsonUpdate) +// .suffixIfNot("\n") +// +// logger.debug(packageJsonContentUpdated) +// +// packageJsonFile.get().asFile.writer().useToRun { +// write(packageJsonContentUpdated) +// } +// +// } +} + +tasks.assemble { dependsOn(updatePackageJson) } + +tasks.withType().configureEach { + dependsOn(updatePackageJson) +} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/extensions/gradle.kt b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/extensions/gradle.kt new file mode 100644 index 0000000..ebfbcdc --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/extensions/gradle.kt @@ -0,0 +1,118 @@ +package kafkatorio.extensions + +import java.io.ByteArrayOutputStream +import org.gradle.api.Project +import org.gradle.api.Task +import org.gradle.api.file.Directory +import org.gradle.api.file.ProjectLayout +import org.gradle.api.file.RelativePath +import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.provider.Provider +import org.gradle.api.specs.NotSpec +import org.gradle.api.specs.Spec +import org.gradle.api.tasks.TaskProvider +import org.gradle.api.tasks.application.CreateStartScripts +import org.gradle.kotlin.dsl.register +import org.gradle.plugins.ide.idea.model.IdeaModule +import org.gradle.process.ExecSpec +import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension +import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn +import org.jetbrains.kotlin.incremental.md5 + + +operator fun Spec.not(): NotSpec = NotSpec(this) + + +//fun isProcessRunning(process: String, ignoreCase: Boolean = true): Spec = +// Spec { +// ByteArrayOutputStream().use { outputStream -> +// project.exec { +// } +// outputStream.toString().contains(process, ignoreCase) +// } +// } +// + + +/** exclude generated Gradle code, so it doesn't clog up search results */ +fun IdeaModule.excludeGeneratedGradleDsl(layout: ProjectLayout) { + + val generatedSrcDirs = listOf( + "kotlin-dsl-accessors", + "kotlin-dsl-external-plugin-spec-builders", + "kotlin-dsl-plugins", + ) + + excludeDirs.addAll( + layout.projectDirectory.asFile.walk() + .filter { it.isDirectory } + .filter { it.parentFile.name in generatedSrcDirs } + .flatMap { file -> + file.walk().maxDepth(1).filter { it.isDirectory }.toList() + } + ) +} + + +// https://stackoverflow.com/a/70317110/4161471 +fun Project.execCapture(spec: ExecSpec.() -> Unit): String { + return ByteArrayOutputStream().use { outputStream -> + exec { + this.spec() + this.standardOutput = outputStream + } + val output = outputStream.toString().trim() + logger.lifecycle(output) + output + } +} + + +/** https://youtrack.jetbrains.com/issue/KT-50848 */ +fun Project.yarn(configure: YarnRootExtension.() -> Unit) = with(yarn, configure) + + +fun Directory.filesChecksum(): Long = asFileTree + .files + .map { it.readBytes() + it.absolutePath.toByteArray() } + .fold(byteArrayOf()) { acc, bytes -> acc + bytes } + .md5() + + +/** Drop the first [count] directories from the path */ +fun RelativePath.dropDirectories(count: Int): RelativePath = + RelativePath(true, *segments.drop(count).toTypedArray()) + + +/** Drop the first directory from the path */ +fun RelativePath.dropDirectory(): RelativePath = + dropDirectories(1) + + +/** https://github.com/gradle/gradle/issues/16543 */ +fun Project.taskProvider(taskName: String): Provider = providers.provider { + taskName +}.flatMap { + tasks.named(it) +} + + +const val DOCKER_COMPOSE_TASK_GROUP = "docker-compose" + + +fun Project.registerStartScriptTask( + appName: String, + configureStartScripts: CreateStartScripts.() -> Unit = {}, +): TaskProvider = + tasks.register("startScript$appName") { + + val jarTask = tasks.getByName(JavaPlugin.JAR_TASK_NAME) + val runtimeClasspath = configurations.getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME) + dependsOn(jarTask) + dependsOn(runtimeClasspath) + + applicationName = appName + outputDir = layout.buildDirectory.dir("scripts").get().asFile + classpath = jarTask.outputs.files + runtimeClasspath + configureStartScripts() + } diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/extensions/ideProjectLogo.kt b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/extensions/ideProjectLogo.kt new file mode 100644 index 0000000..929d0f9 --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/extensions/ideProjectLogo.kt @@ -0,0 +1,21 @@ +package kafkatorio.extensions + +import org.gradle.api.Project + +/** Sets a logo for project IDEs */ +fun Project.initIdeProjectLogo() { + val logoSvg = rootProject.layout.projectDirectory.file("docs/media/img/kafkatorio-logo.svg") + val ideaDir = rootProject.layout.projectDirectory.dir(".idea") + + if ( + logoSvg.asFile.exists() + && ideaDir.asFile.exists() + && !ideaDir.file("icon.png").asFile.exists() + && !ideaDir.file("icon.svg").asFile.exists() + ) { + copy { + from(logoSvg) { rename { "icon.svg" } } + into(ideaDir) + } + } +} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/GenerateTypeScriptTask.kt b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/GenerateTypeScriptTask.kt new file mode 100644 index 0000000..6cf739a --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/GenerateTypeScriptTask.kt @@ -0,0 +1,37 @@ +package kafkatorio.tasks + +import javax.inject.Inject +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.FileSystemOperations +import org.gradle.api.tasks.JavaExec +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.TaskAction +import org.gradle.work.DisableCachingByDefault + + +@DisableCachingByDefault(because = "caching makes regenerating more difficult") +abstract class GenerateTypeScriptTask @Inject constructor( + private val fileOps: FileSystemOperations, +) : JavaExec() { + + @get:OutputDirectory + abstract val output: DirectoryProperty + + init { + group = "kt2ts" + } + + @TaskAction + fun generate() { + fileOps.delete { delete(temporaryDir) } + temporaryDir.mkdirs() + + super.exec() + + fileOps.sync { + from(temporaryDir) + into(output) + include("**/*.ts") + } + } +} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/JsonPropertiesUpToDateSpec.kt b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/JsonPropertiesUpToDateSpec.kt new file mode 100644 index 0000000..271cced --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/JsonPropertiesUpToDateSpec.kt @@ -0,0 +1,59 @@ +package kafkatorio.tasks + +import kafkatorio.tasks.UpdatePackageJson.Companion.foldParseToJsonObject +import kafkatorio.tasks.UpdatePackageJson.Companion.parseToJsonObject +import kotlinx.serialization.json.JsonObject +import org.gradle.api.Task +import org.gradle.api.internal.specs.ExplainingSpec +import org.gradle.api.logging.Logger +import org.gradle.api.logging.Logging + + +object JsonPropertiesUpToDateSpec : ExplainingSpec { + + private val logger: Logger = Logging.getLogger(this::class.java) + + override fun isSatisfiedBy(element: Task?): Boolean { + val reason = whyUnsatisfied(element) + + if (reason != null) { + logger.lifecycle("JsonProperties not up to date:\n$reason") + } + + return reason == null + } + + + // Returns a description explaining why the task is outdated, + // or null if the task is up to date + override fun whyUnsatisfied(task: Task?): String? { + require(task is UpdatePackageJson) { "$task is not a UpdatePackageJson task" } + + val current = task.packageJsonFile.asFile.orNull?.parseToJsonObject() + ?: return "no package.json file" + + val updates = task.expectedJsonUpdates.orNull?.toList()?.foldParseToJsonObject() + ?: return "no package.json updates" + + val expected = JsonObject(current + updates) + + if (current != expected) { + return (current.keys + expected.keys) + .asSequence() + .distinct() + .sorted() + .mapNotNull { + val currentVal = current[it] + val expectedVal = expected[it] + + if (currentVal == expectedVal) { + null + } else { + "'$it' - expected:$expectedVal, actual:$currentVal" + } + }.joinToString(separator = "\n\t", prefix = "package.json is not up to date.\n\t") + } + + return null + } +} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/KafkaConsumerGroupsTask.kt b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/KafkaConsumerGroupsTask.kt new file mode 100644 index 0000000..c4c88b4 --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/KafkaConsumerGroupsTask.kt @@ -0,0 +1,77 @@ +package kafkatorio.tasks + +import kafkatorio.extensions.execCapture +import org.gradle.api.DefaultTask +import org.gradle.api.logging.LogLevel +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.TaskAction +import org.intellij.lang.annotations.Language +import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs + +abstract class KafkaConsumerGroupsTask : DefaultTask() { + + @get:Input + val bootstrapServer: String = "localhost:9092" + @get:Input + val kafkaDockerContainerName: String = "kafka" + + @get:Internal + protected val bootstrapArg = "--bootstrap-server $bootstrapServer" + + abstract class ResetAll : KafkaConsumerGroupsTask() { + + @get:Input + @Language("Shell Script") + val resetCommand: String = + """ + /kafka/bin/kafka-consumer-groups.sh --execute --reset-offsets --all-topics --to-earliest $bootstrapArg + """.trimIndent() + + @TaskAction + fun reset() { + getAllGroups().forEach { group -> + logger.lifecycle("Resetting group $group\n---") + dockerExec("$resetCommand --group $group") + logger.lifecycle("---") + } + } + } + + abstract class DeleteAll : KafkaConsumerGroupsTask() { + + @get:Input + @Language("Shell Script") + val deleteCommand: String = + """ + /kafka/bin/kafka-consumer-groups.sh --delete $bootstrapArg + """.trimIndent() + + @TaskAction + fun reset() { + val groups = getAllGroups().joinToString(" ") { group -> "--group $group" } + dockerExec("$deleteCommand $groups") + } + } + + @Internal + protected fun getAllGroups(): List = dockerExec( + """ + /kafka/bin/kafka-consumer-groups.sh --list $bootstrapArg + """.trimIndent() + ).lines() + .filter { it.trim().isNotBlank() } + + +// fun reset(applicationId: String) = """ +// /kafka/bin/kafka-streams-application-reset.sh --application-id $applicationId --force --to-earliest +// """.trimIndent() + + protected fun dockerExec( + @Language("Shell Script") + cmd: String + ): String = project.execCapture { + logging.captureStandardOutput(LogLevel.LIFECYCLE) + commandLine = parseSpaceSeparatedArgs(""" docker exec $kafkaDockerContainerName $cmd """) + } +} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/ProcessRunningSpec.kt b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/ProcessRunningSpec.kt new file mode 100644 index 0000000..629c727 --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/ProcessRunningSpec.kt @@ -0,0 +1,39 @@ +package kafkatorio.tasks + +import java.io.ByteArrayOutputStream +import org.gradle.api.Task +import org.gradle.api.internal.specs.ExplainingSpec +import org.gradle.api.tasks.Exec +import org.gradle.process.ExecOperations + +/** Checks if a process is running. Windows only. */ +class ProcessRunningSpec( + private val executor: ExecOperations, + private val process: String, + private val ignoreCase: Boolean = true, +) : ExplainingSpec { + + override fun isSatisfiedBy(element: Task?): Boolean = whyUnsatisfied(element) == null + + override fun whyUnsatisfied(element: Task?): String? { + return when (element) { + null -> "task is null" + !is Exec -> "task ${this::class.simpleName} is not ${Exec::class.simpleName}" + else -> { + return ByteArrayOutputStream().use { outputStream -> + + executor.exec { + commandLine("tasklist") // Windows only for now... + standardOutput = outputStream + } + + if (outputStream.toString().contains(process, ignoreCase)) { + null + } else { + "found $process in tasklist" + } + } + } + } + } +} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/TypeScriptToLuaTask.kt b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/TypeScriptToLuaTask.kt new file mode 100644 index 0000000..a057288 --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/TypeScriptToLuaTask.kt @@ -0,0 +1,50 @@ +package kafkatorio.tasks + +import com.github.gradle.node.npm.task.NpmTask +import javax.inject.Inject +import org.gradle.api.file.ConfigurableFileCollection +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.FileSystemOperations +import org.gradle.api.plugins.BasePlugin +import org.gradle.api.tasks.* +import org.gradle.work.NormalizeLineEndings +import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs + +@CacheableTask +abstract class TypeScriptToLuaTask @Inject constructor( + private val fs: FileSystemOperations +) : NpmTask() { + + @get:InputFiles + @get:SkipWhenEmpty + @get:PathSensitive(PathSensitivity.RELATIVE) + @get:NormalizeLineEndings + @get:IgnoreEmptyDirectories + abstract val sourceFiles: ConfigurableFileCollection + + @get:OutputDirectory + abstract val outputDirectory: DirectoryProperty + + init { + super.setGroup(BasePlugin.BUILD_GROUP) + super.setDescription("Convert TypeScript To Lua") + super.execOverrides { standardOutput = System.out } + super.npmCommand.set(listOf("run", "build")) + super.ignoreExitValue.set(false) + super.args.set(parseSpaceSeparatedArgs("-- --outDir $temporaryDir")) + } + + @TaskAction + fun tstl() { + fs.delete { delete(temporaryDir) } + temporaryDir.mkdirs() + + super.exec() + + fs.sync { + from(temporaryDir) + into(outputDirectory) + } + } + +} diff --git a/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/UpdatePackageJson.kt b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/UpdatePackageJson.kt new file mode 100644 index 0000000..bcbd523 --- /dev/null +++ b/gradle-plugins/builder-plugins/src/main/kotlin/kafkatorio/tasks/UpdatePackageJson.kt @@ -0,0 +1,116 @@ +package kafkatorio.tasks + +import com.github.gradle.node.NodePlugin +import kafkatorio.* +import java.io.File +import javax.inject.Inject +import kotlinx.serialization.encodeToString +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonObject +import kotlinx.serialization.json.JsonObjectBuilder +import kotlinx.serialization.json.buildJsonObject +import kotlinx.serialization.json.jsonObject +import org.gradle.api.DefaultTask +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.Property +import org.gradle.api.provider.ProviderFactory +import org.gradle.api.tasks.CacheableTask +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction +import org.gradle.kotlin.dsl.support.useToRun +import org.jetbrains.kotlin.util.suffixIfNot + + +@CacheableTask +abstract class UpdatePackageJson @Inject constructor( + private val providers: ProviderFactory, +) : DefaultTask(), + ProviderFactory by providers { + + /** Cumulative updates - will be combined one by one, then applied to [packageJsonFile] */ + @get:Input + internal abstract val expectedJsonUpdates: ListProperty + + @get:OutputFile + abstract val packageJsonFile: RegularFileProperty + + + init { + group = NodePlugin.NPM_GROUP + description = "Update package.json properties" + + outputs.upToDateWhen(JsonPropertiesUpToDateSpec) + } + + + @TaskAction + fun exec() { + val packageJsonFile = packageJsonFile.asFile.get() + val expectedJsonUpdates: List = expectedJsonUpdates.get().toList() + + logger.lifecycle("updating package.json ${packageJsonFile.canonicalFile}") + + val expectedJson = expectedJsonUpdates.fold(JsonObject(emptyMap())) { acc, update -> + val updateJson = jsonMapper.parseToJsonElement(update).jsonObject + JsonObject(acc + updateJson) + } + + val updatedPackageJson = JsonObject( + packageJsonFile.parseToJsonObject() + expectedJson + ) + + val packageJsonContentFormatted = + jsonMapper + .encodeToString(updatedPackageJson) + + // change empty arrays/objects, because `npm install` also formats package.json, + // but slightly differently to kxs. + .replace(": {\n }", ": {}") + .replace(": [\n ]", ": []") + + .suffixIfNot("\n") + + logger.info(packageJsonContentFormatted) + + packageJsonFile.writer().useToRun { + write(packageJsonContentFormatted) + } + } + + + /** Update [expectedJson] by merging [updateJsonProvider] with the existing value. */ + fun updateExpectedJson( + expectedJsonUpdate: JsonObjectBuilder.() -> Unit + ) { + val expectedJsonUpdateProvider = provider { + buildJsonObject(expectedJsonUpdate).toString() + } + + expectedJsonUpdates.add(expectedJsonUpdateProvider) + } + + + companion object { + private val jsonMapper = Json { + prettyPrint = true + prettyPrintIndent = " " + } + + + internal fun File.parseToJsonObject(): JsonObject = + jsonMapper.parseToJsonElement(readText()).jsonObject + + + internal fun Property.parseToJsonObject(): JsonObject = + jsonMapper.parseToJsonElement(get()).jsonObject + + + internal fun List.foldParseToJsonObject(): JsonObject = + fold(JsonObject(emptyMap())) { acc, update -> + val updateJson = jsonMapper.parseToJsonElement(update).jsonObject + JsonObject(acc + updateJson) + } + } +} diff --git a/gradle-plugins/docker-compose/build.gradle.kts b/gradle-plugins/docker-compose/build.gradle.kts new file mode 100644 index 0000000..1c4ca45 --- /dev/null +++ b/gradle-plugins/docker-compose/build.gradle.kts @@ -0,0 +1,19 @@ +plugins { + id("kafkatorio.conventions.kotlin-dsl") + `java-gradle-plugin` +} + +dependencies { + implementation(platform(libs.kotlin.bom)) + implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${libs.versions.kotlin.get()}") +} + +gradlePlugin { + plugins { + create("geedeecee") { + id = "dev.adamko.geedeecee" + displayName = "geedeecee - Gradle Docker Compose" + implementationClass = "dev.adamko.geedeecee.GDCPlugin" + } + } +} diff --git a/gradle-plugins/docker-compose/settings.gradle.kts b/gradle-plugins/docker-compose/settings.gradle.kts new file mode 100644 index 0000000..2ebeaa3 --- /dev/null +++ b/gradle-plugins/docker-compose/settings.gradle.kts @@ -0,0 +1,18 @@ +rootProject.name = "docker-compose" + +pluginManagement { + @Suppress("UnstableApiUsage") + includeBuild("../settings-plugins/") +} + +plugins { + id("kafkatorio.conventions.settings.repositories") +} + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../../gradle/libs.versions.toml")) + } + } +} diff --git a/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/GDCPlugin.kt b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/GDCPlugin.kt new file mode 100644 index 0000000..61710e3 --- /dev/null +++ b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/GDCPlugin.kt @@ -0,0 +1,138 @@ +package dev.adamko.geedeecee + +import dev.adamko.geedeecee.tasks.DockerContextFilesPreparation +import dev.adamko.geedeecee.tasks.DockerEnvUpdateTask +import dev.adamko.geedeecee.tasks.GDCCommandTask +import javax.inject.Inject +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.provider.Provider +import org.gradle.api.provider.ProviderFactory +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.create +import org.gradle.kotlin.dsl.getValue +import org.gradle.kotlin.dsl.provideDelegate +import org.gradle.kotlin.dsl.registering +import org.gradle.kotlin.dsl.withType +import org.gradle.language.base.plugins.LifecycleBasePlugin +import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs + + +@Suppress("UnstableApiUsage") +abstract class GDCPlugin @Inject constructor( + private val providers: ProviderFactory, +) : Plugin { + + + override fun apply(target: Project) { + target.plugins.apply(LifecycleBasePlugin::class) + + val gdcSettings = target.createSettings() + + val dockerComposeEnvUpdate by target.tasks.registering(DockerEnvUpdateTask::class) { + dotEnvFile.set(gdcSettings.srcDir.file(".env")) + + envProperties.putAll(gdcSettings.dotEnv) +// properties( +// "COMPOSE_PROJECT_NAME" to gdcSettings.composeProjectName, +// "KAFKATORIO_VERSION" to gdcSettings.composeProjectVersion, +// "REGISTRY_HOST" to providers.gradleProperty("dockerContainerRegistryHost"), +// ) + } + + val dockerContextPrepareFiles by target.tasks.registering(DockerContextFilesPreparation::class) { + into(gdcSettings.dockerBuildContextDir) + includeEmptyDirs = false +// dockerContextDir.set(gdcSettings.dockerBuildContextDir) +// copySpec.convention(target.copySpec()) +// copySpec = Action { } + } + + val dockerComposeUp by target.tasks.registering(GDCCommandTask::class) { + `docker-compose`("up -d") + } + val dockerComposeDown by target.tasks.registering(GDCCommandTask::class) { + `docker-compose`("down") + } + val dockerComposeStop by target.tasks.registering(GDCCommandTask::class) { + `docker-compose`("stop") + } + val dockerComposeBuild by target.tasks.registering(GDCCommandTask::class) { + `docker-compose`("build") + cacheable.set(true) + } + val dockerComposePush by target.tasks.registering(GDCCommandTask::class) { + dependsOn(dockerComposeBuild) + `docker-compose`("push") + } + val dockerComposeRemove by target.tasks.registering(GDCCommandTask::class) { + `docker-compose`("rm --stop -v -f") + } + + dockerComposeUp.configure { dependsOn(dockerComposeBuild) } + dockerComposeRemove.configure { dependsOn(dockerComposeDown) } + +// target.tasks.withType().configureEach { +// dependsOn(dockerComposeEnvUpdate) +// dockerIsActive.set(isDockerActive()) +// stateFile.set(temporaryDir.resolve("docker-state.md5")) +// } + + target.tasks.withType().configureEach { + dependsOn(dockerComposeEnvUpdate) + dependsOn(dockerContextPrepareFiles) + + workingDir.convention(gdcSettings.srcDir) + dockerActive.set(gdcSettings.dockerActive) + stateFile.set( + gdcSettings.stateDir.file(workingDir.map { "dc_state${name.hashCode()}${it.asFile.hashCode()}.md5" }) + ) + } + + val assembleTasks = target.tasks.matching { LifecycleBasePlugin.ASSEMBLE_TASK_NAME == it.name } + + assembleTasks.configureEach { + dependsOn(dockerComposeEnvUpdate) + } + + dockerComposeUp.configure { + dependsOn(assembleTasks) + } + } + + + private fun Project.createSettings(): GDCSettings = + extensions.create(GDC_EXTENSION_NAME).apply { + composeProjectName.convention(providers.provider { rootProject.name }) + composeProjectVersion.convention(providers.provider { project.version.toString() }) + containerRegistryHost.convention(providers.gradleProperty("dockerContainerRegistryHost")) + srcDir.convention(layout.projectDirectory.dir("docker")) + dockerBuildContextDir.convention(srcDir.dir("build")) + stateDir.convention(layout.buildDirectory.dir("geedeecee/state/")) + + dotEnv.put("COMPOSE_PROJECT_NAME", composeProjectName) + dotEnv.put("APP_NAME", providers.provider { project.name }) + dotEnv.put("APP_GROUP", providers.provider { project.group.toString() }) + dotEnv.put("PROJECT_VERSION", composeProjectVersion) + dotEnv.put("KAFKATORIO_VERSION", composeProjectVersion) + dotEnv.put("REGISTRY_HOST", containerRegistryHost) + + dockerActive.convention(isDockerActive()) + } + + + private fun isDockerActive(): Provider = + providers.exec { + commandLine = parseSpaceSeparatedArgs("docker info") + isIgnoreExitValue = true + }.result.map { + it.exitValue == 0 + } + + + companion object { + const val GDC_EXTENSION_NAME = "geedeecee" + const val GCD_TASK_GROUP = "docker-compose" + } + +} diff --git a/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/GDCSettings.kt b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/GDCSettings.kt new file mode 100644 index 0000000..a2efcdc --- /dev/null +++ b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/GDCSettings.kt @@ -0,0 +1,79 @@ +package dev.adamko.geedeecee + +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.provider.MapProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Internal + +interface GDCSettings { + + @get:Input + val composeProjectName: Property + + @get:Input + val composeProjectVersion: Property + + @get:Input + val containerRegistryHost: Property + + @get:Internal + val srcDir: DirectoryProperty + + @get:Input + val dotEnv: MapProperty + + @get:Input + val dockerActive: Property + + @get:Input + val dockerBuildContextDir: DirectoryProperty + + val stateDir: DirectoryProperty + +// @Suppress("PropertyName", "FunctionName") +// abstract class DotEnv( +// private val dotEnv: MapProperty, +// private val providers: ProviderFactory, +// ) { +// var COMPOSE_API_VERSION: Provider by dotEnv +// fun COMPOSE_API_VERSION(value: () -> String) { +// COMPOSE_API_VERSION = providers.provider(value) +// } +// // var COMPOSE_CONVERT_WINDOWS_PATHS: String +//// var COMPOSE_FILE: String +//// var COMPOSE_HTTP_TIMEOUT: String +//// var COMPOSE_PROFILES: String +//// var COMPOSE_PROJECT_NAME: String +//// var COMPOSE_TLS_VERSION: String +//// var DOCKER_CERT_PATH: String +//// var DOCKER_HOST: String +//// var DOCKER_TLS_VERIFY: String +// fun setComposeApiVersion(composeApiVersion: String) {} +// fun setComposeConvertWindowsPaths(composeConvertWindowsPaths: String) {} +// fun setComposeFile(composeFile: String) {} +// fun setComposeHttpTimeout(composeHttpTimeout: String) {} +// fun setComposeProfiles(composeProfiles: String) {} +// fun setComposeProjectName(composeProjectName: String) {} +// fun setComposeTlsVersion(composeTlsVersion: String) {} +// fun setDockerCertPath(dockerCertPath: String) {} +// fun setDockerHost(dockerHost: String) {} +// fun setDockerTlsVerify(dockerTlsVerify: String) {} +// } + +} +// +//private operator fun > MapProperty.setValue( +// dotEnv: GDCSettings.DotEnv, +// property: KProperty<*>, +// v: PV +//) { +// put(property.name, v) +//} +// +//private operator fun MapProperty.getValue( +// dotEnv: GDCSettings.DotEnv, +// property: KProperty<*> +//): Provider { +// return getting(property.name) +//} diff --git a/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/internal/files.kt b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/internal/files.kt new file mode 100644 index 0000000..e0ba466 --- /dev/null +++ b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/internal/files.kt @@ -0,0 +1,12 @@ +package dev.adamko.geedeecee.internal + +import org.gradle.api.file.Directory +import org.jetbrains.kotlin.incremental.md5 + +// should be moved to common plugins lib + +internal fun Directory.filesChecksum(): Long = asFileTree + .files + .map { it.readBytes() + it.absolutePath.toByteArray() } + .fold(byteArrayOf()) { acc, bytes -> acc + bytes } + .md5() diff --git a/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/internal/gradle.kt b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/internal/gradle.kt new file mode 100644 index 0000000..21385e6 --- /dev/null +++ b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/internal/gradle.kt @@ -0,0 +1,14 @@ +package dev.adamko.geedeecee.internal + +import org.gradle.api.Task +import org.gradle.api.file.FileCopyDetails +import org.gradle.api.file.RelativePath + +// move to common-lib + +internal inline fun T.enabledIf(crossinline spec: (T) -> Boolean) { + onlyIf { + require(it is T) + spec(it) + } +} diff --git a/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/tasks/DockerContextFilesPreparation.kt b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/tasks/DockerContextFilesPreparation.kt new file mode 100644 index 0000000..a400711 --- /dev/null +++ b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/tasks/DockerContextFilesPreparation.kt @@ -0,0 +1,56 @@ +package dev.adamko.geedeecee.tasks + +import dev.adamko.geedeecee.GDCPlugin +import javax.inject.Inject +import org.gradle.api.tasks.Sync + + +// look into using 'build context' for up-to-date check +// https://stackoverflow.com/questions/38946683/how-to-test-dockerignore-file +// https://github.com/pwaller/docker-show-context +// https://snippets.khromov.se/see-which-files-are-included-in-your-docker-build-context/ + + +//@CacheableTask +//@Suppress("UnstableApiUsage") +abstract class DockerContextFilesPreparation @Inject constructor( +// private val files: FileSystemOperations, +) : Sync() { + +// @get:InputFiles +//// @get:SkipWhenEmpty +// @get:PathSensitive(PathSensitivity.RELATIVE) +// @get:NormalizeLineEndings +// abstract val dockerContextFiles: ConfigurableFileCollection + +// @get:Input +// abstract val copySpec: Property +// +// @get:OutputDirectory +// abstract val dockerContextDir: DirectoryProperty + + init { + group = GDCPlugin.GCD_TASK_GROUP + } + +// @TaskAction +// fun exec() { +// files.sync { +// from(dockerContextFiles, copySpec) +// into(dockerContextDir) +//// with(copySpec) +// } +// } + +// /** @see [CopySpec.from] */ +// override fun from(vararg sourcePaths: Any?): CopySpec = +// copySpec.from(sourcePaths) +// +// /** @see [CopySpec.from] */ +// override fun from(sourcePath: Any, configureClosure: Closure<*>): CopySpec = +// copySpec.from(sourcePath, configureClosure) +// +// /** @see [CopySpec.from] */ +// override fun from(sourcePath: Any, configureAction: Action): CopySpec = +// copySpec.from(sourcePath, configureAction) +} diff --git a/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/tasks/DockerEnvUpdateTask.kt b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/tasks/DockerEnvUpdateTask.kt new file mode 100644 index 0000000..6fddbd6 --- /dev/null +++ b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/tasks/DockerEnvUpdateTask.kt @@ -0,0 +1,101 @@ +package dev.adamko.geedeecee.tasks + +import dev.adamko.geedeecee.GDCPlugin +import java.io.File +import java.nio.charset.Charset +import java.util.Properties +import javax.inject.Inject +import org.gradle.api.DefaultTask +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.MapProperty +import org.gradle.api.provider.Property +import org.gradle.api.provider.Provider +import org.gradle.api.tasks.CacheableTask +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction + + +/** + * (Based on [org.gradle.api.tasks.WriteProperties], but updated to use [MapProperty]) + */ +@CacheableTask +abstract class DockerEnvUpdateTask @Inject constructor( +) : DefaultTask() { + + @get:Input + @get:Optional + abstract val envProperties: MapProperty + + @get:Input + @get:Optional + abstract val comment: Property + + @get:Input + @get:Optional + abstract val charset: Property + + @get:OutputFile + abstract val dotEnvFile: RegularFileProperty + + init { + group = GDCPlugin.GCD_TASK_GROUP + } + + @TaskAction + fun writeProperties() { + val dotEnvFile: File = dotEnvFile.get().asFile + val charset: Charset = charset.orNull ?: Charsets.UTF_8 + + val comment: String = comment.orNull + ?: " Do not edit manually. This file was created with task '$name'" + + val envProperties = envProperties.getOrElse(emptyMap()) + + dotEnvFile.writer(charset).use { writer -> + val properties = Properties() + properties.putAll(envProperties) + properties.store(writer, comment) + } + + // make the file reproducible by sorting and filtering lines in the file + val lines = dotEnvFile.useLines(charset) { lines -> + lines + .filterNot { it.isBlank() } + .sorted() + .toList() + } + + // first comment is our comment + // second comment is the auto generated timestamp - which we will filter out, so the file is reproducible + val parsedComment = lines.firstOrNull { it.isComment() } ?: "" + val parsedLines = lines.filterNot { it.isComment() }.joinToString(separator = "\n") + + dotEnvFile.writeText( + charset = charset, + text = """ + |$parsedComment + | + |$parsedLines + | + """.trimMargin() + ) + } + + fun envProperties(configure: MapProperty.() -> Unit) { + envProperties.configure() + } + + companion object { + @JvmName("putProvider") + fun MapProperty.put(entry: Pair>) = + put(entry.first, entry.second) + + @JvmName("putValue") + fun MapProperty.put(entry: Pair) = + put(entry.first, entry.second) + + private fun String.isComment(): Boolean = trim().startsWith('#') + } +} diff --git a/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/tasks/GDCCommandTask.kt b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/tasks/GDCCommandTask.kt new file mode 100644 index 0000000..fba14f3 --- /dev/null +++ b/gradle-plugins/docker-compose/src/main/kotlin/dev/adamko/geedeecee/tasks/GDCCommandTask.kt @@ -0,0 +1,90 @@ +package dev.adamko.geedeecee.tasks + +import dev.adamko.geedeecee.GDCPlugin +import dev.adamko.geedeecee.internal.enabledIf +import dev.adamko.geedeecee.internal.filesChecksum +import javax.inject.Inject +import org.gradle.api.DefaultTask +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.logging.LogLevel +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputDirectory +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity +import org.gradle.api.tasks.SkipWhenEmpty +import org.gradle.api.tasks.TaskAction +import org.gradle.process.ExecOperations +import org.gradle.work.NormalizeLineEndings +import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs + + +// look into using 'build context' for up-to-date check +// https://stackoverflow.com/questions/38946683/how-to-test-dockerignore-file +// https://github.com/pwaller/docker-show-context +// https://snippets.khromov.se/see-which-files-are-included-in-your-docker-build-context/ +// or parsing Dockerfile +// https://github.com/keilerkonzept/dockerfile-json + + +@Suppress("UnstableApiUsage") // NormalizeLineEndings +abstract class GDCCommandTask @Inject constructor( + private val executor: ExecOperations, +) : DefaultTask() { + + @get:InputDirectory + @get:SkipWhenEmpty + @get:PathSensitive(PathSensitivity.RELATIVE) + @get:NormalizeLineEndings + abstract val workingDir: DirectoryProperty + + @get:Input + abstract val separatedArgs: ListProperty + + @get:Input + abstract val dockerActive: Property + + @get:Input + @get:Optional + abstract val cacheable: Property + + @get:OutputFile + abstract val stateFile: RegularFileProperty + + init { + group = GDCPlugin.GCD_TASK_GROUP + description = "Run a docker-compose command." + + enabledIf { it.dockerActive.getOrElse(false) } + + logging.captureStandardOutput(LogLevel.LIFECYCLE) + } + + @TaskAction + fun dockerCompose() { + val separatedArgs: List = separatedArgs.get() + + executor.exec { + environment("BUILDKIT_PROGRESS", "plain") + workingDir(this@GDCCommandTask.workingDir) + commandLine(separatedArgs) + } + + if (cacheable.getOrElse(false)) { + val inputChecksum = workingDir.get().filesChecksum() + stateFile.get().asFile.writeText("$inputChecksum") + } + } + + /** Set the `docker-compose` argument */ + @Suppress("FunctionName") + fun `docker-compose`(args: String) { + separatedArgs.set( + parseSpaceSeparatedArgs("docker-compose $args") + ) + } +} diff --git a/gradle-plugins/factorio-gradle/build.gradle.kts b/gradle-plugins/factorio-gradle/build.gradle.kts new file mode 100644 index 0000000..ea4c623 --- /dev/null +++ b/gradle-plugins/factorio-gradle/build.gradle.kts @@ -0,0 +1,64 @@ +import kafkatorio.conventions.overrideKotlinLanguageVersion +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("kafkatorio.conventions.kotlin-dsl") + id("kafkatorio.conventions.kotlin-serialization") +} + + +dependencies { + implementation(platform(libs.kotlin.bom)) + + implementation(platform(libs.kotlinx.coroutines.bom)) + implementation(libs.kotlinx.coroutines.core) + + implementation(platform(libs.kotlinxSerialization.bom)) + implementation(libs.kotlinxSerialization.core) + implementation(libs.kotlinxSerialization.json) + + implementation(platform(libs.okio.bom)) + implementation(libs.okio.core) + + implementation(libs.kotlinx.cli) + + implementation(platform(libs.ktor.bom)) + implementation(libs.ktorClient.auth) + implementation(libs.ktorClient.contentNegotiation) + implementation(libs.ktorClient.core) + implementation(libs.ktorClient.encoding) + implementation(libs.ktorClient.logging) + implementation(libs.ktorClient.cio) + implementation(libs.ktorClient.resources) + implementation(libs.ktorSerialization.kotlinxJson) + + implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:${libs.versions.kotlin.get()}") +} + +gradlePlugin { + plugins { + create("factorioMod") { + displayName = "Factorio Mod" + id = "dev.adamko.factorio-mod" + implementationClass = "dev.adamko.gradle.factorio.FactorioModPlugin" + } + } + plugins { + create("factorioModLibrary") { + displayName = "Factorio Mod Library" + id = "dev.adamko.factorio-mod-library" + implementationClass = "dev.adamko.gradle.factorio.FactorioModLibraryPlugin" + } + } +} + +overrideKotlinLanguageVersion("1.7") // required for Kotlinx Serialization + +tasks.withType().configureEach { + kotlinOptions.freeCompilerArgs += listOf( + "-opt-in=kotlin.RequiresOptIn", + "-opt-in=kotlin.ExperimentalStdlibApi", + "-opt-in=kotlin.time.ExperimentalTime", + "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + ) +} diff --git a/gradle-plugins/factorio-gradle/settings.gradle.kts b/gradle-plugins/factorio-gradle/settings.gradle.kts new file mode 100644 index 0000000..72f93af --- /dev/null +++ b/gradle-plugins/factorio-gradle/settings.gradle.kts @@ -0,0 +1,20 @@ +@file:Suppress("UnstableApiUsage") + +rootProject.name = "factorio-gradle" + +pluginManagement { + @Suppress("UnstableApiUsage") + includeBuild("../settings-plugins/") +} + +plugins { + id("kafkatorio.conventions.settings.repositories") +} + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + from(files("../../gradle/libs.versions.toml")) + } + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModConfigurations.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModConfigurations.kt new file mode 100644 index 0000000..ab13cee --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModConfigurations.kt @@ -0,0 +1,9 @@ +package dev.adamko.gradle.factorio + +import org.gradle.api.NamedDomainObjectProvider +import org.gradle.api.artifacts.Configuration + +internal data class FactorioModConfigurations( + val factorioMod: NamedDomainObjectProvider, + val factorioModProvider: NamedDomainObjectProvider, + ) diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModLibraryPlugin.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModLibraryPlugin.kt new file mode 100644 index 0000000..0e96e2f --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModLibraryPlugin.kt @@ -0,0 +1,48 @@ +package dev.adamko.gradle.factorio + +import javax.inject.Inject +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.slf4j.LoggerFactory + +/** + * Configure a [Project] to produce components that will be used in a Factorio mod, but no tasks + * that will create a Factorio mod. + */ +abstract class FactorioModLibraryPlugin @Inject constructor( +// private val objects: ObjectFactory, +// private val providers: ProviderFactory, +// private val layout: ProjectLayout, +// private val files: FileSystemOperations, +) : Plugin { + + internal val logger = LoggerFactory.getLogger(this::class.java) + + internal var factorioModConfigurations: FactorioModConfigurations? = null + private set + + override fun apply(target: Project) { + factorioModConfigurations = target.createConfigurations() + } + + private fun Project.createConfigurations(): FactorioModConfigurations { + return FactorioModConfigurations( + factorioMod = project.configurations.register(CONFIGURATION_NAME__FACTORIO_MOD) { + asConsumer() + factorioModAttributes(objects) + }, + + factorioModProvider = project.configurations.register( + CONFIGURATION_NAME__FACTORIO_MOD_PROVIDER + ) { + asProvider() + factorioModAttributes(objects) + }, + ) + } + + companion object { + const val CONFIGURATION_NAME__FACTORIO_MOD = "factorioMod" + const val CONFIGURATION_NAME__FACTORIO_MOD_PROVIDER = "factorioModProvider" + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModPlugin.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModPlugin.kt new file mode 100644 index 0000000..aee6ba0 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModPlugin.kt @@ -0,0 +1,108 @@ +package dev.adamko.gradle.factorio + +import dev.adamko.gradle.factorio.tasks.AssembleFactorioModContents +import dev.adamko.gradle.factorio.tasks.GenerateFactorioModInfoTask +import dev.adamko.gradle.factorio.tasks.LaunchFactorioClientTask +import dev.adamko.gradle.factorio.tasks.LocalPublishFactorioModTask +import dev.adamko.gradle.factorio.tasks.PackageFactorioModTask +import javax.inject.Inject +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.file.FileSystemOperations +import org.gradle.api.file.ProjectLayout +import org.gradle.api.model.ObjectFactory +import org.gradle.api.provider.ProviderFactory +import org.gradle.api.tasks.TaskProvider +import org.gradle.kotlin.dsl.create +import org.gradle.kotlin.dsl.newInstance +import org.gradle.kotlin.dsl.register +import org.slf4j.LoggerFactory + + +abstract class FactorioModPlugin @Inject constructor( + private val objects: ObjectFactory, + private val providers: ProviderFactory, + private val layout: ProjectLayout, + private val files: FileSystemOperations, +) : Plugin { + + internal val logger = LoggerFactory.getLogger(this::class.java) + + override fun apply(target: Project) { + + val settings = target.extensions.create(FACTORIO_GRADLE_EXTENSION_NAME) + + val factorioModLibraryPlugin = objects.newInstance() + factorioModLibraryPlugin.apply(target) + val factorioModConfigurations = factorioModLibraryPlugin.factorioModConfigurations + ?: error("Could not create Factorio Mod Configurations") + + val context = PluginContext( + target, + + settings, + target.createTasks(), + factorioModConfigurations, + + objects, + providers, + layout, + files, + ) + + context.configureModSettings() + + context.configureTasks() + + context.configureIdea() + +// context.configureDistribution() + } + + private fun Project.createTasks(): PluginContext.Tasks { + return PluginContext.Tasks( + launchFactorioClient = project.tasks.register("launchFactorioClient"), + assembleModContents = project.tasks.register("assembleFactorioModContents"), + packageMod = project.tasks.register("packageFactorioMod"), + publishModToLocalClient = project.tasks.register("publishFactorioModToLocalClient"), + generateModInfoJson = project.tasks.register("generateFactorioModInfoJson"), + ) + } + + internal class PluginContext( + val project: Project, + val settings: FactorioModSettings, + val tasks: Tasks, + val configurations: FactorioModConfigurations, + + val objects: ObjectFactory, + val providers: ProviderFactory, + val layout: ProjectLayout, + val files: FileSystemOperations, + ) { + internal val logger = LoggerFactory.getLogger(this::class.java) + + data class Tasks( + val launchFactorioClient: TaskProvider, + val assembleModContents: TaskProvider, + val packageMod: TaskProvider, + val publishModToLocalClient: TaskProvider, + val generateModInfoJson: TaskProvider, + ) + } + + + companion object { + const val FACTORIO_GRADLE_EXTENSION_NAME = "factorioMod" + + const val CONFIGURATION_NAME__FACTORIO_MOD = "factorioMod" + const val CONFIGURATION_NAME__FACTORIO_MOD_PROVIDER = "factorioModProvider" + + const val TASK_GROUP = "factorio mod" + + /** Lifecycle task for publishing the mod locally */ + const val PUBLISH_MOD_LOCAL_TASK_NAME = "publishModLocal" + + const val PUBLISH_MOD_TASK_NAME = "publishMod" + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModSettings.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModSettings.kt new file mode 100644 index 0000000..1acb4f2 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModSettings.kt @@ -0,0 +1,69 @@ +package dev.adamko.gradle.factorio + +import javax.inject.Inject +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.ProjectLayout +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.model.ObjectFactory +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.Property +import org.gradle.api.provider.ProviderFactory +import org.gradle.kotlin.dsl.newInstance + +abstract class FactorioModSettings @Inject constructor( + internal val objects: ObjectFactory, + internal val providers: ProviderFactory, + internal val layout: ProjectLayout, +) { + + abstract val modName: Property + abstract val modTitle: Property + abstract val modDescription: Property + abstract val modAuthor: Property + abstract val modVersion: Property + abstract val modDependencies: ListProperty + + // version of Factorio that the mod is compatible with (must only be "major.minor" - patch causes error) + abstract val factorioCompatibility: Property + + abstract val distributionZipName: Property + + val mainSources: FactorioModSourceSet.WithResources = objects.newInstance("Main") + val testSources: FactorioModSourceSet.WithResources = objects.newInstance("Test") + val generatedSources: FactorioModSourceSet = objects.newInstance("Generated") + + +// abstract val typescriptSrcDir: DirectoryProperty +// abstract val resourcesDir: DirectoryProperty +// abstract val modDataResourcesDir: DirectoryProperty +// abstract val generatedLuaSrcDir: DirectoryProperty + + + abstract val factorioServerDataDirectory: DirectoryProperty + + + val localDev: LocalDev = objects.newInstance() + + fun localDev(configure: LocalDev.() -> Unit) { + localDev.configure() + } + + interface LocalDev { + val currentOs: Property + + val windowsSteamExe: Property + + val factorioSteamId: Property + + val serverConnectHost: Property + + val clientModsDirectory: RegularFileProperty + + val macApplicationSupportDir: RegularFileProperty + + val macFactorioApp: RegularFileProperty + + /** Supported local dev OSes */ + enum class OS { WINDOWS, MAC_OS, UNSUPPORTED } + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModSourceSet.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModSourceSet.kt new file mode 100644 index 0000000..fcf4849 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/FactorioModSourceSet.kt @@ -0,0 +1,38 @@ +package dev.adamko.gradle.factorio + +import javax.inject.Inject +import org.gradle.api.Named +import org.gradle.api.file.SourceDirectorySet +import org.gradle.api.model.ObjectFactory + +abstract class FactorioModSourceSet @Inject constructor( + private val named: String, + objects: ObjectFactory, +) : Named { + + val typescript: SourceDirectorySet = objects + .sourceDirectorySet("ts${named}", "TypeScript $named source files") + .apply { + include("**/*.d.ts", "**/*.ts") + } + + val lua: SourceDirectorySet = objects + .sourceDirectorySet("lua${named}", "Lua $named source files") + .apply { + include("**/*.lua") + } + + override fun getName(): String = named + + abstract class WithResources @Inject constructor( + type: String, + objects: ObjectFactory, + ) : FactorioModSourceSet(type, objects) { + + val resources: SourceDirectorySet = objects + .sourceDirectorySet("resources${type}", "$type resources") + .apply { + exclude("**/*.d.ts", "**/*.ts", "**/*.lua") + } + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/artifactDistributions.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/artifactDistributions.kt new file mode 100644 index 0000000..bcb7e5c --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/artifactDistributions.kt @@ -0,0 +1,44 @@ +package dev.adamko.gradle.factorio + +import org.gradle.api.artifacts.Configuration +import org.gradle.api.attributes.Bundling +import org.gradle.api.attributes.Bundling.BUNDLING_ATTRIBUTE +import org.gradle.api.attributes.Category +import org.gradle.api.attributes.Category.CATEGORY_ATTRIBUTE +import org.gradle.api.attributes.LibraryElements +import org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE +import org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE +import org.gradle.api.model.ObjectFactory +import org.gradle.kotlin.dsl.named + + +fun Configuration.asProvider(visible: Boolean = false) { + isVisible = visible + isCanBeResolved = false + isCanBeConsumed = true +} + + +fun Configuration.asConsumer(visible: Boolean = false) { + isVisible = visible + isCanBeResolved = true + isCanBeConsumed = false +} + + +fun Configuration.factorioModAttributes(objects: ObjectFactory): Configuration = + attributes { + attribute(USAGE_ATTRIBUTE, objects.named("dev.adamko.factorio")) + attribute(CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY)) + attribute(LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.CLASSES_AND_RESOURCES)) + attribute(BUNDLING_ATTRIBUTE, objects.named(Bundling.EMBEDDED)) + } + + +fun Configuration.typescriptAttributes(objects: ObjectFactory): Configuration = + attributes { + attribute(USAGE_ATTRIBUTE, objects.named("dev.adamko.typescript")) + attribute(CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY)) + attribute(LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.OBJECTS)) + attribute(BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL)) + } diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureDistribution.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureDistribution.kt new file mode 100644 index 0000000..72f4c81 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureDistribution.kt @@ -0,0 +1,42 @@ +package dev.adamko.gradle.factorio + +import org.gradle.api.distribution.DistributionContainer +import org.gradle.api.distribution.plugins.DistributionPlugin +import org.gradle.api.tasks.bundling.Zip +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.named + +internal fun FactorioModPlugin.PluginContext.configureDistribution() { + + project.plugins.apply(DistributionPlugin::class) + + val distributions = project.extensions.getByType() + + distributions.named(DistributionPlugin.MAIN_DISTRIBUTION_NAME) { + + distributionBaseName.set(settings.modName) + + contents { + includeEmptyDirs = false + + from(settings.mainSources.resources) { + include("**/**") + } + + exclude { + // exclude empty files + it.file.run { + isFile && useLines { lines -> lines.all { line -> line.isBlank() } } + } + } + } + } + + val distZipTask = project.tasks.named("distZip") + + configurations.factorioModProvider.configure { + outgoing.artifact(distZipTask.flatMap { it.archiveFile }) + } + +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureIdea.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureIdea.kt new file mode 100644 index 0000000..6b9654c --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureIdea.kt @@ -0,0 +1,38 @@ +package dev.adamko.gradle.factorio + +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.withType +import org.gradle.plugins.ide.idea.IdeaPlugin +import org.gradle.plugins.ide.idea.model.IdeaModel +//import org.gradle.plugins.ide.idea.model.Module as IdeaModule + +internal fun FactorioModPlugin.PluginContext.configureIdea() { + project.plugins.withType().configureEach { + + project.extensions.configure { + module { + // scopes["MAIN"] = mapOf("plus" to listOf(configurations.factorioMod.get())) + + sourceDirs.plusAssign(settings.mainSources.typescript.srcDirs) + sourceDirs.plusAssign(settings.mainSources.lua.srcDirs) + sourceDirs.plusAssign(settings.generatedSources.lua.srcDirs) + + testSources.from(settings.testSources.typescript) + testSources.from(settings.testSources.lua) + + resourceDirs.plusAssign(settings.mainSources.resources.srcDirs) + testResources.from(settings.testSources.resources) + + generatedSourceDirs.plusAssign(settings.generatedSources.lua.srcDirs) + generatedSourceDirs.plusAssign(settings.generatedSources.typescript.srcDirs) + +// iml { +// whenMerged { +// require(this is IdeaModule) +// +// } +// } + } + } + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureModSettings.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureModSettings.kt new file mode 100644 index 0000000..a587b30 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureModSettings.kt @@ -0,0 +1,99 @@ +package dev.adamko.gradle.factorio + +import dev.adamko.gradle.factorio.FactorioModSettings.LocalDev.OS +import java.io.File +import org.gradle.api.internal.provider.Providers +import org.gradle.api.provider.ProviderFactory + + +internal fun FactorioModPlugin.PluginContext.configureModSettings() = with(settings) { + modName.convention(providers.provider { project.name }) + modTitle.convention(modName) + modDescription.convention(providers.provider { project.description ?: "" }) + modVersion.convention(providers.provider { project.version.toString() }) + + distributionZipName.convention(providers.zip(modName, modVersion) { name, version -> + "${name}_${version}.zip" + }) + + val srcBaseMain = layout.projectDirectory.dir("src/main") + mainSources.lua.srcDir(srcBaseMain.dir("lua")) + mainSources.typescript.srcDir(srcBaseMain.dir("typescript")) + mainSources.resources.srcDir(srcBaseMain.dir("resources")) + + + val srcBaseTest = layout.projectDirectory.dir("src/test") + testSources.lua.srcDir(srcBaseTest.dir("lua")) + testSources.typescript.srcDir(srcBaseTest.dir("typescript")) + testSources.resources.srcDir(srcBaseTest.dir("resources")) + + + val srcBaseGenerated = layout.buildDirectory.dir("generated-src").get() + generatedSources.lua.srcDir(srcBaseGenerated.dir("lua")) + generatedSources.typescript.srcDir(srcBaseGenerated.dir("typescript")) + + mainSources.typescript.destinationDirectory.convention(srcBaseGenerated.dir("lua")) + + configureLocalDev() +} + + +private fun FactorioModPlugin.PluginContext.configureLocalDev() = with(settings) { + + val userHome = providers.systemProperty("user.home") + .map { home -> File(home) } + + + localDev { + + currentOs.convention(providers.systemProperty("os.name").map { osName -> + val currentOS = osName.lowercase() + when { + "windows" in currentOS -> OS.WINDOWS + "mac" in currentOS -> OS.MAC_OS + else -> { + logger.warn("cannot select OS for Factorio local dev - '${osName}' is unsupported") + OS.UNSUPPORTED + } + } + }) + + windowsSteamExe.convention("""C:\Program Files (x86)\Steam\steam.exe""") + factorioSteamId.convention("427520") +// serverConnectHost.convention("localhost") + + macApplicationSupportDir.convention(layout.file(userHome.map { home -> + home.resolve("""Library/Application Support/""") + })) + + macFactorioApp.convention(layout.file(macApplicationSupportDir.map { appSupport -> + appSupport.asFile.resolve("""Steam/steamapps/common/Factorio/factorio.app/Contents/MacOS/factorio""") + })) + + clientModsDirectory.convention(layout.file( + currentOs.flatMap { os -> + when (os) { + OS.WINDOWS -> userHome.map { home -> + home.resolve("""AppData/Roaming/Factorio/mods""") + } + + OS.MAC_OS -> macApplicationSupportDir.map { appSupport -> + appSupport.asFile.resolve("""factorio/mods""") + + } + + OS.UNSUPPORTED -> { + logger.warn("cannot automatically determine Factorio client mod directory, $os is unsupported") + Providers.notDefined() // https://github.com/gradle/gradle/issues/12388 + } + } + } + )) + } +} + + +private fun ProviderFactory.factorioModProp(name: String) { + environmentVariable("FACTORIO_MOD_$name") + .orElse(gradleProperty("factorioMod_$name")) +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureTasks.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureTasks.kt new file mode 100644 index 0000000..5876803 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/configureTasks.kt @@ -0,0 +1,137 @@ +package dev.adamko.gradle.factorio + +import dev.adamko.gradle.factorio.tasks.AssembleFactorioModContents +import dev.adamko.gradle.factorio.tasks.GenerateFactorioModInfoTask +import dev.adamko.gradle.factorio.tasks.LaunchFactorioClientTask +import dev.adamko.gradle.factorio.tasks.LocalPublishFactorioModTask +import dev.adamko.gradle.factorio.tasks.PackageFactorioModTask +import org.gradle.kotlin.dsl.withType + +internal fun FactorioModPlugin.PluginContext.configureTasks() { + + tasks.launchFactorioClient.configure { + + } + tasks.assembleModContents.configure { + modFiles.apply { + from(settings.mainSources.typescript.destinationDirectory) + from(tasks.generateModInfoJson) + from(settings.mainSources.resources) + } + } + tasks.packageMod.configure { + from(tasks.assembleModContents) + } + tasks.publishModToLocalClient.configure { + dependsOn(tasks.packageMod) + } + tasks.generateModInfoJson.configure { + + } + + + project.tasks.withType().configureEach { + description = "Copy the mod to the Factorio client" + group = FactorioModPlugin.TASK_GROUP + + onlyIf { + require(it is LocalPublishFactorioModTask) + it.clientModDirectory.asFile.get().exists() + } + + modFiles.from( + configurations.factorioMod.map { + it.incoming + .artifactView { lenient(true) } + .files + } + ) + + doLast { + logger.lifecycle("Published Factorio Mod to '${clientModDirectory.asFile.get()}'") + } + } + + configureLaunchFactorioClientTasks() + + project.tasks.withType().configureEach { + description = "Generate info.json (required for Factorio Mods)" + group = FactorioModPlugin.TASK_GROUP + + modName.convention(settings.modName) + modTitle.convention(settings.modTitle) + modDescription.convention(settings.modDescription) + modAuthor.convention(settings.modAuthor) + modVersion.convention(settings.modVersion) + factorioCompatibility.convention(settings.factorioCompatibility) + modDependencies.convention(settings.modDependencies) + infoJson.convention( + layout.file( + providers.provider { + temporaryDir.resolve("info.json") + } + ) + ) + } + + project.tasks.withType().configureEach { + description = "Gather the mod files that will be packaged into the mod zip" + group = FactorioModPlugin.TASK_GROUP + + modName.convention(settings.modName) + modVersion.convention(settings.modVersion) + + destination.convention(layout.dir(providers.provider { temporaryDir })) + } + + project.tasks.withType().configureEach { + description = "Package the Factorio mod" + group = FactorioModPlugin.TASK_GROUP + + archiveFileName.convention(settings.distributionZipName) + + includeEmptyDirs = false + + exclude { + // exclude empty files + it.file.run { + isFile && useLines { lines -> lines.all { line -> line.isBlank() } } + } + } + } + + project.tasks.withType().configureEach { + description = "Launch local Factorio Steam game client" + group = FactorioModPlugin.TASK_GROUP + + modFiles.from(project.tasks.withType()) + clientModDirectory.convention(layout.dir(settings.localDev.clientModsDirectory.asFile)) + } +} + + +private fun FactorioModPlugin.PluginContext.configureLaunchFactorioClientTasks() { + + val localDev = settings.localDev + +// // convert to local props -> try to comply with Gradle config cache +// val localDevCurrentOs = localDev.currentOs +// val localDevWindowsSteamExe = localDev.windowsSteamExe +// val localDevFactorioSteamId = localDev.factorioSteamId +// val localDevServerConnectHost = localDev.serverConnectHost +// val localDevClientModDirectory = localDev.clientModDirectory +// val localDevMacApplicationSupportDir = localDev.macApplicationSupportDir +// val localDevMacFactorioApp = localDev.macFactorioApp + + project.tasks.withType().configureEach { + description = "Launch local Factorio Steam game client" + group = FactorioModPlugin.TASK_GROUP + + currentOs.convention(localDev.currentOs) + windowsSteamExe.convention(localDev.windowsSteamExe) + factorioSteamId.convention(localDev.factorioSteamId) + serverConnectHost.convention(localDev.serverConnectHost) + clientModsPath.convention(localDev.clientModsDirectory.map { it.asFile.canonicalPath }) + macFactorioApp.convention(localDev.macFactorioApp) + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod/FactorioModProperties.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod/FactorioModProperties.kt new file mode 100644 index 0000000..8c73c13 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod/FactorioModProperties.kt @@ -0,0 +1,19 @@ +package dev.adamko.gradle.factorio.mod + +// to be used in a NamedDomainObject container? + +//import org.gradle.api.Named +//import org.gradle.api.provider.Property +// +//abstract class FactorioModProperties : Named { +// +// abstract val modName: Property +// abstract val modTitle: Property +// abstract val modDescription: Property +// abstract val modVersion: Property +// +// // version of Factorio that the mod is compatible with (must only be "major.minor" - patch causes error) +// abstract val factorioCompatibility: Property +// +// abstract val distributionZipName: Property +//} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod_portal/FactorioModPortalPublishClient.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod_portal/FactorioModPortalPublishClient.kt new file mode 100644 index 0000000..b382bc3 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod_portal/FactorioModPortalPublishClient.kt @@ -0,0 +1,139 @@ +package dev.adamko.gradle.factorio.mod_portal + +import io.ktor.client.HttpClient +import io.ktor.client.engine.cio.CIO +import io.ktor.client.plugins.contentnegotiation.ContentNegotiation +import io.ktor.client.plugins.defaultRequest +import io.ktor.client.plugins.logging.LogLevel +import io.ktor.client.request.forms.MultiPartFormDataContent +import io.ktor.client.request.forms.formData +import io.ktor.client.request.forms.submitForm +import io.ktor.client.request.header +import io.ktor.client.request.post +import io.ktor.client.request.setBody +import io.ktor.client.statement.bodyAsText +import io.ktor.http.ContentType +import io.ktor.http.Headers +import io.ktor.http.HttpHeaders +import io.ktor.http.Parameters +import io.ktor.http.append +import io.ktor.http.isSuccess +import io.ktor.serialization.kotlinx.json.json +import java.io.File +import kotlinx.coroutines.runBlocking +import kotlinx.serialization.json.Json +import org.gradle.api.internal.tasks.userinput.UserInputHandler +import org.gradle.kotlin.dsl.support.useToRun +import io.ktor.client.plugins.logging.Logger as KtorLogger +import io.ktor.client.plugins.logging.Logging as KtorLogging +import org.gradle.api.logging.Logger as GradleLogger +import org.gradle.api.logging.Logging as GradleLogging + + +class FactorioModPortalPublishClient( + private val userInputHandler: UserInputHandler, + private val distributionZip: File, + private val modName: String, + private val modVersion: String, + private val portalApiKey: String, + private val portalUploadEndpoint: String, + private val modPortalBaseURl: String, +) { + + private val logger: GradleLogger = GradleLogging.getLogger(this::class.java) + + private fun client() = HttpClient(CIO) { + install(KtorLogging) { + logger = object : KtorLogger { + override fun log(message: String) { + this@FactorioModPortalPublishClient.logger.debug(message) + } + } + level = LogLevel.ALL + } + install(ContentNegotiation) { + json(Json { + prettyPrint = false + isLenient = true + }) + } + defaultRequest { + header(HttpHeaders.Authorization, "Bearer $portalApiKey") + port = 443 + } + followRedirects = false + expectSuccess = false + } + + fun uploadMod(): Unit = runBlocking { + client().useToRun { + val initUploadResponse = initUpload() + + val enteredVersion = userInputHandler.askQuestion( + """ + |Are you sure you want to publish $modName:$modVersion? + |Enter the version number to confirm: + """.trimMargin(), + "", + ) + + val confirmed = enteredVersion.trim().equals(modVersion.trim(), ignoreCase = true) + + if (confirmed) { + upload(initUploadResponse) + } else { + logger.lifecycle("aborting mod '$modName' upload") + } + } + } + + private suspend fun HttpClient.initUpload(): InitUploadResponse.Success { + + val response = submitForm( + url = portalUploadEndpoint, + formParameters = Parameters.build { + append("mod", modName) + } + ) + +// println(response) + val initUploadResponse: InitUploadResponse = + Json.decodeFromString(InitUploadResponse.serializer(), response.bodyAsText()) +// println(initUploadResponse) + + require(response.status.isSuccess()) { "init upload request failed" } + + return when (initUploadResponse) { + is Failure -> error(initUploadResponse) + is InitUploadResponse.Success -> initUploadResponse + } + } + + private suspend fun HttpClient.upload(initUploadResponse: InitUploadResponse.Success) { + + val requestForm = formData { + append( + "file", + distributionZip.readBytes(), + Headers.build { + append(HttpHeaders.ContentType, ContentType.Application.Zip) + append(HttpHeaders.ContentDisposition, "filename=${distributionZip.name}") + } + ) + } + + val response = post(initUploadResponse.uploadUrl) { + setBody(MultiPartFormDataContent(requestForm)) + } + + val submitUploadResponse = + Json.decodeFromString(SubmitUploadResponse.serializer(), response.bodyAsText()) + +// logger(response) +// println(submitUploadResponse) + require(response.status.isSuccess() && submitUploadResponse is SubmitUploadResponse.Success) { + "upload request failed" + } + logger.lifecycle("Mod '$modName' uploaded successfully! ${modPortalBaseURl.removeSuffix("/")}/$modName") + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod_portal/FactorioModPublishTask.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod_portal/FactorioModPublishTask.kt new file mode 100644 index 0000000..32e1002 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod_portal/FactorioModPublishTask.kt @@ -0,0 +1,111 @@ +package dev.adamko.gradle.factorio.mod_portal + +import dev.adamko.gradle.factorio.FactorioModPlugin +import io.ktor.http.URLBuilder +import io.ktor.http.takeFrom +import javax.inject.Inject +import kotlinx.coroutines.runBlocking +import org.gradle.api.DefaultTask +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.internal.tasks.userinput.UserInputHandler +import org.gradle.api.model.ObjectFactory +import org.gradle.api.provider.Property +import org.gradle.api.provider.ProviderFactory +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.TaskAction +import org.gradle.kotlin.dsl.property +import org.gradle.kotlin.dsl.support.get + + +abstract class FactorioModPublishTask @Inject constructor( + objects: ObjectFactory, + providers: ProviderFactory, +) : DefaultTask() { + + @get:InputFile + abstract val distributionZip: RegularFileProperty + + @get:Input + abstract val modName: Property + + @get:Input + abstract val modVersion: Property + +// @get:Input +// abstract val factorioVersion: Property + + /** Bearer API key */ + @get:Input + val portalApiKey: Property = objects.property().convention( + providers.gradleProperty("FACTORIO_MOD_PORTAL_API_KEY") + ) + + @get:Input + val portalApiUrl: Property = objects.property() + .convention("https://mods.factorio.com/api/v2/") + + /** + * Base URL for linking to a mod page in the portal + * + * Example `https://mods.factorio.com/mod/my-mod-name` + */ + @get:Input + val modPortalBaseURl: Property = objects.property() + .convention("https://mods.factorio.com/mod/") + + @get:Input + val portalUploadEndpoint: Property = objects.property() + .convention("mods/releases/init_upload") + + + init { + group = FactorioModPlugin.TASK_GROUP + } + + + @TaskAction + fun deploy(): Unit = runBlocking { + + val userInputHandler = services.get() + + val portalUploadEndpoint = URLBuilder(portalApiUrl.get()) + .takeFrom(portalUploadEndpoint.get()) + .buildString() + + val client = FactorioModPortalPublishClient( + userInputHandler = userInputHandler, + distributionZip = distributionZip.get().asFile, + modName = modName.get(), + modVersion = modVersion.get(), + portalApiKey = portalApiKey.get(), + portalUploadEndpoint = portalUploadEndpoint, + modPortalBaseURl = modPortalBaseURl.get(), + ) + + client.uploadMod() + } + +// private fun validateInfoJson() { +// val modVersion = modVersion.get() +// val factorioVersion = factorioVersion.get() +// +// val distributionZip = distributionZip.get().asFile.toOkioPath() +// +// val zipContents = FileSystem.SYSTEM.openZip(distributionZip) +// +// val infoJson = zipContents.read("info.json".toPath()) { +// generateSequence { readUtf8Line() } +// }.joinToString("\n") +// +// val info: FactorioModInfo = Json.decodeFromString(FactorioModInfo.serializer(), infoJson) +// +// require(info.version == modVersion) { +// "mod version mismatch, ${info.version} vs $modVersion " +// } +// +// require(info.factorioVersion == factorioVersion) { +// "Factorio version mismatch, ${info.factorioVersion} vs $factorioVersion " +// } +// } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod_portal/model.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod_portal/model.kt new file mode 100644 index 0000000..788c5df --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/mod_portal/model.kt @@ -0,0 +1,88 @@ +package dev.adamko.gradle.factorio.mod_portal + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.JsonContentPolymorphicSerializer +import kotlinx.serialization.json.JsonElement +import kotlinx.serialization.json.jsonObject + + +@Serializable(with = InitUploadResponse.Serializer::class) +sealed interface InitUploadResponse { + + /** + * @param[uploadUrl] URL the mod zip file should be uploaded to + */ + @Serializable + data class Success( + @SerialName("upload_url") + val uploadUrl: String, + ) : InitUploadResponse + + object Serializer : + JsonContentPolymorphicSerializer(InitUploadResponse::class) { + override fun selectDeserializer(element: JsonElement) = when { + "upload_url" in element.jsonObject -> Success.serializer() + else -> Failure.serializer() + } + } +} + + +@Serializable(with = SubmitUploadResponse.Serializer::class) +sealed interface SubmitUploadResponse { + + @Serializable + data class Success( + val success: Boolean + ) : SubmitUploadResponse + + object Serializer : JsonContentPolymorphicSerializer( + SubmitUploadResponse::class + ) { + override fun selectDeserializer(element: JsonElement) = when { + "success" in element.jsonObject -> Success.serializer() + else -> Failure.serializer() + } + } +} + + +@Serializable +data class Failure( + val error: String? = null, + val message: String? = null, +) : InitUploadResponse, SubmitUploadResponse { + + private val reason: String? + get() = reasons[error] + + override fun toString() = "Failure(error=$error, message=$message, reason=$reason)" + + companion object { + private val reasons: Map = mapOf( + //@formatter:off + "InvalidApiKey" to "Missing or invalid API key for the current endpoint", + "InvalidRequest" to "Invalid request", + "InternalError" to "Internal error, please try again later.", + "Forbidden" to "Insufficient permission for current endpoint", + "Unknown" to "Unknown error, please try again later", + "InvalidModRelease" to "Invalid release data in info.json", + "InvalidModUpload" to "Invalid mod data in zipfile", + "UnknownMod" to "Mod does not exist in mod portal", + //@formatter:on + ) + } +} + + +@Serializable +data class FactorioModInfo( + val name: String, + val version: String, + val title: String, + val description: String, + val author: String, + @SerialName("factorio_version") val factorioVersion: String, + val dependencies: List, +) diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/AssembleFactorioModContents.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/AssembleFactorioModContents.kt new file mode 100644 index 0000000..d1ca05c --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/AssembleFactorioModContents.kt @@ -0,0 +1,40 @@ +package dev.adamko.gradle.factorio.tasks + +import javax.inject.Inject +import org.gradle.api.* +import org.gradle.api.file.* +import org.gradle.api.internal.file.* +import org.gradle.api.provider.Property +import org.gradle.api.tasks.* + +abstract class AssembleFactorioModContents @Inject constructor( + private val files: FileSystemOperations, +) : DefaultTask() { + + @get:Input + abstract val modName: Property + + @get:Input + abstract val modVersion: Property + + @get:InputFiles + @get:SkipWhenEmpty + @get:PathSensitive(PathSensitivity.NAME_ONLY) + @get:IgnoreEmptyDirectories + abstract val modFiles: ConfigurableFileCollection + + @get:OutputDirectory + abstract val destination: DirectoryProperty + + @TaskAction + fun assemble() { + val modName = modName.get() + val modVersion = modVersion.get() + val modDirectory = "${modName}_${modVersion}" + + files.sync { + from(modFiles) + into(destination.dir(modDirectory)) + } + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/GenerateFactorioModInfoTask.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/GenerateFactorioModInfoTask.kt new file mode 100644 index 0000000..e01dab0 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/GenerateFactorioModInfoTask.kt @@ -0,0 +1,132 @@ +package dev.adamko.gradle.factorio.tasks + +import javax.inject.Inject +import kotlinx.serialization.* +import kotlinx.serialization.json.* +import org.gradle.api.DefaultTask +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.ListProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction + +abstract class GenerateFactorioModInfoTask @Inject constructor( + +) : DefaultTask() { + + /** + * Mandatory field. The internal name of mod. The game accepts anything as a mod name, however the mod portal restricts mod names to only consist of alphanumeric characters, dashes and underscores. Note that the mod folder or mod zip file name has to contain the mod name, where the restrictions of the file system apply. + * + * The game accepts mod names with a maximum length of 100 characters. The mod portal only accepts mods with names that are longer than 3 characters and shorter than 50 characters. + */ + @get:Input + abstract val modName: Property + + /** + * Mandatory field. The display name of the mod, so it is not recommended to use someUgly_pRoGrAmMeR-name here. Can be overwritten with a locale entry in the mod-name category, using the internal mod name as the key. + * + * The game will reject a title field that is longer than 100 characters. However, this can be worked around by using the locale entry. The mod portal does not restrict mod title length. + */ + @get:Input + abstract val modTitle: Property + + /** + * Optional field. A short description of what your mod does. This is all that people get to see in-game. Can be overwritten with a locale entry in the mod-description category, using the internal mod name as the key. + */ + @get:Input + @get:Optional + abstract val modDescription: Property + + /** + * Optional field. Where the mod can be found on the internet. Note that the in-game mod browser shows the mod portal link additionally to this field. Please don't put "None" here, it makes the field on the mod portal website look ugly. Just leave the field empty if the mod doesn't have a website/forum thread/discord. + */ + @get:Input + @get:Optional + abstract val modHomepage: Property + + /** + * Mandatory field. The author of the mod. This field does not have restrictions, it can also be a list of authors etc. The mod portal ignores this field, it will simply display the uploader's name as the author. + */ + @get:Input + abstract val modAuthor: Property + + /** + * Mandatory field. Defines the version of the mod in the format `number.number.number` for `Major.Middle.Minor`, for example `0.6.4`. Each number can range from 0 to 65535. + */ + @get:Input + abstract val modVersion: Property + + /** + * Optional field in the format "major.minor". The Factorio version that this mod supports. This can only be one Factorio version, not multiple. However, it includes all .sub versions. While the field is optional, usually mods are developed for versions higher than the default 0.12, so the field has to be added anyway. + * + * Adding a sub part, e.g. "0.18.27" will make the mod portal reject the mod and the game act weirdly. That means this shouldn't be done; use only the major and minor components "major.minor", for example "1.0". + * + * Mods with the factorio_version "0.18" can also be loaded in 1.0 and the mod portal will return them when queried for factorio_version 1.0 mods. + */ + @get:Input + @get:Optional + abstract val factorioCompatibility: Property + + /** + * Optional field. Mods that this mod depends on or is incompatible with. + * If this mod depends on another, the other mod will load first, see Data-Lifecycle. + * An empty array allows get around the default and have no dependencies at all. + * + * Example: + * + * `"dependencies": ["mod-a", "? mod-c > 0.4.3", "! mod-g"]` + * + * Each dependency is a string that consists of up to three parts: ` internal-mod-name `, for example `? some-mod-everyone-loves >= 4.2.0`. + * + * The equality operator (`<`, `<=`, `=`, `>=` or `>`) combined with the version allows to define dependencies that require certain mod versions, but it is not required. + * + * Incompatibility does not support versions; if incompatibility is used, version is ignored. + * + * The possible prefixes are: + * * `!` for incompatibility + * * `?` for an optional dependency + * * `(?)` for a hidden optional dependency + * * `~` for a dependency that does not affect load order + * * no prefix for a hard requirement for the other mod. + */ + @get:Input + @get:Optional + abstract val modDependencies: ListProperty + + @get:OutputFile + abstract val infoJson: RegularFileProperty + + @TaskAction + fun generate() { + val infoJsonObject = buildJsonObject { + put("name", modName.get()) + put("title", modTitle.get()) + put("version", modVersion.get()) + put("author", modAuthor.get()) + + modDescription.orNull?.let { put("description", it) } + modHomepage.orNull?.let { put("homepage", it) } + factorioCompatibility.orNull?.let { put("factorio_version", it) } + modDependencies.orNull?.let { + putJsonArray("dependencies") { it.forEach(::add) } + } + } + + val infoJsonContent = encoder.encodeToString(infoJsonObject) + .replace("[\n ]", "[]") + + val infoJson = infoJson.get().asFile + infoJson.parentFile.mkdirs() + infoJson.writeText(infoJsonContent + "\n") + } + + companion object { + @OptIn(ExperimentalSerializationApi::class) + private val encoder = Json { + prettyPrint = true + prettyPrintIndent = " " + } + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/LaunchFactorioClientTask.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/LaunchFactorioClientTask.kt new file mode 100644 index 0000000..de09e86 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/LaunchFactorioClientTask.kt @@ -0,0 +1,95 @@ +package dev.adamko.gradle.factorio.tasks + +import dev.adamko.gradle.factorio.FactorioModSettings +import javax.inject.Inject +import org.gradle.api.DefaultTask +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.TaskAction +import org.gradle.process.ExecOperations +import org.gradle.work.DisableCachingByDefault +import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs + +@DisableCachingByDefault(because = "Not a cacheable task") +abstract class LaunchFactorioClientTask @Inject constructor( + private val executor: ExecOperations +) : DefaultTask() { + + @get:Input + abstract val currentOs: Property + + @get:Input + @get:Optional + abstract val windowsSteamExe: Property + + @get:Input + @get:Optional + abstract val factorioSteamId: Property + + @get:Input + @get:Optional + abstract val serverConnectHost: Property + + @get:Input + @get:Optional + abstract val clientModsPath: Property + + @get:InputFile + @get:Optional + abstract val macFactorioApp: RegularFileProperty + + @get:Input + @get:Optional + abstract val launchFactorioCommand: Property + + @TaskAction + fun launch() { + val launchCommand = + launchFactorioCommand.orNull ?: when (currentOs.orNull) { + FactorioModSettings.LocalDev.OS.WINDOWS -> windowsCmd() + FactorioModSettings.LocalDev.OS.MAC_OS -> macOSCmd() + null, FactorioModSettings.LocalDev.OS.UNSUPPORTED -> error("no can do, unsupported OS") + } + + logger.lifecycle("Launching Factorio client\n > $launchCommand") + + executor.exec { + commandLine = parseSpaceSeparatedArgs(launchCommand) + } + } + + private fun windowsCmd(): String { + val steamExe = windowsSteamExe.orNull ?: error("missing Steam exe") + val factorioId = factorioSteamId.orNull ?: error("missing Factorio Steam ID") + val modsDirFlag = clientModsPath.map { """--mod-directory "$it"""" }.getOrElse("") + val mpConnectFlag = serverConnectHost.map { "--mp-connect $it" }.getOrElse("") + +// commandLine = parseSpaceSeparatedArgs( +//// """explorer "steam://rungameid/$factorioGameId// --mp-connect localhost/" """ // not working +//// """explorer "steam://run/$factorioGameId//--mp-connect localhost/" """ // works! But has annoying pop-up +// """ ${steamExe.asFile.orNull?.canonicalPath} -applaunch $factorioGameId --mp-connect localhost --mod-directory ${clientModsDirectory.asFile.orNull?.canonicalPath} """ +// ) + + return """ + $steamExe --applaunch $factorioId $modsDirFlag $mpConnectFlag + """.trimIndent() + } + + private fun macOSCmd(): String { +// val factorioApp = macFactorioApp.orNull ?: error("missing Factorio app") + + val modsDirFlag = "" //clientModsPath.map { """--mod-directory "$it"""" }.getOrElse("") + val mpConnectFlag = serverConnectHost.map { "-mp-connect $it" }.getOrElse("") + + return """ + /Applications/Steam.app/Contents/MacOS/steam_osx -applaunch 427520 $modsDirFlag $mpConnectFlag + """.trimIndent() + +// return """ +// open -a "$factorioApp" --args $modsDirFlag $mpConnectFlag +// """.trimIndent() + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/LocalPublishFactorioModTask.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/LocalPublishFactorioModTask.kt new file mode 100644 index 0000000..51aaae5 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/LocalPublishFactorioModTask.kt @@ -0,0 +1,40 @@ +package dev.adamko.gradle.factorio.tasks + +import javax.inject.Inject +import org.gradle.api.DefaultTask +import org.gradle.api.file.ConfigurableFileCollection +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.FileSystemOperations +import org.gradle.api.tasks.IgnoreEmptyDirectories +import org.gradle.api.tasks.InputFiles +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity +import org.gradle.api.tasks.SkipWhenEmpty +import org.gradle.api.tasks.TaskAction + +abstract class LocalPublishFactorioModTask @Inject constructor( + private val files: FileSystemOperations, +) : DefaultTask() { + + @get:OutputDirectory + abstract val clientModDirectory: DirectoryProperty + + @get:InputFiles + @get:SkipWhenEmpty + @get:PathSensitive(PathSensitivity.NAME_ONLY) + @get:IgnoreEmptyDirectories + abstract val modFiles: ConfigurableFileCollection + + @TaskAction + fun install() { + logger.lifecycle("Copying mod from ${modFiles.files} to ${clientModDirectory.asFile.get()}") + + files.copy { + from(modFiles) { + include("*.zip") + } + into(clientModDirectory) + } + } +} diff --git a/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/PackageFactorioModTask.kt b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/PackageFactorioModTask.kt new file mode 100644 index 0000000..13586e8 --- /dev/null +++ b/gradle-plugins/factorio-gradle/src/main/kotlin/dev/adamko/gradle/factorio/tasks/PackageFactorioModTask.kt @@ -0,0 +1,6 @@ +package dev.adamko.gradle.factorio.tasks + +import org.gradle.api.tasks.bundling.Zip + + +abstract class PackageFactorioModTask : Zip() diff --git a/gradle-plugins/settings-plugins/build.gradle.kts b/gradle-plugins/settings-plugins/build.gradle.kts new file mode 100644 index 0000000..f7fdd89 --- /dev/null +++ b/gradle-plugins/settings-plugins/build.gradle.kts @@ -0,0 +1,43 @@ +import org.gradle.kotlin.dsl.support.expectedKotlinDslPluginsVersion +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + `kotlin-dsl` +} + +val gradleJvmTarget = "11" + +description = "Provide Gradle settings plugins, used to configure base Gradle behaviour" + +dependencies { + // This project should only be providing simple plugins for configuring Gradle without + // dependencies. Try to avoid setting dependencies here, else the Gradle script classpath might + // get polluted and messy. + + implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:$expectedKotlinDslPluginsVersion") + implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.get()}") + + // https://github.com/gradle/gradle/issues/22510 + implementation("org.jetbrains.kotlin:kotlin-sam-with-receiver:${libs.versions.kotlin.get()}") + + implementation(platform(libs.kotlin.bom)) + implementation("org.jetbrains.kotlin:kotlin-serialization:${libs.versions.kotlin.get()}") + + implementation(platform(libs.kotlinx.coroutines.bom)) +} + +kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget)) + } +} + +kotlinDslPluginOptions { + jvmTarget.set(gradleJvmTarget) +} + +tasks.withType().configureEach { + kotlinOptions { + jvmTarget = gradleJvmTarget + } +} diff --git a/gradle-plugins/settings-plugins/settings.gradle.kts b/gradle-plugins/settings-plugins/settings.gradle.kts new file mode 100644 index 0000000..eef7211 --- /dev/null +++ b/gradle-plugins/settings-plugins/settings.gradle.kts @@ -0,0 +1,25 @@ +rootProject.name = "settings-plugins" + + +@Suppress("UnstableApiUsage") // Central declaration of repositories is an incubating feature +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) + + repositories { + mavenCentral() + gradlePluginPortal() + } + + pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + } + } + + versionCatalogs { + create("libs") { + from(files("../../gradle/libs.versions.toml")) + } + } +} diff --git a/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/kotlin-dsl.gradle.kts b/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/kotlin-dsl.gradle.kts new file mode 100644 index 0000000..22d4998 --- /dev/null +++ b/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/kotlin-dsl.gradle.kts @@ -0,0 +1,29 @@ +package kafkatorio.conventions + +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("org.gradle.kotlin.kotlin-dsl") +} + +val gradleJvmTarget = 11 + +//kotlin { +// jvmToolchain(gradleJvmTarget) +//} + +kotlin { + jvmToolchain { + languageVersion.set(JavaLanguageVersion.of(gradleJvmTarget)) + } +} + +kotlinDslPluginOptions { + jvmTarget.set("$gradleJvmTarget") +} + +tasks.withType().configureEach { + kotlinOptions { + jvmTarget = "$gradleJvmTarget" + } +} diff --git a/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/kotlin-serialization.gradle.kts b/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/kotlin-serialization.gradle.kts new file mode 100644 index 0000000..ad386e9 --- /dev/null +++ b/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/kotlin-serialization.gradle.kts @@ -0,0 +1,8 @@ +package kafkatorio.conventions + +plugins { + kotlin("plugin.serialization") +} + +// No config required or available. This convention plugin is only required because Gradle gets +// confused about the version. diff --git a/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/kotlinDslExtensions.kt b/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/kotlinDslExtensions.kt new file mode 100644 index 0000000..72d1709 --- /dev/null +++ b/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/kotlinDslExtensions.kt @@ -0,0 +1,21 @@ +package kafkatorio.conventions + +import org.gradle.api.Project +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import org.gradle.jvm.toolchain.JavaLanguageVersion +import org.gradle.jvm.toolchain.JavaToolchainSpec +import org.gradle.kotlin.dsl.plugins.dsl.* +import org.gradle.kotlin.dsl.withType + +fun Project.overrideKotlinLanguageVersion( + gradleKotlinTarget: String = "1.6" +) { + afterEvaluate { + tasks.withType().configureEach { + kotlinOptions { + apiVersion = gradleKotlinTarget + languageVersion = gradleKotlinTarget + } + } + } +} diff --git a/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/settings/repositories.kt b/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/settings/repositories.kt new file mode 100644 index 0000000..5f63f3f --- /dev/null +++ b/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/settings/repositories.kt @@ -0,0 +1,86 @@ +@file:Suppress("PackageDirectoryMismatch") + +package org.gradle.kotlin.dsl + +import org.gradle.api.artifacts.dsl.RepositoryHandler + + +fun RepositoryHandler.jitpack() { + maven("https://jitpack.io") +} + + +fun RepositoryHandler.myMavenLocal(enabled: Boolean = true) { + if (enabled) { + println("Maven local is enabled") + mavenLocal { + content { +// includeGroup("dev.adamko") +// includeGroup("dev.adamko.kxtsgen") + includeGroup("io.kotest") + } + } + } +} + + +fun RepositoryHandler.sonatypeSnapshot() { + maven("https://oss.sonatype.org/content/repositories/snapshots") { + mavenContent { + snapshotsOnly() + includeGroup("io.kotest") + } + } + maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") { + mavenContent { + snapshotsOnly() + includeGroup("io.kotest") + } + } +} + + +fun RepositoryHandler.nodeDistributions() { + // Declare the Node.js download repository + ivy("https://nodejs.org/dist/") { + name = "Node Distributions at $url" + patternLayout { artifact("v[revision]/[artifact](-v[revision]-[classifier]).[ext]") } + metadataSources { artifact() } + content { includeModule("org.nodejs", "node") } + } +} + + +fun RepositoryHandler.yarnDistributions() { + ivy("https://github.com/yarnpkg/yarn/releases/download") { + name = "Yarn Distributions at $url" + patternLayout { artifact("v[revision]/[artifact](-v[revision]).[ext]") } + metadataSources { artifact() } + content { includeModule("com.yarnpkg", "yarn") } + } +} + + +// https://stackoverflow.com/a/34327202/4161471 +// example: implementation("jmeter-gradle-plugin:jmeter-gradle-plugin:1.0.3@zip") +fun RepositoryHandler.gitHub() { + ivy("https://github.com/") { + patternLayout { + artifact("/[organisation]/[module]/archive/[revision].[ext]") + } + metadataSources { artifact() } + + content { + includeGroup("jmeter-gradle-plugin") + } + } +} + + +fun RepositoryHandler.kotlinxHtml() { + maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") { + mavenContent { + includeGroup("org.jetbrains.kotlinx") + } + } +} diff --git a/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/settings/repositories.settings.gradle.kts b/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/settings/repositories.settings.gradle.kts new file mode 100644 index 0000000..e49aed8 --- /dev/null +++ b/gradle-plugins/settings-plugins/src/main/kotlin/kafkatorio/conventions/settings/repositories.settings.gradle.kts @@ -0,0 +1,35 @@ +package kafkatorio.conventions.settings + +@Suppress("UnstableApiUsage") // Central declaration of repositories is an incubating feature +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) + + repositories { + myMavenLocal() + mavenCentral() + jitpack() + gradlePluginPortal() + + // Declare the Node.js download repository + nodeDistributions() + yarnDistributions() + + maven("https://raw.githubusercontent.com/adamko-dev/kotka-streams/artifacts/m2") { + content { includeGroup("dev.adamko.kotka") } + } + + kotlinxHtml() + + sonatypeSnapshot() + } + + pluginManagement { + repositories { + myMavenLocal() + gradlePluginPortal() + mavenCentral() + jitpack() + sonatypeSnapshot() + } + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..4c07fa9 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,14 @@ +org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx4g + +kotlin.mpp.stability.nowarn=true +#kotlin.mpp.enableGranularSourceSetsMetadata=true +#kotlin.native.enableDependencyPropagation=false +org.gradle.dependency.verification.console=verbose + +org.gradle.caching=true +org.gradle.unsafe.configuration-cache=true +org.gradle.unsafe.configuration-cache-problems=warn + +org.gradle.kotlin.dsl.precompiled.accessors.strict=true + +org.gradle.parallel=true diff --git a/gradle/kotlin-js-store/yarn.lock b/gradle/kotlin-js-store/yarn.lock new file mode 100644 index 0000000..43a23de --- /dev/null +++ b/gradle/kotlin-js-store/yarn.lock @@ -0,0 +1,3107 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@babel/runtime@^7.9.2": + version "7.17.9" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.9.tgz#d19fbf802d01a8cb6cf053a64e472d42c434ba72" + integrity sha512-lSiBBvodq29uShpWGNbgFdKYNiFDo5/HIYsaCEY9ff4sb10x9jizo2+pRrSyF4jKZCXqgzuqBOQKbUm90gQwJg== + dependencies: + regenerator-runtime "^0.13.4" + +"@colors/colors@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" + integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== + +"@discoveryjs/json-ext@^0.5.0": + version "0.5.7" + resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" + integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== + +"@fortawesome/fontawesome-free@^6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-6.2.1.tgz#344baf6ff9eaad7a73cff067d8c56bfc11ae5304" + integrity sha512-viouXhegu/TjkvYQoiRZK3aax69dGXxgEjpvZW81wIJdxm5Fnvp3VVIP4VHKqX4SvFw6qpmkILkD4RJWAdrt7A== + +"@leichtgewicht/ip-codec@^2.0.1": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.4.tgz#b2ac626d6cb9c8718ab459166d4bb405b8ffa78b" + integrity sha512-Hcv+nVC0kZnQ3tD9GVu5xSMR4VVYOteQIr/hwFPVEvPdlXqgGEuRjiheChHgdM+JyqdgNcmzZOX/tnl0JOiI7A== + +"@popperjs/core@^2.11.6": + version "2.11.6" + resolved "https://registry.yarnpkg.com/@popperjs/core/-/core-2.11.6.tgz#cee20bd55e68a1720bdab363ecf0c821ded4cd45" + integrity sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw== + +"@rjaros/snabbdom-virtualize@^1.0.0-beta.5": + version "1.0.0-beta.5" + resolved "https://registry.yarnpkg.com/@rjaros/snabbdom-virtualize/-/snabbdom-virtualize-1.0.0-beta.5.tgz#17f2586beee5e6c130e1b0ae2f589ff9162a86db" + integrity sha512-2rf1MI7wVSZLOgy+EXtOfYzqcwLtMjak4wzRBQUVJjO4qlCmlSo+bh890eKkILhRGxkp6aTQS9gMjH1fP9g8Nw== + dependencies: + html-parse-stringify "^3" + +"@types/body-parser@*": + version "1.19.2" + resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.2.tgz#aea2059e28b7658639081347ac4fab3de166e6f0" + integrity sha512-ALYone6pm6QmwZoAgeyNksccT9Q4AWZQ6PvfwR37GT6r6FWUPguq6sUmNGSMV2Wr761oQoBxwGGa6DR5o1DC9g== + dependencies: + "@types/connect" "*" + "@types/node" "*" + +"@types/bonjour@^3.5.9": + version "3.5.10" + resolved "https://registry.yarnpkg.com/@types/bonjour/-/bonjour-3.5.10.tgz#0f6aadfe00ea414edc86f5d106357cda9701e275" + integrity sha512-p7ienRMiS41Nu2/igbJxxLDWrSZ0WxM8UQgCeO9KhoVF7cOVFkrKsiDr1EsJIla8vV3oEEjGcz11jc5yimhzZw== + dependencies: + "@types/node" "*" + +"@types/component-emitter@^1.2.10": + version "1.2.11" + resolved "https://registry.yarnpkg.com/@types/component-emitter/-/component-emitter-1.2.11.tgz#50d47d42b347253817a39709fef03ce66a108506" + integrity sha512-SRXjM+tfsSlA9VuG8hGO2nft2p8zjXCK1VcC6N4NXbBbYbSia9kzCChYQajIjzIqOOOuh5Ock6MmV2oux4jDZQ== + +"@types/connect-history-api-fallback@^1.3.5": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.3.5.tgz#d1f7a8a09d0ed5a57aee5ae9c18ab9b803205dae" + integrity sha512-h8QJa8xSb1WD4fpKBDcATDNGXghFj6/3GRWG6dhmRcu0RX1Ubasur2Uvx5aeEwlf0MwblEC2bMzzMQntxnw/Cw== + dependencies: + "@types/express-serve-static-core" "*" + "@types/node" "*" + +"@types/connect@*": + version "3.4.35" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" + integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ== + dependencies: + "@types/node" "*" + +"@types/cookie@^0.4.1": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.1.tgz#bfd02c1f2224567676c1545199f87c3a861d878d" + integrity sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q== + +"@types/cors@^2.8.12": + version "2.8.12" + resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080" + integrity sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw== + +"@types/eslint-scope@^3.7.3": + version "3.7.3" + resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.3.tgz#125b88504b61e3c8bc6f870882003253005c3224" + integrity sha512-PB3ldyrcnAicT35TWPs5IcwKD8S333HMaa2VVv4+wdvebJkjWuW/xESoB8IwRcog8HYVYamb1g/R31Qv5Bx03g== + dependencies: + "@types/eslint" "*" + "@types/estree" "*" + +"@types/eslint@*": + version "8.4.1" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.4.1.tgz#c48251553e8759db9e656de3efc846954ac32304" + integrity sha512-GE44+DNEyxxh2Kc6ro/VkIj+9ma0pO0bwv9+uHSyBrikYOHr8zYcdPvnBOp1aw8s+CjRvuSx7CyWqRrNFQ59mA== + dependencies: + "@types/estree" "*" + "@types/json-schema" "*" + +"@types/estree@*", "@types/estree@^0.0.51": + version "0.0.51" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" + integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== + +"@types/express-serve-static-core@*", "@types/express-serve-static-core@^4.17.18": + version "4.17.29" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.29.tgz#2a1795ea8e9e9c91b4a4bbe475034b20c1ec711c" + integrity sha512-uMd++6dMKS32EOuw1Uli3e3BPgdLIXmezcfHv7N4c1s3gkhikBplORPpMq3fuWkxncZN1reb16d5n8yhQ80x7Q== + dependencies: + "@types/node" "*" + "@types/qs" "*" + "@types/range-parser" "*" + +"@types/express@*", "@types/express@^4.17.13": + version "4.17.13" + resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.13.tgz#a76e2995728999bab51a33fabce1d705a3709034" + integrity sha512-6bSZTPaTIACxn48l50SR+axgrqm6qXFIxrdAKaG6PaJk3+zuUr35hBlgT7vOmJcum+OEaIBLtHV/qloEAFITeA== + dependencies: + "@types/body-parser" "*" + "@types/express-serve-static-core" "^4.17.18" + "@types/qs" "*" + "@types/serve-static" "*" + +"@types/geojson@7946.0.10": + version "7946.0.10" + resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.10.tgz#6dfbf5ea17142f7f9a043809f1cd4c448cb68249" + integrity sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA== + +"@types/glob@5 - 7": + version "7.2.0" + resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb" + integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA== + dependencies: + "@types/minimatch" "*" + "@types/node" "*" + +"@types/http-proxy@^1.17.8": + version "1.17.8" + resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.8.tgz#968c66903e7e42b483608030ee85800f22d03f55" + integrity sha512-5kPLG5BKpWYkw/LVOGWpiq3nEVqxiN32rTgI53Sk12/xHFQ2rG3ehI9IO+O3W2QoKeyB92dJkoka8SUm6BX1pA== + dependencies: + "@types/node" "*" + +"@types/json-schema@*", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": + version "7.0.11" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" + integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== + +"@types/mime@^1": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a" + integrity sha512-YATxVxgRqNH6nHEIsvg6k2Boc1JHI9ZbH5iWFFv/MTkchz3b1ieGDa5T0a9RznNdI0KhVbdbWSN+KWWrQZRxTw== + +"@types/minimatch@*": + version "3.0.5" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40" + integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ== + +"@types/node@*", "@types/node@>=10.0.0": + version "17.0.25" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.25.tgz#527051f3c2f77aa52e5dc74e45a3da5fb2301448" + integrity sha512-wANk6fBrUwdpY4isjWrKTufkrXdu1D2YHCot2fD/DfWxF5sMrVSA+KN7ydckvaTCh0HiqX9IVl0L5/ZoXg5M7w== + +"@types/parse5@^5": + version "5.0.3" + resolved "https://registry.yarnpkg.com/@types/parse5/-/parse5-5.0.3.tgz#e7b5aebbac150f8b5fdd4a46e7f0bd8e65e19109" + integrity sha512-kUNnecmtkunAoQ3CnjmMkzNU/gtxG8guhi+Fk2U/kOpIKjIMKnXGp4IJCgQJrXSgMsWYimYG4TGjz/UzbGEBTw== + +"@types/qs@*": + version "6.9.7" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.7.tgz#63bb7d067db107cc1e457c303bc25d511febf6cb" + integrity sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw== + +"@types/range-parser@*": + version "1.2.4" + resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc" + integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw== + +"@types/retry@0.12.0": + version "0.12.0" + resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.0.tgz#2b35eccfcee7d38cd72ad99232fbd58bffb3c84d" + integrity sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA== + +"@types/serve-index@^1.9.1": + version "1.9.1" + resolved "https://registry.yarnpkg.com/@types/serve-index/-/serve-index-1.9.1.tgz#1b5e85370a192c01ec6cec4735cf2917337a6278" + integrity sha512-d/Hs3nWDxNL2xAczmOVZNj92YZCS6RGxfBPjKzuu/XirCgXdpKEb88dYNbrYGint6IVWLNP+yonwVAuRC0T2Dg== + dependencies: + "@types/express" "*" + +"@types/serve-static@*", "@types/serve-static@^1.13.10": + version "1.13.10" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.10.tgz#f5e0ce8797d2d7cc5ebeda48a52c96c4fa47a8d9" + integrity sha512-nCkHGI4w7ZgAdNkrEu0bv+4xNV/XDqW+DydknebMOQwkpDGx8G+HTlj7R7ABI8i8nKxVw0wtKPi1D+lPOkh4YQ== + dependencies: + "@types/mime" "^1" + "@types/node" "*" + +"@types/sockjs@^0.3.33": + version "0.3.33" + resolved "https://registry.yarnpkg.com/@types/sockjs/-/sockjs-0.3.33.tgz#570d3a0b99ac995360e3136fd6045113b1bd236f" + integrity sha512-f0KEEe05NvUnat+boPTZ0dgaLZ4SfSouXUgv5noUiefG2ajgKjmETo9ZJyuqsl7dfl2aHlLJUiki6B4ZYldiiw== + dependencies: + "@types/node" "*" + +"@types/ws@^8.5.1": + version "8.5.3" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.3.tgz#7d25a1ffbecd3c4f2d35068d0b283c037003274d" + integrity sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w== + dependencies: + "@types/node" "*" + +"@webassemblyjs/ast@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.1.tgz#2bfd767eae1a6996f432ff7e8d7fc75679c0b6a7" + integrity sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw== + dependencies: + "@webassemblyjs/helper-numbers" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + +"@webassemblyjs/floating-point-hex-parser@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz#f6c61a705f0fd7a6aecaa4e8198f23d9dc179e4f" + integrity sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ== + +"@webassemblyjs/helper-api-error@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz#1a63192d8788e5c012800ba6a7a46c705288fd16" + integrity sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg== + +"@webassemblyjs/helper-buffer@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz#832a900eb444884cde9a7cad467f81500f5e5ab5" + integrity sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA== + +"@webassemblyjs/helper-numbers@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz#64d81da219fbbba1e3bd1bfc74f6e8c4e10a62ae" + integrity sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ== + dependencies: + "@webassemblyjs/floating-point-hex-parser" "1.11.1" + "@webassemblyjs/helper-api-error" "1.11.1" + "@xtuc/long" "4.2.2" + +"@webassemblyjs/helper-wasm-bytecode@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz#f328241e41e7b199d0b20c18e88429c4433295e1" + integrity sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q== + +"@webassemblyjs/helper-wasm-section@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz#21ee065a7b635f319e738f0dd73bfbda281c097a" + integrity sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" + +"@webassemblyjs/ieee754@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz#963929e9bbd05709e7e12243a099180812992614" + integrity sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ== + dependencies: + "@xtuc/ieee754" "^1.2.0" + +"@webassemblyjs/leb128@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.1.tgz#ce814b45574e93d76bae1fb2644ab9cdd9527aa5" + integrity sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw== + dependencies: + "@xtuc/long" "4.2.2" + +"@webassemblyjs/utf8@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.1.tgz#d1f8b764369e7c6e6bae350e854dec9a59f0a3ff" + integrity sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ== + +"@webassemblyjs/wasm-edit@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz#ad206ebf4bf95a058ce9880a8c092c5dec8193d6" + integrity sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/helper-wasm-section" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" + "@webassemblyjs/wasm-opt" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + "@webassemblyjs/wast-printer" "1.11.1" + +"@webassemblyjs/wasm-gen@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz#86c5ea304849759b7d88c47a32f4f039ae3c8f76" + integrity sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/ieee754" "1.11.1" + "@webassemblyjs/leb128" "1.11.1" + "@webassemblyjs/utf8" "1.11.1" + +"@webassemblyjs/wasm-opt@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz#657b4c2202f4cf3b345f8a4c6461c8c2418985f2" + integrity sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-buffer" "1.11.1" + "@webassemblyjs/wasm-gen" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + +"@webassemblyjs/wasm-parser@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz#86ca734534f417e9bd3c67c7a1c75d8be41fb199" + integrity sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/helper-api-error" "1.11.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.1" + "@webassemblyjs/ieee754" "1.11.1" + "@webassemblyjs/leb128" "1.11.1" + "@webassemblyjs/utf8" "1.11.1" + +"@webassemblyjs/wast-printer@1.11.1": + version "1.11.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz#d0c73beda8eec5426f10ae8ef55cee5e7084c2f0" + integrity sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg== + dependencies: + "@webassemblyjs/ast" "1.11.1" + "@xtuc/long" "4.2.2" + +"@webpack-cli/configtest@^2.0.0": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-2.0.1.tgz#a69720f6c9bad6aef54a8fa6ba9c3533e7ef4c7f" + integrity sha512-njsdJXJSiS2iNbQVS0eT8A/KPnmyH4pv1APj2K0d1wrZcBLw+yppxOy4CGqa0OxDJkzfL/XELDhD8rocnIwB5A== + +"@webpack-cli/info@^2.0.0": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-2.0.1.tgz#eed745799c910d20081e06e5177c2b2569f166c0" + integrity sha512-fE1UEWTwsAxRhrJNikE7v4EotYflkEhBL7EbajfkPlf6E37/2QshOy/D48Mw8G5XMFlQtS6YV42vtbG9zBpIQA== + +"@webpack-cli/serve@^2.0.0": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-2.0.1.tgz#34bdc31727a1889198855913db2f270ace6d7bf8" + integrity sha512-0G7tNyS+yW8TdgHwZKlDWYXFA6OJQnoLCQvYKkQP0Q2X205PSQ6RNUj0M+1OB/9gRQaUZ/ccYfaxd0nhaWKfjw== + +"@xtuc/ieee754@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" + integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== + +"@xtuc/long@4.2.2": + version "4.2.2" + resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" + integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== + +abab@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.6.tgz#41b80f2c871d19686216b82309231cfd3cb3d291" + integrity sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA== + +accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8: + version "1.3.8" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" + integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== + dependencies: + mime-types "~2.1.34" + negotiator "0.6.3" + +acorn-import-assertions@^1.7.6: + version "1.8.0" + resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz#ba2b5939ce62c238db6d93d81c9b111b29b855e9" + integrity sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw== + +acorn@^8.5.0: + version "8.7.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf" + integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ== + +acorn@^8.7.1: + version "8.8.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.0.tgz#88c0187620435c7f6015803f5539dae05a9dbea8" + integrity sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w== + +ajv-formats@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520" + integrity sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA== + dependencies: + ajv "^8.0.0" + +ajv-keywords@^3.5.2: + version "3.5.2" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" + integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== + +ajv-keywords@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-5.1.0.tgz#69d4d385a4733cdbeab44964a1170a88f87f0e16" + integrity sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw== + dependencies: + fast-deep-equal "^3.1.3" + +ajv@^6.12.5: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ajv@^8.0.0, ajv@^8.8.0: + version "8.11.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.11.0.tgz#977e91dd96ca669f54a11e23e378e33b884a565f" + integrity sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg== + dependencies: + fast-deep-equal "^3.1.1" + json-schema-traverse "^1.0.0" + require-from-string "^2.0.2" + uri-js "^4.2.2" + +ansi-colors@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + +ansi-html-community@^0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/ansi-html-community/-/ansi-html-community-0.0.8.tgz#69fbc4d6ccbe383f9736934ae34c3f8290f1bf41" + integrity sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw== + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +anymatch@~3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" + integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + +array-flatten@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" + integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== + +array-flatten@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-2.1.2.tgz#24ef80a28c1a893617e2149b0c6d0d788293b099" + integrity sha512-hNfzcOV8W4NdualtqBFPyVO+54DSJuZGY9qT4pRroB6S9e3iiido2ISIC5h9R2sPJ8H3FHCIiEnsv1lPXO3KtQ== + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +base64id@2.0.0, base64id@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" + integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== + +batch@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" + integrity sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw== + +binary-extensions@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" + integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== + +body-parser@1.20.0, body-parser@^1.19.0: + version "1.20.0" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.0.tgz#3de69bd89011c11573d7bfee6a64f11b6bd27cc5" + integrity sha512-DfJ+q6EPcGKZD1QWUjSpqp+Q7bDQTsQIF4zfUAtZ6qk+H/3/QRhg9CEp39ss+/T2vw0+HaidC0ecJj/DRLIaKg== + dependencies: + bytes "3.1.2" + content-type "~1.0.4" + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + http-errors "2.0.0" + iconv-lite "0.4.24" + on-finished "2.4.1" + qs "6.10.3" + raw-body "2.5.1" + type-is "~1.6.18" + unpipe "1.0.0" + +bonjour-service@^1.0.11: + version "1.0.13" + resolved "https://registry.yarnpkg.com/bonjour-service/-/bonjour-service-1.0.13.tgz#4ac003dc1626023252d58adf2946f57e5da450c1" + integrity sha512-LWKRU/7EqDUC9CTAQtuZl5HzBALoCYwtLhffW3et7vZMwv3bWLpJf8bRYlMD5OCcDpTfnPgNCV4yo9ZIaJGMiA== + dependencies: + array-flatten "^2.1.2" + dns-equal "^1.0.0" + fast-deep-equal "^3.1.3" + multicast-dns "^7.2.5" + +bootstrap-icons@^1.10.0: + version "1.10.2" + resolved "https://registry.yarnpkg.com/bootstrap-icons/-/bootstrap-icons-1.10.2.tgz#6a5729e0475e007ed82d752225645e4e6fec48d7" + integrity sha512-PTPYadRn1AMGr+QTSxe4ZCc+Wzv9DGZxbi3lNse/dajqV31n2/wl/7NX78ZpkvFgRNmH4ogdIQPQmxAfhEV6nA== + +bootstrap@^5.2.3: + version "5.2.3" + resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.2.3.tgz#54739f4414de121b9785c5da3c87b37ff008322b" + integrity sha512-cEKPM+fwb3cT8NzQZYEu4HilJ3anCrWqh3CHAok1p9jXqMPsPTBhU25fBckEJHJ/p+tTxTFTsFQGM+gaHpi3QQ== + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + +braces@^3.0.2, braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + +browserslist@^4.14.5: + version "4.20.2" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.20.2.tgz#567b41508757ecd904dab4d1c646c612cd3d4f88" + integrity sha512-CQOBCqp/9pDvDbx3xfMi+86pr4KXIf2FDkTTdeuYw8OxS9t898LA1Khq57gtufFILXpfgsSx5woNgsBgvGjpsA== + dependencies: + caniuse-lite "^1.0.30001317" + electron-to-chromium "^1.4.84" + escalade "^3.1.1" + node-releases "^2.0.2" + picocolors "^1.0.0" + +buffer-from@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +bytes@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" + integrity sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw== + +bytes@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" + integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== + +call-bind@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" + integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== + dependencies: + function-bind "^1.1.1" + get-intrinsic "^1.0.2" + +camelcase@^6.0.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +caniuse-lite@^1.0.30001317: + version "1.0.30001332" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001332.tgz#39476d3aa8d83ea76359c70302eafdd4a1d727dd" + integrity sha512-10T30NYOEQtN6C11YGg411yebhvpnC6Z102+B95eAsN0oB6KUs01ivE8u+G6FMIRtIrVlYXhL+LUwQ3/hXwDWw== + +chalk@^2.3.0: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chalk@^4.1.0: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +chart.js@^3.9.1: + version "3.9.1" + resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-3.9.1.tgz#3abf2c775169c4c71217a107163ac708515924b8" + integrity sha512-Ro2JbLmvg83gXF5F4sniaQ+lTbSv18E+TIf2cOeiH1Iqd2PGFOtem+DUufMZsCJwFE7ywPOpfXFBwRTGq7dh6w== + +chokidar@3.5.3, chokidar@^3.5.1, chokidar@^3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +chrome-trace-event@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" + integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== + +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + +clone-deep@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387" + integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ== + dependencies: + is-plain-object "^2.0.4" + kind-of "^6.0.2" + shallow-clone "^3.0.0" + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +colorette@^2.0.10: + version "2.0.19" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.19.tgz#cdf044f47ad41a0f4b56b3a0d5b4e6e1a2d5a798" + integrity sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ== + +colorette@^2.0.14: + version "2.0.16" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.16.tgz#713b9af84fdb000139f04546bd4a93f62a5085da" + integrity sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g== + +commander@^2.20.0: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + +commander@^6.0.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" + integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== + +commander@^9.4.1: + version "9.4.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-9.4.1.tgz#d1dd8f2ce6faf93147295c0df13c7c21141cfbdd" + integrity sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw== + +component-emitter@~1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" + integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== + +compressible@~2.0.16: + version "2.0.18" + resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.18.tgz#af53cca6b070d4c3c0750fbd77286a6d7cc46fba" + integrity sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg== + dependencies: + mime-db ">= 1.43.0 < 2" + +compression@^1.7.4: + version "1.7.4" + resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.4.tgz#95523eff170ca57c29a0ca41e6fe131f41e5bb8f" + integrity sha512-jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ== + dependencies: + accepts "~1.3.5" + bytes "3.0.0" + compressible "~2.0.16" + debug "2.6.9" + on-headers "~1.0.2" + safe-buffer "5.1.2" + vary "~1.1.2" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + +connect-history-api-fallback@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz#647264845251a0daf25b97ce87834cace0f5f1c8" + integrity sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA== + +connect@^3.7.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/connect/-/connect-3.7.0.tgz#5d49348910caa5e07a01800b030d0c35f20484f8" + integrity sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ== + dependencies: + debug "2.6.9" + finalhandler "1.1.2" + parseurl "~1.3.3" + utils-merge "1.0.1" + +content-disposition@0.5.4: + version "0.5.4" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe" + integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ== + dependencies: + safe-buffer "5.2.1" + +content-type@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b" + integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA== + +cookie-signature@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" + integrity sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ== + +cookie@0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.5.0.tgz#d1f5d71adec6558c58f389987c366aa47e994f8b" + integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== + +cookie@~0.4.1: + version "0.4.2" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" + integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== + +core-util-is@~1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" + integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== + +cors@~2.8.5: + version "2.8.5" + resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" + integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== + dependencies: + object-assign "^4" + vary "^1" + +cross-spawn@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + +css-loader@^6.7.2: + version "6.7.2" + resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-6.7.2.tgz#26bc22401b5921686a10fbeba75d124228302304" + integrity sha512-oqGbbVcBJkm8QwmnNzrFrWTnudnRZC+1eXikLJl0n4ljcfotgRifpg2a1lKy8jTrc4/d9A/ap1GFq1jDKG7J+Q== + dependencies: + icss-utils "^5.1.0" + postcss "^8.4.18" + postcss-modules-extract-imports "^3.0.0" + postcss-modules-local-by-default "^4.0.0" + postcss-modules-scope "^3.0.0" + postcss-modules-values "^4.0.0" + postcss-value-parser "^4.2.0" + semver "^7.3.8" + +css-selector-parser@^1.3: + version "1.4.1" + resolved "https://registry.yarnpkg.com/css-selector-parser/-/css-selector-parser-1.4.1.tgz#03f9cb8a81c3e5ab2c51684557d5aaf6d2569759" + integrity sha512-HYPSb7y/Z7BNDCOrakL4raGO2zltZkbeXyAd6Tg9obzix6QhzxCotdBl6VT0Dv4vZfJGVz3WL/xaEI9Ly3ul0g== + +cssesc@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee" + integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg== + +custom-event@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" + integrity sha1-XQKkaFCt8bSjF5RqOSj8y1v9BCU= + +date-format@^4.0.10: + version "4.0.11" + resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.11.tgz#ae0d1e069d7f0687938fd06f98c12f3a6276e526" + integrity sha512-VS20KRyorrbMCQmpdl2hg5KaOUsda1RbnsJg461FfrcyCUg+pkd0b40BSW4niQyTheww4DBXQnS7HwSrKkipLw== + +debug@2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +debug@4.3.4, debug@^4.1.0, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== + +default-gateway@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/default-gateway/-/default-gateway-6.0.3.tgz#819494c888053bdb743edbf343d6cdf7f2943a71" + integrity sha512-fwSOJsbbNzZ/CUFpqFBqYfYNLj1NbMPm8MMCIzHjC83iSJRBEGmDUxU+WP661BaBQImeC2yHwXtz+P/O9o+XEg== + dependencies: + execa "^5.0.0" + +define-lazy-prop@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz#3f7ae421129bcaaac9bc74905c98a0009ec9ee7f" + integrity sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og== + +depd@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" + integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== + +depd@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== + +destroy@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" + integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== + +detect-node@^2.0.4: + version "2.1.0" + resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1" + integrity sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g== + +di@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" + integrity sha1-gGZJMmzqp8qjMG112YXqJ0i6kTw= + +diff@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + +dns-equal@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d" + integrity sha512-z+paD6YUQsk+AbGCEM4PrOXSss5gd66QfcVBFTKR/HpFL9jCqikS94HYwKww6fQyO7IxrIIyUu+g0Ka9tUS2Cg== + +dns-packet@^5.2.2: + version "5.4.0" + resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.4.0.tgz#1f88477cf9f27e78a213fb6d118ae38e759a879b" + integrity sha512-EgqGeaBB8hLiHLZtp/IbaDQTL8pZ0+IvwzSHA6d7VyMDM+B9hgddEMa9xjK5oYnw0ci0JQ6g2XCD7/f6cafU6g== + dependencies: + "@leichtgewicht/ip-codec" "^2.0.1" + +dom-serialize@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" + integrity sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs= + dependencies: + custom-event "~1.0.0" + ent "~2.2.0" + extend "^3.0.0" + void-elements "^2.0.0" + +dukat@0.5.8-rc.3: + version "0.5.8-rc.3" + resolved "https://registry.yarnpkg.com/dukat/-/dukat-0.5.8-rc.3.tgz#4a2b848b9d2978cb610af8d5cf24ff5e5a408743" + integrity sha512-wzl9A5alTT1Mag4y7bUVjPF4L/wkts7AiiWxe6/6tL5gSDowexUzlJX/pYVTbnHcOo48/bok3Ao1gzU4/cFFjw== + dependencies: + google-protobuf "3.12.2" + typescript "3.9.5" + +dukat@0.5.8-rc.4: + version "0.5.8-rc.4" + resolved "https://registry.yarnpkg.com/dukat/-/dukat-0.5.8-rc.4.tgz#90384dcb50b14c26f0e99dae92b2dea44f5fce21" + integrity sha512-ZnMt6DGBjlVgK2uQamXfd7uP/AxH7RqI0BL9GLrrJb2gKdDxvJChWy+M9AQEaL+7/6TmxzJxFOsRiInY9oGWTA== + dependencies: + google-protobuf "3.12.2" + typescript "3.9.5" + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0= + +electron-to-chromium@^1.4.84: + version "1.4.114" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.114.tgz#d85ec0808dd50b0cf6e6b262480ffd385f71c873" + integrity sha512-gRwLpVYWHGbERPU6o8pKfR168V6enWEXzZc6zQNNXbgJ7UJna+9qzAIHY94+9KOv71D/CH+QebLA9pChD2q8zA== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +encodeurl@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + integrity sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k= + +encoding@^0.1.12: + version "0.1.13" + resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9" + integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A== + dependencies: + iconv-lite "^0.6.2" + +engine.io-parser@~5.0.3: + version "5.0.4" + resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-5.0.4.tgz#0b13f704fa9271b3ec4f33112410d8f3f41d0fc0" + integrity sha512-+nVFp+5z1E3HcToEnO7ZIj3g+3k9389DvWtvJZz0T6/eOCPIyyxehFcedoYrZQrp0LgQbD9pPXhpMBKMd5QURg== + +engine.io@~6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-6.2.0.tgz#003bec48f6815926f2b1b17873e576acd54f41d0" + integrity sha512-4KzwW3F3bk+KlzSOY57fj/Jx6LyRQ1nbcyIadehl+AnXjKT7gDO0ORdRi/84ixvMKTym6ZKuxvbzN62HDDU1Lg== + dependencies: + "@types/cookie" "^0.4.1" + "@types/cors" "^2.8.12" + "@types/node" ">=10.0.0" + accepts "~1.3.4" + base64id "2.0.0" + cookie "~0.4.1" + cors "~2.8.5" + debug "~4.3.1" + engine.io-parser "~5.0.3" + ws "~8.2.3" + +enhanced-resolve@^5.10.0: + version "5.10.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz#0dc579c3bb2a1032e357ac45b8f3a6f3ad4fb1e6" + integrity sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ== + dependencies: + graceful-fs "^4.2.4" + tapable "^2.2.0" + +ent@~2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" + integrity sha1-6WQhkyWiHQX0RGai9obtbOX13R0= + +envinfo@^7.7.3: + version "7.8.1" + resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" + integrity sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw== + +es-module-lexer@^0.9.0: + version "0.9.3" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19" + integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ== + +escalade@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" + integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= + +escape-string-regexp@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + +eslint-scope@5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" + integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== + dependencies: + esrecurse "^4.3.0" + estraverse "^4.1.1" + +esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== + dependencies: + estraverse "^5.2.0" + +estraverse@^4.1.1: + version "4.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" + integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== + +estraverse@^5.2.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== + +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== + +eventemitter3@^4.0.0: + version "4.0.7" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + +events@^3.2.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== + +execa@^5.0.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" + integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== + dependencies: + cross-spawn "^7.0.3" + get-stream "^6.0.0" + human-signals "^2.1.0" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.1" + onetime "^5.1.2" + signal-exit "^3.0.3" + strip-final-newline "^2.0.0" + +express@^4.17.3: + version "4.18.1" + resolved "https://registry.yarnpkg.com/express/-/express-4.18.1.tgz#7797de8b9c72c857b9cd0e14a5eea80666267caf" + integrity sha512-zZBcOX9TfehHQhtupq57OF8lFZ3UZi08Y97dwFCkD8p9d/d2Y3M+ykKcwaMDEL+4qyUolgBDX6AblpR3fL212Q== + dependencies: + accepts "~1.3.8" + array-flatten "1.1.1" + body-parser "1.20.0" + content-disposition "0.5.4" + content-type "~1.0.4" + cookie "0.5.0" + cookie-signature "1.0.6" + debug "2.6.9" + depd "2.0.0" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "1.2.0" + fresh "0.5.2" + http-errors "2.0.0" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "2.4.1" + parseurl "~1.3.3" + path-to-regexp "0.1.7" + proxy-addr "~2.0.7" + qs "6.10.3" + range-parser "~1.2.1" + safe-buffer "5.2.1" + send "0.18.0" + serve-static "1.15.0" + setprototypeof "1.2.0" + statuses "2.0.1" + type-is "~1.6.18" + utils-merge "1.0.1" + vary "~1.1.2" + +extend@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + +fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== + +fast-json-stable-stringify@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +fastest-levenshtein@^1.0.12: + version "1.0.12" + resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz#9990f7d3a88cc5a9ffd1f1745745251700d497e2" + integrity sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow== + +faye-websocket@^0.11.3: + version "0.11.4" + resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.4.tgz#7f0d9275cfdd86a1c963dc8b65fcc451edcbb1da" + integrity sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g== + dependencies: + websocket-driver ">=0.5.1" + +fecha@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/fecha/-/fecha-4.2.3.tgz#4d9ccdbc61e8629b259fdca67e65891448d569fd" + integrity sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw== + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +finalhandler@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" + integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== + dependencies: + debug "2.6.9" + encodeurl "~1.0.2" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.3" + statuses "~1.5.0" + unpipe "~1.0.0" + +finalhandler@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.2.0.tgz#7d23fe5731b207b4640e4fcd00aec1f9207a7b32" + integrity sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg== + dependencies: + debug "2.6.9" + encodeurl "~1.0.2" + escape-html "~1.0.3" + on-finished "2.4.1" + parseurl "~1.3.3" + statuses "2.0.1" + unpipe "~1.0.0" + +find-up@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +find-up@^4.0.0, find-up@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" + integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== + dependencies: + locate-path "^5.0.0" + path-exists "^4.0.0" + +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + +flatted@^3.2.5: + version "3.2.5" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3" + integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg== + +follow-redirects@^1.0.0: + version "1.14.8" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.8.tgz#016996fb9a11a100566398b1c6839337d7bfa8fc" + integrity sha512-1x0S9UVJHsQprFcEC/qnNzBLcIxsjAV905f/UkQxbclCsoTWlacCNOpQa/anodLl2uaEKFhfWOvM2Qg77+15zA== + +format-util@1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271" + integrity sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg== + +forwarded@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" + integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== + +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== + +fs-extra@^10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" + integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + +fs-extra@^8.0.1: + version "8.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" + integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^4.0.0" + universalify "^0.1.0" + +fs-monkey@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/fs-monkey/-/fs-monkey-1.0.3.tgz#ae3ac92d53bb328efe0e9a1d9541f6ad8d48e2d3" + integrity sha512-cybjIfiiE+pTWicSCLFHSrXZ6EilF30oh91FDP9S2B051prEa7QWfrVTQm10/dDpswBDXZugPa1Ogu8Yh+HV0Q== + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + +fsevents@~2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + +function-bind@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" + integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== + +geojson@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/geojson/-/geojson-0.5.0.tgz#3cd6c96399be65b56ee55596116fe9191ce701c0" + integrity sha1-PNbJY5m+ZbVu5VWWEW/pGRznAcA= + +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-intrinsic@^1.0.2: + version "1.1.1" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" + integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== + dependencies: + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + +get-stream@^6.0.0: + version "6.0.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" + integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== + +gettext-extract@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/gettext-extract/-/gettext-extract-2.0.1.tgz#4ade7e3d7c1c247d95a81f28059ca1923c355886" + integrity sha512-k51R90txkCZeXQEDjK0e7gNHfBHJVCu8IQ3AbSVZoOL5nR3yl+C+7qpzp6hoZwOtiniaY+CKeLyvNulsEUM6MA== + dependencies: + chalk "^2.3.0" + find-up "^4.1.0" + fs-extra "^8.0.1" + gettext-extractor "^3.1.0" + minimist "^1.2.0" + +gettext-extractor@^3.1.0: + version "3.5.4" + resolved "https://registry.yarnpkg.com/gettext-extractor/-/gettext-extractor-3.5.4.tgz#bd36c65b4d26014ffd925f9ac7b4738d6893d6b2" + integrity sha512-iK4tSnteSw+pFMts43OP8hUnsOklbkxz3ytWqru7dPf8Ec3uzTYv1aw70ojAvKItmofpj1ibfY7sZWsdSN6zIw== + dependencies: + "@types/glob" "5 - 7" + "@types/parse5" "^5" + css-selector-parser "^1.3" + glob "5 - 7" + parse5 "5 - 6" + pofile "1.0.x" + typescript "2 - 4" + +gettext-parser@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/gettext-parser/-/gettext-parser-2.0.0.tgz#c28bb31e61f76f14665dfafbb5c0518cdc1270ed" + integrity sha512-FDs/7XjNw58ToQwJFO7avZZbPecSYgw8PBYhd0An+4JtZSrSzKhEvTsVV2uqdO7VziWTOGSgLGD5YRPdsCjF7Q== + dependencies: + encoding "^0.1.12" + safe-buffer "^5.1.2" + +gettext-parser@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/gettext-parser/-/gettext-parser-1.4.0.tgz#f8baf34a292f03d5e42f02df099d301f167a7ace" + integrity sha512-sedZYLHlHeBop/gZ1jdg59hlUEcpcZJofLq2JFwJT1zTqAU3l2wFv6IsuwFHGqbiT9DWzMUW4/em2+hspnmMMA== + dependencies: + encoding "^0.1.12" + safe-buffer "^5.1.1" + +gettext-to-messageformat@0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/gettext-to-messageformat/-/gettext-to-messageformat-0.3.1.tgz#c303ff9e31a5c781b14629b13bddb27b9ffca1f8" + integrity sha512-UyqIL3Ul4NryU95Wome/qtlcuVIqgEWVIFw0zi7Lv14ACLXfaVDCbrjZ7o+3BZ7u+4NS1mP/2O1eXZoHCoas8g== + dependencies: + gettext-parser "^1.4.0" + +gettext.js@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/gettext.js/-/gettext.js-1.2.0.tgz#783e166c604bc60c4b70f4656391038aa9e950b2" + integrity sha512-qOafHtn/xsXKiBOFO8enhdx8k09ViBYSnckhn4pn/QLCpQMF8S87q9f4cE2pVgbqWD9/9SyGpWRO0nWJsEDmlg== + dependencies: + po2json "^1.0.0-beta-3" + +glob-parent@~5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob-to-regexp@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" + integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== + +"glob@5 - 7", glob@7.2.0, glob@^7.1.3, glob@^7.1.7: + version "7.2.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" + integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +google-protobuf@3.12.2: + version "3.12.2" + resolved "https://registry.yarnpkg.com/google-protobuf/-/google-protobuf-3.12.2.tgz#50ce9f9b6281235724eb243d6a83e969a2176e53" + integrity sha512-4CZhpuRr1d6HjlyrxoXoocoGFnRYgKULgMtikMddA9ztRyYR59Aondv2FioyxWVamRo0rF2XpYawkTCBEQOSkA== + +graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.9: + version "4.2.10" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" + integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== + +handle-thing@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.1.tgz#857f79ce359580c340d43081cc648970d0bb234e" + integrity sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg== + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +has-symbols@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + +has@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" + integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw== + dependencies: + function-bind "^1.1.1" + +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + +hpack.js@^2.1.6: + version "2.1.6" + resolved "https://registry.yarnpkg.com/hpack.js/-/hpack.js-2.1.6.tgz#87774c0949e513f42e84575b3c45681fade2a0b2" + integrity sha512-zJxVehUdMGIKsRaNt7apO2Gqp0BdqW5yaiGHXXmbpvxgBYVZnAql+BJb4RO5ad2MgpbZKn5G6nMnegrH1FcNYQ== + dependencies: + inherits "^2.0.1" + obuf "^1.0.0" + readable-stream "^2.0.1" + wbuf "^1.1.0" + +html-entities@^2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.3.3.tgz#117d7626bece327fc8baace8868fa6f5ef856e46" + integrity sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA== + +html-parse-stringify@^3: + version "3.0.1" + resolved "https://registry.yarnpkg.com/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz#dfc1017347ce9f77c8141a507f233040c59c55d2" + integrity sha512-KknJ50kTInJ7qIScF3jeaFRpMpE8/lfiTdzf/twXyPBLAGrLRTmkz3AdTnKeh40X8k9L2fdYwEp/42WGXIRGcg== + dependencies: + void-elements "3.1.0" + +http-deceiver@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/http-deceiver/-/http-deceiver-1.2.7.tgz#fa7168944ab9a519d337cb0bec7284dc3e723d87" + integrity sha512-LmpOGxTfbpgtGVxJrj5k7asXHCgNZp5nLfp+hWc8QQRqtb7fUy6kRY3BO1h9ddF6yIPYUARgxGOwB42DnxIaNw== + +http-errors@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" + integrity sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ== + dependencies: + depd "2.0.0" + inherits "2.0.4" + setprototypeof "1.2.0" + statuses "2.0.1" + toidentifier "1.0.1" + +http-errors@~1.6.2: + version "1.6.3" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" + integrity sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A== + dependencies: + depd "~1.1.2" + inherits "2.0.3" + setprototypeof "1.1.0" + statuses ">= 1.4.0 < 2" + +http-parser-js@>=0.5.1: + version "0.5.8" + resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.8.tgz#af23090d9ac4e24573de6f6aecc9d84a48bf20e3" + integrity sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q== + +http-proxy-middleware@^2.0.3: + version "2.0.6" + resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f" + integrity sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw== + dependencies: + "@types/http-proxy" "^1.17.8" + http-proxy "^1.18.1" + is-glob "^4.0.1" + is-plain-obj "^3.0.0" + micromatch "^4.0.2" + +http-proxy@^1.18.1: + version "1.18.1" + resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" + integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== + dependencies: + eventemitter3 "^4.0.0" + follow-redirects "^1.0.0" + requires-port "^1.0.0" + +human-signals@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" + integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== + +iconv-lite@0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +iconv-lite@^0.6.2, iconv-lite@^0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" + integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw== + dependencies: + safer-buffer ">= 2.1.2 < 3.0.0" + +icss-utils@^5.0.0, icss-utils@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/icss-utils/-/icss-utils-5.1.0.tgz#c6be6858abd013d768e98366ae47e25d5887b1ae" + integrity sha512-soFhflCVWLfRNOPU3iv5Z9VUdT44xFRbzjLsEzSr5AQmgqPMTHdU3PMT1Cf1ssx8fLNJDA1juftYl+PUcv3MqA== + +import-local@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" + integrity sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg== + dependencies: + pkg-dir "^4.2.0" + resolve-cwd "^3.0.0" + +imports-loader@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/imports-loader/-/imports-loader-4.0.1.tgz#a3d3067d0c369cd621e2b322b6b6bb2593756be5" + integrity sha512-ZiY+1xH5fqAJ1Qu1CFv+zw54rvPCC92DdYRDe0IIUboOhbJPLfOPbF/paA2iipelvMwjQUKWydcFOJ7f1+ZFcA== + dependencies: + source-map "^0.6.1" + strip-comments "^2.0.1" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw== + +interpret@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4" + integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ== + +ipaddr.js@1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" + integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== + +ipaddr.js@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.0.1.tgz#eca256a7a877e917aeb368b0a7497ddf42ef81c0" + integrity sha512-1qTgH9NG+IIJ4yfKs2e6Pp1bZg8wbDbKHT21HrLIeYBTRLgMYKnMTPAuI3Lcs61nfx5h1xlXnbJtH1kX5/d/ng== + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-core-module@^2.9.0: + version "2.11.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.11.0.tgz#ad4cb3e3863e814523c96f3f58d26cc570ff0144" + integrity sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw== + dependencies: + has "^1.0.3" + +is-docker@^2.0.0, is-docker@^2.1.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" + integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== + +is-plain-obj@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-3.0.0.tgz#af6f2ea14ac5a646183a5bbdb5baabbc156ad9d7" + integrity sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA== + +is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== + dependencies: + isobject "^3.0.1" + +is-stream@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" + integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== + +is-unicode-supported@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" + integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== + +is-wsl@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" + integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== + dependencies: + is-docker "^2.0.0" + +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== + +isbinaryfile@^4.0.8: + version "4.0.10" + resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-4.0.10.tgz#0c5b5e30c2557a2f06febd37b7322946aaee42b3" + integrity sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + +isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= + +jest-worker@^27.4.5: + version "27.5.1" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" + integrity sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg== + dependencies: + "@types/node" "*" + merge-stream "^2.0.0" + supports-color "^8.0.0" + +jquery@^3.5.1: + version "3.6.0" + resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470" + integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw== + +js-yaml@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + +json-parse-even-better-errors@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" + integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json-schema-traverse@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" + integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== + +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= + optionalDependencies: + graceful-fs "^4.1.6" + +jsonfile@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" + integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== + dependencies: + universalify "^2.0.0" + optionalDependencies: + graceful-fs "^4.1.6" + +karma-chrome-launcher@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-3.1.1.tgz#baca9cc071b1562a1db241827257bfe5cab597ea" + integrity sha512-hsIglcq1vtboGPAN+DGCISCFOxW+ZVnIqhDQcCMqqCp+4dmJ0Qpq5QAjkbA0X2L9Mi6OBkHi2Srrbmm7pUKkzQ== + dependencies: + which "^1.2.1" + +karma-mocha@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/karma-mocha/-/karma-mocha-2.0.1.tgz#4b0254a18dfee71bdbe6188d9a6861bf86b0cd7d" + integrity sha512-Tzd5HBjm8his2OA4bouAsATYEpZrp9vC7z5E5j4C5Of5Rrs1jY67RAwXNcVmd/Bnk1wgvQRou0zGVLey44G4tQ== + dependencies: + minimist "^1.2.3" + +karma-sourcemap-loader@0.3.8: + version "0.3.8" + resolved "https://registry.yarnpkg.com/karma-sourcemap-loader/-/karma-sourcemap-loader-0.3.8.tgz#d4bae72fb7a8397328a62b75013d2df937bdcf9c" + integrity sha512-zorxyAakYZuBcHRJE+vbrK2o2JXLFWK8VVjiT/6P+ltLBUGUvqTEkUiQ119MGdOrK7mrmxXHZF1/pfT6GgIZ6g== + dependencies: + graceful-fs "^4.1.2" + +karma-webpack@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/karma-webpack/-/karma-webpack-5.0.0.tgz#2a2c7b80163fe7ffd1010f83f5507f95ef39f840" + integrity sha512-+54i/cd3/piZuP3dr54+NcFeKOPnys5QeM1IY+0SPASwrtHsliXUiCL50iW+K9WWA7RvamC4macvvQ86l3KtaA== + dependencies: + glob "^7.1.3" + minimatch "^3.0.4" + webpack-merge "^4.1.5" + +karma@6.4.1: + version "6.4.1" + resolved "https://registry.yarnpkg.com/karma/-/karma-6.4.1.tgz#f2253716dd3a41aaa813fa9f54b6ee047e1127d9" + integrity sha512-Cj57NKOskK7wtFWSlMvZf459iX+kpYIPXmkNUzP2WAFcA7nhr/ALn5R7sw3w+1udFDcpMx/tuB8d5amgm3ijaA== + dependencies: + "@colors/colors" "1.5.0" + body-parser "^1.19.0" + braces "^3.0.2" + chokidar "^3.5.1" + connect "^3.7.0" + di "^0.0.1" + dom-serialize "^2.2.1" + glob "^7.1.7" + graceful-fs "^4.2.6" + http-proxy "^1.18.1" + isbinaryfile "^4.0.8" + lodash "^4.17.21" + log4js "^6.4.1" + mime "^2.5.2" + minimatch "^3.0.4" + mkdirp "^0.5.5" + qjobs "^1.2.0" + range-parser "^1.2.1" + rimraf "^3.0.2" + socket.io "^4.4.1" + source-map "^0.6.1" + tmp "^0.2.1" + ua-parser-js "^0.7.30" + yargs "^16.1.1" + +kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + +kvision-assets@^7.0.4: + version "7.0.4" + resolved "https://registry.yarnpkg.com/kvision-assets/-/kvision-assets-7.0.4.tgz#59c62f38b15b44db10699305159be63828a5e645" + integrity sha512-DY2j6Wm3vaMWwBSjnhutOKZQA6pzOvL40hAkUUc52QkrRn4K2E7GHdWR1qGIR4/YyraWvzkVWasr6R4vg8l9mQ== + +leaflet@^1.9.3: + version "1.9.3" + resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.9.3.tgz#52ec436954964e2d3d39e0d433da4b2500d74414" + integrity sha512-iB2cR9vAkDOu5l3HAay2obcUHZ7xwUBBjph8+PGtmW/2lYhbLizWtG7nTeYht36WfOslixQF9D/uSIzhZgGMfQ== + +loader-runner@^4.2.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" + integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg== + +locate-path@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" + integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== + dependencies: + p-locate "^4.1.0" + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash@^4.17.15, lodash@^4.17.21: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + +log-symbols@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" + integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== + dependencies: + chalk "^4.1.0" + is-unicode-supported "^0.1.0" + +log4js@^6.4.1: + version "6.5.2" + resolved "https://registry.yarnpkg.com/log4js/-/log4js-6.5.2.tgz#9ae371e5b3cb3a3a209c24686e5547f8670834e5" + integrity sha512-DXtpNtt+KDOMT7RHUDIur/WsSA3rntlUh9Zg4XCdV42wUuMmbFkl38+LZ92Z5QvQA7mD5kAVkLiBSEH/tvUB8A== + dependencies: + date-format "^4.0.10" + debug "^4.3.4" + flatted "^3.2.5" + rfdc "^1.3.0" + streamroller "^3.1.1" + +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g= + +memfs@^3.4.3: + version "3.4.7" + resolved "https://registry.yarnpkg.com/memfs/-/memfs-3.4.7.tgz#e5252ad2242a724f938cb937e3c4f7ceb1f70e5a" + integrity sha512-ygaiUSNalBX85388uskeCyhSAoOSgzBbtVCr9jA2RROssFL9Q19/ZXFqS+2Th2sr1ewNIWgFdLzLC3Yl1Zv+lw== + dependencies: + fs-monkey "^1.0.3" + +merge-descriptors@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" + integrity sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w== + +merge-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" + integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== + +methods@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" + integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w== + +micromatch@^4.0.2: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + +mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + +mime@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== + +mime@^2.5.2: + version "2.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367" + integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== + +mimic-fn@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" + integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== + +minimalistic-assert@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" + integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== + +minimatch@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b" + integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g== + dependencies: + brace-expansion "^2.0.1" + +minimatch@^3.0.4: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.6: + version "1.2.6" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" + integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== + +mkdirp@^0.5.5: + version "0.5.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== + dependencies: + minimist "^1.2.6" + +mocha@10.1.0: + version "10.1.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.1.0.tgz#dbf1114b7c3f9d0ca5de3133906aea3dfc89ef7a" + integrity sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg== + dependencies: + ansi-colors "4.1.1" + browser-stdout "1.3.1" + chokidar "3.5.3" + debug "4.3.4" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "7.2.0" + he "1.2.0" + js-yaml "4.1.0" + log-symbols "4.1.0" + minimatch "5.0.1" + ms "2.1.3" + nanoid "3.3.3" + serialize-javascript "6.0.0" + strip-json-comments "3.1.1" + supports-color "8.1.1" + workerpool "6.2.1" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +ms@2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +multicast-dns@^7.2.5: + version "7.2.5" + resolved "https://registry.yarnpkg.com/multicast-dns/-/multicast-dns-7.2.5.tgz#77eb46057f4d7adbd16d9290fa7299f6fa64cced" + integrity sha512-2eznPJP8z2BFLX50tf0LuODrpINqP1RVIm/CObbTcBRITQgmC/TjcREF1NeTBzIcR5XO/ukWo+YHOjBbFwIupg== + dependencies: + dns-packet "^5.2.2" + thunky "^1.0.2" + +nanoid@3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25" + integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w== + +nanoid@^3.3.4: + version "3.3.4" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" + integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== + +navigo@^8.11.1: + version "8.11.1" + resolved "https://registry.yarnpkg.com/navigo/-/navigo-8.11.1.tgz#aca756dbca40e2da2ae688a2a247ab4f070fcf4a" + integrity sha512-e3sc1UzakF+bWquC8/dbPCgo7LgPEW1ekgwb4pmEcl8tOc/I7lML8r7HBql+b0VRk7tJWTZqtkeObwJAVR1pxg== + +negotiator@0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" + integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== + +neo-async@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" + integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== + +node-forge@^1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" + integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== + +node-releases@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.3.tgz#225ee7488e4a5e636da8da52854844f9d716ca96" + integrity sha512-maHFz6OLqYxz+VQyCAtA3PTX4UP/53pa05fyDNc9CwjvJ0yEh6+xBwKsgCxMNhS8taUKBFYxfuiaD9U/55iFaw== + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +npm-run-path@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" + integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== + dependencies: + path-key "^3.0.0" + +object-assign@^4: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= + +object-inspect@^1.9.0: + version "1.12.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.0.tgz#6e2c120e868fd1fd18cb4f18c31741d0d6e776f0" + integrity sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g== + +obuf@^1.0.0, obuf@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.2.tgz#09bea3343d41859ebd446292d11c9d4db619084e" + integrity sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg== + +on-finished@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" + integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== + dependencies: + ee-first "1.1.1" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= + dependencies: + ee-first "1.1.1" + +on-headers@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.2.tgz#772b0ae6aaa525c399e489adfad90c403eb3c28f" + integrity sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA== + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + dependencies: + wrappy "1" + +onetime@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== + dependencies: + mimic-fn "^2.1.0" + +open@^8.0.9: + version "8.4.0" + resolved "https://registry.yarnpkg.com/open/-/open-8.4.0.tgz#345321ae18f8138f82565a910fdc6b39e8c244f8" + integrity sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q== + dependencies: + define-lazy-prop "^2.0.0" + is-docker "^2.1.1" + is-wsl "^2.2.0" + +p-limit@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" + integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== + dependencies: + p-limit "^2.2.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + +p-retry@^4.5.0: + version "4.6.2" + resolved "https://registry.yarnpkg.com/p-retry/-/p-retry-4.6.2.tgz#9baae7184057edd4e17231cee04264106e092a16" + integrity sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ== + dependencies: + "@types/retry" "0.12.0" + retry "^0.13.1" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +"parse5@5 - 6": + version "6.0.1" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b" + integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw== + +parseurl@~1.3.2, parseurl@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" + integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + +path-key@^3.0.0, path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + +path-parse@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== + +path-to-regexp@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" + integrity sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ== + +picocolors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" + integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== + +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +pkg-dir@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" + integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== + dependencies: + find-up "^4.0.0" + +po2json@^1.0.0-beta-3: + version "1.0.0-beta-3" + resolved "https://registry.yarnpkg.com/po2json/-/po2json-1.0.0-beta-3.tgz#f087abeeccdc82c1e5315a749e5f3bcf7e1421e1" + integrity sha512-taS8y6ZEGzPAs0rygW9CuUPY8C3Zgx6cBy31QXxG2JlWS3fLxj/kuD3cbIfXBg30PuYN7J5oyBa/TIRjyqFFtg== + dependencies: + commander "^6.0.0" + gettext-parser "2.0.0" + gettext-to-messageformat "0.3.1" + +pofile@1.0.x: + version "1.0.11" + resolved "https://registry.yarnpkg.com/pofile/-/pofile-1.0.11.tgz#35aff58c17491d127a07336d5522ebc9df57c954" + integrity sha512-Vy9eH1dRD9wHjYt/QqXcTz+RnX/zg53xK+KljFSX30PvdDMb2z+c6uDUeblUGqqJgz3QFsdlA0IJvHziPmWtQg== + +postcss-modules-extract-imports@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/postcss-modules-extract-imports/-/postcss-modules-extract-imports-3.0.0.tgz#cda1f047c0ae80c97dbe28c3e76a43b88025741d" + integrity sha512-bdHleFnP3kZ4NYDhuGlVK+CMrQ/pqUm8bx/oGL93K6gVwiclvX5x0n76fYMKuIGKzlABOy13zsvqjb0f92TEXw== + +postcss-modules-local-by-default@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/postcss-modules-local-by-default/-/postcss-modules-local-by-default-4.0.0.tgz#ebbb54fae1598eecfdf691a02b3ff3b390a5a51c" + integrity sha512-sT7ihtmGSF9yhm6ggikHdV0hlziDTX7oFoXtuVWeDd3hHObNkcHRo9V3yg7vCAY7cONyxJC/XXCmmiHHcvX7bQ== + dependencies: + icss-utils "^5.0.0" + postcss-selector-parser "^6.0.2" + postcss-value-parser "^4.1.0" + +postcss-modules-scope@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/postcss-modules-scope/-/postcss-modules-scope-3.0.0.tgz#9ef3151456d3bbfa120ca44898dfca6f2fa01f06" + integrity sha512-hncihwFA2yPath8oZ15PZqvWGkWf+XUfQgUGamS4LqoP1anQLOsOJw0vr7J7IwLpoY9fatA2qiGUGmuZL0Iqlg== + dependencies: + postcss-selector-parser "^6.0.4" + +postcss-modules-values@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/postcss-modules-values/-/postcss-modules-values-4.0.0.tgz#d7c5e7e68c3bb3c9b27cbf48ca0bb3ffb4602c9c" + integrity sha512-RDxHkAiEGI78gS2ofyvCsu7iycRv7oqw5xMWn9iMoR0N/7mf9D50ecQqUo5BZ9Zh2vH4bCUR/ktCqbB9m8vJjQ== + dependencies: + icss-utils "^5.0.0" + +postcss-selector-parser@^6.0.2, postcss-selector-parser@^6.0.4: + version "6.0.10" + resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz#79b61e2c0d1bfc2602d549e11d0876256f8df88d" + integrity sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w== + dependencies: + cssesc "^3.0.0" + util-deprecate "^1.0.2" + +postcss-value-parser@^4.1.0, postcss-value-parser@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz#723c09920836ba6d3e5af019f92bc0971c02e514" + integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== + +postcss@^8.4.18: + version "8.4.19" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.19.tgz#61178e2add236b17351897c8bcc0b4c8ecab56fc" + integrity sha512-h+pbPsyhlYj6N2ozBmHhHrs9DzGmbaarbLvWipMRO7RLS+v4onj26MPFXA5OBYFxyqYhUJK456SwDcY9H2/zsA== + dependencies: + nanoid "^3.3.4" + picocolors "^1.0.0" + source-map-js "^1.0.2" + +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + +proxy-addr@~2.0.7: + version "2.0.7" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" + integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== + dependencies: + forwarded "0.2.0" + ipaddr.js "1.9.1" + +punycode@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" + integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== + +qjobs@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" + integrity sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg== + +qs@6.10.3: + version "6.10.3" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.10.3.tgz#d6cde1b2ffca87b5aa57889816c5f81535e22e8e" + integrity sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ== + dependencies: + side-channel "^1.0.4" + +randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + +range-parser@^1.2.1, range-parser@~1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" + integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== + +raw-body@2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.1.tgz#fe1b1628b181b700215e5fd42389f98b71392857" + integrity sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig== + dependencies: + bytes "3.1.2" + http-errors "2.0.0" + iconv-lite "0.4.24" + unpipe "1.0.0" + +readable-stream@^2.0.1: + version "2.3.7" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" + integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + +readable-stream@^3.0.6: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" + integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + +rechoir@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.8.0.tgz#49f866e0d32146142da3ad8f0eff352b3215ff22" + integrity sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ== + dependencies: + resolve "^1.20.0" + +redux-thunk@^2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/redux-thunk/-/redux-thunk-2.4.1.tgz#0dd8042cf47868f4b29699941de03c9301a75714" + integrity sha512-OOYGNY5Jy2TWvTL1KgAlVy6dcx3siPJ1wTq741EPyUKfn6W6nChdICjZwCd0p8AZBs5kWpZlbkXW2nE/zjUa+Q== + +redux@^4.1.2: + version "4.2.0" + resolved "https://registry.yarnpkg.com/redux/-/redux-4.2.0.tgz#46f10d6e29b6666df758780437651eeb2b969f13" + integrity sha512-oSBmcKKIuIR4ME29/AeNUnl5L+hvBq7OaJWzaptTQJAntaPvxIJqfnjbaEiCzzaIz+XmVILfqAM3Ob0aXLPfjA== + dependencies: + "@babel/runtime" "^7.9.2" + +regenerator-runtime@^0.13.4: + version "0.13.9" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52" + integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA== + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + +require-from-string@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" + integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== + +requires-port@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + integrity sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8= + +resolve-cwd@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" + integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== + dependencies: + resolve-from "^5.0.0" + +resolve-from@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" + integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== + +resolve@^1.20.0: + version "1.22.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177" + integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw== + dependencies: + is-core-module "^2.9.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + +retry@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" + integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== + +rfdc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" + integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== + +rimraf@^3.0.0, rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== + dependencies: + glob "^7.1.3" + +safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + +safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +schema-utils@^3.1.0, schema-utils@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.1.tgz#bc74c4b6b6995c1d88f76a8b77bea7219e0c8281" + integrity sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw== + dependencies: + "@types/json-schema" "^7.0.8" + ajv "^6.12.5" + ajv-keywords "^3.5.2" + +schema-utils@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-4.0.0.tgz#60331e9e3ae78ec5d16353c467c34b3a0a1d3df7" + integrity sha512-1edyXKgh6XnJsJSQ8mKWXnN/BVaIbFMLpouRUrXgVq7WYne5kw3MW7UPhO44uRXQSIpTSXoJbmrR2X0w9kUTyg== + dependencies: + "@types/json-schema" "^7.0.9" + ajv "^8.8.0" + ajv-formats "^2.1.1" + ajv-keywords "^5.0.0" + +select-hose@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca" + integrity sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg== + +selfsigned@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.1.1.tgz#18a7613d714c0cd3385c48af0075abf3f266af61" + integrity sha512-GSL3aowiF7wa/WtSFwnUrludWFoNhftq8bUkH9pkzjpN2XSPOAYEgg6e0sS9s0rZwgJzJiQRPU18A6clnoW5wQ== + dependencies: + node-forge "^1" + +semver@^7.3.8: + version "7.3.8" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" + integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== + dependencies: + lru-cache "^6.0.0" + +send@0.18.0: + version "0.18.0" + resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be" + integrity sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg== + dependencies: + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "2.0.0" + mime "1.6.0" + ms "2.1.3" + on-finished "2.4.1" + range-parser "~1.2.1" + statuses "2.0.1" + +serialize-javascript@6.0.0, serialize-javascript@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== + dependencies: + randombytes "^2.1.0" + +serve-index@^1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.1.tgz#d3768d69b1e7d82e5ce050fff5b453bea12a9239" + integrity sha512-pXHfKNP4qujrtteMrSBb0rc8HJ9Ms/GrXwcUtUtD5s4ewDJI8bT3Cz2zTVRMKtri49pLx2e0Ya8ziP5Ya2pZZw== + dependencies: + accepts "~1.3.4" + batch "0.6.1" + debug "2.6.9" + escape-html "~1.0.3" + http-errors "~1.6.2" + mime-types "~2.1.17" + parseurl "~1.3.2" + +serve-static@1.15.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.15.0.tgz#faaef08cffe0a1a62f60cad0c4e513cff0ac9540" + integrity sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g== + dependencies: + encodeurl "~1.0.2" + escape-html "~1.0.3" + parseurl "~1.3.3" + send "0.18.0" + +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ== + +setprototypeof@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" + integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== + +shallow-clone@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" + integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA== + dependencies: + kind-of "^6.0.2" + +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + +side-channel@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" + integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== + dependencies: + call-bind "^1.0.0" + get-intrinsic "^1.0.2" + object-inspect "^1.9.0" + +signal-exit@^3.0.3: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== + +snabbdom@^3.5.1: + version "3.5.1" + resolved "https://registry.yarnpkg.com/snabbdom/-/snabbdom-3.5.1.tgz#25f80ef15b194baea703d9d5441892e369de18e1" + integrity sha512-wHMNIOjkm/YNE5EM3RCbr/+DVgPg6AqQAX1eOxO46zYNvCXjKP5Y865tqQj3EXnaMBjkxmQA5jFuDpDK/dbfiA== + +socket.io-adapter@~2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-2.4.0.tgz#b50a4a9ecdd00c34d4c8c808224daa1a786152a6" + integrity sha512-W4N+o69rkMEGVuk2D/cvca3uYsvGlMwsySWV447y99gUPghxq42BxqLNMndb+a1mm/5/7NeXVQS7RLa2XyXvYg== + +socket.io-parser@~4.0.4: + version "4.0.4" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.0.4.tgz#9ea21b0d61508d18196ef04a2c6b9ab630f4c2b0" + integrity sha512-t+b0SS+IxG7Rxzda2EVvyBZbvFPBCjJoyHuE0P//7OAsN23GItzDRdWa6ALxZI/8R5ygK7jAR6t028/z+7295g== + dependencies: + "@types/component-emitter" "^1.2.10" + component-emitter "~1.3.0" + debug "~4.3.1" + +socket.io@^4.4.1: + version "4.5.1" + resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-4.5.1.tgz#aa7e73f8a6ce20ee3c54b2446d321bbb6b1a9029" + integrity sha512-0y9pnIso5a9i+lJmsCdtmTTgJFFSvNQKDnPQRz28mGNnxbmqYg2QPtJTLFxhymFZhAIn50eHAKzJeiNaKr+yUQ== + dependencies: + accepts "~1.3.4" + base64id "~2.0.0" + debug "~4.3.2" + engine.io "~6.2.0" + socket.io-adapter "~2.4.0" + socket.io-parser "~4.0.4" + +sockjs@^0.3.24: + version "0.3.24" + resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.24.tgz#c9bc8995f33a111bea0395ec30aa3206bdb5ccce" + integrity sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ== + dependencies: + faye-websocket "^0.11.3" + uuid "^8.3.2" + websocket-driver "^0.7.4" + +source-map-js@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" + integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== + +source-map-loader@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-4.0.0.tgz#bdc6b118bc6c87ee4d8d851f2d4efcc5abdb2ef5" + integrity sha512-i3KVgM3+QPAHNbGavK+VBq03YoJl24m9JWNbLgsjTj8aJzXG9M61bantBTNBt7CNwY2FYf+RJRYJ3pzalKjIrw== + dependencies: + abab "^2.0.6" + iconv-lite "^0.6.3" + source-map-js "^1.0.2" + +source-map-support@~0.5.20: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0, source-map@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +source-map@~0.7.2: + version "0.7.3" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" + integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== + +spdy-transport@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdy-transport/-/spdy-transport-3.0.0.tgz#00d4863a6400ad75df93361a1608605e5dcdcf31" + integrity sha512-hsLVFE5SjA6TCisWeJXFKniGGOpBgMLmerfO2aCyCU5s7nJ/rpAepqmFifv/GCbSbueEeAJJnmSQ2rKC/g8Fcw== + dependencies: + debug "^4.1.0" + detect-node "^2.0.4" + hpack.js "^2.1.6" + obuf "^1.1.2" + readable-stream "^3.0.6" + wbuf "^1.7.3" + +spdy@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/spdy/-/spdy-4.0.2.tgz#b74f466203a3eda452c02492b91fb9e84a27677b" + integrity sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA== + dependencies: + debug "^4.1.0" + handle-thing "^2.0.0" + http-deceiver "^1.2.7" + select-hose "^2.0.0" + spdy-transport "^3.0.0" + +split.js@^1.6.5: + version "1.6.5" + resolved "https://registry.yarnpkg.com/split.js/-/split.js-1.6.5.tgz#f7f61da1044c9984cb42947df4de4fadb5a3f300" + integrity sha512-mPTnGCiS/RiuTNsVhCm9De9cCAUsrNFFviRbADdKiiV+Kk8HKp/0fWu7Kr8pi3/yBmsqLFHuXGT9UUZ+CNLwFw== + +statuses@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" + integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== + +"statuses@>= 1.4.0 < 2", statuses@~1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= + +streamroller@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-3.1.1.tgz#679aae10a4703acdf2740755307df0a05ad752e6" + integrity sha512-iPhtd9unZ6zKdWgMeYGfSBuqCngyJy1B/GPi/lTpwGpa3bajuX30GjUVd0/Tn/Xhg0mr4DOSENozz9Y06qyonQ== + dependencies: + date-format "^4.0.10" + debug "^4.3.4" + fs-extra "^10.1.0" + +string-width@^4.1.0, string-width@^4.2.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-comments@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/strip-comments/-/strip-comments-2.0.1.tgz#4ad11c3fbcac177a67a40ac224ca339ca1c1ba9b" + integrity sha512-ZprKx+bBLXv067WTCALv8SSz5l2+XhpYCsVtSqlMnkAXMWDq+/ekVbl1ghqP9rUHTzv6sm/DwCOiYutU/yp1fw== + +strip-final-newline@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" + integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== + +strip-json-comments@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +style-loader@^3.3.1: + version "3.3.1" + resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-3.3.1.tgz#057dfa6b3d4d7c7064462830f9113ed417d38575" + integrity sha512-GPcQ+LDJbrcxHORTRes6Jy2sfvK2kS6hpSfI/fXhPt+spVzxF6LJ1dHLN9zIGmVaaP044YKaIatFaufENRiDoQ== + +supports-color@8.1.1, supports-color@^8.0.0: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== + +tapable@^2.1.1, tapable@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" + integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== + +terser-webpack-plugin@^5.1.3: + version "5.3.1" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.1.tgz#0320dcc270ad5372c1e8993fabbd927929773e54" + integrity sha512-GvlZdT6wPQKbDNW/GDQzZFg/j4vKU96yl2q6mcUkzKOgW4gwf1Z8cZToUCrz31XHlPWH8MVb1r2tFtdDtTGJ7g== + dependencies: + jest-worker "^27.4.5" + schema-utils "^3.1.1" + serialize-javascript "^6.0.0" + source-map "^0.6.1" + terser "^5.7.2" + +terser@^5.7.2: + version "5.12.1" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.12.1.tgz#4cf2ebed1f5bceef5c83b9f60104ac4a78b49e9c" + integrity sha512-NXbs+7nisos5E+yXwAD+y7zrcTkMqb0dEJxIGtSKPdCBzopf7ni4odPul2aechpV7EXNvOudYOX2bb5tln1jbQ== + dependencies: + acorn "^8.5.0" + commander "^2.20.0" + source-map "~0.7.2" + source-map-support "~0.5.20" + +thunky@^1.0.2: + version "1.1.0" + resolved "https://registry.yarnpkg.com/thunky/-/thunky-1.1.0.tgz#5abaf714a9405db0504732bbccd2cedd9ef9537d" + integrity sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA== + +tmp@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14" + integrity sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ== + dependencies: + rimraf "^3.0.0" + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +toidentifier@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== + +type-is@~1.6.18: + version "1.6.18" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" + integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== + dependencies: + media-typer "0.3.0" + mime-types "~2.1.24" + +"typescript@2 - 4": + version "4.6.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.3.tgz#eefeafa6afdd31d725584c67a0eaba80f6fc6c6c" + integrity sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw== + +typescript@3.9.5: + version "3.9.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.5.tgz#586f0dba300cde8be52dd1ac4f7e1009c1b13f36" + integrity sha512-hSAifV3k+i6lEoCJ2k6R2Z/rp/H3+8sdmcn5NrS3/3kE7+RyZXm9aqvxWqjEXHAd8b0pShatpcdMTvEdvAJltQ== + +ua-parser-js@^0.7.30: + version "0.7.31" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.31.tgz#649a656b191dffab4f21d5e053e27ca17cbff5c6" + integrity sha512-qLK/Xe9E2uzmYI3qLeOmI0tEOt+TBBQyUIAh4aAgU05FVYzeZrKUdkAZfBNVGRaHVgV0TDkdEngJSw/SyQchkQ== + +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + +universalify@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" + integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + integrity sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw= + +uri-js@^4.2.2: + version "4.4.1" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== + dependencies: + punycode "^2.1.0" + +util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= + +uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + +vary@^1, vary@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" + integrity sha1-IpnwLG3tMNSllhsLn3RSShj2NPw= + +void-elements@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-3.1.0.tgz#614f7fbf8d801f0bb5f0661f5b2f5785750e4f09" + integrity sha1-YU9/v42AHwu18GYfWy9XhXUOTwk= + +void-elements@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" + integrity sha1-wGavtYK7HLQSjWDqkjkulNXp2+w= + +watchpack@^2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.0.tgz#fa33032374962c78113f93c7f2fb4c54c9862a5d" + integrity sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg== + dependencies: + glob-to-regexp "^0.4.1" + graceful-fs "^4.1.2" + +wbuf@^1.1.0, wbuf@^1.7.3: + version "1.7.3" + resolved "https://registry.yarnpkg.com/wbuf/-/wbuf-1.7.3.tgz#c1d8d149316d3ea852848895cb6a0bfe887b87df" + integrity sha512-O84QOnr0icsbFGLS0O3bI5FswxzRr8/gHwWkDlQFskhSPryQXvrTMxjxGP4+iWYoauLoBvfDpkrOauZ+0iZpDA== + dependencies: + minimalistic-assert "^1.0.0" + +webpack-cli@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-5.0.0.tgz#bd380a9653e0cd1a08916c4ff1adea17201ef68f" + integrity sha512-AACDTo20yG+xn6HPW5xjbn2Be4KUzQPebWXsDMHwPPyKh9OnTOJgZN2Nc+g/FZKV3ObRTYsGvibAvc+5jAUrVA== + dependencies: + "@discoveryjs/json-ext" "^0.5.0" + "@webpack-cli/configtest" "^2.0.0" + "@webpack-cli/info" "^2.0.0" + "@webpack-cli/serve" "^2.0.0" + colorette "^2.0.14" + commander "^9.4.1" + cross-spawn "^7.0.3" + envinfo "^7.7.3" + fastest-levenshtein "^1.0.12" + import-local "^3.0.2" + interpret "^3.1.1" + rechoir "^0.8.0" + webpack-merge "^5.7.3" + +webpack-dev-middleware@^5.3.1: + version "5.3.3" + resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-5.3.3.tgz#efae67c2793908e7311f1d9b06f2a08dcc97e51f" + integrity sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA== + dependencies: + colorette "^2.0.10" + memfs "^3.4.3" + mime-types "^2.1.31" + range-parser "^1.2.1" + schema-utils "^4.0.0" + +webpack-dev-server@4.11.1: + version "4.11.1" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-4.11.1.tgz#ae07f0d71ca0438cf88446f09029b92ce81380b5" + integrity sha512-lILVz9tAUy1zGFwieuaQtYiadImb5M3d+H+L1zDYalYoDl0cksAB1UNyuE5MMWJrG6zR1tXkCP2fitl7yoUJiw== + dependencies: + "@types/bonjour" "^3.5.9" + "@types/connect-history-api-fallback" "^1.3.5" + "@types/express" "^4.17.13" + "@types/serve-index" "^1.9.1" + "@types/serve-static" "^1.13.10" + "@types/sockjs" "^0.3.33" + "@types/ws" "^8.5.1" + ansi-html-community "^0.0.8" + bonjour-service "^1.0.11" + chokidar "^3.5.3" + colorette "^2.0.10" + compression "^1.7.4" + connect-history-api-fallback "^2.0.0" + default-gateway "^6.0.3" + express "^4.17.3" + graceful-fs "^4.2.6" + html-entities "^2.3.2" + http-proxy-middleware "^2.0.3" + ipaddr.js "^2.0.1" + open "^8.0.9" + p-retry "^4.5.0" + rimraf "^3.0.2" + schema-utils "^4.0.0" + selfsigned "^2.1.1" + serve-index "^1.9.1" + sockjs "^0.3.24" + spdy "^4.0.2" + webpack-dev-middleware "^5.3.1" + ws "^8.4.2" + +webpack-merge@^4.1.5: + version "4.2.2" + resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.2.2.tgz#a27c52ea783d1398afd2087f547d7b9d2f43634d" + integrity sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g== + dependencies: + lodash "^4.17.15" + +webpack-merge@^5.7.3: + version "5.8.0" + resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.8.0.tgz#2b39dbf22af87776ad744c390223731d30a68f61" + integrity sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q== + dependencies: + clone-deep "^4.0.1" + wildcard "^2.0.0" + +webpack-sources@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" + integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== + +webpack@5.75.0: + version "5.75.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.75.0.tgz#1e440468647b2505860e94c9ff3e44d5b582c152" + integrity sha512-piaIaoVJlqMsPtX/+3KTTO6jfvrSYgauFVdt8cr9LTHKmcq/AMd4mhzsiP7ZF/PGRNPGA8336jldh9l2Kt2ogQ== + dependencies: + "@types/eslint-scope" "^3.7.3" + "@types/estree" "^0.0.51" + "@webassemblyjs/ast" "1.11.1" + "@webassemblyjs/wasm-edit" "1.11.1" + "@webassemblyjs/wasm-parser" "1.11.1" + acorn "^8.7.1" + acorn-import-assertions "^1.7.6" + browserslist "^4.14.5" + chrome-trace-event "^1.0.2" + enhanced-resolve "^5.10.0" + es-module-lexer "^0.9.0" + eslint-scope "5.1.1" + events "^3.2.0" + glob-to-regexp "^0.4.1" + graceful-fs "^4.2.9" + json-parse-even-better-errors "^2.3.1" + loader-runner "^4.2.0" + mime-types "^2.1.27" + neo-async "^2.6.2" + schema-utils "^3.1.0" + tapable "^2.1.1" + terser-webpack-plugin "^5.1.3" + watchpack "^2.4.0" + webpack-sources "^3.2.3" + +websocket-driver@>=0.5.1, websocket-driver@^0.7.4: + version "0.7.4" + resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760" + integrity sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg== + dependencies: + http-parser-js ">=0.5.1" + safe-buffer ">=5.1.0" + websocket-extensions ">=0.1.1" + +websocket-extensions@>=0.1.1: + version "0.1.4" + resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" + integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== + +which@^1.2.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +wildcard@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec" + integrity sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw== + +workerpool@6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" + integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== + +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + +ws@^8.4.2: + version "8.8.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.8.0.tgz#8e71c75e2f6348dbf8d78005107297056cb77769" + integrity sha512-JDAgSYQ1ksuwqfChJusw1LSJ8BizJ2e/vVu5Lxjq3YvNJNlROv1ui4i+c/kUUrPheBvQl4c5UbERhTwKa6QBJQ== + +ws@~8.2.3: + version "8.2.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.2.3.tgz#63a56456db1b04367d0b721a0b80cae6d8becbba" + integrity sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA== + +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + +yargs-parser@^20.2.2: + version "20.2.9" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@16.2.0, yargs@^16.1.1: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..9e54ae4 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,331 @@ +# @formatter:off + +########## +[versions] +########## + +## compilation ## +jvm = "11" +kotlin = "1.7.22" + +## libs ## +camel-kafkaConnectors = "0.11.0" +http4k = "4.25.16.2" +kafka = "3.3.1" # https://kafka.apache.org/downloads +kvision = "5.18.1" # https://github.com/rjaros/kvision/releases +log4j2 = "2.17.2" +okio = "3.2.0" # https://search.maven.org/artifact/com.squareup.okio/okio +qosLogback = "1.2.11" +scrimage = "4.0.32" # https://github.com/sksamuel/scrimage/releases +semver = "1.2.0" # https://github.com/swiftzer/semver/releases +slf4j = "1.7.36" + +kotlinx-serialization = "1.4.0" # https://github.com/Kotlin/kotlinx.serialization/releases +kxs-charleskornKaml = "0.44.0" +kxs-mamoeYamlkt = "0.12.0" +kxs-kxsTsGen = "0.2.1" + +kotlinJsWrappers = "1.0.0-pre.456" # https://search.maven.org/artifact/org.jetbrains.kotlin-wrappers/kotlin-wrappers-bom + +kotlinx-cli = "0.3.5" # https://github.com/Kotlin/kotlinx-cli/releases +kotlinx-coroutines = "1.6.4" # https://github.com/Kotlin/kotlinx.coroutines/releases +kotlinx-datetime = "0.4.0" # https://github.com/Kotlin/kotlinx-datetime/releases +kotlinx-html = "0.8.0" # https://github.com/Kotlin/kotlinx.html/releases +kotlinx-nodejs = "0.0.7" + +kSvgDsl = "v2.2.0" + +ktor = "2.1.3" # https://github.com/ktorio/ktor/releases + +hoplite = "2.7.0" # https://github.com/sksamuel/hoplite/releases + +simpleSyslogParser = "1.0.0" # https://search.maven.org/artifact/com.github.palindromicity/simple-syslog + +kotkaStreams = "22.08.06" + +marykRocksDb = "7.3.1-2" # https://search.maven.org/artifact/io.maryk.rocksdb/rocksdb-multiplatform + +klogging = "0.4.9" + +nimbusJoseJwt = "9.25.6" # https://search.maven.org/artifact/com.nimbusds/nimbus-jose-jwt + +## npm ## + +npm-luaTypes = "2.13.1" # https://www.npmjs.com/package/lua-types +npm-typescriptToLua = "1.11.1" # https://www.npmjs.com/package/typescript-to-lua +npm-typedFactorio = "1.11.0" # https://github.com/GlassBricks/typed-factorio/blob/main/Changelog.md https://www.npmjs.com/package/typed-factorio +npm-typescript = "4.9" # https://github.com/microsoft/TypeScript/releases + +npm-bootswatch = "5.2.2" # https://www.jsdelivr.com/package/npm/bootswatch + +## test ## +junit = "5.9.1" # https://github.com/junit-team/junit5/releases +kotest = "5.5.4" # https://github.com/kotest/kotest/releases +mockk = "1.13.3" # https://github.com/mockk/mockk/releases/ + + +## infra ## +factorio = "1.1.72" # https://www.factorio.com/download +confluent-kafkaConnect = "7.0.1" +grafana = "8.5.0" +prometheus = "v2.34.0" + + +## gradle plugins ## +gradleNodePlugin = "3.5.0" # https://github.com/node-gradle/gradle-node-plugin/releases + + +######### +[plugins] +######### + +kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlinJs = { id = "org.jetbrains.kotlin.js", version.ref = "kotlin" } +kotlinSerialization = { id = "org.jetbrains.kotlin.kotlin-serialization", version.ref = "kotlin" } + +loggingCapabilities = { id = "dev.jacomet.logging-capabilities", version = "0.10.0" } + + +########### +[libraries] +########### + +## kotlin ## +kotlin-bom = { group = "org.jetbrains.kotlin", name = "kotlin-bom", version.ref = "kotlin" } + +kotlin-embeddableCompiler = { module = "org.jetbrains.kotlin:kotlin-compiler-embeddable" } + +kotlinScripting-common = { group = "org.jetbrains.kotlin", name = "kotlin-scripting-common" } +kotlinScripting-jvm = { group = "org.jetbrains.kotlin", name = "kotlin-scripting-jvm" } +kotlinScripting-jvmHost = { group = "org.jetbrains.kotlin", name = "kotlin-scripting-jvm-host" } +kotlinScripting-dependencies = { group = "org.jetbrains.kotlin", name = "kotlin-scripting-dependencies" } +kotlinScripting-dependenciesMaven = { group = "org.jetbrains.kotlin", name = "kotlin-scripting-dependencies-maven" } + + +kotlinxSerialization-bom = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-bom", version.ref = "kotlinx-serialization" } +kotlinxSerialization-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core" } +kotlinxSerialization-cbor = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-cbor" } +kotlinxSerialization-hocon = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-hocon" } +kotlinxSerialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json" } +kotlinxSerialization-properties = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-properties" } +kotlinxSerialization-protobuf = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-protobuf" } +kotlinxSerialization-jsonOkio = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json-okio" } + + +kotlinxSerialization-charleskornKaml = { group = "com.charleskorn.kaml", name = "kaml", version.ref = "kxs-charleskornKaml" } +kotlinxSerialization-mamoeYamlkt = { group = "net.mamoe.yamlkt", name = "yamlkt", version.ref = "kxs-mamoeYamlkt" } +#kxs-kxsTsGen = { group = "dev.adamko.kxstsgen", name = "kxs-ts-gen-core", version.ref = "kxs-kxsTsGen" } +kotlinxSerialization-kxsTsGen = { group = "com.github.adamko-dev.kotlinx-serialization-typescript-generator", name = "kxs-ts-gen-core", version.ref = "kxs-kxsTsGen" } + + +kotlinx-coroutines-bom = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-bom", version.ref = "kotlinx-coroutines" } +kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core" } +kotlinx-coroutines-jdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk8" } + +kotlinx-html = { group = "org.jetbrains.kotlinx", name = "kotlinx-html", version.ref = "kotlinx-html" } +kotlinx-nodejs = { group = "org.jetbrains.kotlinx", name = "kotlinx-nodejs", version.ref = "kotlinx-nodejs" } +kotlinx-cli = { group = "org.jetbrains.kotlinx", name = "kotlinx-cli", version.ref = "kotlinx-cli" } +kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", version.ref = "kotlinx-datetime" } + + +kSvgDsl = { group = "com.github.nwillc", name = "ksvg", version.ref = "kSvgDsl" } + + +kotlin-jsWrappers-bom = { group = "org.jetbrains.kotlin-wrappers", name = "kotlin-wrappers-bom", version.ref = "kotlinJsWrappers" } + + +## http4k ## +http4k-bom = { group = "org.http4k", name = "http4k-bom", version.ref = "http4k" } +http4k-core = { group = "org.http4k", name = "http4k-core" } +http4k-contract = { group = "org.http4k", name = "http4k-contract" } +http4k-client-okhttp = { group = "org.http4k", name = "http4k-client-okhttp" } +http4k-client-ws = { group = "org.http4k", name = "http4k-client-websocket" } +http4k-server = { group = "org.http4k", name = "http4k-server-undertow" } +http4k-cloudnative = { group = "org.http4k", name = "http4k-cloudnative" } +#http4k-format-jackson-json = { group = "org.http4k", name = "http4k-format-jackson" } +#http4k-format-jackson-xml = { group = "org.http4k", name = "http4k-format-jackson-xml" } +#http4k-format-jackson-yaml = { group = "org.http4k", name = "http4k-format-jackson-yaml" } +http4k-format-kotlinx = { group = "org.http4k", name = "http4k-format-kotlinx-serialization" } +http4k-graphql = { group = "org.http4k", name = "http4k-graphql" } + + +## ktor ## +ktor-bom = { group = "io.ktor", name = "ktor-bom", version.ref = "ktor" } + +ktorSerialization-kotlinxJson = { group = "io.ktor", name = "ktor-serialization-kotlinx-json" } + +ktorClient-core = { group = "io.ktor", name = "ktor-client-core" } +ktorClient-auth = { group = "io.ktor", name = "ktor-client-auth" } +ktorClient-cio = { group = "io.ktor", name = "ktor-client-cio" } +ktorClient-contentNegotiation = { group = "io.ktor", name = "ktor-client-content-negotiation" } +ktorClient-encoding = { group = "io.ktor", name = "ktor-client-encoding" } +ktorClient-logging = { group = "io.ktor", name = "ktor-client-logging" } +ktorClient-resources = { group = "io.ktor", name = "ktor-client-resources" } +ktorClient-websockets = { group = "io.ktor", name = "ktor-client-websockets" } + +ktorClient-testMock = { group = "io.ktor", name = "ktor-client-mock" } + + +ktorServer-core = { group = "io.ktor", name = "ktor-server-core" } +ktorServer-auth = { group = "io.ktor", name = "ktor-server-auth" } +ktorServer-authJwt = { group = "io.ktor", name = "ktor-server-auth-jwt" } +ktorServer-autoHeadResponse = { group = "io.ktor", name = "ktor-server-auto-head-response" } +ktorServer-cachingHeaders = { group = "io.ktor", name = "ktor-server-caching-headers" } +ktorServer-callId = { group = "io.ktor", name = "ktor-server-call-id" } +ktorServer-callLogging = { group = "io.ktor", name = "ktor-server-call-logging" } +ktorServer-compression = { group = "io.ktor", name = "ktor-server-compression" } +ktorServer-conditionalHeaders = { group = "io.ktor", name = "ktor-server-conditional-headers" } +ktorServer-contentNegotiaion = { group = "io.ktor", name = "ktor-server-content-negotiation" } +ktorServer-cors = { group = "io.ktor", name = "ktor-server-cors" } +ktorServer-dataConversion = { group = "io.ktor", name = "ktor-server-data-conversion" } +ktorServer-defaultHeaders = { group = "io.ktor", name = "ktor-server-default-headers" } +ktorServer-forwardedHeader = { group = "io.ktor", name = "ktor-server-forwarded-header" } +ktorServer-hsts = { group = "io.ktor", name = "ktor-server-hsts" } +ktorServer-httpRedirect = { group = "io.ktor", name = "ktor-server-http-redirect" } +ktorServer-netty = { group = "io.ktor", name = "ktor-server-netty" } +ktorServer-cio = { group = "io.ktor", name = "ktor-server-cio" } +ktorServer-partialContent = { group = "io.ktor", name = "ktor-server-partial-content" } +ktorServer-resources = { group = "io.ktor", name = "ktor-server-resources" } +ktorServer-sessions = { group = "io.ktor", name = "ktor-server-sessions" } +ktorServer-statusPages = { group = "io.ktor", name = "ktor-server-status-pages" } +ktorServer-websockets = { group = "io.ktor", name = "ktor-server-websockets" } + +ktorServer-testHost = { group = "io.ktor", name = "ktor-server-test-host" } + + +ktorNetwork-core = { group = "io.ktor", name = "ktor-network" } +ktorNetwork-tls = { group = "io.ktor", name = "ktor-network-tls" } + + +### jackson ## +#jackson-bom = { group = " com.fasterxml.jackson.module", name = ":jackson-module-kotlin", version = "2.13.+" } +#jackson-kotlin = { group = " com.fasterxml.jackson.module", name = ":jackson-module-kotlin", version = "2.13.+" } + +## logging ## +slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" } +kotlin-logging = { group = "io.github.microutils", name = "kotlin-logging-jvm", version = "2.1.21" } +logback-core = { group = "ch.qos.logback", name = "logback-core", version.ref = "qosLogback" } +logback-classic = { group = "ch.qos.logback", name = "logback-classic", version.ref = "qosLogback" } +logback-encoder = { group = "net.logstash.logback", name = "logstash-logback-encoder", version = "6.6" } + + +klogging = { group = "io.klogging", name = "klogging-jvm", version.ref = "klogging" } + +## gcp ## +#gcp-bom = { group = "com.google.cloud", name = "libraries-bom", version = "23.1.0" } +#gcp-pubsub = { group = "com.google.cloud", name = "google-cloud-pubsub" } +#gcp-speech = { group = "com.google.cloud", name = "google-cloud-speech" } + + +## kafka ## +kafka-streams = { group = "org.apache.kafka", name = "kafka-streams", version.ref = "kafka" } +kafka-streamsTestUtils = { group = "org.apache.kafka", name = "kafka-streams-test-utils", version.ref = "kafka" } +# kafka helpers +#kotka = { group = "com.github.blueanvil", name = "kotka", version = "1.1.1" } + +kafka-kotkaStreams = { group = "dev.adamko.kotka", name = "kotka-streams", version.ref = "kotkaStreams" } + + +marykRocksDb = { group = "io.maryk.rocksdb", name = "rocksdb-multiplatform", version.ref = "marykRocksDb" } + +jsoup = { group = "org.jsoup", name = "jsoup", version = "1.14.3" } +skrapeit = { group = "it.skrape", name = "skrapeit", version = "1.2.0" } + +scrimage-core = { group = "com.sksamuel.scrimage", name = "scrimage-core", version.ref = "scrimage" } + +semver = { group = "net.swiftzer.semver", name = "semver", version.ref = "semver" } + +## okio ## +okio-bom = { group = "com.squareup.okio", name = "okio-bom", version.ref = "okio" } +okio-core = { group = "com.squareup.okio", name = "okio" } + + +hoplite-core = { group = "com.sksamuel.hoplite", name = "hoplite-core", version.ref = "hoplite" } +hoplite-datetime = { group = "com.sksamuel.hoplite", name = "hoplite-datetime", version.ref = "hoplite" } +hoplite-yaml = { group = "com.sksamuel.hoplite", name = "hoplite-yaml", version.ref = "hoplite" } + + +simpleSyslogParser = { group = "com.github.palindromicity", name = "simple-syslog", version.ref = "simpleSyslogParser" } + + +nimbusJoseJwt = { group = "com.nimbusds", name = "nimbus-jose-jwt", version.ref = "nimbusJoseJwt" } + +############# +### test ### +############# + +mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" } + +## junit ## +junit-bom = { group = "org.junit", name = "junit-bom", version.ref = "junit" } +junit-api = { group = "org.junit.jupiter", name = "junit-jupiter-api" } # version.ref = "junit" } +junit-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine" } # version.ref = "junit" } +junit-launcher = { group = "org.junit.platform", name = "junit-platform-launcher" } # version = "1.7.2" } + +## kotest ## +kotest-bom = { module = "io.kotest:kotest-bom", version.ref = "kotest" } +kotest-core = { module = "io.kotest:kotest-assertions-core" } +kotest-datatest = { module = "io.kotest:kotest-framework-datatest" } +kotest-json = { module = "io.kotest:kotest-assertions-json" } +kotest-prop = { module = "io.kotest:kotest-property" } +kotest-frameworkEngine = { module = "io.kotest:kotest-framework-engine" } +kotest-runnerJunit5 = { module = "io.kotest:kotest-runner-junit5" } + +kotestPlugin-embeddedCompiler = { group = "io.kotest", name = "kotest-framework-multiplatform-plugin-embeddable-compiler" } +kotestPlugin-multiplatform = { group = "io.kotest", name = "kotest-framework-multiplatform-plugin-gradle" } + +## http4k ## +http4k-test-chaos = { group = "org.http4k", name = "http4k-testing-chaos", version.ref = "http4k" } +http4k-test-approval = { group = "org.http4k", name = "http4k-testing-approval", version.ref = "http4k" } +http4k-test-kotest = { group = "org.http4k", name = "http4k-testing-kotest", version.ref = "http4k" } + +################ +### plugins ### +################ + +gradlePlugin-kvision = { module = "io.kvision:io.kvision.gradle.plugin", version.ref = "kvision" } + +######### +[bundles] +######### + +logging = [ + "slf4j-api", + "kotlin-logging", + "logback-core", + "logback-classic", + "logback-encoder", +] + +#kt-testing = [ +# "kotest-core", +# "kotest-datatest", +# "kotest-runner", +# "kotest-prop", +# "kotest-json", +# "mockk", +#] + +junit-runtime = [ + "junit-engine", + "junit-launcher", +] + +kotlinScripting-def = [ + "kotlinScripting-common", + "kotlinScripting-jvm", + "kotlinScripting-dependencies", + "kotlinScripting-dependenciesMaven", +] + +kotlinScripting-host = [ + "kotlinScripting-common", + "kotlinScripting-jvm", + "kotlinScripting-jvmHost", +] + +hoplite = [ + "hoplite-core", + "hoplite-yaml", + "hoplite-datetime", +] diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..943f0cb Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..f398c33 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..65dcd68 --- /dev/null +++ b/gradlew @@ -0,0 +1,244 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100755 index 0000000..93e3f59 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/kt52647.gradle.kts b/kt52647.gradle.kts new file mode 100644 index 0000000..2923b90 --- /dev/null +++ b/kt52647.gradle.kts @@ -0,0 +1,32 @@ + +// git update-index --skip-worktree kt52647.gradle.kts + +val projectsMustBeConfiguringBuster by tasks.registering { + val buildFile = layout.projectDirectory.file("kt52647.gradle.kts").asFile + doLast { + logger.warn("Applying 'Projects must be configuring' workaround - https://youtrack.jetbrains.com/issue/KT-52647") + + val newLines = buildFile.readText().lines().joinToString("\n") { line -> + if (line.startsWith("// projects must be configuring buster")) { + "// projects must be configuring buster ${System.currentTimeMillis()}" + } else { + line + } + } + + buildFile.writeText(newLines) + } +} + + +allprojects { + tasks + .matching { it.name != projectsMustBeConfiguringBuster.name } + .configureEach { + finalizedBy(projectsMustBeConfiguringBuster) + } +} + + +// projects must be configuring buster +// ^ this line will be edited by projectsMustBeConfiguringBuster diff --git a/modules/events-library/build.gradle.kts b/modules/events-library/build.gradle.kts new file mode 100644 index 0000000..96d4725 --- /dev/null +++ b/modules/events-library/build.gradle.kts @@ -0,0 +1,175 @@ +import kafkatorio.tasks.GenerateTypeScriptTask +import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmCompilation +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import dev.adamko.gradle.factorio.typescriptAttributes + + +plugins { + id("kafkatorio.conventions.lang.kotlin-multiplatform") + id("dev.adamko.factorio-mod-library") // only needed for 'attributes' - need to split up the plugin? + kotlin("plugin.serialization") + distribution +} + + +description = "shared data structures and utilities" + + +kotlin { + + js(IR) { + browser {} + // this is a library - don't set binaries.executable() + } + jvm { + val main by compilations.getting { + kotlinOptions { + jvmTarget = "11" + } + } + testRuns.configureEach { + executionTask.configure { + useJUnitPlatform() + } + } + } + + sourceSets { + + configureEach { + languageSettings.apply { + optIn("kotlin.ExperimentalStdlibApi") + optIn("kotlin.ExperimentalUnsignedTypes") + optIn("kotlin.RequiresOptIn") + optIn("kotlin.js.ExperimentalJsExport") + optIn("kotlin.time.ExperimentalTime") + optIn("kotlinx.coroutines.FlowPreview") + optIn("kotlinx.serialization.ExperimentalSerializationApi") + } + } + + val commonMain by getting { + dependencies { + implementation(dependencies.platform(projects.modules.versionsPlatform)) + + implementation(libs.kotlinxSerialization.core) + implementation(libs.kotlinxSerialization.json) + api(libs.kotlinxSerialization.kxsTsGen) + + implementation(libs.okio.core) + + implementation(libs.kotlinx.coroutines.core) + } + } + + val commonTest by getting { + dependencies { + implementation(dependencies.platform(projects.modules.versionsPlatform)) + + implementation(kotlin("test")) + + implementation(libs.kotest.core) + implementation(libs.kotest.datatest) + implementation(libs.kotest.frameworkEngine) + implementation(libs.kotest.json) + implementation(libs.kotest.prop) + } + } + + val jvmMain by getting { + dependencies { + implementation(dependencies.platform(projects.modules.versionsPlatform)) + + implementation(kotlin("reflect")) + } + } + + val jvmTest by getting { + dependencies { + implementation(dependencies.platform(projects.modules.versionsPlatform)) + + implementation(libs.kotest.runnerJunit5) + } + } + + val jsTest by getting { + dependencies { } + } + } +} + + +val kotlinJvmMainCompilation: NamedDomainObjectProvider = + kotlin.jvm().compilations.named(KotlinCompilation.MAIN_COMPILATION_NAME) + + +val jvmJar: TaskProvider = tasks.named(kotlin.jvm().artifactsTaskName) + +val kotlinMainRuntimeDependencies: Provider = + kotlinJvmMainCompilation.map { it.runtimeDependencyFiles } + +val kotlinMainCompileDependencies: Provider = + kotlinJvmMainCompilation.map { it.compileDependencyFiles } + +val kotlinMainCompileTask: Provider = + kotlinJvmMainCompilation.map { it.compileKotlinTask } + + +val generateTypeScript by tasks.registering(GenerateTypeScriptTask::class) { + dependsOn(jvmJar) +// dependsOn(kotlinMainCompileTask) + +// inputs.files(jvmJar.map { it.outputs.files }) +// inputs.files(kotlinMainCompileTask.map { it.javaSources }) + + classpath( + jvmJar, + kotlinMainRuntimeDependencies, +// kotlinMainCompileTask.map { it.libraries } +// kotlinMainDependencies, + ) + output.set(layout.buildDirectory.dir("generated/typescript")) + mainClass.set("dev.adamko.kafkatorio.schema.Kt2ts2Kt") + args(temporaryDir.canonicalPath) +} + + +val schemaTsDistributionName: Provider = providers.provider { + "${rootProject.name}-${project.name}" +} + + +val generateTypeScriptOutputFiles: Provider = + generateTypeScript.map { it.outputs.files.asFileTree } + + +//val schemaTs by distributions.registering { +// distributionBaseName.set(schemaTsDistributionName) +// contents { +// from(generateTypeScriptOutputFiles) +// } +//} + + +//val schemaTsZipTask: TaskProvider = tasks.named("${schemaTs.name}DistZip") +//val schemaTsZipTaskArchiveFile: Provider = schemaTsZipTask.flatMap { it.archiveFile } + + +val schemaTsZip by tasks.registering(Zip::class) { + group = "kt2ts" + + archiveBaseName.set("schema-ts") + from(generateTypeScriptOutputFiles) + destinationDirectory.set(layout.buildDirectory.dir("distributions/kt2ts")) +} +val schemaTsZipTaskArchiveFile: Provider = schemaTsZip.flatMap { it.archiveFile } + + +val typeScriptModelGenerated by configurations.creating { + asProvider() + typescriptAttributes(objects) + + outgoing.artifact(schemaTsZipTaskArchiveFile) +// outgoing.artifact(schemaTsZipTaskArchiveFile) +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/library/json.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/library/json.kt new file mode 100644 index 0000000..33bdffc --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/library/json.kt @@ -0,0 +1,79 @@ +package dev.adamko.kafkatorio.library + +import kotlin.jvm.JvmInline +import kotlinx.serialization.KSerializer +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationException +import kotlinx.serialization.builtins.ListSerializer +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.Decoder +import kotlinx.serialization.encoding.Encoder +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonArray +import kotlinx.serialization.json.JsonDecoder +import kotlinx.serialization.json.JsonObject +import kotlinx.serialization.modules.SerializersModule + + +val jsonMapperKafkatorio = Json { + prettyPrint = true + prettyPrintIndent = " " + + serializersModule = SerializersModule { +// contextual(List::class) { args -> FactorioListJsonSerializer(args[0]) } + } +} + + +/** @see LuaJsonListSerializer */ +@Serializable(with = LuaJsonListSerializer::class) +@JvmInline +value class LuaJsonList(private val list: List) : List by list + + +/** + * Factorio outputs **empty** lists `[]` as *empty* Json objects `{}`. + * + * When deserializing JSON, this serializer transforms any incoming empty objects to empty + * [array][JsonArray]s. + */ +class LuaJsonListSerializer( + elementSerializer: KSerializer +) : KSerializer> { + + private val listSerializer: KSerializer> = ListSerializer(elementSerializer) + + override val descriptor: SerialDescriptor = + SerialDescriptor("kafkatorio.LuaList", listSerializer.descriptor) + + override fun deserialize(decoder: Decoder): LuaJsonList = LuaJsonList( + when (decoder) { + is JsonDecoder -> deserializeJson(decoder) + else -> decoder.decodeSerializableValue(listSerializer) + } + ) + + private fun deserializeJson(decoder: JsonDecoder): List = + when (val element = decoder.decodeJsonElement()) { + is JsonObject -> when { + element.entries.isEmpty() -> emptyList() + else -> deserializeError( + "expected empty Json object, but contained ${element.entries.size} entries ${element.entries}" + ) + } + is JsonArray -> decoder.json.decodeFromJsonElement(listSerializer, element) + else -> deserializeError( + "expected empty Json object or a Json array, but was $element" + ) + } + + override fun serialize(encoder: Encoder, value: LuaJsonList) { + encoder.encodeSerializableValue(listSerializer, value) + } + + companion object { + private fun deserializeError(msg: String): Nothing = throw SerializationException( + "Error deserializing LuaList: $msg" + ) + } +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/library/kxsBinary.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/library/kxsBinary.kt new file mode 100644 index 0000000..2293971 --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/library/kxsBinary.kt @@ -0,0 +1,160 @@ +package dev.adamko.kafkatorio.library + +import kotlinx.serialization.BinaryFormat +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.SerializationStrategy +import kotlinx.serialization.builtins.ByteArraySerializer +import kotlinx.serialization.descriptors.SerialDescriptor +import kotlinx.serialization.encoding.AbstractDecoder +import kotlinx.serialization.encoding.AbstractEncoder +import kotlinx.serialization.encoding.CompositeDecoder +import kotlinx.serialization.encoding.CompositeEncoder +import kotlinx.serialization.modules.EmptySerializersModule +import kotlinx.serialization.modules.SerializersModule +import okio.Buffer +import okio.BufferedSink +import okio.BufferedSource + + +val kxsBinary: KxsBinary = KxsBinary() + +/** [`https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/formats.md#efficient-binary-format`](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/formats.md#efficient-binary-format) */ +class KxsBinary( + override val serializersModule: SerializersModule = EmptySerializersModule() +) : BinaryFormat { + + override fun encodeToByteArray(serializer: SerializationStrategy, value: T): ByteArray { + val output = Buffer() + val encoder = KxsDataOutputEncoder(output, serializersModule) + encoder.encodeSerializableValue(serializer, value) + return output.readByteArray() + } + + override fun decodeFromByteArray( + deserializer: DeserializationStrategy, + bytes: ByteArray + ): T { + val input = Buffer().write(bytes) + val decoder = KxsDataInputDecoder(input, serializersModule) + return decoder.decodeSerializableValue(deserializer) + } +} + +private val byteArraySerializer = ByteArraySerializer() + +class KxsDataOutputEncoder( + private val output: BufferedSink, + override val serializersModule: SerializersModule = EmptySerializersModule(), +) : AbstractEncoder() { + + private operator fun BufferedSink.invoke(action: BufferedSink.() -> Unit): Unit = action() + + override fun encodeBoolean(value: Boolean) = output { writeByte(if (value) 1 else 0) } + override fun encodeByte(value: Byte) = output { writeByte(value.toInt()) } + override fun encodeChar(value: Char) = output { writeUtf8CodePoint(value.code) } + override fun encodeDouble(value: Double) = output { writeLong(value.toRawBits()) } + override fun encodeEnum(enumDescriptor: SerialDescriptor, index: Int) = output { writeInt(index) } + override fun encodeFloat(value: Float) = output { writeInt(value.toRawBits()) } + override fun encodeInt(value: Int) = output { writeInt(value) } + override fun encodeLong(value: Long) = output { writeLong(value) } + override fun encodeShort(value: Short) = output { writeShort(value.toInt()) } + override fun encodeString(value: String) = output { + encodeCompactSize(value.length) + writeUtf8(value) + } + + override fun beginCollection( + descriptor: SerialDescriptor, + collectionSize: Int + ): CompositeEncoder { + encodeCompactSize(collectionSize) + return this + } + + override fun encodeNull() = encodeBoolean(false) + override fun encodeNotNullMark() = encodeBoolean(true) + + override fun encodeSerializableValue(serializer: SerializationStrategy, value: T) { + when (serializer.descriptor) { + byteArraySerializer.descriptor -> encodeByteArray(value as ByteArray) + else -> super.encodeSerializableValue(serializer, value) + } + } + + private fun encodeByteArray(bytes: ByteArray) { + encodeCompactSize(bytes.size) + output.write(bytes) + } + + private fun encodeCompactSize(value: Int) { + if (value < 0xff) { + output.writeByte(value) + } else { + output.writeByte(0xff) + output.writeInt(value) + } + } +} + + +class KxsDataInputDecoder( + private val input: BufferedSource, + override val serializersModule: SerializersModule = EmptySerializersModule(), + private var elementsCount: Int = 0, +) : AbstractDecoder() { + + private var elementIndex = 0 + + override fun decodeBoolean(): Boolean = input.readByte().toInt() != 0 + override fun decodeByte(): Byte = input.readByte() + override fun decodeChar(): Char = input.readUtf8CodePoint().toChar() + override fun decodeDouble(): Double = Double.fromBits(input.readLong()) + override fun decodeEnum(enumDescriptor: SerialDescriptor): Int = input.readInt() + override fun decodeFloat(): Float = Float.fromBits(input.readInt()) + override fun decodeInt(): Int = input.readInt() + override fun decodeLong(): Long = input.readLong() + override fun decodeShort(): Short = input.readShort() + override fun decodeString(): String { + val size = decodeCompactSize() + return input.readUtf8(size.toLong()) + } + + override fun decodeElementIndex(descriptor: SerialDescriptor): Int { + if (elementIndex == elementsCount) return CompositeDecoder.DECODE_DONE + return elementIndex++ + } + + override fun beginStructure(descriptor: SerialDescriptor): CompositeDecoder = + KxsDataInputDecoder(input, serializersModule, descriptor.elementsCount) + + override fun decodeSequentially(): Boolean = true + + override fun decodeCollectionSize(descriptor: SerialDescriptor): Int = + decodeCompactSize().also { elementsCount = it } + + override fun decodeNotNullMark(): Boolean = decodeBoolean() + + override fun decodeSerializableValue( + deserializer: DeserializationStrategy, + previousValue: T? + ): T { + @Suppress("UNCHECKED_CAST") + return when (deserializer.descriptor) { + byteArraySerializer.descriptor -> decodeByteArray() as T + else -> super.decodeSerializableValue(deserializer, previousValue) + } + } + + private fun decodeByteArray(): ByteArray { + val bytes = ByteArray(decodeCompactSize()) + input.readFully(bytes) + return bytes + } + + private fun decodeCompactSize(): Int { + val byte = input.readByte().toInt() and 0xff + if (byte < 0xff) return byte + return input.readInt() + } + +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/library/positionOperations.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/library/positionOperations.kt new file mode 100644 index 0000000..2467172 --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/library/positionOperations.kt @@ -0,0 +1,103 @@ +package dev.adamko.kafkatorio.library + +import dev.adamko.kafkatorio.schema.common.ChunkSize +import dev.adamko.kafkatorio.schema.common.MapChunkPosition +import dev.adamko.kafkatorio.schema.common.MapEntityPosition +import dev.adamko.kafkatorio.schema.common.MapTilePosition +import kotlin.math.floor + + +operator fun MapTilePosition.times(factor: Int): MapTilePosition = + MapTilePosition(x * factor, y * factor) + + +operator fun MapTilePosition.div(divisor: Int): MapTilePosition = + MapTilePosition(x / divisor, y / divisor) + + +operator fun MapTilePosition.plus(addend: Int): MapTilePosition = + MapTilePosition(x + addend, y + addend) + + +operator fun MapTilePosition.plus(addend: MapTilePosition): MapTilePosition = + MapTilePosition(x + addend.x, y + addend.y) + + +operator fun MapTilePosition.minus(subtrahend: MapTilePosition): MapTilePosition = + MapTilePosition(x - subtrahend.x, y - subtrahend.y) + + +/** Get the [MapChunkPosition] of the tile */ +fun MapTilePosition.toMapChunkPosition(chunkSize: ChunkSize): MapChunkPosition = + MapChunkPosition( + x = floor(x.toDouble() / chunkSize.lengthInTiles.toDouble()).toInt(), + y = floor(y.toDouble() / chunkSize.lengthInTiles.toDouble()).toInt(), + chunkSize = chunkSize, + ) + + +/** Get the [MapTilePosition] of the entity */ +fun MapEntityPosition.toMapTilePosition(): MapTilePosition = + MapTilePosition( + x = floor(x).toInt(), + y = floor(y).toInt(), + ) + + +/** Get the [MapChunkPosition] of the entity */ +fun MapEntityPosition.toMapChunkPosition(chunkSize: ChunkSize): MapChunkPosition = + MapChunkPosition( + x = floor(x / chunkSize.lengthInTiles.toDouble()).toInt(), + y = floor(y / chunkSize.lengthInTiles.toDouble()).toInt(), + chunkSize = chunkSize, + ) + + +fun MapChunkPosition.resize(chunkSize: ChunkSize): MapChunkPosition = + leftTopTile().toMapChunkPosition(chunkSize) + + +operator fun MapChunkPosition.times(factor: Int): MapChunkPosition = + copy(x = x * factor, y = y * factor) + + +operator fun MapChunkPosition.plus(addend: Int): MapChunkPosition = + copy(x = x + addend, y = y + addend) + + +operator fun MapChunkPosition.minus(subtrahend: Int): MapChunkPosition = + copy(x = x - subtrahend, y = y - subtrahend) + + +fun MapChunkPosition.leftTopTile(): MapTilePosition = + MapTilePosition( + x * chunkSize.lengthInTiles, + y * chunkSize.lengthInTiles, + ) + + +fun MapChunkPosition.rightBottomTile(): MapTilePosition = + leftTopTile() + (chunkSize.lengthInTiles - 1) + + +/** Iterate over all possible [MapTilePosition]s in the chunk. */ +fun MapChunkPosition.iterateTiles(): Iterator { + val leftTop = leftTopTile() + val rightBottom = rightBottomTile() + + return iterator { + (leftTop.x..rightBottom.x).forEach { x -> + (leftTop.y..rightBottom.y).forEach { y -> + yield(MapTilePosition(x, y)) + } + } + } +} + + +//val MapChunkPosition.rightBottomTile: MapTilePosition +// get() = leftTopTile + (MAP_CHUNK_SIZE - 1) + +// +//val MapChunkPosition.boundingBox: MapBoundingBox +// get() = MapBoundingBox(leftTopTile, rightBottomTile) diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/colours.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/colours.kt new file mode 100644 index 0000000..c7c7f22 --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/colours.kt @@ -0,0 +1,143 @@ +package dev.adamko.kafkatorio.schema.common + +import dev.adamko.kxstsgen.core.experiments.TupleSerializer +import kotlin.math.roundToInt +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +/** + * Red, green, blue and alpha values, all in range `[0, 1]` or all in range `[0, 255]` if any + * value is > 1. + * + * All values here are optional. Colour channels default to `0`, the alpha channel defaults to `1`. + */ +@Serializable(with = Colour.Serializer::class) +@SerialName("kafkatorio.common.Colour") +data class Colour( + val red: Float = 0f, + val green: Float = 0f, + val blue: Float = 0f, + val alpha: Float = 1f, +) { + object Serializer : TupleSerializer( + "Colour", + { + element(Colour::red) + element(Colour::green) + element(Colour::blue) + element(Colour::alpha) + } + ) { + override fun tupleConstructor(elements: Iterator<*>): Colour { + return Colour( + elements.next() as Float, + elements.next() as Float, + elements.next() as Float, + elements.next() as Float, + ) + } + } +} + + +/** Size-efficient version of [Colour] (`4*4` bytes vs `4*1` bytes) */ +@Serializable +@SerialName("kafkatorio.common.ColourHex") +data class ColourHex( + val red: UByte = UByte.MIN_VALUE, + val green: UByte = UByte.MIN_VALUE, + val blue: UByte = UByte.MIN_VALUE, + val alpha: UByte = UByte.MAX_VALUE, +) { + companion object { + val TRANSPARENT = ColourHex(0u, 0u, 0u, 0u) + val WHITE = ColourHex(UByte.MAX_VALUE, UByte.MAX_VALUE, UByte.MAX_VALUE, UByte.MAX_VALUE) + } +} + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + +/** True if any value is greater than 1, so the values are hexadecimal. */ +fun Colour.isHexadecimal(): Boolean { + return red > 1f + || green > 1f + || blue > 1f + || alpha > 1f +} + +/** True if all values are between `[0..1]`. */ +fun Colour.isPercentage(): Boolean = !isHexadecimal() + + +fun Colour.toHexString(includeAlpha: Boolean = false): String { + + val hexConverter: Float.() -> String = when { + isHexadecimal() -> Float::hexadecimalToString + else -> Float::percentageToHexadecimalString + } + + val length = if (includeAlpha) 9 else 7 + return buildString(length) { + append('#') + append(red.hexConverter()) + append(green.hexConverter()) + append(blue.hexConverter()) + if (includeAlpha) { + append(alpha.hexConverter()) + } + } +} + +fun Float.hexadecimalToString(): String = + roundToInt().toString(16).padStart(2, ' ') + +fun Float.percentageToHexadecimalString(): String = + times(255).roundToInt().toString(16).padStart(2, ' ') + + +private val ubyteMaxFloat = UByte.MAX_VALUE.toFloat() +private val ubyteMinFloat = UByte.MIN_VALUE.toFloat() +private val ubyteRangeFloat = ubyteMinFloat..ubyteMaxFloat + + +private fun Float.toColourHex() = (this * ubyteMaxFloat) + .coerceIn(ubyteRangeFloat) + .toUInt() + .toUByte() + + +private fun Float.coerceToColourHex() = coerceIn(ubyteRangeFloat) + .toUInt() + .toUByte() + + +fun Colour.toHex(): ColourHex { + + val converter: Float.() -> UByte = when { + isPercentage() -> Float::toColourHex + else -> Float::coerceToColourHex + } + + return ColourHex( + red.converter(), + green.converter(), + blue.converter(), + alpha.converter(), + ) +} + + +private fun UByte.toPercentileFloat() = (this.toFloat() / ubyteMaxFloat).coerceIn(0f..1f) + + +fun ColourHex.toPercentile(): Colour { + return Colour( + red.toPercentileFloat(), + green.toPercentileFloat(), + blue.toPercentileFloat(), + alpha.toPercentileFloat(), + ) +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/entities.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/entities.kt new file mode 100644 index 0000000..d203ad8 --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/entities.kt @@ -0,0 +1,276 @@ +package dev.adamko.kafkatorio.schema.common + +import kotlin.jvm.JvmInline +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +// TODO change all booleans to be optional, and default to 'false' (also in events-mod) + + +@Serializable +@SerialName("kafkatorio.entity.FactorioEntityData") +sealed interface FactorioEntityData { + + val protoId: PrototypeId + + val position: MapEntityPosition + + /** Non-specific entity data */ + @Serializable + @SerialName("kafkatorio.entity.FactorioEntityDataStandard") + data class Standard( + override val protoId: PrototypeId, + override val position: MapEntityPosition, + + val graphicsVariation: UByte? = null, + val health: Float? = null, + val isActive: Boolean = false, + val isRotatable: Boolean = false, + val lastUser: UInt? = null, + val status: Status? = null, + val unitNumber: UnitNumber? = null, + ) : FactorioEntityData + + + @Serializable + @SerialName("kafkatorio.entity.FactorioEntityDataResource") + data class Resource( + override val protoId: PrototypeId, + + override val position: MapEntityPosition, + val amount: UInt, + /** Count of initial resource units contained. `null` if resource is not infinite. */ + val initialAmount: UInt? = null, + ) : FactorioEntityData + + + /** + * [`https://lua-api.factorio.com/latest/defines.html#defines.entity_status`](https://lua-api.factorio.com/latest/defines.html#defines.entity_status) + */ + @Suppress("unused") // not directly used at the moment - maybe later + @Serializable + @SerialName("kafkatorio.entity.FactorioEntityData.FactorioEntityStatus") + enum class Status { + WORKING, + NORMAL, + NO_POWER, + LOW_POWER, + NO_FUEL, + DISABLED_BY_CONTROL_BEHAVIOR, + OPENED_BY_CIRCUIT_NETWORK, + CLOSED_BY_CIRCUIT_NETWORK, + DISABLED_BY_SCRIPT, + MARKED_FOR_DECONSTRUCTION, + + /** Used by generators and solar panels. */ + NOT_PLUGGED_IN_ELECTRIC_NETWORK, + + /** Used by power switches. */ + NETWORKS_CONNECTED, + + /** Used by power switches. */ + NETWORKS_DISCONNECTED, + + /** Used by accumulators. */ + CHARGING, + /** Used by accumulators. */ + DISCHARGING, + /** Used by accumulators. */ + FULLY_CHARGED, + + /** Used by logistic containers. */ + OUT_OF_LOGISTIC_NETWORK, + + /** Used by assembling machines. */ + NO_RECIPE, + + /** Used by furnaces. */ + NO_INGREDIENTS, + + /** USED BY BOILERS, fluid turrets and fluid energy sources: Boiler has no fluid to work with. */ + NO_INPUT_FLUID, + + /** Used by labs. */ + NO_RESEARCH_IN_PROGRESS, + + /** Used by mining drills. */ + NO_MINABLE_RESOURCES, + + /** Used by boilers and fluid turrets: Boiler still has some fluid but is about to run out. */ + LOW_INPUT_FLUID, + + /** Used by crafting machines. */ + FLUID_INGREDIENT_SHORTAGE, + + /** + * Used by crafting machines, boilers, burner energy sources and reactors: Reactor/burner has + * full burnt result inventory, boiler has full output fluid box. + */ + FULL_OUTPUT, + + /** Used by crafting machines. */ + ITEM_INGREDIENT_SHORTAGE, + + /** Used by mining drills when the mining fluid is missing. */ + MISSING_REQUIRED_FLUID, + + /** Used by labs. */ + MISSING_SCIENCE_PACKS, + + /** Used by inserters. */ + WAITING_FOR_SOURCE_ITEMS, + + /** Used by inserters and mining drills. */ + WAITING_FOR_SPACE_IN_DESTINATION, + + /** Used by the rocket silo. */ + PREPARING_ROCKET_FOR_LAUNCH, + /** Used by the rocket silo. */ + WAITING_TO_LAUNCH_ROCKET, + /** Used by the rocket silo. */ + LAUNCHING_ROCKET, + + /** Used by beacons. */ + NO_MODULES_TO_TRANSMIT, + + /** Used by roboports. */ + RECHARGING_AFTER_POWER_OUTAGE, + + /** Used by inserters targeting entity ghosts. */ + WAITING_FOR_TARGET_TO_BE_BUILT, + /** Used by inserters targeting rails. */ + WAITING_FOR_TRAIN, + + /** Used by ammo turrets. */ + NO_AMMO, + + /** Used by heat energy sources. */ + LOW_TEMPERATURE, + + /** Used by constant combinators: Combinator is turned off via switch in GUI. */ + DISABLED, + + /** Used by lamps. */ + TURNED_OFF_DURING_DAYTIME, + + /** Used by rail signals. */ + NOT_CONNECTED_TO_RAIL, + /** Used by rail signals. */ + CANT_DIVIDE_SEGMENTS, + } + +} + + +sealed interface FactorioEntityUpdateDictionary + : Iterable> { + + val entitiesXY: Map> + + operator fun get(position: MapEntityPosition): T? = + entitiesXY[position.x.toString()]?.get(position.y.toString()) + + override fun iterator(): Iterator> = + iterator { + val invalid = mutableListOf() + entitiesXY.forEach { (xString, column) -> + val x = xString.toDoubleOrNull() + column.forEach { (yString, entity) -> + val y = yString.toDoubleOrNull() + if (x == null || y == null) { + invalid += "$xString/$yString" + } else { + yield(MapEntityPosition(x, y) to entity) + } + } + } + + if (invalid.isNotEmpty()) { + println("WARNING FactorioEntityUpdateDictionary contained invalid x/y coords: ${invalid.joinToString()}") + } + } + + @Serializable + @SerialName("kafkatorio.entity.FactorioEntityUpdateResourceAmountDictionary") + @JvmInline + value class ResourceAmounts( + override val entitiesXY: Map> = emptyMap() + ) : FactorioEntityUpdateDictionary + + @Serializable + @SerialName("kafkatorio.entity.FactorioEntityUpdateEntityDictionary") + @JvmInline + value class Entity( + override val entitiesXY: Map> + ) : FactorioEntityUpdateDictionary + +} + + +sealed interface FactorioEntityUpdateElement { + + @Serializable + @SerialName("kafkatorio.entity.FactorioEntityUpdateElementStandard") + data class Standard( + val status: FactorioEntityData.Status? = null, + + val unitNumber: UnitNumber? = null, + + val graphicsVariation: UByte? = null, + val health: Float? = null, + val isActive: Boolean = false, + val isRotatable: Boolean = false, + val lastUser: UInt? = null, + ) : FactorioEntityUpdateElement + +} + + +/* +AssemblingMachine +Beam +Car +Character +CharacterCorpse +CraftingMachine +ElectricEnergyInterface +ElectricPole +EntityGhost +EntityWithHealth +EntityWithOwner +FlyingText +Furnace +Gate +Generator +Ghost +HeatInterface +HighlightBox +InfinityContainer +InfinityPipe +Inserter +ItemEntity +LandMine +LinkedBelt +Loader +Market +MiningDrill +ProgrammableSpeaker +Pump +Radar +Rail +RailChainSignal +RailSignal +Reactor +ResourceEntity +RocketSilo +SmokeWithTrigger +SpiderVehicle +Splitter +TrainStop +TransportBeltConnectable +TransportBeltToGround +Turret +Unit +Vehicle + */ diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/factorioIds.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/factorioIds.kt new file mode 100644 index 0000000..65b8f0e --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/factorioIds.kt @@ -0,0 +1,114 @@ +package dev.adamko.kafkatorio.schema.common + +import kotlin.jvm.JvmInline +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +@Serializable +@SerialName("kafkatorio.id.Tick") +@JvmInline +value class Tick(val value: UInt) + +val UInt.tick + get() = Tick(this) + +/** + * Unique ID associated with this surface + * + * See [`LuaSurface.index`](https://lua-api.factorio.com/latest/LuaSurface.html#LuaSurface.index) + */ +@Serializable +@SerialName("kafkatorio.id.SurfaceIndex") +@JvmInline +value class SurfaceIndex(private val id: UInt) { + override fun toString(): String = "$id" +} + + +@Serializable +@SerialName("kafkatorio.id.ForceIndex") +@JvmInline +value class ForceIndex(private val id: UInt) { + override fun toString(): String = "$id" +} + + +/** The player's index in `LuaGameScript::players` */ +@Serializable +@SerialName("kafkatorio.id.PlayerIndex") +@JvmInline +value class PlayerIndex(private val id: UInt) { + override fun toString(): String = "$id" +} + + +/** > This is universally unique for every entity that has one, for the lifetime of a whole game. */ +@Serializable +@SerialName("kafkatorio.id.UnitNumber") +@JvmInline +value class UnitNumber(private val id: UInt) { + override fun toString(): String = "$id" +} + + +@Serializable +@SerialName("kafkatorio.id.EventName") +@JvmInline +value class EventName(private val name: String) { + override fun toString(): String = name +} + + +interface EntityIdentifiers { + val unitNumber: UnitNumber? + /** The 'prototype type' and 'prototype name' of the entity. */ + val protoId: PrototypeId +} + + +// instant of EntityIdentifiers, because kxs needs a concrete instance +@Serializable +@SerialName("kafkatorio.id.EntityIdentifiersData") +data class EntityIdentifiersData( + override val unitNumber: UnitNumber? = null, + override val protoId: PrototypeId, +) : EntityIdentifiers + + +/** Friendly identifier, used in URLs. Should be human-readable. */ +@Serializable +@SerialName("kafkatorio.id.FactorioServerId") +@JvmInline +value class FactorioServerId(val id: String) : CharSequence by id { + + init { + require(id.isNotBlank()) { "require FactorioServerId is not blank: '$id'" } + require(id.matches(validIdRegex)) { "require FactorioServerId matches $validIdRegex: '$id'" } + } + + override fun toString(): String = id + + companion object { + val validIdRegex = Regex("""^[a-zA-Z0-9\-_]+""" + "\$") + } +} + + +/** Short identifier, used in tokens. Might not be human-readable. */ +@Serializable +@SerialName("kafkatorio.id.FactorioServerToken") +@JvmInline +value class FactorioServerToken(private val id: String) : CharSequence by id { + + init { + require(id.isNotBlank()) { "require FactorioServerToken is not blank: '$id'" } + require(id.matches(FactorioServerId.validIdRegex)) { "require FactorioServerToken matches ${validIdRegex}: '$id'" } + } + + override fun toString(): String = id + + companion object { + val validIdRegex = Regex("^[a-zA-Z0-9]+\$") + } +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/factorioPrototypes.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/factorioPrototypes.kt new file mode 100644 index 0000000..6217dec --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/factorioPrototypes.kt @@ -0,0 +1,82 @@ +package dev.adamko.kafkatorio.schema.common + +import dev.adamko.kafkatorio.library.LuaJsonList +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +@Serializable +@SerialName("kafkatorio.prototype.FactorioPrototype") +sealed interface FactorioPrototype { + + val protoId: PrototypeId + + + @SerialName("kafkatorio.prototype.MapTile") + @Serializable + data class MapTile( + override val protoId: PrototypeId, + + val mapColour: Colour, + + val layer: UInt, +// @Contextual + val collisionMasks: LuaJsonList, + val order: String, + /** Can the tile be mined for resources? */ + val canBeMined: Boolean = false, + ) : FactorioPrototype + + + /** + * @param[colour] The colour of the prototype, or `null` if the prototype doesn't have colour. + * @param[mapColour] The map colour used when charting this entity if a + * [friendly][mapColourFriend] or [enemy][mapColourEnemy] colour isn't defined or `null`. + * @param[mapColourFriend] The friendly map colour used when charting this entity. + * @param[mapColourEnemy] The enemy map colour used when charting this entity. + * @param[tileWidth] Tiling size. If odd, center is the center of the tiles. If even, it's on the tile border. + * @param[tileHeight] Tiling size. If odd, center is the center of the tiles. If even, it's on the tile border. + */ + @SerialName("kafkatorio.prototype.Entity") + @Serializable + data class Entity( + override val protoId: PrototypeId, + + val group: ItemGroup, + val subgroup: ItemGroup, + + val colour: Colour? = null, + val mapColour: Colour? = null, + val mapColourFriend: Colour? = null, + val mapColourEnemy: Colour? = null, + + val maxHealth: Float, + val isBuilding: Boolean = false, + val isEntityWithOwner: Boolean = false, + val isMilitaryTarget: Boolean = false, + val miningProperties: MiningProperties? = null, + + val collisionBox: MapBoundingBox? = null, + + val tileWidth: Int? = null, + val tileHeight: Int? = null, + ) : FactorioPrototype { + + @Serializable + @SerialName("kafkatorio.prototype.EntityMiningProperties") + data class MiningProperties( + val canBeMined: Boolean = false, +// @Contextual + val products: LuaJsonList?, + ) + + @Serializable + @SerialName("kafkatorio.prototype.EntityItemGroup") + data class ItemGroup( + val name: String? = null, + val type: String? = null, + val parentName: String? = null, + ) + + } +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/mapTile.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/mapTile.kt new file mode 100644 index 0000000..964227e --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/mapTile.kt @@ -0,0 +1,123 @@ +package dev.adamko.kafkatorio.schema.common + +import dev.adamko.kafkatorio.schema.common.MapTileDictionary.PrototypeKey +import kotlin.jvm.JvmInline +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +const val MAP_CHUNK_SIZE = 32 + + +@Serializable +data class MapTile( + val x: Int, + val y: Int, + val protoId: PrototypeId, +) + + +/** + * 2D map of x/y tile positions and prototype-name, optimised for JSON size. + * + * [protos] is a one-to-one map between a prototype[PrototypeId] and [PrototypeKey]. + * + * [PrototypeKey] is an arbitrary integer value, which maps to one [PrototypeId] only for a + * specific instance of [MapTileDictionary]. + * + * @param[tilesXY] Map an X/Y coordinate to a [PrototypeKey]. + */ +@Serializable +@SerialName("kafkatorio.packet.keyed.MapTileDictionary") +data class MapTileDictionary( + val tilesXY: Map>, + val protos: Map, +) { + + private val protosIndexToId: Map by lazy { + protos.entries.associate { (name, key) -> key to name } + } + + fun toMapTileList(): List = buildList { + tilesXY.forEach { (xString, row) -> + row.forEach { (yString, protoIndex) -> + val x = xString.toIntOrNull() + val y = yString.toIntOrNull() + val protoName = protosIndexToId[protoIndex] + if (x != null && y != null && protoName != null) { + add(MapTile(x, y, protoName)) + } else if (protoName == null) { + println("warning: no prototype name found for index:$protoIndex. $protosIndexToId") + } + } + } + } + + /** An arbitrary ID for a prototype in [MapTileDictionary.protos]. */ + @Serializable + @JvmInline + value class PrototypeKey(private val index: Int) : Comparable by index + +// companion object { +// fun MapTileDictionary?.isNullOrEmpty(): Boolean { +// return this == null || (tilesXY.isEmpty() && tilesXY.all { it.value.isEmpty() }) +// } +// } +} + + +@Serializable +data class ServerMapChunkId( + val serverId: FactorioServerId, + val layer: ServerMapTileLayer, + val chunkPosition: MapChunkPosition, + val surfaceIndex: SurfaceIndex, +) { + val chunkSize: ChunkSize get() = chunkPosition.chunkSize +} + + +@Serializable +enum class ServerMapTileLayer(val dir: String) { + @SerialName("terrain") + TERRAIN("terrain"), + @SerialName("resource") + RESOURCE("resource"), + @SerialName("building") + BUILDING("building"), +} + + +/** `${serverDataDir}/servers/{serverId}/map/${layer}/s{surfaceIndex}/z{zoomLevel}/x{chunkX}/y{chunkY}.png` */ +@Serializable +@JvmInline +value class ServerMapTilePngFilename(val value: String) { + + constructor(id: ServerMapChunkId) : this( + serverId = id.serverId, + layer = id.layer, + surfaceIndex = id.surfaceIndex, + zoomLevel = id.chunkSize.zoomLevel, + chunkX = id.chunkPosition.x, + chunkY = id.chunkPosition.y, + ) + + constructor( + serverId: FactorioServerId, + layer: ServerMapTileLayer, + surfaceIndex: SurfaceIndex, + zoomLevel: Int, + chunkX: Int, + chunkY: Int, + ) : this( + "servers/${serverId.id}" + + "/map" + + "/layers/${layer.dir}" + + "/s${surfaceIndex}" + + "/z${zoomLevel}" + + "/x${chunkX}" + + "/y${chunkY}" + + ".png" + ) + +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/positions.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/positions.kt new file mode 100644 index 0000000..54f6d2d --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/positions.kt @@ -0,0 +1,224 @@ +package dev.adamko.kafkatorio.schema.common + +import dev.adamko.kafkatorio.library.leftTopTile +import dev.adamko.kafkatorio.library.rightBottomTile +import dev.adamko.kxstsgen.core.experiments.TupleSerializer +import kotlin.math.abs +import kotlin.math.ceil +import kotlin.math.pow +import kotlin.math.roundToInt +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +/** + * The position of something that exists in-game (not conceptually, like a + * [chunk][MapChunkPosition]) + */ +sealed interface MapPosition : Comparable { + val x: Number + val y: Number +} + + +/** + * Coordinates of an [entity][FactorioEntityData.Standard] on a map. + * + * Positive y points south, positive x points east. + * + * A [MapEntityPosition] can be translated to a [MapChunkPosition] by dividing the `x`/`y` values + * by [32][MAP_CHUNK_SIZE]. + */ +@Serializable(with = MapEntityPosition.Companion.Serializer::class) +data class MapEntityPosition( + override val x: Double, + override val y: Double, +) : MapPosition { + + + override fun compareTo(other: MapPosition): Int = + when (val resultX = x.compareTo(other.x.toDouble())) { + 0 -> y.compareTo(other.y.toDouble()) + else -> resultX + } + + + companion object { + object Serializer : TupleSerializer( + "MapEntityPosition", + { + element(MapEntityPosition::x) + element(MapEntityPosition::y) + } + ) { + override fun tupleConstructor(elements: Iterator<*>): MapEntityPosition { + return MapEntityPosition( + elements.next() as Double, + elements.next() as Double, + ) + } + } + } +} + + +/** + * Coordinates of a tile on a surface, where each `x`/`y` coordinate represents a different + * [MapTile]. + * + * Positive y points south, positive x points east. + * + * It rounds any `x`/`y` down to whole numbers. + */ +@Serializable(with = MapTilePosition.Companion.Serializer::class) +data class MapTilePosition( + override val x: Int, + override val y: Int, +) : MapPosition { + + + override fun compareTo(other: MapPosition): Int = + when (val resultX = x.compareTo(other.x.toInt())) { + 0 -> y.compareTo(other.y.toInt()) + else -> resultX + } + + + companion object { + object Serializer : TupleSerializer( + "MapTilePosition", + { + element(MapTilePosition::x) + element(MapTilePosition::y) + } + ) { + override fun tupleConstructor(elements: Iterator<*>): MapTilePosition { + val x = requireNotNull(elements.next() as? Int) + val y = requireNotNull(elements.next() as? Int) + return MapTilePosition(x, y) + } + } + } + +} + + +/** + * Coordinates of a chunk on a surface, where each `x`/`y` coordinate represents a different + * chunk. + * + * Positive y points south, positive x points east. + * + * A [MapChunkPosition] can be translated to a [MapEntityPosition] by multiplying the `x`/`y` + * values by [32][MAP_CHUNK_SIZE]. + */ +@Serializable(with = MapChunkPosition.Companion.Serializer::class) +data class MapChunkPosition( + val x: Int, + val y: Int, + // Don't set a default for ChunkSize. It could default to 32, but it's clearer to make it explicit + // and avoid accidentally not setting it. Also, a default doesn't save much in serialization size. + val chunkSize: ChunkSize, +) { + + val bounds: MapChunkPositionBounds by lazy { + MapChunkPositionBounds(this) + } + + operator fun contains(tilePosition: MapTilePosition): Boolean = tilePosition in bounds + operator fun contains(entityPosition: MapEntityPosition): Boolean = entityPosition in bounds + + companion object { + object Serializer : TupleSerializer( + "MapChunkPosition", + { + element(MapChunkPosition::x) + element(MapChunkPosition::y) + element(MapChunkPosition::chunkSize) + } + ) { + override fun tupleConstructor(elements: Iterator<*>): MapChunkPosition { + return MapChunkPosition( + elements.next() as Int, + elements.next() as Int, + elements.next() as ChunkSize, + ) + } + } + } +} + + +/** + * The bounds of a [MapChunkPosition], that may contain a [MapPosition]. + * + * Because Factorio uses screen-coordinates, the lowest `x/y` coordinate is the [leftTop], and + * the highest is [rightBottomTile]. + */ +@Serializable +data class MapChunkPositionBounds( + val leftTop: MapTilePosition, + val rightBottom: MapTilePosition, + val chunkSize: ChunkSize, // should be computable based on the tiles, but include it for completeness +) : ClosedRange { + + constructor(chunkPosition: MapChunkPosition) : this( + chunkPosition.leftTopTile(), + chunkPosition.rightBottomTile(), + chunkPosition.chunkSize, + ) + + override val start: MapTilePosition + get() = leftTop + + override val endInclusive: MapTilePosition + get() = rightBottom +} + + +@Serializable +enum class ChunkSize( + val zoomLevel: Int, +) : Comparable { + CHUNK_512(-1), + CHUNK_256(0), + CHUNK_128(1), + CHUNK_064(2), + CHUNK_032(3), + ; + + /** 32, 64, 128, 256, or 512 */ + val lengthInTiles: Int = 2f.pow(8 - zoomLevel).roundToInt() + + init { + require(lengthInTiles > 0) { "tilesPerChunk $lengthInTiles must be positive" } + // 1000 & 0111 = 0000 => pow^2 + // 1001 & 1000 = 1000 => !pow^2 + require(lengthInTiles and (lengthInTiles - 1) == 0) { + "tilesPerChunk $lengthInTiles must be a power-of-two number" + } + } + + companion object { + // cache values for better performance. KT-48872 + val entries: Set = values().toSet() + + val MAX: ChunkSize = entries.maxByOrNull { it.lengthInTiles }!! + val MIN: ChunkSize = entries.minByOrNull { it.lengthInTiles }!! + val STANDARD: ChunkSize = entries.first { it.zoomLevel == 0 } + } +} + + +@Serializable +@SerialName("kafkatorio.position.MapBoundingBox") +data class MapBoundingBox( + val leftTop: MapEntityPosition, + val rightBottom: MapEntityPosition, +) { + val width: Double get() = abs(leftTop.x - rightBottom.x) + val height: Double get() = abs(leftTop.y - rightBottom.y) + + val tileWidth: Int get() = ceil(width).toInt() + val tileHeight: Int get() = ceil(height).toInt() +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/prototypeIds.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/prototypeIds.kt new file mode 100644 index 0000000..be4441a --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/prototypeIds.kt @@ -0,0 +1,783 @@ +package dev.adamko.kafkatorio.schema.common + +import kotlin.jvm.JvmInline +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +/** + * Both a [name] and [type] are required to unique identify a [prototype][FactorioPrototype]. + * + * @property[name] The name of the prototype, which is unique per specific Prototype [type] + */ +@Serializable +@JvmInline +@SerialName("kafkatorio.id.PrototypeId") +value class PrototypeId private constructor( + private val typeNameConcat: String, +) { + + val type: Type get() = Type(typeNameConcat.substringBefore(delim, "")) + val name: Name get() = Name(typeNameConcat.substringAfter(delim, "")) + + + operator fun component1(): Type = type + operator fun component2(): Name = name + + + constructor( + type: String, + name: String, + ) : this("${type}${delim}${name}") + + + /** Denotes the class of the Prototype */ + @Serializable + @JvmInline + @SerialName("kafkatorio.id.PrototypeIdType") + value class Type(private val id: String) { + override fun toString(): String = id + } + + + /** A specific implementation of a [type]. Unique per prototype 'super class' */ + @Serializable + @JvmInline + @SerialName("kafkatorio.id.PrototypeIdName") + value class Name(private val name: String) { + override fun toString(): String = name + } + + + companion object { + private const val delim = '/' + } +} + + +/** Serialize a [PrototypeId] as an integer - more efficient storage */ +@JvmInline +@Serializable +value class PrototypeHashCode private constructor(val code: Int) { + constructor(id: PrototypeId) : this(id.hashCode()) + constructor(tile: FactorioPrototype) : this(tile.protoId) +} + + +//@Suppress("unused") +//enum class PrototypeTypeId( +// val id: String +//) { +// AmbientSound("ambient-sound"), +// Animation("animation"), +// EditorController("editor-controller"), +// Font("font"), +// GodController("god-controller"), +// MapGenPresets("map-gen-presets"), +// MapSettings("map-settings"), +// MouseCursor("mouse-cursor"), +// Sound("sound"), +// SpectatorController("spectator-controller"), +// Sprite("sprite"), +// TileEffect("tile-effect"), +// TipsAndTricksItemCategory("tips-and-tricks-item-category"), +// TriggerTargetType("trigger-target-type"), +// WindSound("wind-sound"), +// Achievement("achievement"), +// BuildEntityAchievement("build-entity-achievement"), +// CombatRobotCountAchievement("combat-robot-count"), +// ConstructWithRobotsAchievement("construct-with-robots-achievement"), +// DeconstructWithRobotsAchievement("deconstruct-with-robots-achievement"), +// DeliverByRobotsAchievement("deliver-by-robots-achievement"), +// DontBuildEntityAchievement("dont-build-entity-achievement"), +// DontCraftManuallyAchievement("dont-craft-manually-achievement"), +// DontUseEntityInEnergyProductionAchievement("dont-use-entity-in-energy-production-achievement"), +// FinishTheGameAchievement("finish-the-game-achievement"), +// GroupAttackAchievement("group-attack-achievement"), +// KillAchievement("kill-achievement"), +// PlayerDamagedAchievement("player-damaged-achievement"), +// ProduceAchievement("produce-achievement"), +// ProducePerHourAchievement("produce-per-hour-achievement"), +// ResearchAchievement("research-achievement"), +// TrainPathAchievement("train-path-achievement"), +// AmmoCategory("ammo-category"), +// AutoplaceControl("autoplace-control"), +// CustomInput("custom-input"), +// DamageType("damage-type"), +// Decorative("optimized-decorative"), +// Entity(""), +// Arrow("arrow"), +// ArtilleryFlare("artillery-flare"), +// ArtilleryProjectile("artillery-projectile"), +// Beam("beam"), +// CharacterCorpse("character-corpse"), +// Cliff("cliff"), +// Corpse("corpse"), +// RailRemnants("rail-remnants"), +// DeconstructibleTileProxy("deconstructible-tile-proxy"), +// EntityGhost("entity-ghost"), +// /** for migration, cannot be used */ +// EntityParticle("particle"), +// /** for migration, cannot be used */ +// LeafParticle("leaf-particle"), +// EntityWithHealth(""), +// EntityWithOwner(""), +// Accumulator("accumulator"), +// ArtilleryTurret("artillery-turret"), +// Beacon("beacon"), +// Boiler("boiler"), +// BurnerGenerator("burner-generator"), +// Character("character"), +// Combinator(""), +// ArithmeticCombinator("arithmetic-combinator"), +// DeciderCombinator("decider-combinator"), +// ConstantCombinator("constant-combinator"), +// Container("container"), +// LogisticContainer("logistic-container"), +// InfinityContainer("infinity-container"), +// CraftingMachine(""), +// AssemblingMachine("assembling-machine"), +// RocketSilo("rocket-silo"), +// Furnace("furnace"), +// ElectricEnergyInterface("electric-energy-interface"), +// ElectricPole("electric-pole"), +// EnemySpawner("unit-spawner"), +// FlyingRobot(""), +// CombatRobot("combat-robot"), +// RobotWithLogisticInterface(""), +// ConstructionRobot("construction-robot"), +// LogisticRobot("logistic-robot"), +// Gate("gate"), +// Generator("generator"), +// HeatInterface("heat-interface"), +// HeatPipe("heat-pipe"), +// Inserter("inserter"), +// Lab("lab"), +// Lamp("lamp"), +// LandMine("land-mine"), +// LinkedContainer("linked-container"), +// Market("market"), +// MiningDrill("mining-drill"), +// OffshorePump("offshore-pump"), +// Pipe("pipe"), +// InfinityPipe("infinity-pipe"), +// PipeToGround("pipe-to-ground"), +// PlayerPort("player-port"), +// PowerSwitch("power-switch"), +// ProgrammableSpeaker("programmable-speaker"), +// Pump("pump"), +// Radar("radar"), +// Rail(""), +// CurvedRail("curved-rail"), +// StraightRail("straight-rail"), +// RailSignalBase(""), +// RailChainSignal("rail-chain-signal"), +// RailSignal("rail-signal"), +// Reactor("reactor"), +// Roboport("roboport"), +// SimpleEntityWithOwner("simple-entity-with-owner"), +// SimpleEntityWithForce("simple-entity-with-force"), +// SolarPanel("solar-panel"), +// StorageTank("storage-tank"), +// TrainStop("train-stop"), +// TransportBeltConnectable(""), +// LinkedBelt("linked-belt"), +// Loader1x1("loader-1x1"), +// Loader1x2("loader"), +// Splitter("splitter"), +// TransportBelt("transport-belt"), +// UndergroundBelt("underground-belt"), +// Turret("turret"), +// AmmoTurret("ammo-turret"), +// ElectricTurret("electric-turret"), +// FluidTurret("fluid-turret"), +// Unit("unit"), +// Vehicle(""), +// Car("car"), +// RollingStock(""), +// ArtilleryWagon("artillery-wagon"), +// CargoWagon("cargo-wagon"), +// FluidWagon("fluid-wagon"), +// Locomotive("locomotive"), +// SpiderVehicle("spider-vehicle"), +// Wall("wall"), +// Fish("fish"), +// SimpleEntity("simple-entity"), +// SpiderLeg("spider-leg"), +// Tree("tree"), +// Explosion("explosion"), +// FlameThrowerExplosion("flame-thrower-explosion"), +// FireFlame("fire"), +// FluidStream("stream"), +// FlyingText("flying-text"), +// HighlightBoxEntity("highlight-box"), +// ItemEntity("item-entity"), +// ItemRequestProxy("item-request-proxy"), +// ParticleSource("particle-source"), +// Projectile("projectile"), +// ResourceEntity("resource"), +// RocketSiloRocket("rocket-silo-rocket"), +// RocketSiloRocketShadow("rocket-silo-rocket-shadow"), +// Smoke(""), +// /** for migration, cannot be used */ +// SimpleSmoke("smoke"), +// SmokeWithTrigger("smoke-with-trigger"), +// SpeechBubble("speech-bubble"), +// Sticker("sticker"), +// TileGhost("tile-ghost"), +// Equipment(""), +// ActiveDefenseEquipment("active-defense-equipment"), +// BatteryEquipment("battery-equipment"), +// BeltImmunityEquipment("belt-immunity-equipment"), +// EnergyShieldEquipment("energy-shield-equipment"), +// GeneratorEquipment("generator-equipment"), +// MovementBonusEquipment("movement-bonus-equipment"), +// NightVisionEquipment("night-vision-equipment"), +// RoboportEquipment("roboport-equipment"), +// SolarPanelEquipment("solar-panel-equipment"), +// EquipmentCategory("equipment-category"), +// EquipmentGrid("equipment-grid"), +// Fluid("fluid"), +// FuelCategory("fuel-category"), +// GuiStyle("gui-style"), +// Item("item"), +// AmmoItem("ammo"), +// Capsule("capsule"), +// Gun("gun"), +// ItemWithEntityData("item-with-entity-data"), +// ItemWithLabel("item-with-label"), +// ItemWithInventory("item-with-inventory"), +// BlueprintBook("blueprint-book"), +// ItemWithTags("item-with-tags"), +// SelectionTool("selection-tool"), +// BlueprintItem("blueprint"), +// CopyPasteTool("copy-paste-tool"), +// DeconstructionItem("deconstruction-item"), +// UpgradeItem("upgrade-item"), +// Module("module"), +// RailPlanner("rail-planner"), +// SpidertronRemote("spidertron-remote"), +// Tool("tool"), +// Armor("armor"), +// /** for migration, cannot be used */ +// MiningTool("mining-tool"), +// RepairTool("repair-tool"), +// ItemGroup("item-group"), +// ItemSubGroup("item-subgroup"), +// ModuleCategory("module-category"), +// NamedNoiseExpression("noise-expression"), +// NoiseLayer("noise-layer"), +// Particle("optimized-particle"), +// Recipe("recipe"), +// RecipeCategory("recipe-category"), +// ResourceCategory("resource-category"), +// Shortcut("shortcut"), +// Technology("technology"), +// Tile("tile"), +// TipsAndTricksItem("tips-and-tricks-item"), +// TrivialSmoke("trivial-smoke"), +// Tutorial("tutorial"), +// UtilityConstants("utility-constants"), +// UtilitySounds("utility-sounds"), +// UtilitySprites("utility-sprites"), +// VirtualSignal("virtual-signal"), +// ; +// +// fun named(protoName: String): PrototypeId = PrototypeId(this, protoName) +// +// companion object { +// val entries: Set = values().toSet() +// } +// +//} + +//@Suppress("unused") +//sealed class PrototypeType( +// val id: String +//) { +// +// object AmbientSound : PrototypeType("ambient-sound") +// object Animation : PrototypeType("animation") +// object EditorController : PrototypeType("editor-controller") +// object Font : PrototypeType("font") +// object GodController : PrototypeType("god-controller") +// object MapGenPresets : PrototypeType("map-gen-presets") +// object MapSettings : PrototypeType("map-settings") +// object MouseCursor : PrototypeType("mouse-cursor") +// object Sound : PrototypeType("sound") +// object SpectatorController : PrototypeType("spectator-controller") +// object Sprite : PrototypeType("sprite") +// object TileEffect : PrototypeType("tile-effect") +// object TipsAndTricksItemCategory : PrototypeType("tips-and-tricks-item-category") +// object TriggerTargetType : PrototypeType("trigger-target-type") +// object WindSound : PrototypeType("wind-sound") +// +// +// object Achievement : PrototypeType("achievement") +// object BuildEntityAchievement : PrototypeType("build-entity-achievement") +// object CombatRobotCountAchievement : PrototypeType("combat-robot-count") +// object ConstructWithRobotsAchievement : PrototypeType("construct-with-robots-achievement") +// object DeconstructWithRobotsAchievement : PrototypeType("deconstruct-with-robots-achievement") +// object DeliverByRobotsAchievement : PrototypeType("deliver-by-robots-achievement") +// object DontBuildEntityAchievement : PrototypeType("dont-build-entity-achievement") +// object DontCraftManuallyAchievement : PrototypeType("dont-craft-manually-achievement") +// object DontUseEntityInEnergyProductionAchievement : PrototypeType("dont-use-entity-in-energy-production-achievement") +// +// +// object FinishTheGameAchievement : PrototypeType("finish-the-game-achievement") +// object GroupAttackAchievement : PrototypeType("group-attack-achievement") +// object KillAchievement : PrototypeType("kill-achievement") +// object PlayerDamagedAchievement : PrototypeType("player-damaged-achievement") +// object ProduceAchievement : PrototypeType("produce-achievement") +// object ProducePerHourAchievement : PrototypeType("produce-per-hour-achievement") +// object ResearchAchievement : PrototypeType("research-achievement") +// object TrainPathAchievement : PrototypeType("train-path-achievement") +// object AmmoCategory : PrototypeType("ammo-category") +// object AutoplaceControl : PrototypeType("autoplace-control") +// object CustomInput : PrototypeType("custom-input") +// object DamageType : PrototypeType("damage-type") +// object Decorative : PrototypeType("optimized-decorative") +// +// +// object Entity : PrototypeType("stract>") +// object Arrow : PrototypeType("arrow") +// object ArtilleryFlare : PrototypeType("artillery-flare") +// object ArtilleryProjectile : PrototypeType("artillery-projectile") +// object Beam : PrototypeType("beam") +// object CharacterCorpse : PrototypeType("character-corpse") +// object Cliff : PrototypeType("cliff") +// object Corpse : PrototypeType("corpse") +// object RailRemnants : PrototypeType("rail-remnants") +// object DeconstructibleTileProxy : PrototypeType("deconstructible-tile-proxy") +// object EntityGhost : PrototypeType("entity-ghost") +// /** for migration, cannot be used */ +// object EntityParticle : PrototypeType("particle") +// /** for migration, cannot be used */ +// object LeafParticle : PrototypeType("leaf-particle") +// +// +// object EntityWithOwner : PrototypeType("stract>") +// object Accumulator : PrototypeType("accumulator") +// object ArtilleryTurret : PrototypeType("artillery-turret") +// object Beacon : PrototypeType("beacon") +// object Boiler : PrototypeType("boiler") +// object BurnerGenerator : PrototypeType("burner-generator") +// object Character : PrototypeType("character") +// +// +// object Combinator : PrototypeType("stract>") +// object ArithmeticCombinator : PrototypeType("arithmetic-combinator") +// object DeciderCombinator : PrototypeType("decider-combinator") +// object ConstantCombinator : PrototypeType("constant-combinator") +// object Container : PrototypeType("container") +// object LogisticContainer : PrototypeType("logistic-container") +// object InfinityContainer : PrototypeType("infinity-container") +// +// +// object CraftingMachine : PrototypeType("stract>") +// object AssemblingMachine : PrototypeType("assembling-machine") +// object RocketSilo : PrototypeType("rocket-silo") +// object Furnace : PrototypeType("furnace") +// object ElectricEnergyInterface : PrototypeType("electric-energy-interface") +// object ElectricPole : PrototypeType("electric-pole") +// object EnemySpawner : PrototypeType("unit-spawner") +// +// +// object FlyingRobot : PrototypeType("stract>") +// object CombatRobot : PrototypeType("combat-robot") , PrototypeAbstract.FlyingRobot +// +// +// object RobotWithLogisticInterface : PrototypeType("stract>") +// object ConstructionRobot : PrototypeType("construction-robot") +// object LogisticRobot : PrototypeType("logistic-robot") +// object Gate : PrototypeType("gate") +// object Generator : PrototypeType("generator") +// object HeatInterface : PrototypeType("heat-interface") +// object HeatPipe : PrototypeType("heat-pipe") +// object Inserter : PrototypeType("inserter") +// object Lab : PrototypeType("lab") +// object Lamp : PrototypeType("lamp") +// object LandMine : PrototypeType("land-mine") +// object LinkedContainer : PrototypeType("linked-container") +// object Market : PrototypeType("market") +// object MiningDrill : PrototypeType("mining-drill") +// object OffshorePump : PrototypeType("offshore-pump") +// object Pipe : PrototypeType("pipe") +// object InfinityPipe : PrototypeType("infinity-pipe") +// object PipeToGround : PrototypeType("pipe-to-ground") +// object PlayerPort : PrototypeType("player-port") +// object PowerSwitch : PrototypeType("power-switch") +// object ProgrammableSpeaker : PrototypeType("programmable-speaker") +// object Pump : PrototypeType("pump") +// object Radar : PrototypeType("radar") +// +// object CurvedRail : PrototypeType("curved-rail"), PrototypeAbstract.Rail +// object StraightRail : PrototypeType("straight-rail"), PrototypeAbstract.Rail +// +// object RailSignalBase : PrototypeType("stract>") +// object RailChainSignal : PrototypeType("rail-chain-signal") +// object RailSignal : PrototypeType("rail-signal") +// object Reactor : PrototypeType("reactor") +// object Roboport : PrototypeType("roboport") +// object SimpleEntityWithOwner : PrototypeType("simple-entity-with-owner") +// object SimpleEntityWithForce : PrototypeType("simple-entity-with-force") +// object SolarPanel : PrototypeType("solar-panel") +// object StorageTank : PrototypeType("storage-tank") +// object TrainStop : PrototypeType("train-stop") +// +// +// object TransportBeltConnectable : PrototypeType("stract>") +// object LinkedBelt : PrototypeType("linked-belt") +// object Loader1x1 : PrototypeType("loader-1x1") +// object Loader1x2 : PrototypeType("loader") +// object Splitter : PrototypeType("splitter") +// object TransportBelt : PrototypeType("transport-belt") +// object UndergroundBelt : PrototypeType("underground-belt") +// object Turret : PrototypeType("turret") +// object AmmoTurret : PrototypeType("ammo-turret") +// object ElectricTurret : PrototypeType("electric-turret") +// object FluidTurret : PrototypeType("fluid-turret") +// object Unit : PrototypeType("unit") +// +// +// object Car : PrototypeType("car>"), PrototypeAbstract.Vehicle +// object SpiderVehicle : PrototypeType("spider-vehicle"), PrototypeAbstract.Vehicle +// +// +// object ArtilleryWagon : PrototypeType("artillery-wagon"), PrototypeAbstract.RollingStock +// object CargoWagon : PrototypeType("cargo-wagon"), PrototypeAbstract.RollingStock +// object FluidWagon : PrototypeType("fluid-wagon"), PrototypeAbstract.RollingStock +// object Locomotive : PrototypeType("locomotive"), PrototypeAbstract.RollingStock +// +// object Wall : PrototypeType("wall") +// +// +// object Fish : PrototypeType("fish"), PrototypeAbstract.EntityWithHealth +// object SimpleEntity : PrototypeType("simple-entity"), PrototypeAbstract.EntityWithHealth +// object SpiderLeg : PrototypeType("spider-leg"), PrototypeAbstract.EntityWithHealth +// object Tree : PrototypeType("tree"), PrototypeAbstract.EntityWithHealth +// +// +// object Explosion : PrototypeType("explosion"), +// object FlameThrowerExplosion : PrototypeType("flame-thrower-explosion"), +// object FireFlame : PrototypeType("fire"), +// object FluidStream : PrototypeType("stream"), +// object FlyingText : PrototypeType("flying-text"), +// object HighlightBoxEntity : PrototypeType("highlight-box"), +// object ItemEntity : PrototypeType("item-entity"), +// object ItemRequestProxy : PrototypeType("item-request-proxy"), +// object ParticleSource : PrototypeType("particle-source"), +// object Projectile : PrototypeType("projectile"), +// object ResourceEntity : PrototypeType("resource"), +// object RocketSiloRocket : PrototypeType("rocket-silo-rocket"), +// object RocketSiloRocketShadow : PrototypeType("rocket-silo-rocket-shadow"), +// +// /** for migration, cannot be used */ +// object SimpleSmoke : PrototypeType("smoke"), PrototypeAbstract.Smoke +// object SmokeWithTrigger : PrototypeType("smoke-with-trigger"), PrototypeAbstract.Smoke +// object SpeechBubble : PrototypeType("speech-bubble"), PrototypeAbstract.Smoke +// object Sticker : PrototypeType("sticker"), PrototypeAbstract.Smoke +// object TileGhost : PrototypeType("tile-ghost"), PrototypeAbstract.Smoke +// +// object Equipment : PrototypeType("abstract>") +// object ActiveDefenseEquipment : PrototypeType("active-defense-equipment") +// object BatteryEquipment : PrototypeType("battery-equipment") +// object BeltImmunityEquipment : PrototypeType("belt-immunity-equipment") +// object EnergyShieldEquipment : PrototypeType("energy-shield-equipment") +// object GeneratorEquipment : PrototypeType("generator-equipment") +// object MovementBonusEquipment : PrototypeType("movement-bonus-equipment") +// object NightVisionEquipment : PrototypeType("night-vision-equipment") +// object RoboportEquipment : PrototypeType("roboport-equipment") +// object SolarPanelEquipment : PrototypeType("solar-panel-equipment") +// object EquipmentCategory : PrototypeType("equipment-category") +// object EquipmentGrid : PrototypeType("equipment-grid") +// object Fluid : PrototypeType("fluid") +// object FuelCategory : PrototypeType("fuel-category") +// object GuiStyle : PrototypeType("gui-style") +// object Item : PrototypeType("item") +// object AmmoItem : PrototypeType("ammo") +// object Capsule : PrototypeType("capsule") +// object Gun : PrototypeType("gun") +// object ItemWithEntityData : PrototypeType("item-with-entity-data") +// object ItemWithLabel : PrototypeType("item-with-label") +// object ItemWithInventory : PrototypeType("item-with-inventory") +// object BlueprintBook : PrototypeType("blueprint-book") +// object ItemWithTags : PrototypeType("item-with-tags") +// object SelectionTool : PrototypeType("selection-tool") +// object BlueprintItem : PrototypeType("blueprint") +// object CopyPasteTool : PrototypeType("copy-paste-tool") +// object DeconstructionItem : PrototypeType("deconstruction-item") +// object UpgradeItem : PrototypeType("upgrade-item") +// object Module : PrototypeType("module") +// object RailPlanner : PrototypeType("rail-planner") +// object SpidertronRemote : PrototypeType("spidertron-remote") +// object Tool : PrototypeType("tool") +// object Armor : PrototypeType("armor") +// /** for migration, cannot be used */ +// object MiningTool : PrototypeType("mining-tool") +// object RepairTool : PrototypeType("repair-tool") +// object ItemGroup : PrototypeType("item-group") +// object ItemSubGroup : PrototypeType("item-subgroup") +// object ModuleCategory : PrototypeType("module-category") +// object NamedNoiseExpression : PrototypeType("noise-expression") +// object NoiseLayer : PrototypeType("noise-layer") +// object Particle : PrototypeType("optimized-particle") +// object Recipe : PrototypeType("recipe") +// object RecipeCategory : PrototypeType("recipe-category") +// object ResourceCategory : PrototypeType("resource-category") +// object Shortcut : PrototypeType("shortcut") +// object Technology : PrototypeType("technology") +// object Tile : PrototypeType("tile") +// object TipsAndTricksItem : PrototypeType("tips-and-tricks-item") +// object TrivialSmoke : PrototypeType("trivial-smoke") +// object Tutorial : PrototypeType("tutorial") +// object UtilityConstants : PrototypeType("utility-constants") +// object UtilitySounds : PrototypeType("utility-sounds") +// object UtilitySprites : PrototypeType("utility-sprites") +// object VirtualSignal : PrototypeType("virtual-signal") +// +//} +// +//@Suppress("unused") +//sealed interface PrototypeAbstract { +// //@formatter:off +// sealed interface PrototypeBase : PrototypeAbstract +// sealed interface Entity : PrototypeAbstract +// sealed interface EntityWithHealth : Entity +// +// sealed interface EntityWithOwner : EntityWithHealth +// +// sealed interface Combinator : EntityWithOwner +// sealed interface CraftingMachine : EntityWithOwner +// sealed interface FlyingRobot : EntityWithOwner +// +// sealed interface RobotWithLogisticInterface : FlyingRobot +// +// sealed interface Rail : EntityWithOwner +// +// sealed interface RailSignalBase : EntityWithOwner +// sealed interface TransportBeltConnectable : EntityWithOwner +// sealed interface Vehicle : EntityWithOwner +// sealed interface RollingStock : Vehicle +// sealed interface Smoke : Entity +// sealed interface Equipment : PrototypeAbstract +// //@formatter:on +//} + + +/* + + +* [[Prototype/AmbientSound]] '''ambient-sound''' +* [[Prototype/Animation]] '''animation''' +* [[Prototype/EditorController]] '''editor-controller''' +* [[Prototype/Font]] '''font''' +* [[Prototype/GodController]] '''god-controller''' +* [[Prototype/MapGenPresets]] '''map-gen-presets''' +* [[Prototype/MapSettings]] '''map-settings''' +* [[Prototype/MouseCursor]] '''mouse-cursor''' +* [[Prototype/Sound]] '''sound''' +* [[Prototype/SpectatorController]] '''spectator-controller''' +* [[Prototype/Sprite]] '''sprite''' +* [[Prototype/TileEffect]] '''tile-effect''' +* [[Prototype/TipsAndTricksItemCategory]] '''tips-and-tricks-item-category''' +* [[Prototype/TriggerTargetType]] '''trigger-target-type''' +* [[Prototype/WindSound]] '''wind-sound''' +* [[PrototypeBase]] +
+* [[Prototype/Achievement]] '''achievement''' +** [[Prototype/BuildEntityAchievement]] '''build-entity-achievement''' +** [[Prototype/CombatRobotCountAchievement]] '''combat-robot-count''' +** [[Prototype/ConstructWithRobotsAchievement]] '''construct-with-robots-achievement''' +** [[Prototype/DeconstructWithRobotsAchievement]] '''deconstruct-with-robots-achievement''' +** [[Prototype/DeliverByRobotsAchievement]] '''deliver-by-robots-achievement''' +** [[Prototype/DontBuildEntityAchievement]] '''dont-build-entity-achievement''' +** [[Prototype/DontCraftManuallyAchievement]] '''dont-craft-manually-achievement''' +** [[Prototype/DontUseEntityInEnergyProductionAchievement]] '''dont-use-entity-in-energy-production-achievement''' +** [[Prototype/FinishTheGameAchievement]] '''finish-the-game-achievement''' +** [[Prototype/GroupAttackAchievement]] '''group-attack-achievement''' +** [[Prototype/KillAchievement]] '''kill-achievement''' +** [[Prototype/PlayerDamagedAchievement]] '''player-damaged-achievement''' +** [[Prototype/ProduceAchievement]] '''produce-achievement''' +** [[Prototype/ProducePerHourAchievement]] '''produce-per-hour-achievement''' +** [[Prototype/ResearchAchievement]] '''research-achievement''' +** [[Prototype/TrainPathAchievement]] '''train-path-achievement''' +* [[Prototype/AmmoCategory]] '''ammo-category''' +* [[Prototype/AutoplaceControl]] '''autoplace-control''' +* [[Prototype/CustomInput]] '''custom-input''' +* [[Prototype/DamageType]] '''damage-type''' +* [[Prototype/Decorative]] '''optimized-decorative''' +* [[Prototype/Entity]] +** [[Prototype/Arrow]] '''arrow''' +** [[Prototype/ArtilleryFlare]] '''artillery-flare''' +** [[Prototype/ArtilleryProjectile]] '''artillery-projectile''' +** [[Prototype/Beam]] '''beam''' +** [[Prototype/CharacterCorpse]] '''character-corpse''' +** [[Prototype/Cliff]] '''cliff''' +** [[Prototype/Corpse]] '''corpse''' +*** [[Prototype/RailRemnants]] '''rail-remnants''' +** [[Prototype/DeconstructibleTileProxy]] '''deconstructible-tile-proxy''' +** [[Prototype/EntityGhost]] '''entity-ghost''' +** [[Prototype/EntityParticle]] '''particle''' (for migration, cannot be used) +*** [[Prototype/LeafParticle]] '''leaf-particle''' (for migration, cannot be used) +** [[Prototype/EntityWithHealth]] +*** [[Prototype/EntityWithOwner]] +**** [[Prototype/Accumulator]] '''accumulator''' +**** [[Prototype/ArtilleryTurret]] '''artillery-turret''' +**** [[Prototype/Beacon]] '''beacon''' +**** [[Prototype/Boiler]] '''boiler''' +**** [[Prototype/BurnerGenerator]] '''burner-generator''' +**** [[Prototype/Character]] '''character''' +**** [[Prototype/Combinator]] +***** [[Prototype/ArithmeticCombinator]] '''arithmetic-combinator''' +***** [[Prototype/DeciderCombinator]] '''decider-combinator''' +**** [[Prototype/ConstantCombinator]] '''constant-combinator''' +**** [[Prototype/Container]] '''container''' +***** [[Prototype/LogisticContainer]] '''logistic-container''' +****** [[Prototype/InfinityContainer]] '''infinity-container''' +**** [[Prototype/CraftingMachine]] +***** [[Prototype/AssemblingMachine]] '''assembling-machine''' +****** [[Prototype/RocketSilo]] '''rocket-silo''' +***** [[Prototype/Furnace]] '''furnace''' +**** [[Prototype/ElectricEnergyInterface]] '''electric-energy-interface''' +**** [[Prototype/ElectricPole]] '''electric-pole''' +**** [[Prototype/EnemySpawner]] '''unit-spawner''' +**** [[Prototype/FlyingRobot]] +***** [[Prototype/CombatRobot]] '''combat-robot''' +***** [[Prototype/RobotWithLogisticInterface]] +****** [[Prototype/ConstructionRobot]] '''construction-robot''' +****** [[Prototype/LogisticRobot]] '''logistic-robot''' +**** [[Prototype/Gate]] '''gate''' +**** [[Prototype/Generator]] '''generator''' +**** [[Prototype/HeatInterface]] '''heat-interface''' +**** [[Prototype/HeatPipe]] '''heat-pipe''' +**** [[Prototype/Inserter]] '''inserter''' +**** [[Prototype/Lab]] '''lab''' +**** [[Prototype/Lamp]] '''lamp''' +**** [[Prototype/LandMine]] '''land-mine''' +**** [[Prototype/LinkedContainer]] '''linked-container''' +**** [[Prototype/Market]] '''market''' +**** [[Prototype/MiningDrill]] '''mining-drill''' +**** [[Prototype/OffshorePump]] '''offshore-pump''' +**** [[Prototype/Pipe]] '''pipe''' +***** [[Prototype/InfinityPipe]] '''infinity-pipe''' +**** [[Prototype/PipeToGround]] '''pipe-to-ground''' +**** [[Prototype/PlayerPort]] '''player-port''' +**** [[Prototype/PowerSwitch]] '''power-switch''' +**** [[Prototype/ProgrammableSpeaker]] '''programmable-speaker''' +**** [[Prototype/Pump]] '''pump''' +**** [[Prototype/Radar]] '''radar''' +**** [[Prototype/Rail]] +***** [[Prototype/CurvedRail]] '''curved-rail''' +***** [[Prototype/StraightRail]] '''straight-rail''' +**** [[Prototype/RailSignalBase]] +***** [[Prototype/RailChainSignal]] '''rail-chain-signal''' +***** [[Prototype/RailSignal]] '''rail-signal''' +**** [[Prototype/Reactor]] '''reactor''' +**** [[Prototype/Roboport]] '''roboport''' +**** [[Prototype/SimpleEntityWithOwner]] '''simple-entity-with-owner''' +***** [[Prototype/SimpleEntityWithForce]] '''simple-entity-with-force''' +**** [[Prototype/SolarPanel]] '''solar-panel''' +**** [[Prototype/StorageTank]] '''storage-tank''' +**** [[Prototype/TrainStop]] '''train-stop''' +**** [[Prototype/TransportBeltConnectable]] +***** [[Prototype/LinkedBelt]] '''linked-belt''' +***** [[Prototype/Loader1x1]] '''loader-1x1''' +***** [[Prototype/Loader1x2]] '''loader''' +***** [[Prototype/Splitter]] '''splitter''' +***** [[Prototype/TransportBelt]] '''transport-belt''' +***** [[Prototype/UndergroundBelt]] '''underground-belt''' +**** [[Prototype/Turret]] '''turret''' +***** [[Prototype/AmmoTurret]] '''ammo-turret''' +***** [[Prototype/ElectricTurret]] '''electric-turret''' +***** [[Prototype/FluidTurret]] '''fluid-turret''' +**** [[Prototype/Unit]] '''unit''' +**** [[Prototype/Vehicle]] +***** [[Prototype/Car]] '''car''' +***** [[Prototype/RollingStock]] +****** [[Prototype/ArtilleryWagon]] '''artillery-wagon''' +****** [[Prototype/CargoWagon]] '''cargo-wagon''' +****** [[Prototype/FluidWagon]] '''fluid-wagon''' +****** [[Prototype/Locomotive]] '''locomotive''' +***** [[Prototype/SpiderVehicle]] '''spider-vehicle''' +**** [[Prototype/Wall]] '''wall''' +*** [[Prototype/Fish]] '''fish''' +*** [[Prototype/SimpleEntity]] '''simple-entity''' +*** [[Prototype/SpiderLeg]] '''spider-leg''' +*** [[Prototype/Tree]] '''tree''' +** [[Prototype/Explosion]] '''explosion''' +*** [[Prototype/FlameThrowerExplosion]] '''flame-thrower-explosion''' +** [[Prototype/FireFlame]] '''fire''' +** [[Prototype/FluidStream]] '''stream''' +** [[Prototype/FlyingText]] '''flying-text''' +** [[Prototype/HighlightBoxEntity]] '''highlight-box''' +** [[Prototype/ItemEntity]] '''item-entity''' +** [[Prototype/ItemRequestProxy]] '''item-request-proxy''' +** [[Prototype/ParticleSource]] '''particle-source''' +** [[Prototype/Projectile]] '''projectile''' +** [[Prototype/ResourceEntity]] '''resource''' +** [[Prototype/RocketSiloRocket]] '''rocket-silo-rocket''' +** [[Prototype/RocketSiloRocketShadow]] '''rocket-silo-rocket-shadow''' +** [[Prototype/Smoke]] +*** [[Prototype/SimpleSmoke]] '''smoke''' (for migration, cannot be used) +*** [[Prototype/SmokeWithTrigger]] '''smoke-with-trigger''' +** [[Prototype/SpeechBubble]] '''speech-bubble''' +** [[Prototype/Sticker]] '''sticker''' +** [[Prototype/TileGhost]] '''tile-ghost''' +* [[Prototype/Equipment]] +** [[Prototype/ActiveDefenseEquipment]] '''active-defense-equipment''' +** [[Prototype/BatteryEquipment]] '''battery-equipment''' +** [[Prototype/BeltImmunityEquipment]] '''belt-immunity-equipment''' +** [[Prototype/EnergyShieldEquipment]] '''energy-shield-equipment''' +** [[Prototype/GeneratorEquipment]] '''generator-equipment''' +** [[Prototype/MovementBonusEquipment]] '''movement-bonus-equipment''' +** [[Prototype/NightVisionEquipment]] '''night-vision-equipment''' +** [[Prototype/RoboportEquipment]] '''roboport-equipment''' +** [[Prototype/SolarPanelEquipment]] '''solar-panel-equipment''' +* [[Prototype/EquipmentCategory]] '''equipment-category''' +* [[Prototype/EquipmentGrid]] '''equipment-grid''' +* [[Prototype/Fluid]] '''fluid''' +* [[Prototype/FuelCategory]] '''fuel-category''' +* [[Prototype/GuiStyle]] '''gui-style''' +* [[Prototype/Item]] '''item''' +** [[Prototype/AmmoItem]] '''ammo''' +** [[Prototype/Capsule]] '''capsule''' +** [[Prototype/Gun]] '''gun''' +** [[Prototype/ItemWithEntityData]] '''item-with-entity-data''' +** [[Prototype/ItemWithLabel]] '''item-with-label''' +*** [[Prototype/ItemWithInventory]] '''item-with-inventory''' +**** [[Prototype/BlueprintBook]] '''blueprint-book''' +*** [[Prototype/ItemWithTags]] '''item-with-tags''' +*** [[Prototype/SelectionTool]] '''selection-tool''' +**** [[Prototype/BlueprintItem]] '''blueprint''' +**** [[Prototype/CopyPasteTool]] '''copy-paste-tool''' +**** [[Prototype/DeconstructionItem]] '''deconstruction-item''' +**** [[Prototype/UpgradeItem]] '''upgrade-item''' +** [[Prototype/Module]] '''module''' +** [[Prototype/RailPlanner]] '''rail-planner''' +** [[Prototype/SpidertronRemote]] '''spidertron-remote''' +** [[Prototype/Tool]] '''tool''' +*** [[Prototype/Armor]] '''armor''' +*** [[Prototype/MiningTool]] '''mining-tool''' (for migration, cannot be used) +*** [[Prototype/RepairTool]] '''repair-tool''' +* [[Prototype/ItemGroup]] '''item-group''' +* [[Prototype/ItemSubGroup]] '''item-subgroup''' +* [[Prototype/ModuleCategory]] '''module-category''' +* [[Prototype/NamedNoiseExpression]] '''noise-expression''' +* [[Prototype/NoiseLayer]] '''noise-layer''' +* [[Prototype/Particle]] '''optimized-particle''' +* [[Prototype/Recipe]] '''recipe''' +* [[Prototype/RecipeCategory]] '''recipe-category''' +* [[Prototype/ResourceCategory]] '''resource-category''' +* [[Prototype/Shortcut]] '''shortcut''' +* [[Prototype/Technology]] '''technology''' +* [[Prototype/Tile]] '''tile''' +* [[Prototype/TipsAndTricksItem]] '''tips-and-tricks-item''' +* [[Prototype/TrivialSmoke]] '''trivial-smoke''' +* [[Prototype/Tutorial]] '''tutorial''' +* [[Prototype/UtilityConstants]] '''utility-constants''' +* [[Prototype/UtilitySounds]] '''utility-sounds''' +* [[Prototype/UtilitySprites]] '''utility-sprites''' +* [[Prototype/VirtualSignal]] '''virtual-signal''' + + */ diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/resources.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/resources.kt new file mode 100644 index 0000000..bec5bf3 --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/resources.kt @@ -0,0 +1,44 @@ +package dev.adamko.kafkatorio.schema.common + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +@Serializable +@SerialName("kafkatorio.resource.MinedProduct") +sealed interface MinedProduct { + + val resultProtoId: PrototypeId + //Amount of the item or fluid to give. If not specified, amount_min, amount_max and probability must all be specified. + val amount: Double? + +//Minimal amount of the item or fluid to give. Has no effect when amount is specified. +//amount_min : Uint or double?, + +//Maximum amount of the item or fluid to give. Has no effect when amount is specified. +//amount_max : Uint or double?, + +//A value in range [0, 1]. Item or fluid is only given with this probability; otherwise no product is produced. +//probability : Double?, + + //How much of this product is a catalyst. +//catalyst_amount : Uint or double?, + + + @Serializable + @SerialName("kafkatorio.resource.MinedProduct.MinedProductFluid") + data class Fluid( + override val amount: Double? = null, + override val resultProtoId: PrototypeId, + ) : MinedProduct + + + @Serializable + @SerialName("kafkatorio.resource.MinedProduct.MinedProductItem") + data class Item( + override val amount: Double? = null, + override val resultProtoId: PrototypeId, + ) : MinedProduct + + +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/secrets.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/secrets.kt new file mode 100644 index 0000000..5e855f6 --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/common/secrets.kt @@ -0,0 +1,13 @@ +package dev.adamko.kafkatorio.schema.common + +import kotlin.jvm.JvmInline +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +@Serializable +@SerialName("kafkatorio.common.MaskedValue") +@JvmInline +value class MaskedValue(val value: String) { + override fun toString(): String = "Secret(***)" +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/eventServerPacket.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/eventServerPacket.kt new file mode 100644 index 0000000..83e7fc0 --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/eventServerPacket.kt @@ -0,0 +1,27 @@ +package dev.adamko.kafkatorio.schema.packets + +import dev.adamko.kafkatorio.schema.common.ServerMapChunkId +import dev.adamko.kafkatorio.schema.common.ServerMapTilePngFilename +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +@Serializable +sealed class EventServerPacket { + + + @Serializable + @SerialName("kafkatorio.event-server-packet.Kafkatorio") + data class Kafkatorio( + val packet: KafkatorioPacket + ) : EventServerPacket() + + + @Serializable + @SerialName("kafkatorio.event-server-packet.ChunkTileSaved") + data class ChunkTileSaved( + val chunkId: ServerMapChunkId, + val filename: ServerMapTilePngFilename, + ) : EventServerPacket() + +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/kafkatorioPacket.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/kafkatorioPacket.kt new file mode 100644 index 0000000..0b83f61 --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/kafkatorioPacket.kt @@ -0,0 +1,39 @@ +package dev.adamko.kafkatorio.schema.packets + +import dev.adamko.kafkatorio.schema.common.Tick +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +@Serializable +@SerialName("kafkatorio.packet.KafkatorioPacket") +data class KafkatorioPacket( + val modVersion: String, + val tick: Tick, + val data: KafkatorioPacketData, +) + + +@Serializable +@SerialName("kafkatorio.packet.KafkatorioPacketData") +sealed class KafkatorioPacketData + + +@Serializable +@SerialName("kafkatorio.packet.KafkatorioPacketData.Error") +data class KafkatorioPacketDataError( + val message: String? = null, + val rawValue: String? = null, +) : KafkatorioPacketData() { + constructor( + exception: Exception, + rawValue: String? = null + ) : this( + message = """ + $exception ${exception.message} + + ${exception.stackTraceToString()} + """.trimIndent(), + rawValue = rawValue, + ) +} diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/kafkatorioPacketInstant.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/kafkatorioPacketInstant.kt new file mode 100644 index 0000000..87203db --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/kafkatorioPacketInstant.kt @@ -0,0 +1,81 @@ +package dev.adamko.kafkatorio.schema.packets + +import dev.adamko.kafkatorio.library.LuaJsonList +import dev.adamko.kafkatorio.schema.common.FactorioPrototype +import dev.adamko.kafkatorio.schema.common.PlayerIndex +import dev.adamko.kafkatorio.schema.common.SurfaceIndex +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +/** No key, no caching. Must be sent instantly. */ +@Serializable +@SerialName("kafkatorio.packet.KafkatorioPacket") +sealed class KafkatorioInstantPacketData : KafkatorioPacketData() + + +/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ + + +@Serializable +@SerialName("kafkatorio.packet.instant.ConfigurationUpdate") +data class ConfigurationUpdate( + val factorioData: ConfigurationUpdateGameData, +// @Contextual + val allMods: LuaJsonList, + val modStartupSettingsChange: Boolean = false, + val migrationApplied: Boolean = false, +) : KafkatorioInstantPacketData() { + + @Serializable + @SerialName("kafkatorio.packet.instant.ConfigurationUpdate.ConfigurationUpdateGameData") + data class ConfigurationUpdateGameData( + val oldVersion: String? = null, + val newVersion: String? = null, + ) + + @Serializable + @SerialName("kafkatorio.packet.instant.ConfigurationUpdate.ConfigurationUpdateModData") + data class ConfigurationUpdateModData( + val modName: String, + val currentVersion: String? = null, + val previousVersion: String? = null, + ) +} + + +@Serializable +@SerialName("kafkatorio.packet.instant.ConsoleChatUpdate") +data class ConsoleChatUpdate( + val authorPlayerIndex: PlayerIndex?, + val content: String, +) : KafkatorioInstantPacketData() + + +@Serializable +@SerialName("kafkatorio.packet.instant.ConsoleCommandUpdate") +data class ConsoleCommandUpdate( + val authorPlayerIndex: PlayerIndex?, + val command: String, + val parameters: String, +) : KafkatorioInstantPacketData() + + +@Serializable +@SerialName("kafkatorio.packet.instant.PrototypesUpdate") +data class PrototypesUpdate( +// @Contextual + val prototypes: LuaJsonList, +) : KafkatorioInstantPacketData() + + +@Serializable +@SerialName("kafkatorio.packet.instant.SurfaceUpdate") +data class SurfaceUpdate( + val index: SurfaceIndex, + val daytime: Double, + val name: String, +) : KafkatorioInstantPacketData() + + +/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ diff --git a/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/kafkatorioPacketKeyed.kt b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/kafkatorioPacketKeyed.kt new file mode 100644 index 0000000..7abb190 --- /dev/null +++ b/modules/events-library/src/commonMain/kotlin/dev/adamko/kafkatorio/schema/packets/kafkatorioPacketKeyed.kt @@ -0,0 +1,221 @@ +package dev.adamko.kafkatorio.schema.packets + +import dev.adamko.kafkatorio.library.LuaJsonList +import dev.adamko.kafkatorio.schema.common.Colour +import dev.adamko.kafkatorio.schema.common.EntityIdentifiers +import dev.adamko.kafkatorio.schema.common.EntityIdentifiersData +import dev.adamko.kafkatorio.schema.common.EventName +import dev.adamko.kafkatorio.schema.common.FactorioEntityData +import dev.adamko.kafkatorio.schema.common.FactorioEntityUpdateDictionary +import dev.adamko.kafkatorio.schema.common.FactorioEntityUpdateDictionary.ResourceAmounts +import dev.adamko.kafkatorio.schema.common.ForceIndex +import dev.adamko.kafkatorio.schema.common.MapChunkPosition +import dev.adamko.kafkatorio.schema.common.MapEntityPosition +import dev.adamko.kafkatorio.schema.common.MapTileDictionary +import dev.adamko.kafkatorio.schema.common.PlayerIndex +import dev.adamko.kafkatorio.schema.common.PrototypeId +import dev.adamko.kafkatorio.schema.common.SurfaceIndex +import dev.adamko.kafkatorio.schema.common.Tick +import dev.adamko.kafkatorio.schema.common.UnitNumber +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +/** Has a key, so it can be debounced */ +@Serializable +@SerialName("kafkatorio.packet.keyed.KafkatorioKeyedPacketData") +sealed class KafkatorioKeyedPacketData : KafkatorioPacketData() { + abstract val key: KafkatorioKeyedPacketKey + /** A list of all events that have been aggregated into this packet. */ + // Maybe change to be Map, where Tick is the most recent event? + // A complete event timeline isn't necessary. The most recent tick of an event is good enough, and requires less space. + abstract val events: Map>? +} + + +@Serializable +@SerialName("kafkatorio.packet.keyed.KafkatorioKeyedPacketKey") +sealed class KafkatorioKeyedPacketKey + + +/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ + + +@Serializable +@SerialName("kafkatorio.packet.keyed.EntityUpdateKey") +data class EntityUpdateKey( + /** While normally optional, here a [unitNumber] is required for caching */ + override val unitNumber: UnitNumber, + override val protoId: PrototypeId, +) : EntityIdentifiers, KafkatorioKeyedPacketKey() + + +@Serializable +@SerialName("kafkatorio.packet.keyed.EntityUpdate") +data class EntityUpdate( + override val key: EntityUpdateKey, + + override val events: Map>? = null, + + val chunkPosition: MapEntityPosition? = null, + val graphicsVariation: UByte? = null, + val health: Float? = null, + val isActive: Boolean = false, + val isRotatable: Boolean = false, + val lastUser: UInt? = null, + val localisedDescription: String? = null, + val localisedName: String? = null, +) : KafkatorioKeyedPacketData() + + +/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ + + +@Serializable +@SerialName("kafkatorio.packet.keyed.MapChunkTileUpdateKey") +data class MapChunkTileUpdateKey( +// val index: PlayerIndex, // maybe add player/robot key, to allow metrics like 'player x mined y tiles' + val chunkPosition: MapChunkPosition, + val surfaceIndex: SurfaceIndex, +) : KafkatorioKeyedPacketKey() + + +@Serializable +@SerialName("kafkatorio.packet.keyed.MapChunkTileUpdate") +data class MapChunkTileUpdate( + override val key: MapChunkTileUpdateKey, + + override val events: Map>? = null, + + val player: PlayerIndex? = null, + val robot: EntityIdentifiersData? = null, + val force: ForceIndex? = null, + /** updated tiles - might be partial and not all tiles in the chunk */ + val tileDictionary: MapTileDictionary? = null, + val isDeleted: Boolean = false, +) : KafkatorioKeyedPacketData() + + +/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ + + +@Serializable +@SerialName("kafkatorio.packet.keyed.PlayerUpdateKey") +data class PlayerUpdateKey( + val index: PlayerIndex, +) : KafkatorioKeyedPacketKey() + + +@Serializable +@SerialName("kafkatorio.packet.keyed.PlayerUpdate") +data class PlayerUpdate( + override val key: PlayerUpdateKey, + + override val events: Map>? = null, + + val characterUnitNumber: UnitNumber? = null, + val chatColour: Colour? = null, + val colour: Colour? = null, + val name: String? = null, + + val afkTime: Tick? = null, + val ticksToRespawn: Tick? = null, + val forceIndex: ForceIndex? = null, + val isAdmin: Boolean = false, + val isConnected: Boolean = false, + val isShowOnMap: Boolean = false, + val isSpectator: Boolean = false, + val lastOnline: Tick? = null, + val onlineTime: Tick? = null, + val position: MapEntityPosition? = null, + val surfaceIndex: SurfaceIndex? = null, + val tag: String? = null, + val diedCause: EntityIdentifiersData? = null, + + val bannedReason: String? = null, + val kickedReason: String? = null, + val disconnectReason: String? = null, + /** `true` when a player is removed (deleted) from the game */ + val isRemoved: Boolean = false, +) : KafkatorioKeyedPacketData() + + +/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ + + +@Serializable +@SerialName("kafkatorio.packet.keyed.MapChunkEntityUpdateKey") +data class MapChunkEntityUpdateKey( + val protoId: PrototypeId, + val surfaceIndex: SurfaceIndex, + val chunkPosition: MapChunkPosition, +) : KafkatorioKeyedPacketKey() + + +@Serializable +@SerialName("kafkatorio.packet.keyed.MapChunkEntityUpdate") +data class MapChunkEntityUpdate( + override val key: MapChunkEntityUpdateKey, + + override val events: Map>? = null, + + val entitiesXY: FactorioEntityUpdateDictionary.Entity, +) : KafkatorioKeyedPacketData() { + + fun entities(): List = + entitiesXY.map { (position, entity) -> + FactorioEntityData.Standard( + protoId = key.protoId, + position = position, + + status = entity.status, + unitNumber = entity.unitNumber, + graphicsVariation = entity.graphicsVariation, + health = entity.health, + isActive = entity.isActive, + isRotatable = entity.isRotatable, + lastUser = entity.lastUser + ) + } +} + + +/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ + + +@Serializable +@SerialName("kafkatorio.packet.keyed.MapChunkResourceUpdateKey") +data class MapChunkResourceUpdateKey( + val protoId: PrototypeId, + val surfaceIndex: SurfaceIndex, + val chunkPosition: MapChunkPosition, +) : KafkatorioKeyedPacketKey() + + +@Serializable +@SerialName("kafkatorio.packet.keyed.MapChunkResourceUpdate") +data class MapChunkResourceUpdate( + override val key: MapChunkResourceUpdateKey, + + override val events: Map>? = null, + + // Optimise JSON size by storing amounts separately. + val amounts: ResourceAmounts = ResourceAmounts(), + // Initial amount is only available for infinite resources, and infinite resources (oil) are more + // uncommon, so there are unlikely to be many per chunk + val initialAmounts: ResourceAmounts = ResourceAmounts(), +) : KafkatorioKeyedPacketData() { + + fun resources(): List = + amounts.map { (position, amount) -> + FactorioEntityData.Resource( + protoId = key.protoId, + position = position, + amount = amount, + initialAmount = initialAmounts[position], + ) + } +} + + +/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ diff --git a/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/ColourHexTest.kt b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/ColourHexTest.kt new file mode 100644 index 0000000..2fbf0d3 --- /dev/null +++ b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/ColourHexTest.kt @@ -0,0 +1,77 @@ +package dev.adamko.kafkatorio.schema.common + +import dev.adamko.kafkatorio.library.jsonMapperKafkatorio +import io.kotest.assertions.withClue +import io.kotest.core.spec.style.BehaviorSpec +import io.kotest.matchers.floats.shouldBeWithinPercentageOf +import io.kotest.matchers.should +import io.kotest.matchers.shouldBe +import io.kotest.property.checkAll +import kotlinx.serialization.decodeFromString + + +class ColourHexTest : BehaviorSpec({ + + Given("colour json") { + + //Language=JSON + val colourJson = """ + [0.1, 0.4, 0.7, 0.6] + """.trimIndent() + + val colour: Colour = jsonMapperKafkatorio.decodeFromString(colourJson) + + Then("expect colour is decoded") { + colour shouldBe Colour( + 0.1f, + 0.4f, + 0.7f, + 0.6f, + ) + } + + Then("expect Colour can be converted to ColourHex and back") { + val colourHex = colour.toHex() + colourHex shouldBe ColourHex( + 25u, + 102u, + 178u, + 153u, + ) + + colourHex.toPercentile() should { back -> + withClue(back) { + + val tolerance = 2.6 // 2.6%, because 255/100 = 2.55 + + withClue("red") { back.red.shouldBeWithinPercentageOf(0.1f, tolerance) } + withClue("green") { back.green.shouldBeWithinPercentageOf(0.4f, tolerance) } + withClue("blue") { back.blue.shouldBeWithinPercentageOf(0.7f, tolerance) } + withClue("alpha") { back.alpha.shouldBeWithinPercentageOf(0.6f, tolerance) } + } + } + } + } + + Given("any colour json") { + Then("expect can always convert") { + + checkAll { r, g, b, a -> + + //Language=JSON + val colourJson = """ + [ + ${r.toFloat() / UByte.MAX_VALUE.toFloat()}, + ${g.toFloat() / UByte.MAX_VALUE.toFloat()}, + ${b.toFloat() / UByte.MAX_VALUE.toFloat()}, + ${a.toFloat() / UByte.MAX_VALUE.toFloat()} + ] + """.trimIndent() + + val colour: Colour = jsonMapperKafkatorio.decodeFromString(colourJson) + val colourHex = colour.toHex() + colourHex shouldBe ColourHex(r, g, b, a) + } + } + } +}) diff --git a/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapChunkPositionBoundsTest.kt b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapChunkPositionBoundsTest.kt new file mode 100644 index 0000000..040d4c1 --- /dev/null +++ b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapChunkPositionBoundsTest.kt @@ -0,0 +1,188 @@ +package dev.adamko.kafkatorio.schema.common + +import dev.adamko.kafkatorio.library.kxsBinary +import io.kotest.assertions.asClue +import io.kotest.assertions.withClue +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.collections.shouldContainExactly +import io.kotest.matchers.ints.shouldBeExactly +import io.kotest.matchers.maps.shouldContainExactly +import io.kotest.matchers.shouldBe +import kotlinx.serialization.decodeFromByteArray +import kotlinx.serialization.encodeToByteArray + +class MapChunkPositionBoundsTest : FunSpec({ + + context("create bounds") { + + context("MapChunkPosition(0, 0)") { + + context("chunk size 32") { + + val chunkPos = MapChunkPosition(0, 0, ChunkSize.CHUNK_032) + + test("leftTop should be 0,0") { + chunkPos.bounds.leftTop.asClue { + it.x shouldBeExactly 0 + it.y shouldBeExactly 0 + } + } + + test("rightBottom should be 31,31") { + chunkPos.bounds.rightBottom.asClue { + it.x shouldBeExactly 31 + it.y shouldBeExactly 31 + } + } + } + } + + context("chunk size 256") { + + val chunkPos = MapChunkPosition(0, 0, ChunkSize.CHUNK_256) + + test("leftTop should be 0,0") { + chunkPos.bounds.leftTop.asClue { + it.x shouldBeExactly 0 + it.y shouldBeExactly 0 + } + } + + test("rightBottom should be 255,255") { + chunkPos.bounds.rightBottom.asClue { + it.x shouldBeExactly 255 + it.y shouldBeExactly 255 + } + } + } + } + + context("MapChunkPosition(-10, -10)") { + + context("chunk size 32") { + + val chunkPos = MapChunkPosition(-10, -10, ChunkSize.CHUNK_032) + + test("leftTop should be -320,-320") { + chunkPos.bounds.leftTop.asClue { + it.x shouldBeExactly -320 + it.y shouldBeExactly -320 + } + } + + test("rightBottom should be -289,-289") { + chunkPos.bounds.rightBottom.asClue { + it.x shouldBeExactly -289 + it.y shouldBeExactly -289 + } + } + } + + context("chunk size 256") { + + val chunkPos = MapChunkPosition(-10, -10, ChunkSize.CHUNK_256) + + test("leftTop should be -2560") { + chunkPos.bounds.leftTop.asClue { + it.x shouldBeExactly -2560 + it.y shouldBeExactly -2560 + } + } + + test("rightBottom should be (-2560 + 255)") { + chunkPos.bounds.rightBottom.asClue { + it.x shouldBeExactly (-2560 + 255) + it.y shouldBeExactly (-2560 + 255) + } + } + } + } + + + context("encode MapTileDictionary") { + val actual = MapTileDictionary( + tilesXY = mapOf( + "-192" to mapOf("-65" to MapTileDictionary.PrototypeKey(2)), + "161" to mapOf( + "-96" to MapTileDictionary.PrototypeKey(1), + "-95" to MapTileDictionary.PrototypeKey(2), + "94" to MapTileDictionary.PrototypeKey(2), + "93" to MapTileDictionary.PrototypeKey(32), + ), + + // unknown prototype + "44" to mapOf("1" to MapTileDictionary.PrototypeKey(44)), + ), + protos = mapOf( + PrototypeId("tile", "water") to MapTileDictionary.PrototypeKey(1), + PrototypeId("tile", "grass-4") to MapTileDictionary.PrototypeKey(2), + PrototypeId("tile", "grass-3") to MapTileDictionary.PrototypeKey(32), + + PrototypeId("tile", "not-used") to MapTileDictionary.PrototypeKey(99), + ) + ) + + test("binary round trip") { + val encoded: ByteArray = kxsBinary.encodeToByteArray(actual) + val decoded: MapTileDictionary = kxsBinary.decodeFromByteArray(encoded) + + decoded.tilesXY shouldContainExactly actual.tilesXY + decoded.protos shouldContainExactly actual.protos + + decoded.toMapTileList() shouldContainExactly actual.toMapTileList() + } + } + + context("verify map chunk 'contains'") { + + context("MapChunkPosition(1, 1)") { + + val chunkPos = MapChunkPosition(1, 1, ChunkSize.CHUNK_032) // from 32,32 to 63,63 + + test("tile outside of chunk") { + val outerTilePos = MapTilePosition(1, 1) + + withClue("$outerTilePos in ${chunkPos.bounds}") { + (outerTilePos in chunkPos) shouldBe false + } + } + + test("tile inside of chunk") { + val innerTilePos = MapTilePosition(34, 33) + + withClue("$innerTilePos in ${chunkPos.bounds}") { + (innerTilePos in chunkPos) shouldBe true + } + } + + test("entity outside of chunk") { + val outerEntityPos = MapEntityPosition(1.0, 1.0) + + withClue("$outerEntityPos in ${chunkPos.bounds}") { + (outerEntityPos !in chunkPos) shouldBe true + (outerEntityPos in chunkPos) shouldBe false + } + } + + test("entity inside of chunk") { + val innerEntityPos = MapEntityPosition(34.0, 33.0) + + withClue("$innerEntityPos in ${chunkPos.bounds}") { + (innerEntityPos !in chunkPos) shouldBe false + (innerEntityPos in chunkPos) shouldBe true + } + } + } + context(" MapChunkPosition(9, -5)") { + val chunkPos2 = MapChunkPosition(9, -5, ChunkSize.CHUNK_032) + + test("tile inside of chunk") { + val innerTilePos = MapTilePosition(288, -160) + + withClue("$innerTilePos in ${chunkPos2.bounds}") { + (innerTilePos in chunkPos2) shouldBe true + } + } + } + } +}) diff --git a/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapChunkPositionTest.kt b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapChunkPositionTest.kt new file mode 100644 index 0000000..b72f45c --- /dev/null +++ b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapChunkPositionTest.kt @@ -0,0 +1,81 @@ +package dev.adamko.kafkatorio.schema.common + +import io.kotest.core.spec.style.FunSpec +import io.kotest.datatest.withData +import io.kotest.matchers.shouldBe +import io.kotest.property.Arb +import io.kotest.property.arbitrary.arbitrary +import io.kotest.property.arbitrary.int +import io.kotest.property.checkAll + +class MapChunkPositionTest : FunSpec({ + + context("check MapChunkPosition.contains()") { + + context("MapChunkPosition(0, 0)") { + + val chunkPos = MapChunkPosition(0, 0, ChunkSize.CHUNK_032) + + test("should contain tiles from (0,0) to (31,31)") { + checkAll(mapTilePositionArb(0..31)) { tilePos -> + (tilePos in chunkPos) shouldBe true + } + } + + test("should not contain tiles below (0,0)") { + checkAll( + mapTilePositionArb(-1000..-1) + ) { tilePos -> + (tilePos in chunkPos) shouldBe false + } + } + + test("should not contain tiles above (31,31)") { + checkAll( + mapTilePositionArb(32..100) + ) { tilePos -> + (tilePos in chunkPos) shouldBe false + } + } + } + context("MapChunkPosition(-10, -10)") { + + val chunkPos = MapChunkPosition(-10, -10, ChunkSize.CHUNK_032) + + test("should contain tiles from (-320,-320) to (-289,-289)") { + checkAll(mapTilePositionArb(-320..-289)) { tilePos -> + (tilePos in chunkPos) shouldBe true + } + } + + test("should not contain tiles below (-320,-320)") { + checkAll( + mapTilePositionArb(-400..-321) + ) { tilePos -> + (tilePos in chunkPos) shouldBe false + } + } + + test("should not contain tiles above (-289,-289)") { + checkAll( + mapTilePositionArb(-288..100) + ) { tilePos -> + (tilePos in chunkPos) shouldBe false + } + } + } + } + + +}) { + companion object { + fun mapTilePositionArb( + range: IntRange = -1000..1000 + ) = arbitrary { + MapTilePosition( + Arb.int(range).bind(), + Arb.int(range).bind(), + ) + } + } +} diff --git a/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapTileDictionaryTest.kt b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapTileDictionaryTest.kt new file mode 100644 index 0000000..0822dc7 --- /dev/null +++ b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapTileDictionaryTest.kt @@ -0,0 +1,42 @@ +package dev.adamko.kafkatorio.schema.common + +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.collections.shouldContainAll + +class MapTileDictionaryTest : FunSpec({ + + context("MapTileDictionary") { + val actual = MapTileDictionary( + tilesXY = mapOf( + "-192" to mapOf("-65" to MapTileDictionary.PrototypeKey(2)), + "161" to mapOf( + "-96" to MapTileDictionary.PrototypeKey(1), + "-95" to MapTileDictionary.PrototypeKey(2), + "94" to MapTileDictionary.PrototypeKey(2), + "93" to MapTileDictionary.PrototypeKey(32), + ), + + // unknown prototype + "44" to mapOf("1" to MapTileDictionary.PrototypeKey(44)), + ), + protos = mapOf( + PrototypeId("tile", "water") to MapTileDictionary.PrototypeKey(1), + PrototypeId("tile", "grass-4") to MapTileDictionary.PrototypeKey(2), + PrototypeId("tile", "grass-3") to MapTileDictionary.PrototypeKey(32), + + PrototypeId("tile", "not-used") to MapTileDictionary.PrototypeKey(99), + ) + ) + + test("toMapTileList") { + actual.toMapTileList() shouldContainAll listOf( + MapTile(-192, -65, PrototypeId("tile", "grass-4")), + + MapTile(161, -96, PrototypeId("tile", "water")), + MapTile(161, -95, PrototypeId("tile", "grass-4")), + MapTile(161, 94, PrototypeId("tile", "grass-4")), + MapTile(161, 93, PrototypeId("tile", "grass-3")), + ) + } + } +}) diff --git a/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapTilePositionTest.kt b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapTilePositionTest.kt new file mode 100644 index 0000000..b5756e7 --- /dev/null +++ b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/MapTilePositionTest.kt @@ -0,0 +1,55 @@ +package dev.adamko.kafkatorio.schema.common + +import dev.adamko.kafkatorio.library.minus +import dev.adamko.kafkatorio.library.plus +import dev.adamko.kafkatorio.schema.common.MapChunkPositionTest.Companion.mapTilePositionArb +import io.kotest.core.spec.style.FunSpec +import io.kotest.property.forAll + +class MapTilePositionTest : FunSpec({ + + context("comparison") { + + test("less than <") { + forAll( + mapTilePositionArb(), + mapTilePositionArb(1..100), + ) { tilePos, delta -> + tilePos < (tilePos + delta) + } + } + + test("equal comparing to ==") { + forAll(mapTilePositionArb()) { tilePos -> + tilePos.compareTo(tilePos) == 0 + } + } + + test("less than or equal to <=") { + forAll( + mapTilePositionArb(), + mapTilePositionArb(0..1), + ) { tilePos, delta -> + tilePos <= (tilePos + delta) + } + } + + test("greater than or equal to >=") { + forAll( + mapTilePositionArb(), + mapTilePositionArb(0..1), + ) { tilePos, delta -> + tilePos >= (tilePos - delta) + } + } + + test("greater than >") { + forAll( + mapTilePositionArb(), + mapTilePositionArb(1..100), + ) { tilePos, delta -> + tilePos > (tilePos - delta) + } + } + } +}) diff --git a/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/PrototypesTest.kt b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/PrototypesTest.kt new file mode 100644 index 0000000..37ed7eb --- /dev/null +++ b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/common/PrototypesTest.kt @@ -0,0 +1,945 @@ +package dev.adamko.kafkatorio.schema.common + +import dev.adamko.kafkatorio.library.jsonMapperKafkatorio +import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket +import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate +import io.kotest.core.spec.style.BehaviorSpec +import io.kotest.inspectors.forOne +import io.kotest.matchers.shouldBe +import io.kotest.matchers.types.shouldBeInstanceOf +import kotlinx.serialization.decodeFromString + + +class PrototypesTest : BehaviorSpec({ + Given("Prototypes Json") { + // language=JSON + val raw = """ +{ + "modVersion": "0.2.4", + "tick": 534, + "data": { + "type": "kafkatorio.packet.instant.PrototypesUpdate", + "prototypes": [ + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/stone-path", + "order": "a[artificial]-a[tier-1]-a[stone-path]", + "layer": 60, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 86, + 82, + 74, + 255 + ], + "canBeMined": true + } + ] + } +} + """.trimIndent() + + Then("expect can be parsed") { + val data = jsonMapperKafkatorio.decodeFromString(raw) + println(data) + } + + } + + Given("Big prototypes json") { + // language=JSON + val raw = """ + { + "data": { + "prototypes": [ + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/stone-path", + "order": "a[artificial]-a[tier-1]-a[stone-path]", + "layer": 60, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 86, + 82, + 74, + 255 + ], + "canBeMined": true + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/concrete", + "order": "a[artificial]-b[tier-2]-a[concrete]", + "layer": 61, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 63, + 61, + 59, + 255 + ], + "canBeMined": true + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/hazard-concrete-left", + "order": "a[artificial]-b[tier-2]-b[hazard-concrete-left]", + "layer": 62, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 176, + 142, + 39, + 255 + ], + "canBeMined": true + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/hazard-concrete-right", + "order": "a[artificial]-b[tier-2]-c[hazard-concrete-right]", + "layer": 62, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 176, + 142, + 39, + 255 + ], + "canBeMined": true + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/refined-concrete", + "order": "a[artificial]-c[tier-3]-a[refined-concrete]", + "layer": 64, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 49, + 48, + 45, + 255 + ], + "canBeMined": true + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/refined-hazard-concrete-left", + "order": "a[artificial]-c[tier-3]-b[refined-hazard-concrete-left]", + "layer": 65, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 116, + 94, + 26, + 255 + ], + "canBeMined": true + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/refined-hazard-concrete-right", + "order": "a[artificial]-c[tier-3]-c[refined-hazard-concrete-right]", + "layer": 65, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 116, + 94, + 26, + 255 + ], + "canBeMined": true + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/landfill", + "order": "a[artificial]-d[utility]-a[landfill]", + "layer": 57, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 57, + 39, + 26, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/acid-refined-concrete", + "order": "a[artificial]-e[color-concrete]-acid", + "layer": 97, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 142, + 194, + 40, + 127 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/black-refined-concrete", + "order": "a[artificial]-e[color-concrete]-black", + "layer": 88, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 25, + 25, + 25, + 127 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/blue-refined-concrete", + "order": "a[artificial]-e[color-concrete]-blue", + "layer": 73, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 39, + 137, + 228, + 127 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/brown-refined-concrete", + "order": "a[artificial]-e[color-concrete]-brown", + "layer": 91, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 76, + 29, + 0, + 127 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/cyan-refined-concrete", + "order": "a[artificial]-e[color-concrete]-cyan", + "layer": 94, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 70, + 192, + 181, + 127 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/green-refined-concrete", + "order": "a[artificial]-e[color-concrete]-green", + "layer": 70, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 23, + 195, + 43, + 127 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/orange-refined-concrete", + "order": "a[artificial]-e[color-concrete]-orange", + "layer": 76, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 221, + 127, + 33, + 127 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/pink-refined-concrete", + "order": "a[artificial]-e[color-concrete]-pink", + "layer": 82, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 236, + 98, + 131, + 127 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/purple-refined-concrete", + "order": "a[artificial]-e[color-concrete]-purple", + "layer": 85, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 123, + 28, + 168, + 127 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/red-refined-concrete", + "order": "a[artificial]-e[color-concrete]-red", + "layer": 67, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 207, + 6, + 0, + 127 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/yellow-refined-concrete", + "order": "a[artificial]-e[color-concrete]-yellow", + "layer": 79, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 212, + 169, + 19, + 127 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/grass-1", + "order": "b[natural]-a[grass]-a[grass-1]", + "layer": 26, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 55, + 53, + 11, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/grass-2", + "order": "b[natural]-a[grass]-b[grass-2]", + "layer": 28, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 66, + 57, + 15, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/grass-3", + "order": "b[natural]-a[grass]-c[grass-3]", + "layer": 29, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 65, + 52, + 28, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/grass-4", + "order": "b[natural]-a[grass]-d[grass-4]", + "layer": 30, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 59, + 40, + 18, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/dry-dirt", + "order": "b[natural]-b[dirt]-a[dry-dirt]", + "layer": 18, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 94, + 66, + 37, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/dirt-1", + "order": "b[natural]-b[dirt]-b[dirt-1]", + "layer": 19, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 141, + 104, + 60, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/dirt-2", + "order": "b[natural]-b[dirt]-c[dirt-2]", + "layer": 20, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 136, + 96, + 59, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/dirt-3", + "order": "b[natural]-b[dirt]-d[dirt-3]", + "layer": 21, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 133, + 92, + 53, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/dirt-4", + "order": "b[natural]-b[dirt]-e[dirt-4]", + "layer": 22, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 103, + 72, + 43, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/dirt-5", + "order": "b[natural]-b[dirt]-f[dirt-5]", + "layer": 23, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 91, + 63, + 38, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/dirt-6", + "order": "b[natural]-b[dirt]-g[dirt-6]", + "layer": 24, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 80, + 55, + 31, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/dirt-7", + "order": "b[natural]-b[dirt]-h[dirt-7]", + "layer": 25, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 80, + 54, + 28, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/sand-1", + "order": "b[natural]-c[sand]-a[sand-1]", + "layer": 8, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 138, + 103, + 58, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/sand-2", + "order": "b[natural]-c[sand]-b[sand-2]", + "layer": 9, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 128, + 93, + 52, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/sand-3", + "order": "b[natural]-c[sand]-c[sand-3]", + "layer": 10, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 115, + 83, + 47, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/red-desert-0", + "order": "b[natural]-d[red-desert]-a[red-desert-0]", + "layer": 31, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 103, + 70, + 32, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/red-desert-1", + "order": "b[natural]-d[red-desert]-b[red-desert-1]", + "layer": 14, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 116, + 81, + 39, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/red-desert-2", + "order": "b[natural]-d[red-desert]-c[red-desert-2]", + "layer": 15, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 116, + 84, + 43, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/red-desert-3", + "order": "b[natural]-d[red-desert]-d[red-desert-3]", + "layer": 16, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 128, + 93, + 52, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/water", + "order": "c[water]-a[water]", + "layer": 3, + "collisionMasks": [ + "doodad-layer", + "item-layer", + "player-layer", + "resource-layer", + "water-tile" + ], + "mapColour": [ + 51, + 83, + 95, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/deepwater", + "order": "c[water]-b[deep-water]", + "layer": 3, + "collisionMasks": [ + "doodad-layer", + "item-layer", + "player-layer", + "resource-layer", + "water-tile" + ], + "mapColour": [ + 38, + 64, + 73, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/water-green", + "order": "c[water]-c[water-green]", + "layer": 3, + "collisionMasks": [ + "doodad-layer", + "item-layer", + "player-layer", + "resource-layer", + "water-tile" + ], + "mapColour": [ + 31, + 48, + 18, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/deepwater-green", + "order": "c[water]-d[deepwater-green]", + "layer": 3, + "collisionMasks": [ + "doodad-layer", + "item-layer", + "player-layer", + "resource-layer", + "water-tile" + ], + "mapColour": [ + 23, + 37, + 16, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/water-shallow", + "order": "c[water]-e[water-shallow]", + "layer": 6, + "collisionMasks": [ + "item-layer", + "object-layer", + "resource-layer", + "water-tile" + ], + "mapColour": [ + 82, + 98, + 92, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/water-mud", + "order": "c[water]-g[water-mud]", + "layer": 7, + "collisionMasks": [ + "item-layer", + "object-layer", + "resource-layer", + "water-tile" + ], + "mapColour": [ + 65, + 89, + 90, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/nuclear-ground", + "order": "d[destruction]-a[nuclear]-a[nuclear-ground]", + "layer": 33, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 48, + 40, + 35, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/water-wube", + "order": "x[wube]-a[water-wube]", + "layer": 2, + "collisionMasks": [ + "doodad-layer", + "item-layer", + "player-layer", + "resource-layer", + "water-tile" + ], + "mapColour": [ + 0, + 0, + 0, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/tile-unknown", + "order": "z-a", + "layer": 0, + "collisionMasks": {}, + "mapColour": [ + 0, + 0, + 0, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/out-of-map", + "order": "z[other]-a[out-of-map]", + "layer": 0, + "collisionMasks": [ + "doodad-layer", + "floor-layer", + "ground-tile", + "item-layer", + "object-layer", + "player-layer", + "resource-layer", + "water-tile" + ], + "mapColour": [ + 0, + 0, + 0, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/lab-dark-1", + "order": "z[other]-b[lab]-a[lab-dark-1]", + "layer": 70, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 49, + 49, + 49, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/lab-dark-2", + "order": "z[other]-b[lab]-b[lab-dark-2]", + "layer": 70, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 0, + 0, + 0, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/lab-white", + "order": "z[other]-b[lab]-c[lab-white]", + "layer": 70, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 255, + 255, + 255, + 255 + ], + "canBeMined": false + }, + { + "type": "kafkatorio.prototype.MapTile", + "protoId": "tile/tutorial-grid", + "order": "z[other]-c[tutorial]-a[tutorial-grid]", + "layer": 55, + "collisionMasks": [ + "ground-tile" + ], + "mapColour": [ + 122, + 122, + 122, + 255 + ], + "canBeMined": false + } + ], + "type": "kafkatorio.packet.instant.PrototypesUpdate" + }, + "modVersion": "0.6.1", + "tick": 58468 + } + """.trimIndent() + + Then("expect can be parsed") { + val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(raw) +// println(packet) + + packet.data.shouldBeInstanceOf() + .prototypes + .forOne { + it.shouldBeInstanceOf() + it.protoId shouldBe PrototypeId("tile", "tutorial-grid") + it.order shouldBe "z[other]-c[tutorial]-a[tutorial-grid]" + it.layer shouldBe 55u + it.collisionMasks shouldBe listOf("ground-tile") + it.mapColour shouldBe Colour(122f, 122f, 122f, 255f) + it.canBeMined shouldBe false + } + } + } +}) diff --git a/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/packets/EntityUpdateTest.kt b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/packets/EntityUpdateTest.kt new file mode 100644 index 0000000..dd93cdc --- /dev/null +++ b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/packets/EntityUpdateTest.kt @@ -0,0 +1,47 @@ +package dev.adamko.kafkatorio.schema.packets + +import dev.adamko.kafkatorio.library.jsonMapperKafkatorio +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.types.shouldBeInstanceOf +import kotlinx.serialization.decodeFromString + +class EntityUpdateTest : FunSpec({ + + context("EntityUpdate packet") { + /*language=json*/ + val json = """ + { + "data": { + "type": "kafkatorio.packet.keyed.EntityUpdate", + "key": { + "protoId": "entity/assembling-machine-2", + "unitNumber": 4622 + }, + "events": { + "on_built_entity": [ + 38023 + ] + }, + "chunkPosition": [ + -13.5, + 4.5 + ], + "health": 350, + "isActive": true, + "isRotatable": true, + "lastUser": 1 + }, + "modVersion": "0.4.0", + "tick": 38388 + } + """.trimIndent() + test("decode") { + val entityUpdate: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json) + entityUpdate.data.shouldBeInstanceOf() + +// entityUpdate.health.shouldNotBeNull().shouldBeExactly(350f) + } + + } + +}) diff --git a/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/packets/MapChunkTileUpdateTest.kt b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/packets/MapChunkTileUpdateTest.kt new file mode 100644 index 0000000..fa209b7 --- /dev/null +++ b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/packets/MapChunkTileUpdateTest.kt @@ -0,0 +1,94 @@ +package dev.adamko.kafkatorio.schema.packets + +import dev.adamko.kafkatorio.library.LuaJsonList +import dev.adamko.kafkatorio.library.jsonMapperKafkatorio +import dev.adamko.kafkatorio.schema.common.ChunkSize +import dev.adamko.kafkatorio.schema.common.EventName +import dev.adamko.kafkatorio.schema.common.MapChunkPosition +import dev.adamko.kafkatorio.schema.common.MapTileDictionary +import dev.adamko.kafkatorio.schema.common.PrototypeId +import dev.adamko.kafkatorio.schema.common.SurfaceIndex +import dev.adamko.kafkatorio.schema.common.tick +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe +import kotlinx.serialization.decodeFromString + +class MapChunkTileUpdateTest : FunSpec({ + + context("MapChunkTileUpdate update") { + //language=json + val json = """ +{ + "data": { + "type": "kafkatorio.packet.keyed.MapChunkTileUpdate", + "key": { + "surfaceIndex": 1, + "chunkPosition": [ + -6, + -3, + "CHUNK_032" + ] + }, + "tileDictionary": { + "tilesXY": { + "-192": { + "-65": 2 + }, + "161": { + "-96": 1, + "-95": 2, + "94": 2, + "93": 32 + } + }, + "protos": { + "tile/water": 1, + "tile/grass-4": 2, + "tile/grass-3": 32 + } + }, + "events": { + "on_chunk_generated": [1] + } + }, + "modVersion": "0.4.0", + "tick": 36 +} + """.trimIndent() + + val expected = KafkatorioPacket( + tick = 36u.tick, + modVersion = "0.4.0", + data = MapChunkTileUpdate( + key = MapChunkTileUpdateKey( + MapChunkPosition(-6, -3, ChunkSize.CHUNK_032), + SurfaceIndex(1u), + ), + events = mapOf( + EventName("on_chunk_generated") to LuaJsonList(listOf(1u.tick)) + ), + tileDictionary = MapTileDictionary( + tilesXY = mapOf( + "-192" to mapOf("-65" to MapTileDictionary.PrototypeKey(2)), + "161" to mapOf( + "-96" to MapTileDictionary.PrototypeKey(1), + "-95" to MapTileDictionary.PrototypeKey(2), + "94" to MapTileDictionary.PrototypeKey(2), + "93" to MapTileDictionary.PrototypeKey(32), + ), + ), + protos = mapOf( + PrototypeId("tile", "water") to MapTileDictionary.PrototypeKey(1), + PrototypeId("tile", "grass-4") to MapTileDictionary.PrototypeKey(2), + PrototypeId("tile", "grass-3") to MapTileDictionary.PrototypeKey(32), + ) + ) + ) + ) + + test("decode") { + val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json) + packet shouldBe expected + } + } +}) diff --git a/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/packets/UpdatePacketsTest.kt b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/packets/UpdatePacketsTest.kt new file mode 100644 index 0000000..a983c03 --- /dev/null +++ b/modules/events-library/src/commonTest/kotlin/dev/adamko/kafkatorio/schema/packets/UpdatePacketsTest.kt @@ -0,0 +1,247 @@ +package dev.adamko.kafkatorio.schema.packets + +import dev.adamko.kafkatorio.library.LuaJsonList +import dev.adamko.kafkatorio.library.jsonMapperKafkatorio +import dev.adamko.kafkatorio.schema.common.Colour +import dev.adamko.kafkatorio.schema.common.EntityIdentifiersData +import dev.adamko.kafkatorio.schema.common.EventName +import dev.adamko.kafkatorio.schema.common.ForceIndex +import dev.adamko.kafkatorio.schema.common.MapEntityPosition +import dev.adamko.kafkatorio.schema.common.PlayerIndex +import dev.adamko.kafkatorio.schema.common.PrototypeId +import dev.adamko.kafkatorio.schema.common.SurfaceIndex +import dev.adamko.kafkatorio.schema.common.Tick +import dev.adamko.kafkatorio.schema.common.UnitNumber +import dev.adamko.kafkatorio.schema.common.tick +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.shouldBe +import kotlinx.serialization.decodeFromString +import kotlinx.serialization.encodeToString + + +class UpdatePacketsTest : FunSpec({ + + context("player update packet") { + // language=JSON + val json = """ + { + "tick": 66, + "modVersion": "0.3.2", + "data": { + "type": "kafkatorio.packet.keyed.PlayerUpdate", + "key": {"index": 1}, + "afkTime": 0, + "chatColour": [1, 0.4, 0.6, 1], + "colour": [0.8, 0.5, 0.2, 0.5], + "events": { + "on_player_changed_position": [7, 99], + "on_player_joined_game": [14] + }, + "forceIndex": 1, + "isAdmin": true, + "isConnected": true, + "isShowOnMap": true, + "lastOnline": 0, + "name": "fredthedeadhead", + "onlineTime": 0, + "position": [ + -58, + 13 + ], + "tag": "" + } + } + """.trimIndent() + + test("decode") { + val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json) + + packet shouldBe KafkatorioPacket( + modVersion = "0.3.2", + tick = Tick(66u), + data = PlayerUpdate( + key = PlayerUpdateKey(PlayerIndex(1u)), + afkTime = Tick(0u), + bannedReason = null, + characterUnitNumber = null, + chatColour = Colour(red = 1f, green = 0.4f, blue = 0.6f, alpha = 1f), + colour = Colour(red = 0.8f, green = 0.5f, blue = 0.2f, alpha = 0.5f), + diedCause = null, + disconnectReason = null, + events = mapOf( + EventName("on_player_changed_position") to LuaJsonList(listOf(7u.tick, 99u.tick)), + EventName("on_player_joined_game") to LuaJsonList(listOf(14u.tick)), + ), + forceIndex = ForceIndex(1u), + isAdmin = true, + isConnected = true, +// isRemoved = false, + isShowOnMap = true, + isSpectator = false, + kickedReason = null, + lastOnline = Tick(0u), + name = "fredthedeadhead", + onlineTime = Tick(0u), + position = MapEntityPosition(-58.0, 13.0), + surfaceIndex = null, + tag = "", + ticksToRespawn = null, + ) + ) + } + + test("encode") { + val v = KafkatorioPacket( + modVersion = "0.3.2", + tick = Tick(66u), + data = PlayerUpdate( + key = PlayerUpdateKey(PlayerIndex(1u)), + characterUnitNumber = null, + chatColour = null, + colour = null, + name = "fredthedeadhead", + afkTime = Tick(0u), + ticksToRespawn = null, + forceIndex = null, +// isAdmin = , +// isConnected = , + isShowOnMap = true, + isSpectator = false, + lastOnline = Tick(0u), + onlineTime = Tick(0u), + position = MapEntityPosition(-58.0, 13.0), + surfaceIndex = null, + tag = null, + diedCause = null, + bannedReason = null, + kickedReason = null, + disconnectReason = null, +// isRemoved = null, + ) + ) + + val string = jsonMapperKafkatorio.encodeToString(v) + // language=JSON + string shouldBe """ + { + "modVersion": "0.3.2", + "tick": 66, + "data": { + "type": "kafkatorio.packet.keyed.PlayerUpdate", + "key": { + "index": 1 + }, + "name": "fredthedeadhead", + "afkTime": 0, + "isShowOnMap": true, + "lastOnline": 0, + "onlineTime": 0, + "position": [ + -58.0, + 13.0 + ] + } + } + """.trimIndent() + } + } + + context("player died") { + // language=JSON + val json = """ + { + "tick": 227934, + "modVersion": "0.3.2", + "data": { + "type": "kafkatorio.packet.keyed.PlayerUpdate", + "key": { + "index": 1 + }, + "lastOnline": 227932, + "onlineTime": 227888, + "afkTime": 324, + "isConnected": true, + "diedCause": { + "unitNumber": 66, + "protoId": "unit/small-biter" + }, + "events": { + "on_player_died": [2] + } + } + } + """.trimIndent() + + test("decode") { + val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json) + + packet shouldBe KafkatorioPacket( + modVersion = "0.3.2", + tick = 227934u.tick, + data = PlayerUpdate( + afkTime = 324u.tick, + bannedReason = null, + characterUnitNumber = null, + chatColour = null, + colour = null, + diedCause = EntityIdentifiersData( + unitNumber = UnitNumber(66u), + protoId = PrototypeId("unit", "small-biter"), + ), + disconnectReason = null, + events = mapOf( + EventName("on_player_died") to LuaJsonList(listOf(2u.tick)), + ), + forceIndex = null, + key = PlayerUpdateKey(PlayerIndex(1u)), +// isAdmin = , + isConnected = true, +// isRemoved = null, +// isShowOnMap = , +// isSpectator = , + kickedReason = null, + lastOnline = 227932u.tick, + name = null, + onlineTime = 227888u.tick, + position = null, + surfaceIndex = null, + tag = null, + ticksToRespawn = null, + ) + ) + } + } + + context("surface update") { + //language=json + val json = """ + { + "data": { + "type": "kafkatorio.packet.instant.SurfaceUpdate", + "name": "nauvis", + "index": 1, + "daytime": 0.73 + }, + "modVersion": "0.3.2", + "tick": 176000 + } + """.trimIndent() + + val expected = KafkatorioPacket( + tick = Tick(176000u), + modVersion = "0.3.2", + data = SurfaceUpdate( + name = "nauvis", + index = SurfaceIndex(1u), + daytime = 0.73, + ) + ) + + println(jsonMapperKafkatorio.encodeToString(expected)) + + test("decode") { + val packet: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(json) + packet shouldBe expected + } + } +}) diff --git a/modules/events-library/src/jvmMain/kotlin/dev/adamko/kafkatorio/library/FileEventsFlow.kt b/modules/events-library/src/jvmMain/kotlin/dev/adamko/kafkatorio/library/FileEventsFlow.kt new file mode 100644 index 0000000..2502da5 --- /dev/null +++ b/modules/events-library/src/jvmMain/kotlin/dev/adamko/kafkatorio/library/FileEventsFlow.kt @@ -0,0 +1,193 @@ +package dev.adamko.kafkatorio.library + +import java.io.File +import java.nio.file.FileSystems +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.StandardWatchEventKinds.ENTRY_CREATE +import java.nio.file.StandardWatchEventKinds.ENTRY_DELETE +import java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY +import java.nio.file.WatchEvent +import java.nio.file.WatchKey +import java.nio.file.WatchService +import kotlin.coroutines.CoroutineContext +import kotlin.io.path.isReadable +import kotlin.time.Duration.Companion.seconds +import kotlinx.coroutines.CoroutineExceptionHandler +import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.channels.BufferOverflow +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.asFlow +import kotlinx.coroutines.flow.cancellable +import kotlinx.coroutines.flow.debounce +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.flatMapConcat +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.mapNotNull +import kotlinx.coroutines.flow.runningFold +import kotlinx.coroutines.flow.update +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import kotlinx.coroutines.yield + + +fun File.fileEventsFlow() = FileEventsFlow( + root = this.toPath(), +) + +fun Path.fileEventsFlow() = FileEventsFlow( + root = this, +) + + +/** [SharedFlow] wrapper for Java's [WatchService] */ +class FileEventsFlow private constructor( + private val root: Path, + private val fileEvents: MutableSharedFlow, +) : SharedFlow by fileEvents, CoroutineScope { + + constructor(root: Path) : this(root, MutableSharedFlow(0, Int.MAX_VALUE, BufferOverflow.SUSPEND)) + + override val coroutineContext: CoroutineContext = + CoroutineName("FileEventsFlow") + + Dispatchers.Unconfined + + CoroutineExceptionHandler { _, e -> + println("handling exception in FileEventsFlow") + e.printStackTrace() + watchService.close() + watchKeys.update { + it.cancelAll() + emptyList() + } + } + + + private val watchService: WatchService = FileSystems.getDefault().newWatchService() + + private val watchKeys: MutableStateFlow> = MutableStateFlow(emptyList()) + + + init { + println("launching FileEventsFlow... $root") + registerPaths() + pollFileEvents() + + launch { + fileEvents.emit(KWatchEvent.Initialized) + } + + println("launched FileEventsFlow $root") + + root.toFile().walk() +// .filter { it.isFile } + .onEach { + launch { + fileEvents.emit(KWatchEvent.Created(it.toPath())) + } + } + .count() + .let { + println("initializing KWatchEvent.Created $it") + } + } + + + /** Watch for any file tree changes and re-register the [watchKeys] */ + private fun registerPaths() = launch { + println("launching registerPaths") + fileEvents +// .onEach { println("file event! $it") } + .filter { event -> + when (event) { + is KWatchEvent.Initialized -> true + + is KWatchEvent.Created -> event.path.isDirectory + is KWatchEvent.Deleted -> event.path.isDirectory + + is KWatchEvent.Modified -> false + } + }.debounce(1.seconds) + .runningFold(emptyList()) { previousKeys, directoryTreeAlteredEvent -> + println("re-registering paths $directoryTreeAlteredEvent") + + previousKeys.cancelAll() + + root.toFile().walk() + .filter { it.isDirectory } + .map { +// println("re-registering watch on $it") + it.toPath().register(watchService, ENTRY_CREATE, ENTRY_MODIFY, ENTRY_DELETE) + } + .toList() + .also { + println("${it.count()} registered watches") + } + } + .cancellable() + .collect(watchKeys) + } + + + /** Poll [watchService] for updates while [coroutineContext] is active. */ + private fun pollFileEvents() = launch { + flow { + while (coroutineContext.isActive) { + emit( + withContext(Dispatchers.IO) { watchService.take() } + ) + println("emitted watchService.take()") + yield() + } + }.mapNotNull { monitorKey -> + when (val keyPath = monitorKey.watchable()) { + is Path -> monitorKey to keyPath + else -> null + } + }.filter { it.second.isReadable() } + .flatMapConcat { (monitorKey: WatchKey, keyPath: Path) -> + val events = monitorKey.pollEvents() + monitorKey.reset() + events + .onEach { println("monitorKey event $it") } + .filter { it.context() as? Path != null } + .mapNotNull { event -> + val eventPath = keyPath.resolve(event.context() as Path) + + when (event.kind()) { + ENTRY_CREATE -> KWatchEvent.Created(eventPath) + ENTRY_DELETE -> KWatchEvent.Deleted(eventPath) + ENTRY_MODIFY -> KWatchEvent.Modified(eventPath) + else -> null + } + }.asFlow() + }.cancellable() + .collect(fileEvents) + } + + companion object { + private val Path.isDirectory: Boolean get() = Files.isDirectory(this) + + private fun List.cancelAll() = forEach { it.cancel(); it.pollEvents() } + } +} + +/** Wrapper around [WatchEvent] that comes with properly resolved absolute path */ +sealed interface KWatchEvent { + + object Initialized : KWatchEvent + + sealed interface PathEvent : KWatchEvent { + /** path of modified file or directory */ + val path: Path + } + + data class Created(override val path: Path) : PathEvent + data class Modified(override val path: Path) : PathEvent + data class Deleted(override val path: Path) : PathEvent + +} diff --git a/modules/events-library/src/jvmMain/kotlin/dev/adamko/kafkatorio/schema/kt2ts2.kt b/modules/events-library/src/jvmMain/kotlin/dev/adamko/kafkatorio/schema/kt2ts2.kt new file mode 100644 index 0000000..903bc78 --- /dev/null +++ b/modules/events-library/src/jvmMain/kotlin/dev/adamko/kafkatorio/schema/kt2ts2.kt @@ -0,0 +1,112 @@ +package dev.adamko.kafkatorio.schema + +import dev.adamko.kafkatorio.schema.common.PlayerIndex +import dev.adamko.kafkatorio.schema.common.SurfaceIndex +import dev.adamko.kafkatorio.schema.common.UnitNumber +import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket +import dev.adamko.kxstsgen.KxsTsConfig +import dev.adamko.kxstsgen.KxsTsConfig.TypeAliasTypingConfig.BrandTyping +import dev.adamko.kxstsgen.KxsTsGenerator +import dev.adamko.kxstsgen.core.TsDeclaration.TsTypeAlias +import dev.adamko.kxstsgen.core.TsElementId +import dev.adamko.kxstsgen.core.TsLiteral +import dev.adamko.kxstsgen.core.TsSourceCodeGenerator +import dev.adamko.kxstsgen.core.TsTypeRef +import kotlin.io.path.Path +import kotlin.io.path.createDirectories +import kotlinx.serialization.builtins.serializer +import org.intellij.lang.annotations.Language + + +fun main(args: Array) { + val outputFilename = args.firstOrNull() + + val config = KxsTsConfig( + typeAliasTyping = BrandTyping + ) + + val gen2 = KxsTsGenerator( + config = config, + sourceCodeGenerator = MySourceCodeGenerator(config), + ) + +// gen2.serializerDescriptorOverrides += mapOf( +////@formatter:off +// SurfaceIndex.serializer() to emptySet(), +// PlayerIndex.serializer() to emptySet(), +// UnitNumber.serializer() to emptySet(), +////@formatter:on +// ) + + gen2.descriptorOverrides += mapOf( + //@formatter:off + Float .serializer().descriptor to TsTypeAlias(TsElementId("kotlin.Float" ), TsTypeRef.Literal(TsLiteral.Custom("float" ), false)), + Double.serializer().descriptor to TsTypeAlias(TsElementId("kotlin.Double"), TsTypeRef.Literal(TsLiteral.Custom("double"), false)), + Int .serializer().descriptor to TsTypeAlias(TsElementId("kotlin.Int" ), TsTypeRef.Literal(TsLiteral.Custom("int" ), false)), + Byte .serializer().descriptor to TsTypeAlias(TsElementId("kotlin.Byte" ), TsTypeRef.Literal(TsLiteral.Custom("int8" ), false)), + UInt .serializer().descriptor to TsTypeAlias(TsElementId("kotlin.UInt" ), TsTypeRef.Literal(TsLiteral.Custom("uint" ), false)), + UByte .serializer().descriptor to TsTypeAlias(TsElementId("kotlin.UByte" ), TsTypeRef.Literal(TsLiteral.Custom("uint8" ), false)), + UShort.serializer().descriptor to TsTypeAlias(TsElementId("kotlin.UShort"), TsTypeRef.Literal(TsLiteral.Custom("uint16"), false)), + ULong .serializer().descriptor to TsTypeAlias(TsElementId("kotlin.ULong" ), TsTypeRef.Literal(TsLiteral.Custom("uint64"), false)), + + PlayerIndex.serializer().descriptor to TsTypeAlias(TsElementId("PlayerIndex" ), TsTypeRef.Literal(TsLiteral.Custom("PlayerIndex"), false)), + SurfaceIndex.serializer().descriptor to TsTypeAlias(TsElementId("SurfaceIndex" ), TsTypeRef.Literal(TsLiteral.Custom("SurfaceIndex"), false)), + UnitNumber.serializer().descriptor to TsTypeAlias(TsElementId("UnitNumber" ), TsTypeRef.Literal(TsLiteral.Custom("UnitNumber"), false)), + //@formatter:on + ) + + val definitions = gen2.generate( + KafkatorioPacket.serializer(), + ) + + + when (outputFilename) { + null -> println(definitions) + else -> { + val outPath = Path(outputFilename) + outPath.createDirectories() + val outFile = outPath.resolve("kafkatorio-schema.ts").toFile() + outFile.printWriter().use { + it.println(kt2tsHeader) + it.print(definitions) + } + } + } +} + +@Language("TypeScript") +val kt2tsHeader = """ + |// Generated by kxs-ts-gen - do not edit this file manually + | +""".trimMargin() + + +class MySourceCodeGenerator( + config: KxsTsConfig, +) : TsSourceCodeGenerator.Default(config) { + + private val seenTypeAliases: MutableSet = mutableSetOf() + + override fun generateTypeAlias(element: TsTypeAlias): String { + + if (!seenTypeAliases.add(element.id)) { + return "" + } + + return if (element.id.name in listOf("PlayerIndex", "SurfaceIndex", "UnitNumber")) { + "" + } else if ( + (element.typeRef as? TsTypeRef.Literal)?.element is TsLiteral.Custom + || element.id.name == "Tick" + || element.id.name == "FactorioEntityUpdateEntityDictionary" + || element.id.name == "FactorioEntityUpdateResourceAmountDictionary" + ) { + val aliasedRef = generateTypeReference(element.typeRef) + """ + |export type ${element.id.name} = ${aliasedRef}; + """.trimMargin() + } else { + super.generateTypeAlias(element) + } + } +} diff --git a/modules/events-library/src/jvmTest/kotlin/dev/adamko/kafkatorio/library/KxsBinaryTests.kt b/modules/events-library/src/jvmTest/kotlin/dev/adamko/kafkatorio/library/KxsBinaryTests.kt new file mode 100644 index 0000000..c7a00ac --- /dev/null +++ b/modules/events-library/src/jvmTest/kotlin/dev/adamko/kafkatorio/library/KxsBinaryTests.kt @@ -0,0 +1,329 @@ +package dev.adamko.kafkatorio.library + +import dev.adamko.kafkatorio.schema.common.ChunkSize +import dev.adamko.kafkatorio.schema.common.ColourHex +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.MapChunkPosition +import dev.adamko.kafkatorio.schema.common.MapTilePosition +import dev.adamko.kafkatorio.schema.common.ServerMapChunkId +import dev.adamko.kafkatorio.schema.common.ServerMapTileLayer +import dev.adamko.kafkatorio.schema.common.SurfaceIndex +import io.kotest.assertions.withClue +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.collections.shouldContainExactly +import io.kotest.matchers.comparables.shouldBeEqualComparingTo +import io.kotest.matchers.equality.shouldBeEqualToComparingFields +import io.kotest.matchers.ints.shouldBeExactly +import io.kotest.matchers.longs.shouldBeExactly +import io.kotest.matchers.shouldBe +import io.kotest.property.Arb +import io.kotest.property.arbitrary.boolean +import io.kotest.property.arbitrary.booleanArray +import io.kotest.property.arbitrary.byte +import io.kotest.property.arbitrary.byteArray +import io.kotest.property.arbitrary.char +import io.kotest.property.arbitrary.charArray +import io.kotest.property.arbitrary.double +import io.kotest.property.arbitrary.doubleArray +import io.kotest.property.arbitrary.float +import io.kotest.property.arbitrary.floatArray +import io.kotest.property.arbitrary.int +import io.kotest.property.arbitrary.intArray +import io.kotest.property.arbitrary.long +import io.kotest.property.arbitrary.longArray +import io.kotest.property.arbitrary.positiveInt +import io.kotest.property.arbitrary.short +import io.kotest.property.arbitrary.shortArray +import io.kotest.property.arbitrary.string +import io.kotest.property.arbitrary.uByte +import io.kotest.property.arbitrary.uInt +import io.kotest.property.arbitrary.uLong +import io.kotest.property.arbitrary.uShort +import io.kotest.property.checkAll +import kotlinx.serialization.Serializable +import kotlinx.serialization.builtins.serializer +import kotlinx.serialization.decodeFromByteArray +import kotlinx.serialization.decodeFromString +import kotlinx.serialization.encodeToByteArray +import kotlinx.serialization.encodeToString + + +class KxsBinaryTests : FunSpec({ + + test("byte array") { + val ba = byteArrayOf( + 4, 116, 101, 115, 116, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 1 + ) + + val result = kxsBinary.decodeFromByteArray(ServerMapChunkId.serializer(), ba) + + withClue(ba.toString(Charsets.UTF_8)) { + + result shouldBeEqualToComparingFields ServerMapChunkId( + serverId = FactorioServerId("test"), + layer = ServerMapTileLayer.TERRAIN, + chunkPosition = MapChunkPosition(1, 2, ChunkSize.CHUNK_064), + surfaceIndex = SurfaceIndex(1u), + ) + + } + } + + test("encoding") { + val ba = kxsBinary.encodeToByteArray( + ServerMapChunkId( + serverId = FactorioServerId("test"), + layer = ServerMapTileLayer.TERRAIN, + chunkPosition = MapChunkPosition(1, 2, ChunkSize.CHUNK_064), + surfaceIndex = SurfaceIndex(1u), + ) + ) + + withClue(ba.toString(Charsets.UTF_8)) { + ba shouldBe byteArrayOf( + 4, 116, 101, 115, 116, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 1 + ) + } + } + + context("inline value class") { + val uuid = "fa858d73-6205-44cf-aeeb-6bbf3148c4a7" + //@formatter:off + val expectedBytes = byteArrayOf( + 36, 102, 97, 56, 53, 56, 100, 55, 51, 45, 54, 50, 48, 53, 45, 52, 52, 99, + 102, 45, 97, 101, 101, 98, 45, 54, 98, 98, 102, 51, 49, 52, 56, 99, 52, 97, 55, + ) + //@formatter:on + + test("encode") { + val ba = kxsBinary.encodeToByteArray(FactorioServerId(uuid)) + + withClue(ba.toString(Charsets.UTF_8)) { + ba shouldBe expectedBytes + } + } + test("decode") { + val ba = kxsBinary.encodeToByteArray(FactorioServerId(uuid)) + val id: FactorioServerId = kxsBinary.decodeFromByteArray(ba) + + id shouldBeEqualToComparingFields FactorioServerId(uuid) + } + } + + context("ServerMapChunkTiles") { + val initial = ServerMapChunkTiles( + ServerMapChunkId( + serverId = FactorioServerId("server-id"), + layer = ServerMapTileLayer.TERRAIN, + chunkPosition = MapChunkPosition(33, 44, ChunkSize.CHUNK_032), + surfaceIndex = SurfaceIndex(4u), + ), + mapOf( + MapTilePosition(1, 2) to ColourHex(1u, 2u, 3u, 4u), + ) + ) + + test("!json round trip") { + val jsonEncoded = jsonMapperKafkatorio.encodeToString(initial) + val jsonDecoded = + jsonMapperKafkatorio.decodeFromString>(jsonEncoded) + + jsonDecoded shouldBeEqualToComparingFields initial + } + + test("binary round trip") { + val binaryEncoded = kxsBinary.encodeToByteArray(initial) + val binaryDecoded = + kxsBinary.decodeFromByteArray>(binaryEncoded) + + binaryDecoded shouldBeEqualToComparingFields initial + } + } + + context("primitives round trip") { + test("double") { + checkAll(Arb.double()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: Double = kxsBinary.decodeFromByteArray(encoded) + decoded shouldBeEqualComparingTo input + } + } + + test("float") { + checkAll(Arb.float()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: Float = kxsBinary.decodeFromByteArray(encoded) + decoded shouldBeEqualComparingTo input + } + } + + test("int") { + checkAll(Arb.int()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: Int = kxsBinary.decodeFromByteArray(encoded) + decoded shouldBeExactly input + } + } + + test("long") { + checkAll(Arb.long()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: Long = kxsBinary.decodeFromByteArray(encoded) + decoded shouldBeExactly input + } + } + + test("short") { + checkAll(Arb.short()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: Short = kxsBinary.decodeFromByteArray(encoded) + decoded shouldBeEqualComparingTo input + } + } + + test("byte") { + checkAll(Arb.byte()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: Byte = kxsBinary.decodeFromByteArray(encoded) + decoded shouldBeEqualComparingTo input + } + } + + test("boolean") { + checkAll(Arb.boolean()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: Boolean = kxsBinary.decodeFromByteArray(encoded) + decoded shouldBeEqualComparingTo input + } + } + + test("char") { + checkAll(Arb.char()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: Char = kxsBinary.decodeFromByteArray(encoded) + decoded shouldBeEqualComparingTo input + } + } + + test("string") { + checkAll(Arb.string()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: String = kxsBinary.decodeFromByteArray(encoded) + decoded shouldBeEqualComparingTo input + } + } + } + + + @OptIn(ExperimentalUnsignedTypes::class) + context("unsigned numbers round trip") { + test("uint") { + checkAll(Arb.uInt()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(UInt.serializer(), input) + val decoded: UInt = kxsBinary.decodeFromByteArray(UInt.serializer(), encoded) + decoded shouldBeEqualComparingTo input + } + } + + test("ulong") { + checkAll(Arb.uLong()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(ULong.serializer(), input) + val decoded: ULong = kxsBinary.decodeFromByteArray(ULong.serializer(), encoded) + decoded shouldBeEqualComparingTo input + } + } + + test("ushort") { + checkAll(Arb.uShort()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(UShort.serializer(), input) + val decoded: UShort = kxsBinary.decodeFromByteArray(UShort.serializer(), encoded) + decoded shouldBeEqualComparingTo input + } + } + + test("ubyte") { + checkAll(Arb.uByte()) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(UByte.serializer(), input) + val decoded: UByte = kxsBinary.decodeFromByteArray(UByte.serializer(), encoded) + decoded shouldBeEqualComparingTo input + } + } + } + + context("primitive arrays round trip") { + test("double array") { + checkAll(Arb.doubleArray(Arb.positiveInt(50), Arb.double())) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: DoubleArray = kxsBinary.decodeFromByteArray(encoded) + decoded.asList() shouldContainExactly input.asList() + } + } + + test("float array") { + checkAll(Arb.floatArray(Arb.positiveInt(50), Arb.float())) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: FloatArray = kxsBinary.decodeFromByteArray(encoded) + decoded.asList() shouldContainExactly input.asList() + } + } + + test("int array") { + checkAll(Arb.intArray(Arb.positiveInt(50), Arb.int())) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: IntArray = kxsBinary.decodeFromByteArray(encoded) + decoded.asList() shouldContainExactly input.asList() + } + } + + test("long array") { + checkAll(Arb.longArray(Arb.positiveInt(50), Arb.long())) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: LongArray = kxsBinary.decodeFromByteArray(encoded) + decoded.asList() shouldContainExactly input.asList() + } + } + + test("short array") { + checkAll(Arb.shortArray(Arb.positiveInt(50), Arb.short())) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: ShortArray = kxsBinary.decodeFromByteArray(encoded) + decoded.asList() shouldContainExactly input.asList() + } + } + + test("byte array") { + checkAll(Arb.byteArray(Arb.positiveInt(50), Arb.byte())) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: ByteArray = kxsBinary.decodeFromByteArray(encoded) + decoded.asList() shouldContainExactly input.asList() + } + } + + test("boolean array") { + checkAll(Arb.booleanArray(Arb.positiveInt(50), Arb.boolean())) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: BooleanArray = kxsBinary.decodeFromByteArray(encoded) + decoded.asList() shouldContainExactly input.asList() + } + } + + test("char array") { + checkAll(Arb.charArray(Arb.positiveInt(50), Arb.char())) { input -> + val encoded: ByteArray = kxsBinary.encodeToByteArray(input) + val decoded: CharArray = kxsBinary.decodeFromByteArray(encoded) + decoded.asList() shouldContainExactly input.asList() + } + } + } +}) { + + @Serializable + data class ServerMapChunkTiles( + val chunkId: ServerMapChunkId, + val map: Map, + ) { + operator fun plus(other: ServerMapChunkTiles) = copy(map = map + other.map) + } + + +} diff --git a/modules/events-mod/build.gradle.kts b/modules/events-mod/build.gradle.kts new file mode 100644 index 0000000..82de877 --- /dev/null +++ b/modules/events-mod/build.gradle.kts @@ -0,0 +1,154 @@ +import dev.adamko.gradle.factorio.mod_portal.FactorioModPublishTask +import dev.adamko.gradle.factorio.typescriptAttributes +import kafkatorio.tasks.TypeScriptToLuaTask +import kotlinx.serialization.json.put +import kotlinx.serialization.json.putJsonObject + +plugins { + id("kafkatorio.conventions.lang.node") + id("dev.adamko.factorio-mod") + distribution + idea +} + +description = "Sends in-game information to a server over the internet (requires additional setup)" + + +factorioMod { + modName.set("kafkatorio-events") + modTitle.set("Kafkatorio Events") + modAuthor.set("adam@adamko.dev") + factorioCompatibility.set(libs.versions.factorio.map { it.substringBeforeLast(".") }) +} + +val licenseFile: RegularFile by rootProject.extra + +node { + nodeProjectDir.set(layout.projectDirectory) +} + + +val typescriptEventsSchema: Configuration by configurations.creating { + description = "Fetch the TypeScript schema from the event-schema subproject" + asConsumer() + typescriptAttributes(objects) +} + + +dependencies { + typescriptEventsSchema(projects.modules.eventsLibrary) +} + + +val typescriptToLua by tasks.registering(TypeScriptToLuaTask::class) { + dependsOn( + tasks.npmInstall, + installEventsTsSchema, + tasks.updatePackageJson, + ) + + inputs.file(tasks.updatePackageJson.map { it.packageJsonFile }) + + sourceFiles.from(factorioMod.mainSources.typescript.sourceDirectories) + + outputDirectory.set(factorioMod.mainSources.typescript.destinationDirectory) +} + + +val installEventsTsSchema by tasks.registering(Sync::class) { + description = "Fetch the latest shared TypeScript data-model" + group = project.name + + dependsOn(typescriptEventsSchema) + + from( + provider { typescriptEventsSchema } + .map { eventsSchema -> + eventsSchema.incoming + .artifactView { lenient(true) } + .artifacts + .artifactFiles + .filter { file -> file.exists() } + .map { zipTree(it) } + } + ) { + includeEmptyDirs = false + } + into(layout.projectDirectory.dir("src/main/typescript/generated")) +} + + +tasks.distZip { + val distributionZipName = factorioMod.distributionZipName + archiveFileName.set(distributionZipName) +} + +val publishModToPortal by tasks.registering(FactorioModPublishTask::class) { + dependsOn(tasks.check) + + distributionZip.set(tasks.distZip.flatMap { it.archiveFile }) + + modName.set(factorioMod.modName) + modVersion.set(factorioMod.modVersion) +} + +tasks.assembleFactorioModContents { + modFiles.apply { + from(typescriptToLua.map { it.outputDirectory }) + from(licenseFile) + } +} + +val projectPackageJsonName: Provider = + providers.provider { "${rootProject.name}-${project.name}" } +val projectPackageJsonFile: RegularFile = layout.projectDirectory.file("package.json") +val projectVersion: Provider = providers.provider { "${project.version}" } + + +tasks.updatePackageJson { +// mustRunAfter(tasks.npmInstall) + + updateExpectedJson { + put("name", projectPackageJsonName.get()) + putJsonObject("dependencies") { + put("lua-types", libs.versions.npm.luaTypes.get()) + put("typescript-to-lua", libs.versions.npm.typescriptToLua.get()) + put("typed-factorio", libs.versions.npm.typedFactorio.get()) + put("typescript", libs.versions.npm.typescript.get()) + } + } + + packageJsonFile.set(projectPackageJsonFile) +} + + +tasks.assemble { dependsOn(installEventsTsSchema, tasks.updatePackageJson) } + +//val downloadFactorioApiDocs by tasks.registering { +// group = project.name +// +// val target = uri("https://lua-api.factorio.com/latest/runtime-api.json") +// val apiFilename = File(target.path).name +// val downloadedFile = file("$temporaryDir/$apiFilename") +// +// val apiFile = layout.buildDirectory.file(apiFilename) +// outputs.file(apiFile) +// +// doLast { +// +// ant.invokeMethod( +// "get", mapOf( +// "src" to target, +// "dest" to downloadedFile, +// "verbose" to true, +// ) +// ) +// +// val json = downloadedFile.readText() +// val prettyJson = JsonOutput.prettyPrint(json) +// +// apiFile.get().asFile.writeText(prettyJson) +// +// logger.lifecycle("Downloaded Factorio API json: $apiFile") +// } +//} diff --git a/modules/events-mod/mod-portal-description.md b/modules/events-mod/mod-portal-description.md new file mode 100644 index 0000000..06fcdcf --- /dev/null +++ b/modules/events-mod/mod-portal-description.md @@ -0,0 +1,8 @@ +**Work-in-progress** + +The Kafkatorio Events mod is part of Kafkatorio, an in-development platform that exports data from +Factorio to Apache Kafka, a event-based database. This allows for external systems to access +Factorio data. + +This mod will not work without additional infrastructure. Once development is completed, setup +instructions will be made available. diff --git a/modules/events-mod/package-lock.json b/modules/events-mod/package-lock.json new file mode 100644 index 0000000..b9f4330 --- /dev/null +++ b/modules/events-mod/package-lock.json @@ -0,0 +1,104 @@ +{ + "name": "kafkatorio-events-mod", + "version": "0.10.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@typescript-to-lua/language-extensions": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@typescript-to-lua/language-extensions/-/language-extensions-1.0.0.tgz", + "integrity": "sha512-GtmhFqyg+txpGgGLM3mlS3R6AEG9MQhKALxxcbr6SBzg9u7YAXcPKqUBaBYd6nH+Pi/eQLcWz4BNOLhz8v4TjQ==" + }, + "enhanced-resolve": { + "version": "5.12.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz", + "integrity": "sha512-QHTXI/sZQmko1cbDoNAa3mJ5qhWUUNAq3vR0/YiD379fWQrcfuoX1+HW2S0MTt7XmoPLapdaDKUtelUSPic7hQ==", + "requires": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + } + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "graceful-fs": { + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "requires": { + "function-bind": "^1.1.1" + } + }, + "is-core-module": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", + "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", + "requires": { + "has": "^1.0.3" + } + }, + "lua-types": { + "version": "2.13.1", + "resolved": "https://registry.npmjs.org/lua-types/-/lua-types-2.13.1.tgz", + "integrity": "sha512-rRwtvX6kS+5MpuO3xpvKsnYjdSDDI064Qq1OqX8gY+r+0l7m3dFLiZPDFoHqH22jaBpEvcHcPs6+WD7qkdmFsA==" + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "resolve": { + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "requires": { + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==" + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" + }, + "tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==" + }, + "typed-factorio": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/typed-factorio/-/typed-factorio-1.11.0.tgz", + "integrity": "sha512-RYCEpcECiQ2dw1tj03bPv6fRXCevuAP89ipMBv67FsY09+W7ApZkfjXIJq9RaxoIMtbGkqPUql33O/DYVMtAng==" + }, + "typescript": { + "version": "4.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.3.tgz", + "integrity": "sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA==" + }, + "typescript-to-lua": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/typescript-to-lua/-/typescript-to-lua-1.11.1.tgz", + "integrity": "sha512-XxGOf0zBRrMocGr4BbVaJdnvnk4yTrUs0BCdamfb/Qg94hKZg8ydRUy17ZtHZfYmnwFupR88R5DZXIpHYP0S5g==", + "requires": { + "@typescript-to-lua/language-extensions": "1.0.0", + "enhanced-resolve": "^5.8.2", + "resolve": "^1.15.1", + "source-map": "^0.7.3" + } + } + } +} diff --git a/modules/events-mod/package.json b/modules/events-mod/package.json new file mode 100644 index 0000000..302c099 --- /dev/null +++ b/modules/events-mod/package.json @@ -0,0 +1,23 @@ +{ + "name": "kafkatorio-events-mod", + "version": "0.10.1", + "private": true, + "scripts": { + "build": "tstl", + "dev": "tstl --watch" + }, + "engines": { + "node": "~14.19.1" + }, + "devDependencies": {}, + "dependencies": { + "lua-types": "2.13.1", + "typescript-to-lua": "1.11.1", + "typed-factorio": "1.11.0", + "typescript": "4.9" + }, + "license": "GPL-3.0-only", + "peerDependencies": {}, + "optionalDependencies": {}, + "bundledDependencies": [] +} diff --git a/modules/events-mod/src/main/resources/changelog.txt b/modules/events-mod/src/main/resources/changelog.txt new file mode 100644 index 0000000..ae5a975 --- /dev/null +++ b/modules/events-mod/src/main/resources/changelog.txt @@ -0,0 +1,4 @@ +--------------------------------------------------------------------------------------------------- +Version: 0.0.1 + Features: + - Kafkatorio diff --git a/modules/events-mod/src/main/resources/locale/en/locale.cfg b/modules/events-mod/src/main/resources/locale/en/locale.cfg new file mode 100644 index 0000000..91e03f8 --- /dev/null +++ b/modules/events-mod/src/main/resources/locale/en/locale.cfg @@ -0,0 +1,24 @@ +[mod-setting-name] + +kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-PlayerUpdate=Player update rate (seconds) +kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-MapChunkTileUpdate=Map tile update rate (seconds) +kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-MapChunkEntityUpdate=Map entity update rate (seconds) +kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-MapChunkResourceUpdate=Map resource update rate (seconds) +kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-EntityUpdate=Entity update rate (seconds) + + +[mod-setting-description] + +kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-PlayerUpdate=How frequently Player updates are sent to the Kafkatorio server, in seconds. Lower means updates are sent more frequently, which may cause network congestion or reduce performance. The default (0.25 seconds) is probably fine! +kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-MapChunkTileUpdate=How frequently map-tile updates are sent to the Kafkatorio server, in seconds. Lower means updates are sent more frequently, which may cause network congestion or reduce performance. The default (30 seconds) is probably fine! +kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-MapChunkEntityUpdate=How frequently map-entity updates are sent to the Kafkatorio server, in seconds. Lower means updates are sent more frequently, which may cause network congestion or reduce performance. The default (30 seconds) is probably fine! +kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-MapChunkResourceUpdate=How frequently map-resource updates are sent to the Kafkatorio server, in seconds. Lower means updates are sent more frequently, which may cause network congestion or reduce performance. The default (30 seconds) is probably fine! +kafkatorio:cache-expiration-seconds_kafkatorio-packet-keyed-EntityUpdate=How frequently Entity updates are sent to the Kafkatorio server, in seconds. Lower means updates are sent more frequently, which may cause network congestion or reduce performance. The default (5 seconds) is probably fine! + + +[string-mod-setting] +#-= + + +[string-mod-setting-description] +#-= diff --git a/modules/events-mod/src/main/resources/thumbnail.png b/modules/events-mod/src/main/resources/thumbnail.png new file mode 100644 index 0000000..693598d Binary files /dev/null and b/modules/events-mod/src/main/resources/thumbnail.png differ diff --git a/modules/events-mod/src/main/typescript/control.ts b/modules/events-mod/src/main/typescript/control.ts new file mode 100644 index 0000000..3cb0824 --- /dev/null +++ b/modules/events-mod/src/main/typescript/control.ts @@ -0,0 +1,16 @@ +import {initGlobal} from "./main/global-init"; +import {emitPrototypes} from "./main/events/prototypeUpdates"; + +require("./main/events/registerEventListeners") +require("./main/events/mapChunkUpdates") +require("./main/events/playerUpdates") +require("./main/events/entityUpdates") +require("./main/commands/kafkatorioCommands") + + +script.on_init(() => { + // runs only once (when the mod is first added to the save) + initGlobal(true) + // KafkatorioSettings.loadSettings() + emitPrototypes() +}) diff --git a/modules/events-mod/src/main/typescript/generated/kafkatorio-schema.ts b/modules/events-mod/src/main/typescript/generated/kafkatorio-schema.ts new file mode 100644 index 0000000..3a612cb --- /dev/null +++ b/modules/events-mod/src/main/typescript/generated/kafkatorio-schema.ts @@ -0,0 +1,376 @@ +// Generated by kxs-ts-gen - do not edit this file manually + +export interface KafkatorioPacket { + modVersion: string; + tick: Tick; + data: KafkatorioPacketData; +} + +export type Tick = UInt; + +export type KafkatorioPacketData = + | KafkatorioPacketData.ConfigurationUpdate + | KafkatorioPacketData.ConsoleChatUpdate + | KafkatorioPacketData.ConsoleCommandUpdate + | KafkatorioPacketData.EntityUpdate + | KafkatorioPacketData.Error + | KafkatorioPacketData.MapChunkEntityUpdate + | KafkatorioPacketData.MapChunkResourceUpdate + | KafkatorioPacketData.MapChunkTileUpdate + | KafkatorioPacketData.PlayerUpdate + | KafkatorioPacketData.PrototypesUpdate + | KafkatorioPacketData.SurfaceUpdate; + +export namespace KafkatorioPacketData { + export enum Type { + ConfigurationUpdate = "kafkatorio.packet.instant.ConfigurationUpdate", + ConsoleChatUpdate = "kafkatorio.packet.instant.ConsoleChatUpdate", + ConsoleCommandUpdate = "kafkatorio.packet.instant.ConsoleCommandUpdate", + PrototypesUpdate = "kafkatorio.packet.instant.PrototypesUpdate", + SurfaceUpdate = "kafkatorio.packet.instant.SurfaceUpdate", + EntityUpdate = "kafkatorio.packet.keyed.EntityUpdate", + MapChunkEntityUpdate = "kafkatorio.packet.keyed.MapChunkEntityUpdate", + MapChunkResourceUpdate = "kafkatorio.packet.keyed.MapChunkResourceUpdate", + MapChunkTileUpdate = "kafkatorio.packet.keyed.MapChunkTileUpdate", + PlayerUpdate = "kafkatorio.packet.keyed.PlayerUpdate", + Error = "kafkatorio.packet.KafkatorioPacketData.Error", + } + + export interface ConfigurationUpdate { + type: KafkatorioPacketData.Type.ConfigurationUpdate; + factorioData: ConfigurationUpdateGameData; + allMods: ConfigurationUpdateModData[]; + modStartupSettingsChange?: boolean; + migrationApplied?: boolean; + } + + export interface ConsoleChatUpdate { + type: KafkatorioPacketData.Type.ConsoleChatUpdate; + authorPlayerIndex: PlayerIndex | null; + content: string; + } + + export interface ConsoleCommandUpdate { + type: KafkatorioPacketData.Type.ConsoleCommandUpdate; + authorPlayerIndex: PlayerIndex | null; + command: string; + parameters: string; + } + + export interface PrototypesUpdate { + type: KafkatorioPacketData.Type.PrototypesUpdate; + prototypes: FactorioPrototype[]; + } + + export interface SurfaceUpdate { + type: KafkatorioPacketData.Type.SurfaceUpdate; + index: SurfaceIndex; + daytime: Double; + name: string; + } + + export interface EntityUpdate { + type: KafkatorioPacketData.Type.EntityUpdate; + key: EntityUpdateKey; + events?: { [key: EventName]: Tick[] } | null; + chunkPosition?: MapEntityPosition | null; + graphicsVariation?: UByte | null; + health?: Float | null; + isActive?: boolean; + isRotatable?: boolean; + lastUser?: UInt | null; + localisedDescription?: string | null; + localisedName?: string | null; + } + + export interface MapChunkEntityUpdate { + type: KafkatorioPacketData.Type.MapChunkEntityUpdate; + key: MapChunkEntityUpdateKey; + events?: { [key: EventName]: Tick[] } | null; + entitiesXY: FactorioEntityUpdateEntityDictionary; + } + + export interface MapChunkResourceUpdate { + type: KafkatorioPacketData.Type.MapChunkResourceUpdate; + key: MapChunkResourceUpdateKey; + events?: { [key: EventName]: Tick[] } | null; + amounts?: FactorioEntityUpdateResourceAmountDictionary; + initialAmounts?: FactorioEntityUpdateResourceAmountDictionary; + } + + export interface MapChunkTileUpdate { + type: KafkatorioPacketData.Type.MapChunkTileUpdate; + key: MapChunkTileUpdateKey; + events?: { [key: EventName]: Tick[] } | null; + player?: PlayerIndex | null; + robot?: EntityIdentifiersData | null; + force?: ForceIndex | null; + tileDictionary?: MapTileDictionary | null; + isDeleted?: boolean; + } + + export interface PlayerUpdate { + type: KafkatorioPacketData.Type.PlayerUpdate; + key: PlayerUpdateKey; + events?: { [key: EventName]: Tick[] } | null; + characterUnitNumber?: UnitNumber | null; + chatColour?: Colour | null; + colour?: Colour | null; + name?: string | null; + afkTime?: Tick | null; + ticksToRespawn?: Tick | null; + forceIndex?: ForceIndex | null; + isAdmin?: boolean; + isConnected?: boolean; + isShowOnMap?: boolean; + isSpectator?: boolean; + lastOnline?: Tick | null; + onlineTime?: Tick | null; + position?: MapEntityPosition | null; + surfaceIndex?: SurfaceIndex | null; + tag?: string | null; + diedCause?: EntityIdentifiersData | null; + bannedReason?: string | null; + kickedReason?: string | null; + disconnectReason?: string | null; + isRemoved?: boolean; + } + + export interface Error { + type: KafkatorioPacketData.Type.Error; + message?: string | null; + rawValue?: string | null; + } +} + +export type UInt = uint; + +export interface ConfigurationUpdateGameData { + oldVersion?: string | null; + newVersion?: string | null; +} + +export type Double = double; + +export interface EntityUpdateKey { + unitNumber: UnitNumber; + protoId: PrototypeId; +} + +export type MapEntityPosition = [ + x: Double, + y: Double, +]; + +export type UByte = uint8; + +export type Float = float; + +export interface MapChunkEntityUpdateKey { + protoId: PrototypeId; + surfaceIndex: SurfaceIndex; + chunkPosition: MapChunkPosition; +} + +export type FactorioEntityUpdateEntityDictionary = { [key: string]: { [key: string]: FactorioEntityUpdateElementStandard } }; + +export interface MapChunkResourceUpdateKey { + protoId: PrototypeId; + surfaceIndex: SurfaceIndex; + chunkPosition: MapChunkPosition; +} + +export type FactorioEntityUpdateResourceAmountDictionary = { [key: string]: { [key: string]: UInt } }; + +export interface MapChunkTileUpdateKey { + chunkPosition: MapChunkPosition; + surfaceIndex: SurfaceIndex; +} + +export interface EntityIdentifiersData { + unitNumber?: UnitNumber | null; + protoId: PrototypeId; +} + +export type ForceIndex = UInt & { __ForceIndex__: void }; + +export interface MapTileDictionary { + tilesXY: { [key: string]: { [key: string]: PrototypeKey } }; + protos: { [key: PrototypeId]: PrototypeKey }; +} + +export interface PlayerUpdateKey { + index: PlayerIndex; +} + +export type Colour = [ + red: Float, + green: Float, + blue: Float, + alpha: Float, +]; + +export type Int = int; + +export interface ConfigurationUpdateModData { + modName: string; + currentVersion?: string | null; + previousVersion?: string | null; +} + +export type FactorioPrototype = + | FactorioPrototype.Entity + | FactorioPrototype.MapTile; + +export namespace FactorioPrototype { + export enum Type { + Entity = "kafkatorio.prototype.Entity", + MapTile = "kafkatorio.prototype.MapTile", + } + + export interface Entity { + type: FactorioPrototype.Type.Entity; + protoId: PrototypeId; + group: EntityItemGroup; + subgroup: EntityItemGroup; + colour?: Colour | null; + mapColour?: Colour | null; + mapColourFriend?: Colour | null; + mapColourEnemy?: Colour | null; + maxHealth: Float; + isBuilding?: boolean; + isEntityWithOwner?: boolean; + isMilitaryTarget?: boolean; + miningProperties?: EntityMiningProperties | null; + collisionBox?: MapBoundingBox | null; + tileWidth?: Int | null; + tileHeight?: Int | null; + } + + export interface MapTile { + type: FactorioPrototype.Type.MapTile; + protoId: PrototypeId; + mapColour: Colour; + layer: UInt; + collisionMasks: string[]; + order: string; + canBeMined?: boolean; + } +} + +export type PrototypeId = string & { __PrototypeId__: void }; + +export type EventName = string & { __EventName__: void }; + +export type Byte = int8; + +export type MapChunkPosition = [ + x: Int, + y: Int, + chunkSize: ChunkSize, +]; + +export interface EntityItemGroup { + name?: string | null; + type?: string | null; + parentName?: string | null; +} + +export interface EntityMiningProperties { + canBeMined?: boolean; + products: MinedProduct[] | null; +} + +export interface MapBoundingBox { + leftTop: MapEntityPosition; + rightBottom: MapEntityPosition; +} + +export enum ChunkSize { + CHUNK_512 = "CHUNK_512", + CHUNK_256 = "CHUNK_256", + CHUNK_128 = "CHUNK_128", + CHUNK_064 = "CHUNK_064", + CHUNK_032 = "CHUNK_032", +} + +export type PrototypeKey = Int & { __PrototypeKey__: void }; + +export interface FactorioEntityUpdateElementStandard { + status?: FactorioEntityStatus | null; + unitNumber?: UnitNumber | null; + graphicsVariation?: UByte | null; + health?: Float | null; + isActive?: boolean; + isRotatable?: boolean; + lastUser?: UInt | null; +} + +export type MinedProduct = + | MinedProduct.MinedProductFluid + | MinedProduct.MinedProductItem; + +export namespace MinedProduct { + export enum Type { + MinedProductFluid = "kafkatorio.resource.MinedProduct.MinedProductFluid", + MinedProductItem = "kafkatorio.resource.MinedProduct.MinedProductItem", + } + + export interface MinedProductFluid { + type: MinedProduct.Type.MinedProductFluid; + amount?: Double | null; + resultProtoId: PrototypeId; + } + + export interface MinedProductItem { + type: MinedProduct.Type.MinedProductItem; + amount?: Double | null; + resultProtoId: PrototypeId; + } +} + +export enum FactorioEntityStatus { + WORKING = "WORKING", + NORMAL = "NORMAL", + NO_POWER = "NO_POWER", + LOW_POWER = "LOW_POWER", + NO_FUEL = "NO_FUEL", + DISABLED_BY_CONTROL_BEHAVIOR = "DISABLED_BY_CONTROL_BEHAVIOR", + OPENED_BY_CIRCUIT_NETWORK = "OPENED_BY_CIRCUIT_NETWORK", + CLOSED_BY_CIRCUIT_NETWORK = "CLOSED_BY_CIRCUIT_NETWORK", + DISABLED_BY_SCRIPT = "DISABLED_BY_SCRIPT", + MARKED_FOR_DECONSTRUCTION = "MARKED_FOR_DECONSTRUCTION", + NOT_PLUGGED_IN_ELECTRIC_NETWORK = "NOT_PLUGGED_IN_ELECTRIC_NETWORK", + NETWORKS_CONNECTED = "NETWORKS_CONNECTED", + NETWORKS_DISCONNECTED = "NETWORKS_DISCONNECTED", + CHARGING = "CHARGING", + DISCHARGING = "DISCHARGING", + FULLY_CHARGED = "FULLY_CHARGED", + OUT_OF_LOGISTIC_NETWORK = "OUT_OF_LOGISTIC_NETWORK", + NO_RECIPE = "NO_RECIPE", + NO_INGREDIENTS = "NO_INGREDIENTS", + NO_INPUT_FLUID = "NO_INPUT_FLUID", + NO_RESEARCH_IN_PROGRESS = "NO_RESEARCH_IN_PROGRESS", + NO_MINABLE_RESOURCES = "NO_MINABLE_RESOURCES", + LOW_INPUT_FLUID = "LOW_INPUT_FLUID", + FLUID_INGREDIENT_SHORTAGE = "FLUID_INGREDIENT_SHORTAGE", + FULL_OUTPUT = "FULL_OUTPUT", + ITEM_INGREDIENT_SHORTAGE = "ITEM_INGREDIENT_SHORTAGE", + MISSING_REQUIRED_FLUID = "MISSING_REQUIRED_FLUID", + MISSING_SCIENCE_PACKS = "MISSING_SCIENCE_PACKS", + WAITING_FOR_SOURCE_ITEMS = "WAITING_FOR_SOURCE_ITEMS", + WAITING_FOR_SPACE_IN_DESTINATION = "WAITING_FOR_SPACE_IN_DESTINATION", + PREPARING_ROCKET_FOR_LAUNCH = "PREPARING_ROCKET_FOR_LAUNCH", + WAITING_TO_LAUNCH_ROCKET = "WAITING_TO_LAUNCH_ROCKET", + LAUNCHING_ROCKET = "LAUNCHING_ROCKET", + NO_MODULES_TO_TRANSMIT = "NO_MODULES_TO_TRANSMIT", + RECHARGING_AFTER_POWER_OUTAGE = "RECHARGING_AFTER_POWER_OUTAGE", + WAITING_FOR_TARGET_TO_BE_BUILT = "WAITING_FOR_TARGET_TO_BE_BUILT", + WAITING_FOR_TRAIN = "WAITING_FOR_TRAIN", + NO_AMMO = "NO_AMMO", + LOW_TEMPERATURE = "LOW_TEMPERATURE", + DISABLED = "DISABLED", + TURNED_OFF_DURING_DAYTIME = "TURNED_OFF_DURING_DAYTIME", + NOT_CONNECTED_TO_RAIL = "NOT_CONNECTED_TO_RAIL", + CANT_DIVIDE_SEGMENTS = "CANT_DIVIDE_SEGMENTS", +} \ No newline at end of file diff --git a/modules/events-mod/src/main/typescript/main/commands/kafkatorioCommands.ts b/modules/events-mod/src/main/typescript/main/commands/kafkatorioCommands.ts new file mode 100644 index 0000000..cc29083 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/commands/kafkatorioCommands.ts @@ -0,0 +1,79 @@ +import {initGlobal} from "../global-init"; +import {emitPrototypes} from "../events/prototypeUpdates"; +import EventDataQueue from "../emitting/EventDataQueue"; + + +commands.add_command( + "kafkatorio", + "kafkatorio innit bruv", + (e: CustomCommandData) => { + + const player = (e.player_index != null) ? game.get_player(e.player_index) : null + + if (e.parameter == undefined) { + if (player != null) { + player.print("no parameter") + } + // do nothing + } else { + + const paramUppercase: string = e.parameter.toUpperCase() + + if ("PROTOTYPES" == paramUppercase) { + emitPrototypes() + } else if (paramUppercase.startsWith("CHUNKS")) { + + const size = paramUppercase.split(" ")?.[1] ?? null + let radius = (size != null) ? parseInt(size) : 1 + // radius = Math.max(radius, 10) + + if (e.player_index != undefined) { + let player = game.players[e.player_index] + + const chunkPosition: ChunkPosition = { + x: math.floor(player.position.x / 32), + y: math.floor(player.position.y / 32), + } + + const chunkXMin = chunkPosition.x - radius + const chunkXMax = chunkPosition.x + radius + const chunkYMin = chunkPosition.y - radius + const chunkYMax = chunkPosition.y + radius + + // let i = 100 + let chunkCount = 0 + for (const [, surface] of game.surfaces) { + for (const chunk of surface.get_chunks()) { + if ( + (chunk.x >= chunkXMin && chunk.x <= chunkXMax) + && + (chunk.y >= chunkYMin && chunk.y <= chunkYMax) + ) { + + const data: OnChunkGeneratedEvent = { + name: defines.events.on_chunk_generated, + position: {x: chunk.x, y: chunk.y}, + area: chunk.area, + surface: surface, + tick: e.tick, + } + + EventDataQueue.enqueue( + `${surface.index}${chunk.x}${chunk.y}`, + data, + 50 + ) + chunkCount++ + // handleChunkGeneratedEvent(data, i) + // i = i + 10 + } + } + } + player.print(`enqueued ${chunkCount} chunks from [x:${chunkXMin}, y:${chunkYMin}] to [x:${chunkXMax}, y:${chunkYMax}]`) + } + } else if (paramUppercase.startsWith("INIT_GLOBAL")) { + initGlobal(paramUppercase.startsWith("INIT_GLOBAL FORCE")) + } + } + } +) diff --git a/modules/events-mod/src/main/typescript/main/emitting/EventDataCache.ts b/modules/events-mod/src/main/typescript/main/emitting/EventDataCache.ts new file mode 100644 index 0000000..2547dab --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/emitting/EventDataCache.ts @@ -0,0 +1,240 @@ +import KafkatorioSettings from "../settings/KafkatorioSettings"; +import {KafkatorioKeyedPacketData} from "../types"; +import PacketEmitter from "./PacketEmitter"; + + +declare const global: { + /** Map the hash of the key, as a string, a cache entry */ + eventUpdatesManagerCache: LuaTable>, +} + + +export class EventUpdatesManager { + + constructor() { + this.init() + } + + + init(force?: boolean) { + + const isAnythingUndefined = global.eventUpdatesManagerCache == undefined + + log(`Initialising EventDataCache (force=${force}, isAnythingUndefined=${isAnythingUndefined})...`) + + if (force == true || isAnythingUndefined) { + log("Initialising global.cache") + global.eventUpdatesManagerCache = new LuaTable>() + } + log(`Finished initialising EventDataCache`) + } + + + /** + * Update the cache data without restarting the 'time-to-emit' countdown, so that the data won't + * be emitted more than once per {@link CacheEntry.expirationDurationTicks}. + */ + public throttle( + key: PacketKey, + type: PacketType, + mutate: CacheDataMutator, + expirationDurationTicks?: uint, + ) { + this.update(key, type, mutate, false, expirationDurationTicks) + } + + + /** + * Update the cache data and reset the 'time-to-emit' countdown, so the data won't be emitted + * until there's an inactivity gap of {@link CacheEntry.expirationDurationTicks}. + */ + public debounce( + key: PacketKey, + type: PacketType, + mutate: CacheDataMutator, + expirationDurationTicks?: uint, + ) { + this.update(key, type, mutate, true, expirationDurationTicks) + } + + + private update( + key: PacketKey, + type: PacketType, + mutate: CacheDataMutator, + resetLastUpdated: boolean, + expirationDurationTicks?: uint, + ) { + const entry: CacheEntry = this.getCacheEntry(key, type) ?? + EventUpdatesManager.createCacheEntry(key, type) + mutate(entry.packet) + if (resetLastUpdated) { + entry.lastUpdatedTick = game.tick + } + if (expirationDurationTicks != undefined) { + entry.expirationDurationTicks = expirationDurationTicks + } + + if (entry.expirationDurationTicks != undefined && entry.expirationDurationTicks <= 0) { + this.extractAndEmitExpiredPackets() + } + } + + + /** + * Usage example: If an urgent update comes in, then the expiration can be reduced so that + * it's transmitted sooner. + */ + public setExpiration( + key: PacketKey, + type: PacketType, + expirationDurationTicks: uint, + ) { + const entry = this.getCacheEntry(key, type) + if (entry != undefined) { + entry.expirationDurationTicks = expirationDurationTicks + } + } + + + /** Removes all expired entries from the cache, and return them. */ + // use in/out v4.7.0 https://github.com/microsoft/TypeScript/pull/48240 + private extractExpired(): Array { + let countExpired = 0 + let countTotal = 0 + const expiredData: Array = [] + for (const [key, entry] of global.eventUpdatesManagerCache) { + countTotal++ + if (this.isExpired(entry)) { + countExpired++ + expiredData.push(entry.packet) + global.eventUpdatesManagerCache.delete(key) + } + } + + const hasExpiredItems = countExpired > 0 + const hasAnyItem = countTotal > 0 + + if (hasExpiredItems || (game.tick % 30 == 0 && hasAnyItem)) { + log(`[extractExpired] expired items: ${countExpired}, total: ${countTotal}`) + } + return expiredData + } + + + /** + * Removes and emits all expired packets. + * + * @return the number of emitted packets + */ + public extractAndEmitExpiredPackets() { + const cachedEvents: Array = this.extractExpired() + + if (cachedEvents.length > 0) { + log(`[EventDataCache] emitting ${cachedEvents.length} events on tick ${game.tick}`) + for (const event of cachedEvents) { + PacketEmitter.emitKeyedPacket(event) + } + } + + return cachedEvents.length + } + + + private getCacheEntry( + key: PacketKey, + type: PacketType, + ): CacheEntry | undefined { + const hash = EventUpdatesManager.hashKey(key) + if (!global.eventUpdatesManagerCache.has(hash)) { + return undefined + } + const value: CacheEntry = global.eventUpdatesManagerCache.get(hash) + if (this.isEntryInstanceOf(value, type)) { + return value + } else { + // Type mismatch. This shouldn't happen... + return undefined + } + } + + + private static createCacheEntry( + key: PacketKey, + type: PacketType, + ): CacheEntry { + const data: PACKET = { + type: type, + key: key, + } + const entry: CacheEntry = new CacheEntry(data) + const hash = EventUpdatesManager.hashKey(key) + global.eventUpdatesManagerCache.set(hash, entry) + return entry + } + + + isExpired(entry: CacheEntry): boolean { + const expiryDuration = + entry.expirationDurationTicks + ?? KafkatorioSettings.getEventCacheExpirationTicks(entry.packet) + + if (expiryDuration == undefined) { + return true + } else { + return game.tick - entry.lastUpdatedTick > expiryDuration + } + } + + + isEntryInstanceOf( + entry: CacheEntry | undefined, + type: PacketType, + ): entry is CacheEntry { + return this.isDataInstanceOf(entry?.packet, type) + } + + + isDataInstanceOf( + packet: PACKET | undefined, + type: PacketType, + ): packet is PACKET { + return packet != undefined && packet.type == type + } + + + private static hashKey( + key: PacketKey, + ): string { + return game.encode_string(game.table_to_json(key))!! + } + +} + + +const EventUpdates = new EventUpdatesManager() + +export default EventUpdates + + +export type PacketKey = PACKET["key"] +export type PacketType = PACKET["type"] + +export type CacheDataMutator = (packet: PACKET) => void + + +class CacheEntry { + lastUpdatedTick: uint = game.tick + expirationDurationTicks?: uint + + packet: PACKET + + constructor( + packet: PACKET, + expirationDurationTicks?: uint, + ) { + + this.packet = packet + this.expirationDurationTicks = expirationDurationTicks + } +} diff --git a/modules/events-mod/src/main/typescript/main/emitting/EventDataQueue.ts b/modules/events-mod/src/main/typescript/main/emitting/EventDataQueue.ts new file mode 100644 index 0000000..725ae75 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/emitting/EventDataQueue.ts @@ -0,0 +1,126 @@ +export class EventDataQueueManager { + + static init(force?: boolean) { + + const isAnythingUndefined = global.store == undefined || + global.size == undefined || + global.head == undefined || + global.tail == undefined + + log(`Initialising EventDataQueueManager globals (force=${force}, isAnythingUndefined=${isAnythingUndefined})`) + + if (force == true || isAnythingUndefined) { + global.store = {} + global.head = null + global.tail = null + global.size = 0 + } + + log(`Finished initialising EventDataQueueManager`) + } + + + size(): uint | undefined { + return global.size + } + + + enqueue(key: string, event: EventData, weight: int = 1) { + if (key ! in global.store) { + let node = new Node(key, weight) + if (global.head == null) { + global.head = node + } + if (global.tail != null) { + global.tail.next = node + } + global.tail = node + global.size++ + } + + global.store[key] = event + } + + + dequeue(): WeightedPacket | null { + if (global.head == null) { + return null + } else { + let weight = global.head.weight + let storeKey = global.head.storeKey + global.head = global.head.next + global.size-- + + let storedPacket = global.store[storeKey] + global.store[storeKey] = null + + if (storedPacket == null) { + return null + } else { + return { + value: storedPacket, + weight: weight, + } + } + } + } + + + dequeueValues(targetWeight: uint = 50): EventData[] { + let values: EventData[] = [] + let weight: uint = 0 + + do { + let packet = this.dequeue() + + if (packet == null) { + break; + } else { + weight += packet.weight + values[values.length] = packet.value + } + } while (weight <= targetWeight) + + return values + } + +} + + +const EventDataQueue = new EventDataQueueManager() + + +export default EventDataQueue + + +declare const global: { + store: EventQueueStore + + head: Node | null + tail: Node | null + + size: uint +} + + +class Node { + storeKey: string; + next: Node | null = null; + weight: uint + + constructor(storeKey: string, weight: uint) { + this.storeKey = storeKey; + this.weight = weight + } +} + + +interface EventQueueStore { + [key: string]: EventData | null; +} + + +interface WeightedPacket { + value: EventData, + weight: int, +} diff --git a/modules/events-mod/src/main/typescript/main/emitting/KafkatorioPacketQueue.ts b/modules/events-mod/src/main/typescript/main/emitting/KafkatorioPacketQueue.ts new file mode 100644 index 0000000..60aebdb --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/emitting/KafkatorioPacketQueue.ts @@ -0,0 +1,55 @@ +import {KafkatorioPacketData} from "../../generated/kafkatorio-schema"; + + +/** + * Simple ordered queue for {@link KafkatorioPacketData}. + * + * Implemented so printing multiple packets won't flood the output log, causing messages to be + * missed or garbled. + */ +export class KafkatorioPacketQueueManager { + + private size: int = 0 + private first: Node | null = null + private last: Node | null = null + + public get length() { + return this.size + } + + public enqueue(packet: T) { + const last = this.last + this.last = { + value: packet + } + if (last != null) { + last.next = this.last + } + if (this.first == null) { + this.first = this.last + } + this.size++ + } + + public dequeue(): T | null { + const first = this.first + + if (first == null) { + return null + } + + this.first = first.next ?? null + this.size-- + return first.value + } + +} + +const KafkatorioPacketQueue = new KafkatorioPacketQueueManager() + +export default KafkatorioPacketQueue + +interface Node { + value: T + next?: Node +} diff --git a/modules/events-mod/src/main/typescript/main/emitting/PacketEmitter.ts b/modules/events-mod/src/main/typescript/main/emitting/PacketEmitter.ts new file mode 100644 index 0000000..69e36a9 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/emitting/PacketEmitter.ts @@ -0,0 +1,63 @@ +import {KafkatorioPacket, KafkatorioPacketData} from "../../generated/kafkatorio-schema"; +import {KafkatorioKeyedPacketData} from "../types"; + + +export class KafkatorioPacketEmitter { + + emitInstantPacket( + data: DATA, + ) { + KafkatorioPacketEmitter.emitPacket({ + data: data, + modVersion: global.MOD_VERSION, + tick: game.tick, + }) + } + + emitKeyedPacket( + data: DATA, + ) { + KafkatorioPacketEmitter.emitPacket({ + data: data, + modVersion: global.MOD_VERSION, + tick: game.tick, + }) + } + + /** Emit a serialised KafkatorioPacket */ + private static emitPacket(packet: T) { + const data = game.table_to_json(packet) + + if (data.trim().length <= 0) { + print(`[error] table_to_json returned empty string for packet:${packet}`) + return + } + + const encodedData = game.encode_string(data) + + if (encodedData == null || encodedData.trim().length <= 0) { + print(`[error] could not encode packet`) + print(`KafkatorioPacket:::${data}`) + } else { + print(`KafkatorioPacket:::encoded:${encodedData}`) + // this.appendToFile(encodedData) + } + } + + // private static appendToFile(encodedData: string) { + // // change log files every hour: + // const perHour = game.tick / (60 * 60 * 60) + // game.write_file( + // `kafkatorio/packets_${perHour}.txt`, + // `${encodedData}\n`, + // true, + // 0, // server only + // ) + // } + +} + + +const PacketEmitter = new KafkatorioPacketEmitter() + +export default PacketEmitter diff --git a/modules/events-mod/src/main/typescript/main/events/configurationUpdate.ts b/modules/events-mod/src/main/typescript/main/events/configurationUpdate.ts new file mode 100644 index 0000000..a49b740 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/configurationUpdate.ts @@ -0,0 +1,12 @@ +import {initGlobal} from "../global-init"; +import {emitPrototypes} from "./prototypeUpdates"; +import ConfigurationUpdates from "./handlers/ConfigurationUpdateHandler"; + + +script.on_configuration_changed((data: ConfigurationChangedData) => { + // runs whenever the version of the base game, or a mod, changes + initGlobal(true) + // KafkatorioSettings.loadSettings() + ConfigurationUpdates.emitConfigurationUpdate(data) + emitPrototypes() +}) diff --git a/modules/events-mod/src/main/typescript/main/events/consoleUpdates.ts b/modules/events-mod/src/main/typescript/main/events/consoleUpdates.ts new file mode 100644 index 0000000..ddfd728 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/consoleUpdates.ts @@ -0,0 +1,26 @@ +import {KafkatorioPacketData} from "../../generated/kafkatorio-schema"; +import KafkatorioPacketQueue from "../emitting/KafkatorioPacketQueue"; + + +script.on_event(defines.events.on_console_chat, (event: OnConsoleChatEvent) => { + const update: KafkatorioPacketData.ConsoleChatUpdate = { + type: KafkatorioPacketData.Type.ConsoleChatUpdate, + + authorPlayerIndex: event.player_index ?? null, + content: event.message + } + KafkatorioPacketQueue.enqueue(update) +}) + + +script.on_event(defines.events.on_console_command, (event: OnConsoleCommandEvent) => { + const update: KafkatorioPacketData.ConsoleCommandUpdate = { + type: KafkatorioPacketData.Type.ConsoleCommandUpdate, + + authorPlayerIndex: event.player_index ?? null, + command: event.command, + parameters: event.parameters, + } + + KafkatorioPacketQueue.enqueue(update) +}) diff --git a/modules/events-mod/src/main/typescript/main/events/converters.ts b/modules/events-mod/src/main/typescript/main/events/converters.ts new file mode 100644 index 0000000..3abccbc --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/converters.ts @@ -0,0 +1,223 @@ +import {DefinedEventName} from "../types"; +import { + ChunkSize, + Colour, + EntityMiningProperties, + EventName, + FactorioEntityStatus, + KafkatorioPacketData, + MapBoundingBox, + MapChunkPosition, + MapEntityPosition, + MinedProduct, + PrototypeId, +} from "../../generated/kafkatorio-schema"; + + +export namespace Converters { + + + import floor = math.floor; + const mapEventIdToName = new LuaTable() + for (const [eventName, eventId] of pairs(defines.events)) { + mapEventIdToName.set(eventId, eventName) + } + + + export function eventNameString(event: defines.events): EventName { + return mapEventIdToName.get(event) as EventName + } + + + export function mapColour(color: ColorTable): Colour { + return [ + color.r ?? 0, + color.g ?? 0, + color.b ?? 0, + color.a ?? 0, + ] + } + + + export function convertPlacedTiles( + placedTile: LuaTilePrototype, + oldTiles: OldTileAndPosition[], + ): TileRead[] { + const converted: TileRead[] = [] + for (const [, tile] of ipairs(oldTiles)) { + converted[converted.length] = { + position: {x: tile.position.x, y: tile.position.y}, + name: placedTile.name, + } + } + return converted + } + + + export function convertRemovedTiles( + surface: LuaSurface, + oldTiles: OldTileAndPosition[], + ): TileRead[] { + const converted: TileRead[] = [] + for (const [, tile] of ipairs(oldTiles)) { + converted[converted.length] = surface.get_tile(tile.position.x, tile.position.y) + } + return converted + } + + + export function convertCollisionMaskToNames(cm: CollisionMask): string[] { + let masks: string[] = [] + for (const [name] of pairs(cm)) { + masks.push(name) + } + return masks + } + + + function convertEntityStatus( + status: defines.entity_status | undefined + ): FactorioEntityStatus | null { + if (status == undefined) { + return null + } else { + return EntityStatusRecord[status] + } + } + + + export function prototypeIdEntity(entity: LuaEntity): PrototypeId { + return prototypeId(entity.type, entity.name) + } + + + export function prototypeId(type: string, name: string): PrototypeId { + return `${type}/${name}` as PrototypeId + } + + + export function tilePositionToChunkPosition(mapPosition: TilePositionTable): MapChunkPosition { + return [floor(mapPosition.x / 32), floor(mapPosition.y / 32), ChunkSize.CHUNK_032] + } + + + export function mapPositionToChunkPosition(mapPosition: MapPositionTable): MapChunkPosition { + return [floor(mapPosition.x / 32), floor(mapPosition.y / 32), ChunkSize.CHUNK_032] + } + + + export function entityPosition(position: MapPositionTable): MapEntityPosition { + return [position.x, position.y]; + } + + + export function chunkPosition(position: ChunkPositionTable): MapChunkPosition { + return [position.x, position.y, ChunkSize.CHUNK_032] + } + + + export function entityStatus(status: defines.entity_status | undefined): FactorioEntityStatus | undefined { + if (status == undefined) { + return undefined + } else { + return EntityStatusRecord[status] + } + } + + + export function miningProperties( + properties: LuaEntityPrototype["mineable_properties"] + ): EntityMiningProperties { + + const products: MinedProduct[] = [] + + if (properties.products != null) { + for (const product of properties.products) { + if (product.type == "fluid") { + products[products.length] = { + type: MinedProduct.Type.MinedProductFluid, + amount: product.amount, + resultProtoId: Converters.prototypeId(product.type, product.name), + } + } + if (product.type == "item") { + products[products.length] = { + type: MinedProduct.Type.MinedProductItem, + amount: product.amount, + resultProtoId: Converters.prototypeId(product.type, product.name), + } + } + } + } + + return { + canBeMined: properties.minable, + products: products, + } + } + + + export function playerOnlineInfo(player: LuaPlayer, data: KafkatorioPacketData.PlayerUpdate) { + data.lastOnline = player.last_online + data.onlineTime = player.online_time + data.afkTime = player.afk_time + data.isConnected = player.connected + } + + + export function collisionBox(collision_box: BoundingBox): MapBoundingBox { + return { + leftTop: Converters.entityPosition(collision_box.left_top), + rightBottom: Converters.entityPosition(collision_box.right_bottom), + } + } + + + const EntityStatusRecord: Record = { + //@formatter:off + [ defines.entity_status.cant_divide_segments ]: FactorioEntityStatus.CANT_DIVIDE_SEGMENTS, + [ defines.entity_status.charging ]: FactorioEntityStatus.CHARGING, + [ defines.entity_status.closed_by_circuit_network ]: FactorioEntityStatus.CLOSED_BY_CIRCUIT_NETWORK, + [ defines.entity_status.disabled ]: FactorioEntityStatus.DISABLED, + [ defines.entity_status.disabled_by_control_behavior ]: FactorioEntityStatus.DISABLED_BY_CONTROL_BEHAVIOR, + [ defines.entity_status.disabled_by_script ]: FactorioEntityStatus.DISABLED_BY_SCRIPT, + [ defines.entity_status.discharging ]: FactorioEntityStatus.DISCHARGING, + [ defines.entity_status.fluid_ingredient_shortage ]: FactorioEntityStatus.FLUID_INGREDIENT_SHORTAGE, + [ defines.entity_status.fully_charged ]: FactorioEntityStatus.FULLY_CHARGED, + [ defines.entity_status.full_output ]: FactorioEntityStatus.FULL_OUTPUT, + [ defines.entity_status.item_ingredient_shortage ]: FactorioEntityStatus.ITEM_INGREDIENT_SHORTAGE, + [ defines.entity_status.launching_rocket ]: FactorioEntityStatus.LAUNCHING_ROCKET, + [ defines.entity_status.low_input_fluid ]: FactorioEntityStatus.LOW_INPUT_FLUID, + [ defines.entity_status.low_power ]: FactorioEntityStatus.LOW_POWER, + [ defines.entity_status.low_temperature ]: FactorioEntityStatus.LOW_TEMPERATURE, + [ defines.entity_status.marked_for_deconstruction ]: FactorioEntityStatus.MARKED_FOR_DECONSTRUCTION, + [ defines.entity_status.missing_required_fluid ]: FactorioEntityStatus.MISSING_REQUIRED_FLUID, + [ defines.entity_status.missing_science_packs ]: FactorioEntityStatus.MISSING_SCIENCE_PACKS, + [ defines.entity_status.networks_connected ]: FactorioEntityStatus.NETWORKS_CONNECTED, + [ defines.entity_status.networks_disconnected ]: FactorioEntityStatus.NETWORKS_DISCONNECTED, + [ defines.entity_status.normal ]: FactorioEntityStatus.NORMAL, + [ defines.entity_status.not_connected_to_rail ]: FactorioEntityStatus.NOT_CONNECTED_TO_RAIL, + [ defines.entity_status.not_plugged_in_electric_network ]: FactorioEntityStatus.NOT_PLUGGED_IN_ELECTRIC_NETWORK, + [ defines.entity_status.no_ammo ]: FactorioEntityStatus.NO_AMMO, + [ defines.entity_status.no_fuel ]: FactorioEntityStatus.NO_FUEL, + [ defines.entity_status.no_ingredients ]: FactorioEntityStatus.NO_INGREDIENTS, + [ defines.entity_status.no_input_fluid ]: FactorioEntityStatus.NO_INPUT_FLUID, + [ defines.entity_status.no_minable_resources ]: FactorioEntityStatus.NO_MINABLE_RESOURCES, + [ defines.entity_status.no_modules_to_transmit ]: FactorioEntityStatus.NO_MODULES_TO_TRANSMIT, + [ defines.entity_status.no_power ]: FactorioEntityStatus.NO_POWER, + [ defines.entity_status.no_recipe ]: FactorioEntityStatus.NO_RECIPE, + [ defines.entity_status.no_research_in_progress ]: FactorioEntityStatus.NO_RESEARCH_IN_PROGRESS, + [ defines.entity_status.opened_by_circuit_network ]: FactorioEntityStatus.OPENED_BY_CIRCUIT_NETWORK, + [ defines.entity_status.out_of_logistic_network ]: FactorioEntityStatus.OUT_OF_LOGISTIC_NETWORK, + [ defines.entity_status.preparing_rocket_for_launch ]: FactorioEntityStatus.PREPARING_ROCKET_FOR_LAUNCH, + [ defines.entity_status.recharging_after_power_outage ]: FactorioEntityStatus.RECHARGING_AFTER_POWER_OUTAGE, + [ defines.entity_status.turned_off_during_daytime ]: FactorioEntityStatus.TURNED_OFF_DURING_DAYTIME, + [ defines.entity_status.waiting_for_source_items ]: FactorioEntityStatus.WAITING_FOR_SOURCE_ITEMS, + [ defines.entity_status.waiting_for_space_in_destination ]: FactorioEntityStatus.WAITING_FOR_SPACE_IN_DESTINATION, + [ defines.entity_status.waiting_for_target_to_be_built ]: FactorioEntityStatus.WAITING_FOR_TARGET_TO_BE_BUILT, + [ defines.entity_status.waiting_for_train ]: FactorioEntityStatus.WAITING_FOR_TRAIN, + [ defines.entity_status.waiting_to_launch_rocket ]: FactorioEntityStatus.WAITING_TO_LAUNCH_ROCKET, + [ defines.entity_status.working ]: FactorioEntityStatus.WORKING, + //@formatter:on + } +} diff --git a/modules/events-mod/src/main/typescript/main/events/entityUpdates.ts b/modules/events-mod/src/main/typescript/main/events/entityUpdates.ts new file mode 100644 index 0000000..05507ae --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/entityUpdates.ts @@ -0,0 +1,24 @@ +import EntityUpdates from "./handlers/EntityUpdateHandler"; + +script.on_event(defines.events.on_built_entity, (e: OnBuiltEntityEvent) => { + log(`on_built_entity ${e.tick}`) + EntityUpdates.handleBuiltEntityEvent(e) +}) + + +script.on_event(defines.events.on_robot_built_entity, (e: OnRobotBuiltEntityEvent) => { + log(`on_robot_built_entity ${e.tick}`) + EntityUpdates.handleBuiltEntityEvent(e) +}) + + +script.on_event(defines.events.on_player_mined_entity, (e: OnPlayerMinedEntityEvent) => { + log(`on_player_mined_entity ${e.tick}`) + EntityUpdates.handleMinedEntityEvent(e) +}) + + +script.on_event(defines.events.on_robot_mined_entity, (e: OnRobotMinedEntityEvent) => { + log(`on_robot_mined_entity ${e.tick}`) + EntityUpdates.handleMinedEntityEvent(e) +}) diff --git a/modules/events-mod/src/main/typescript/main/events/eventTypeCheck.ts b/modules/events-mod/src/main/typescript/main/events/eventTypeCheck.ts new file mode 100644 index 0000000..4321eb3 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/eventTypeCheck.ts @@ -0,0 +1,8 @@ + +export function isEventType( + eventData: EventData, + type: ED extends CustomInputEvent ? string : EventId +): eventData is ED { + let id: EventId | string = eventData.name + return id == type +} diff --git a/modules/events-mod/src/main/typescript/main/events/handlers/ConfigurationUpdateHandler.ts b/modules/events-mod/src/main/typescript/main/events/handlers/ConfigurationUpdateHandler.ts new file mode 100644 index 0000000..72f63a3 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/handlers/ConfigurationUpdateHandler.ts @@ -0,0 +1,63 @@ +import { + ConfigurationUpdateGameData, + ConfigurationUpdateModData, + KafkatorioPacketData +} from "../../../generated/kafkatorio-schema"; +import PacketEmitter from "../../emitting/PacketEmitter"; +import ConfigurationUpdate = KafkatorioPacketData.ConfigurationUpdate; +import KafkatorioPacketQueue from "../../emitting/KafkatorioPacketQueue"; + + +export class ConfigurationUpdateHandler { + + + emitConfigurationUpdate(changeData: ConfigurationChangedData) { + + const configUpdateData: ConfigurationUpdate = { + type: KafkatorioPacketData.Type.ConfigurationUpdate, + migrationApplied: changeData.migration_applied, + modStartupSettingsChange: changeData.mod_startup_settings_changed, + allMods: ConfigurationUpdateHandler.allMods(changeData), + factorioData: ConfigurationUpdateHandler.factorioData(changeData) + } + + KafkatorioPacketQueue.enqueue(configUpdateData) + } + + + private static factorioData(changeData: ConfigurationChangedData): ConfigurationUpdateGameData { + return { + oldVersion: changeData.old_version ?? null, + newVersion: changeData.new_version ?? null, + } + } + + + private static allMods(e: ConfigurationChangedData): ConfigurationUpdateModData[] { + + let namesOfChangedMods: string[] = Object.keys(e.mod_changes) + let namesOfCurrentMods: string[] = Object.keys(script.active_mods) + + let modNames = [...new Set( + namesOfChangedMods.concat(namesOfCurrentMods) + )] + + return modNames.map((modName) => { + + let currentVer = script.active_mods[modName] ?? e.mod_changes[modName]?.new_version ?? null + let previousVer = e.mod_changes[modName]?.old_version ?? null + + return { + modName: modName, + currentVersion: currentVer, + previousVersion: previousVer, + } + }) + + } + +} + +const ConfigurationUpdates = new ConfigurationUpdateHandler() + +export default ConfigurationUpdates diff --git a/modules/events-mod/src/main/typescript/main/events/handlers/EntityUpdateHandler.ts b/modules/events-mod/src/main/typescript/main/events/handlers/EntityUpdateHandler.ts new file mode 100644 index 0000000..b575d0d --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/handlers/EntityUpdateHandler.ts @@ -0,0 +1,232 @@ +import { + EventName, + FactorioEntityUpdateElementStandard, + KafkatorioPacketData, + MapChunkPosition, + PrototypeId, + Tick +} from "../../../generated/kafkatorio-schema"; +import {Converters} from "../converters"; +import EventDataCache from "../../emitting/EventDataCache"; + + +export class EntityUpdatesHandler { + + + handleMinedTileEvent(event: OnPlayerMinedTileEvent | OnRobotMinedTileEvent) { + + const surface = game.get_surface(event.surface_index) + if (surface == null) { + return + } + + const tilesByChunk: LuaTable = new LuaTable() + + for (const tile of event.tiles) { + const chunkPosition = Converters.tilePositionToChunkPosition(tile.position) + if (!tilesByChunk.has(chunkPosition)) { + tilesByChunk.set(chunkPosition, []) + } + const tiles = tilesByChunk.get(chunkPosition) + tiles[tiles.length] = tile + tilesByChunk.set(chunkPosition, tiles) + } + + for (const [chunkPos, tiles] of pairs(tilesByChunk)) { + + const entities: LuaEntity[] = [] + + for (const tile of tiles) { + const tileEntities = EntityUpdatesHandler.getTileResourceEntities(surface, tile.position) + for (const resource of tileEntities) { + entities[entities.length] = resource + } + } + + EntityUpdatesHandler.throttleResourcesUpdate( + Converters.eventNameString(event.name), + event.tick as Tick, + event.surface_index, + chunkPos, + entities, + ) + } + } + + + handleMinedEntityEvent( + event: OnPlayerMinedEntityEvent | OnRobotMinedEntityEvent, + ) { + EntityUpdatesHandler.throttleEntityUpdate(event, event.entity) + } + + + handleBuiltEntityEvent( + event: OnBuiltEntityEvent | OnRobotBuiltEntityEvent, + ) { + EntityUpdatesHandler.throttleEntityUpdate(event, event.created_entity) + } + + + handleChunkGeneratedEvent(event: OnChunkGeneratedEvent) { + const entities = EntityUpdatesHandler.getAreaResourceEntities(event.surface, event.area) + EntityUpdatesHandler.throttleResourcesUpdate( + Converters.eventNameString(event.name), + event.tick as Tick, + event.surface.index, + Converters.chunkPosition(event.position), + entities, + ) + } + + + private static throttleEntityUpdate(event: EntityUpdateEvent, entity: LuaEntity) { + + if (entity.unit_number == undefined) { + // ignore for now - I'm not sure how to track entities without a unit_number + return + } + const eventName = Converters.eventNameString(event.name) + + const entityUpdateKey: KafkatorioPacketData.MapChunkEntityUpdate["key"] = { + protoId: Converters.prototypeIdEntity(entity), + surfaceIndex: entity.surface.index, + chunkPosition: Converters.mapPositionToChunkPosition(entity.position) + } + + const entityUpdate: FactorioEntityUpdateElementStandard = { + unitNumber: entity.unit_number, + graphicsVariation: entity.graphics_variation, + health: entity.health, + isActive: entity.active, + isRotatable: entity.rotatable, + lastUser: entity.last_user?.index, + status: Converters.entityStatus(entity.status), + } + + EventDataCache.throttle( + entityUpdateKey, + KafkatorioPacketData.Type.MapChunkEntityUpdate, + data => { + + data.events ??= {} + data.events[eventName] ??= [] + data.events[eventName].push(event.tick) + + data.entitiesXY ??= {} + data.entitiesXY[`${entity.position.x}`] ??= {} + data.entitiesXY[`${entity.position.x}`][`${entity.position.y}`] ??= entityUpdate + } + ) + } + + + private static throttleResourcesUpdate( + eventName: EventName, + eventTick: Tick, + surfaceIndex: SurfaceIndex, + chunkPosition: MapChunkPosition, + entities: LuaEntity[], + ) { + + // first group by prototype ID + const entitiesByProtoId: { [protoId: PrototypeId]: LuaEntity[] } = {} + + for (const entity of entities) { + const protoId = Converters.prototypeIdEntity(entity) + entitiesByProtoId[protoId] ??= [] + entitiesByProtoId[protoId].push(entity) + } + + for (const [protoId, resourceEntities] of pairs(entitiesByProtoId)) { + + // create a MapChunkResourceUpdate for each prototype ID + + const entityUpdateKey: KafkatorioPacketData.MapChunkResourceUpdate["key"] = { + protoId: protoId, + surfaceIndex: surfaceIndex, + chunkPosition: chunkPosition, + } + + EventDataCache.throttle( + entityUpdateKey, + KafkatorioPacketData.Type.MapChunkResourceUpdate, + data => { + + data.events ??= {} + data.events[eventName] ??= [] + data.events[eventName].push(eventTick) + + for (const entity of resourceEntities) { + + data.amounts ??= {} + data.amounts[`${entity.position.x}`] ??= {} + data.amounts[`${entity.position.x}`][`${entity.position.y}`] = entity.amount + + if (entity.initial_amount != null) { + data.initialAmounts ??= {} + data.initialAmounts[`${entity.position.x}`] ??= {} + data.initialAmounts[`${entity.position.x}`][`${entity.position.y}`] = entity.initial_amount + } + } + } + ) + } + } + + + /** Get all resources on a tile-position */ + private static getTileResourceEntities( + surface: LuaSurface, + mapPosition: MapPosition, + ): LuaEntity[] { + return surface.find_entities_filtered({ + position: mapPosition, + collision_mask: "resource-layer", + } + ) + } + + + /** Get all resources within a map-area */ + private static getAreaResourceEntities( + surface: LuaSurface, + area: BoundingBoxTable, + ): LuaEntity[] { + return surface.find_entities_filtered({ + area: area, + collision_mask: "resource-layer", + } + ) + } +} + +const EntityUpdates = new EntityUpdatesHandler() + +export default EntityUpdates + + +type EntityUpdateEvent = + | OnBuiltEntityEvent + + | OnEntityClonedEvent + | OnEntityDamagedEvent + | OnEntityDestroyedEvent + | OnEntityDiedEvent + | OnEntityLogisticSlotChangedEvent + | OnEntityRenamedEvent + | OnEntitySettingsPastedEvent + | OnEntitySpawnedEvent + + | OnPlayerMinedEntityEvent + | OnPlayerRepairedEntityEvent + | OnPlayerRotatedEntityEvent + + | OnRobotMinedEntityEvent + | OnRobotBuiltEntityEvent + + | OnPostEntityDiedEvent + | OnPreEntitySettingsPastedEvent + + | OnSelectedEntityChangedEvent + | OnTriggerCreatedEntityEvent diff --git a/modules/events-mod/src/main/typescript/main/events/handlers/MapChunkUpdateHandler.ts b/modules/events-mod/src/main/typescript/main/events/handlers/MapChunkUpdateHandler.ts new file mode 100644 index 0000000..5ab13ec --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/handlers/MapChunkUpdateHandler.ts @@ -0,0 +1,237 @@ +import {Converters} from "../converters"; +import {isEventType} from "../eventTypeCheck"; +import { + KafkatorioPacketData, + MapChunkPosition, + PrototypeKey +} from "../../../generated/kafkatorio-schema"; +import EventUpdates, {PacketKey} from "../../emitting/EventDataCache"; +import {MapChunkUpdateEvent, MapTileChangeEvent} from "../mapChunkUpdates"; + + +type MapChunkTileUpdater = (data: KafkatorioPacketData.MapChunkTileUpdate) => void + + +class MapChunkUpdateHandler { + + handleChunkGeneratedEvent( + event: OnChunkGeneratedEvent, + expirationDurationTicks?: uint, + ) { + const tiles = event.surface.find_tiles_filtered({area: event.area}) + + MapChunkUpdateHandler.mapTilesUpdateDebounce( + event.surface, + Converters.chunkPosition(event.position), + tiles, + event, + undefined, + expirationDurationTicks, + ) + } + + + handleBuiltTileEvent(event: OnPlayerBuiltTileEvent | OnRobotBuiltTileEvent) { + + const surface = game.get_surface(event.surface_index) + if (surface == undefined) { + const eventName = Converters.eventNameString(event.name) + log(`[handleBuiltTileEvent] undefined surface ${eventName}`) + return + } + + const tiles: TileRead[] = Converters.convertPlacedTiles(event.tile, event.tiles) + const groupedTiles = MapChunkUpdateHandler.groupTiles(tiles) + + for (const [chunkPos, tiles] of groupedTiles) { + MapChunkUpdateHandler.mapTilesUpdateDebounce( + surface, + chunkPos, + tiles, + event, + (data => { + if (isEventType(event, defines.events.on_player_built_tile)) { + data.player = event.player_index + return + } + if (isEventType(event, defines.events.on_robot_built_tile)) { + data.robot = { + unitNumber: event.robot?.unit_number ?? null, + protoId: Converters.prototypeId(event.robot.type, event.robot.name), + } + return + } + // this line will not compile if the previous 'if' statements are not exhaustive + // noinspection UnnecessaryLocalVariableJS,JSUnusedLocalSymbols + const exhaustiveCheck: never = event + } + ) + ) + } + } + + + handleMinedTileEvent(event: OnPlayerMinedTileEvent | OnRobotMinedTileEvent) { + const surface = game.get_surface(event.surface_index) + if (surface == undefined) { + const eventName = Converters.eventNameString(event.name) + log(`[handleMinedTileEvent] undefined surface ${eventName}`) + return + } + + const tiles: TileRead[] = Converters.convertRemovedTiles(surface, event.tiles) + const groupedTiles = MapChunkUpdateHandler.groupTiles(tiles) + + for (const [chunkPos, tiles] of groupedTiles) { + + MapChunkUpdateHandler.mapTilesUpdateDebounce( + surface, + chunkPos, + tiles, + event, + (data => { + if (isEventType(event, defines.events.on_player_mined_tile)) { + data.player = event.player_index + return + } + if (isEventType(event, defines.events.on_robot_mined_tile)) { + data.robot = { + unitNumber: event.robot?.unit_number ?? null, + protoId: Converters.prototypeId(event.robot.type, event.robot.name), + } + return + } + // this line will not compile if the previous 'if' statements are not exhaustive + // noinspection UnnecessaryLocalVariableJS,JSUnusedLocalSymbols + const exhaustiveCheck: never = event + } + ) + ) + } + } + + + handleScriptSetTilesEvent(event: ScriptRaisedSetTilesEvent) { + + const surface = game.get_surface(event.surface_index) + if (surface == undefined) { + return + } + + const groupedTiles = MapChunkUpdateHandler.groupTiles(event.tiles) + + for (const [chunkPos, tiles] of groupedTiles) { + MapChunkUpdateHandler.mapTilesUpdateDebounce(surface, chunkPos, tiles, event) + } + } + + + handlePreChunkDeleted(event: OnPreChunkDeletedEvent) { + + const surface = game.get_surface(event.surface_index) + if (surface == undefined) { + return + } + + for (const position of event.positions) { + const key: PacketKey = { + surfaceIndex: surface.index, + chunkPosition: Converters.chunkPosition(position), + } + + EventUpdates.debounce( + key, + KafkatorioPacketData.Type.MapChunkTileUpdate, + data => data.isDeleted = true, + 0, // deletion is important - emit ASAP + ) + } + } + + + private static mapTilesUpdateDebounce( + surface: LuaSurface | undefined, + chunkPosition: MapChunkPosition, + tiles: TileRead[], + event: MapChunkUpdateEvent | MapTileChangeEvent, + updater?: MapChunkTileUpdater, + expirationDurationTicks?: uint, + ) { + + if (surface == undefined) { + return + } + + const eventName = Converters.eventNameString(event.name) + + const key: KafkatorioPacketData.MapChunkTileUpdate["key"] = { + surfaceIndex: surface.index, + chunkPosition: chunkPosition, + } + + EventUpdates.debounce( + key, + KafkatorioPacketData.Type.MapChunkTileUpdate, + data => { + + // tile dictionary update + if (data.tileDictionary == undefined) { + data.tileDictionary = { + tilesXY: {}, + protos: {}, + } + } + + let protosCount: uint = table_size(data.tileDictionary.protos) + for (const tile of tiles) { + const protoId = Converters.prototypeId("tile", tile.name) + + if (data.tileDictionary.protos[protoId] == null) { + + } + data.tileDictionary.protos[protoId] ??= protosCount++ as PrototypeKey + + const protoKey = data.tileDictionary.protos[protoId] + + const xString = `${tile.position.x}` + const yString = `${tile.position.y}` + + data.tileDictionary.tilesXY[xString] ??= {} + data.tileDictionary.tilesXY[xString][yString] = protoKey + } + + // events count update + data.events ??= {} + data.events[eventName] ??= [] + data.events[eventName].push(event.tick) + + // apply mutator + if (updater != undefined) { + updater(data) + } + }, + expirationDurationTicks, + ) + } + + + private static groupTiles(tiles: TileRead[]): Map { + + const mapChunkPositionToTiles = new Map() + for (const tile of tiles) { + const chunkPosition = Converters.tilePositionToChunkPosition(tile.position) + if (!mapChunkPositionToTiles.has(chunkPosition)) { + mapChunkPositionToTiles.set(chunkPosition, []) + } + mapChunkPositionToTiles.get(chunkPosition)?.push(tile) + } + return mapChunkPositionToTiles + } + + +} + + +const MapChunkUpdate = new MapChunkUpdateHandler() + +export default MapChunkUpdate diff --git a/modules/events-mod/src/main/typescript/main/events/handlers/PlayerUpdateHandler.ts b/modules/events-mod/src/main/typescript/main/events/handlers/PlayerUpdateHandler.ts new file mode 100644 index 0000000..59e243b --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/handlers/PlayerUpdateHandler.ts @@ -0,0 +1,75 @@ +import {KafkatorioPacketData} from "../../../generated/kafkatorio-schema"; +import {Converters} from "../converters"; +import EventUpdates from "../../emitting/EventDataCache"; + + +export type PlayerUpdater = (player: LuaPlayer, data: KafkatorioPacketData.PlayerUpdate) => void + + +export type PlayerUpdateEvent = + | OnPlayerJoinedGameEvent + | OnPlayerChangedPositionEvent + | OnPlayerChangedSurfaceEvent + | OnPlayerDiedEvent + | OnPlayerBannedEvent + | OnPlayerUnbannedEvent + | OnPlayerKickedEvent + | OnPrePlayerLeftGameEvent + | OnPlayerRemovedEvent + + +export class PlayerUpdateHandler { + + handleBannedEvent(event: OnPlayerBannedEvent | OnPlayerUnbannedEvent) { + this.playerUpdateThrottle( + event, + (player, data) => { + data.bannedReason = event.reason ?? null + Converters.playerOnlineInfo(player, data) + } + ) + } + + + playerUpdateThrottle( + event: PlayerUpdateEvent, + mutate: PlayerUpdater, + expirationDurationTicks: uint | undefined = undefined, + ) { + const playerIndex = event.player_index + if (playerIndex == undefined) { + return + } + + const eventName = Converters.eventNameString(event.name) + + EventUpdates.throttle( + {index: playerIndex}, + KafkatorioPacketData.Type.PlayerUpdate, + data => { + const player = game.players[playerIndex] + if (player != undefined) { + mutate(player, data) + } + + data.events ??= {} + data.events[eventName] ??= [] + data.events[eventName].push(event.tick) + }, + expirationDurationTicks, + ) + } + + + playerUpdateImmediate( + event: PlayerUpdateEvent, + mutate: PlayerUpdater, + ) { + this.playerUpdateThrottle(event, mutate, 0) + } + +} + +const PlayerUpdates = new PlayerUpdateHandler() + +export default PlayerUpdates diff --git a/modules/events-mod/src/main/typescript/main/events/mapChunkUpdates.ts b/modules/events-mod/src/main/typescript/main/events/mapChunkUpdates.ts new file mode 100644 index 0000000..ca3cda0 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/mapChunkUpdates.ts @@ -0,0 +1,79 @@ +import EntityUpdates from "./handlers/EntityUpdateHandler"; +import MapChunkUpdate from "./handlers/MapChunkUpdateHandler"; + + +export type MapTileChangeEvent = + | OnPlayerBuiltTileEvent + | OnPlayerMinedTileEvent + | OnRobotBuiltTileEvent + | OnRobotMinedTileEvent + | ScriptRaisedSetTilesEvent + + +export type MapChunkUpdateEvent = + | OnChunkChartedEvent + | OnChunkDeletedEvent + | OnChunkGeneratedEvent + | OnPreChunkDeletedEvent + + +script.on_event(defines.events.on_chunk_generated, (e: OnChunkGeneratedEvent) => { + log(`on_chunk_generated ${e.tick}`) + MapChunkUpdate.handleChunkGeneratedEvent(e) + EntityUpdates.handleChunkGeneratedEvent(e) +}) + + +// script.on_event( +// defines.events.on_chunk_charted, +// (e: OnChunkChartedEvent) => { +// log(`on_chunk_charted ${e.tick}`) +// +// // const surface = getSurface(e.surface_index) +// // if (surface == undefined) { +// // return +// // } +// // +// // let tiles = getTiles(surface, e.area) +// // mapTilesUpdateDebounce(surface, e.position, tiles, (data => { +// // data.force = e.force.index +// // })) +// } +// ) + + +script.on_event(defines.events.script_raised_set_tiles, (event: ScriptRaisedSetTilesEvent) => { + log(`script_raised_set_tiles ${event.tick}`) + MapChunkUpdate.handleScriptSetTilesEvent(event) +}) + + +script.on_event(defines.events.on_player_built_tile, (e: OnPlayerBuiltTileEvent) => { + log(`on_player_built_tile ${e.tick}`) + MapChunkUpdate.handleBuiltTileEvent(e) +}) + + +script.on_event(defines.events.on_robot_built_tile, (e: OnRobotBuiltTileEvent) => { + log(`on_robot_built_tile ${e.tick}`) + MapChunkUpdate.handleBuiltTileEvent(e) +}) + + +script.on_event(defines.events.on_player_mined_tile, (e: OnPlayerMinedTileEvent) => { + log(`on_player_mined_tile ${e.tick}`) + MapChunkUpdate.handleMinedTileEvent(e) + EntityUpdates.handleMinedTileEvent(e) +}) + + +script.on_event(defines.events.on_robot_mined_tile, (e: OnRobotMinedTileEvent) => { + log(`on_robot_mined_tile ${e.tick}`) + MapChunkUpdate.handleMinedTileEvent(e) +}) + + +script.on_event(defines.events.on_pre_chunk_deleted, (e: OnPreChunkDeletedEvent) => { + log(`on_pre_chunk_deleted ${e.tick}`) + MapChunkUpdate.handlePreChunkDeleted(e) +}) diff --git a/modules/events-mod/src/main/typescript/main/events/playerUpdates.ts b/modules/events-mod/src/main/typescript/main/events/playerUpdates.ts new file mode 100644 index 0000000..da34131 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/playerUpdates.ts @@ -0,0 +1,135 @@ +import {Converters} from "./converters"; +import {ForceIndex, KafkatorioPacketData, PlayerUpdateKey} from "../../generated/kafkatorio-schema"; +import packetEmitter from "../emitting/PacketEmitter"; +import PlayerUpdates from "./handlers/PlayerUpdateHandler"; + + +// function playerUpdateDebounce(playerIndex: uint, mutate: PlayerUpdater) { +// EventUpdatesManager.debounce<"PLAYER">( +// {index: playerIndex, updateType: "PLAYER"}, +// data => { +// const player = game.players[playerIndex] +// mutate(player, data) +// } +// ) +// } + + +script.on_event(defines.events.on_player_joined_game, (e: OnPlayerJoinedGameEvent) => { + PlayerUpdates.playerUpdateThrottle( + e, + (player, data) => { + data.isAdmin = player.admin + data.characterUnitNumber = player.character?.unit_number ?? null + data.chatColour = Converters.mapColour(player.chat_color) + data.colour = Converters.mapColour(player.color) + data.forceIndex = player.force.index as ForceIndex + data.name = player.name + data.isShowOnMap = player.show_on_map + data.isSpectator = player.spectator + data.surfaceIndex = player.surface.index + data.tag = player.tag + Converters.playerOnlineInfo(player, data) + } + ) +}) + + +script.on_event(defines.events.on_player_changed_position, (e: OnPlayerChangedPositionEvent) => { + PlayerUpdates.playerUpdateThrottle( + e, + (player, data) => { + data.position = [player.position.x, player.position.y] + } + ) +}) + + +script.on_event(defines.events.on_player_changed_surface, (e: OnPlayerChangedSurfaceEvent) => { + PlayerUpdates.playerUpdateThrottle( + e, + (player, data) => { + data.position = [player.position.x, player.position.y] + data.surfaceIndex = player.surface.index + } + ) +}) + + +script.on_event(defines.events.on_player_died, (e: OnPlayerDiedEvent) => { + PlayerUpdates.playerUpdateThrottle( + e, + (player, data) => { + data.ticksToRespawn = player.ticks_to_respawn ?? null + Converters.playerOnlineInfo(player, data) + if (e.cause != undefined) { + data.diedCause = { + unitNumber: e.cause.unit_number ?? null, + protoId: Converters.prototypeId(e.cause.type, e.cause.name), + } + } + } + ) +}) + + +script.on_event(defines.events.on_player_banned, (event: OnPlayerBannedEvent) => { + PlayerUpdates.handleBannedEvent(event) +}) +script.on_event(defines.events.on_player_unbanned, (event: OnPlayerBannedEvent) => { + PlayerUpdates.handleBannedEvent(event) +}) + + +script.on_event(defines.events.on_player_kicked, (event: OnPlayerKickedEvent) => { + log(`on_player_kicked ${event.tick} ${event.name}`) + PlayerUpdates.playerUpdateImmediate( + event, + (player, data) => { + data.kickedReason = event.reason ?? null + Converters.playerOnlineInfo(player, data) + } + ) +}) + + +script.on_event(defines.events.on_pre_player_left_game, (event: OnPrePlayerLeftGameEvent) => { + log(`on_pre_player_left_game ${event.tick} ${event.name}`) + + const playerUpdateKey: PlayerUpdateKey = { + index: event.player_index, + } + + const playerUpdate: KafkatorioPacketData.PlayerUpdate = { + type: KafkatorioPacketData.Type.PlayerUpdate, + key: playerUpdateKey, + disconnectReason: disconnectReasons.get(event.reason) + } + + packetEmitter.emitKeyedPacket(playerUpdate) + + // playerUpdateImmediate( + // event, + // (player, data) => { + // data.disconnectReason = disconnectReasons.get(event.reason) + // playerOnlineInfo(player, data) + // } + // ) +}) + +script.on_event(defines.events.on_player_removed, (event: OnPlayerRemovedEvent) => { + log(`on_player_removed ${event.tick} ${event.name}`) + PlayerUpdates.playerUpdateImmediate( + event, + (player, data) => { + data.isRemoved = true + Converters.playerOnlineInfo(player, data) + } + ) +}) + + +const disconnectReasons = new LuaTable() +for (const [name, disconnectId] of pairs(defines.disconnect_reason)) { + disconnectReasons.set(disconnectId, name) +} diff --git a/modules/events-mod/src/main/typescript/main/events/prototypeUpdates.ts b/modules/events-mod/src/main/typescript/main/events/prototypeUpdates.ts new file mode 100644 index 0000000..b5f785d --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/prototypeUpdates.ts @@ -0,0 +1,112 @@ +import { + EntityItemGroup, + FactorioPrototype, + KafkatorioPacketData +} from "../../generated/kafkatorio-schema"; +import {Converters} from "./converters"; +import KafkatorioPacketQueue from "../emitting/KafkatorioPacketQueue"; + + +type PrototypesByType = Record + + +export function emitPrototypes() { + + const mapTileProtos: PrototypesByType = getMapTilePrototypes() + emit(mapTileProtos) + + const entityProtos: PrototypesByType = getEntityPrototypes() + emit(entityProtos) +} + + +function emit(protosByType: PrototypesByType) { + for (const [, protos] of pairs(protosByType)) { + KafkatorioPacketQueue.enqueue({ + type: KafkatorioPacketData.Type.PrototypesUpdate, + prototypes: protos, + }) + } +} + + +function getMapTilePrototypes(): PrototypesByType { + const tiles: FactorioPrototype.MapTile[] = [] + + for (const [, tile] of game.tile_prototypes) { + tiles[tiles.length] = { + type: FactorioPrototype.Type.MapTile, + + protoId: Converters.prototypeId("tile", tile.name), + order: tile.order, + layer: tile.layer, + collisionMasks: Converters.convertCollisionMaskToNames(tile.collision_mask), + mapColour: Converters.mapColour(tile.map_color), + canBeMined: tile.mineable_properties.minable, + } + } + + return { + "tiles": tiles + } +} + + +function getEntityPrototypes(): PrototypesByType { + const protos: PrototypesByType = {} + + for (const [, entity] of game.entity_prototypes) { + const key: string = `${entity.group.name}/${entity.subgroup.name}/${entity.type}` + + protos[key] ??= [] + + const entityProto: FactorioPrototype.Entity = { + type: FactorioPrototype.Type.Entity, + protoId: Converters.prototypeId(entity.type, entity.name), + + group: convertItemGroup(entity.group), + subgroup: convertItemSubgroup(entity.subgroup), + + isBuilding: entity.is_building, + isEntityWithOwner: entity.is_entity_with_owner, + isMilitaryTarget: entity.is_military_target, + maxHealth: entity.max_health, + collisionBox: Converters.collisionBox(entity.collision_box), + + tileWidth: entity.tile_width, + tileHeight: entity.tile_height, + } + + if (entity.map_color != undefined) { + entityProto.mapColour = Converters.mapColour(entity.map_color) + } + if (entity.friendly_map_color != undefined) { + entityProto.mapColourFriend = Converters.mapColour(entity.friendly_map_color) + } + if (entity.enemy_map_color != undefined) { + entityProto.mapColourEnemy = Converters.mapColour(entity.enemy_map_color) + } + entityProto.miningProperties = Converters.miningProperties(entity.mineable_properties) + + protos[key].push(entityProto) + } + return protos +} + + +function convertItemGroup(itemGroup: LuaGroup): EntityItemGroup { + return { + name: itemGroup.name, + type: itemGroup.type, + parentName: null, + } +} + + +function convertItemSubgroup(itemGroup: LuaGroup): EntityItemGroup { + return { + name: itemGroup.name, + type: itemGroup.type, + parentName: itemGroup.group?.name ?? null, + } +} diff --git a/modules/events-mod/src/main/typescript/main/events/registerEventListeners.ts b/modules/events-mod/src/main/typescript/main/events/registerEventListeners.ts new file mode 100644 index 0000000..cc50397 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/registerEventListeners.ts @@ -0,0 +1,50 @@ +import {isEventType} from "./eventTypeCheck"; +import {Converters} from "./converters"; +import {handleSurfaceUpdate} from "./surfaceUpdates"; +import EventCacheService from "../emitting/EventDataCache"; +import MapChunkUpdate from "./handlers/MapChunkUpdateHandler"; +import KafkatorioPacketQueue from "../emitting/KafkatorioPacketQueue"; +import PacketEmitter from "../emitting/PacketEmitter"; +import {KafkatorioPacketData} from "../../generated/kafkatorio-schema"; +import EventDataQueue from "../emitting/EventDataQueue"; + + +script.on_event(defines.events.on_tick, (event: OnTickEvent) => { + if (event.tick % 1000 == 0) { + for (const [, surface] of game.surfaces) { + handleSurfaceUpdate(event, Converters.eventNameString(event.name), surface) + } + } + + const kPacket: KafkatorioPacketData | null = KafkatorioPacketQueue.dequeue() + if (kPacket != null) { + PacketEmitter.emitInstantPacket(kPacket) + } + + if (event.tick % 6 == 0) { + // Every 0.1 seconds + const emittedCount = EventCacheService.extractAndEmitExpiredPackets() + if (emittedCount > 0) { + log(`[on_tick:${event.tick}] emitted ${emittedCount} events`) + } + } + + if (event.tick % 7 == 0) { + const events: EventData[] = EventDataQueue.dequeueValues(1) + + if (events.length > 0) { + log(`[on_tick:${event.tick}] dequeued ${events.length} events, current size: ${EventDataQueue.size()}`) + + let i = 1 + for (const event of events) { + if (isEventType(event, defines.events.on_chunk_generated)) { + let eName = Converters.eventNameString(event.name) + + log(`[on_tick:${event.tick}] dequeued event ${eName}, delay ${i}`) + MapChunkUpdate.handleChunkGeneratedEvent(event, i) + i += 1 + } + } + } + } +}) diff --git a/modules/events-mod/src/main/typescript/main/events/settingsUpdate.ts b/modules/events-mod/src/main/typescript/main/events/settingsUpdate.ts new file mode 100644 index 0000000..e22b244 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/settingsUpdate.ts @@ -0,0 +1,4 @@ +script.on_event(defines.events.on_runtime_mod_setting_changed, (e: OnRuntimeModSettingChangedEvent) => { + print(`Settings changed ${e.setting_type}, ${e.player_index}, ${e.setting}, ${e.mod_name}`) + // KafkatorioSettings.loadSettings() +}) diff --git a/modules/events-mod/src/main/typescript/main/events/surfaceUpdates.ts b/modules/events-mod/src/main/typescript/main/events/surfaceUpdates.ts new file mode 100644 index 0000000..005ca34 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/events/surfaceUpdates.ts @@ -0,0 +1,20 @@ +import PacketEmitter from "../emitting/PacketEmitter"; +import {KafkatorioPacketData} from "../../generated/kafkatorio-schema"; +import Type = KafkatorioPacketData.Type; + + +export function handleSurfaceUpdate( + event: OnTickEvent, + eventType: string, + surface: LuaSurface, +) { + const update: KafkatorioPacketData.SurfaceUpdate = { + type: Type.SurfaceUpdate, + + name: surface.name, + index: surface.index, + daytime: surface.daytime, + } + + PacketEmitter.emitInstantPacket(update) +} diff --git a/modules/events-mod/src/main/typescript/main/global-init.ts b/modules/events-mod/src/main/typescript/main/global-init.ts new file mode 100644 index 0000000..3e63718 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/global-init.ts @@ -0,0 +1,15 @@ +import EventUpdates from "./emitting/EventDataCache"; +import {EventDataQueueManager} from "./emitting/EventDataQueue"; + + +export function initGlobal(force: boolean = false) { + log(`Initialising Kafkatorio Global variables (force=${force})...`) + + global.MOD_VERSION = script.active_mods[script.mod_name] + global.FACTORIO_VERSION = script.active_mods["base"] + + EventDataQueueManager.init(true) + EventUpdates.init(true) + + log("Finished initialising Kafkatorio Global variables") +} diff --git a/modules/events-mod/src/main/typescript/main/global.d.ts b/modules/events-mod/src/main/typescript/main/global.d.ts new file mode 100644 index 0000000..7a73643 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/global.d.ts @@ -0,0 +1,4 @@ +declare const global: { + MOD_VERSION: string + FACTORIO_VERSION: string +} diff --git a/modules/events-mod/src/main/typescript/main/settings/KafkatorioSettings.ts b/modules/events-mod/src/main/typescript/main/settings/KafkatorioSettings.ts new file mode 100644 index 0000000..3f53bcd --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/settings/KafkatorioSettings.ts @@ -0,0 +1,56 @@ +import {Data, DoubleSettingDefinition} from "typed-factorio/settings/types" +import {KafkatorioKeyedPacketData, KafkatorioKeyedPacketTypes} from "../types"; + +export class KafkatorioSettingsConfig { + + + private static eventCacheExpirationDefaultSeconds: Record = { + "kafkatorio.packet.keyed.PlayerUpdate": 0.5, + "kafkatorio.packet.keyed.MapChunkTileUpdate": 30, + "kafkatorio.packet.keyed.MapChunkEntityUpdate": 30, + "kafkatorio.packet.keyed.MapChunkResourceUpdate": 30, + "kafkatorio.packet.keyed.EntityUpdate": 5, + } + + + public getEventCacheExpirationTicks(packet: KafkatorioKeyedPacketData): uint { + const settingName = KafkatorioSettingsConfig.cacheDurationSettingName(packet.type) + const seconds: double = settings.global[settingName].value as double + return seconds * 60 // convert ticks to seconds + } + + + public initialiseSettings(data: Data): void { + for (const [type,] of pairs(KafkatorioSettingsConfig.eventCacheExpirationDefaultSeconds)) { + data.extend( + [KafkatorioSettingsConfig.createDefaultCacheDuration(type)] + ) + } + } + + + private static createDefaultCacheDuration( + type: KafkatorioKeyedPacketTypes, + defaultExpirationSeconds: uint = KafkatorioSettingsConfig.eventCacheExpirationDefaultSeconds[type], + ): DoubleSettingDefinition { + return { + type: "double-setting", + name: KafkatorioSettingsConfig.cacheDurationSettingName(type), + setting_type: "runtime-global", + default_value: defaultExpirationSeconds, + // min: 0.25 seconds, max: 2 minutes + minimum_value: 0.25, + maximum_value: 120, + } + } + + + private static cacheDurationSettingName(type: KafkatorioKeyedPacketTypes): string { + return `kafkatorio:cache-expiration-seconds_${type.replaceAll(".", "-")}` + } + +} + +const KafkatorioSettings = new KafkatorioSettingsConfig() + +export default KafkatorioSettings diff --git a/modules/events-mod/src/main/typescript/main/types.d.ts b/modules/events-mod/src/main/typescript/main/types.d.ts new file mode 100644 index 0000000..10270f3 --- /dev/null +++ b/modules/events-mod/src/main/typescript/main/types.d.ts @@ -0,0 +1,29 @@ +import {KafkatorioPacketData} from "../generated/kafkatorio-schema"; + +export type DefinedEventName = keyof typeof defines.events + + +/** Get all keys of `TYPE` that are not nullable. */ +type NonNullKeys = { + [KEY in keyof TYPE]: null extends Exclude ? never : KEY +}[keyof TYPE]; + + +/** Exclude all nullable keys from `TYPE`. */ +type ExcludeNullKeys = Pick> + + +/** Make all keys of `TYPE` non-nullable. */ +type NonNullableKeys = { + [KEY in keyof TYPE]: NonNullable; +} + + +type KafkatorioKeyedPacketData = Extract + +type KafkatorioKeyedPacketTypes = KafkatorioKeyedPacketData["type"]; + +type KafkatorioKeyedPacketKeys = KafkatorioKeyedPacketData["key"]; + + +type WithRequired = T & { [P in K]-?: T[P] } diff --git a/modules/events-mod/src/main/typescript/settings.ts b/modules/events-mod/src/main/typescript/settings.ts new file mode 100644 index 0000000..5a65e74 --- /dev/null +++ b/modules/events-mod/src/main/typescript/settings.ts @@ -0,0 +1,7 @@ +import {Data, Mods} from "typed-factorio/settings/types" +import KafkatorioSettings from "./main/settings/KafkatorioSettings"; + +declare const data: Data +declare const mods: Mods + +KafkatorioSettings.initialiseSettings(data) diff --git a/modules/events-mod/tsconfig.json b/modules/events-mod/tsconfig.json new file mode 100644 index 0000000..f230f54 --- /dev/null +++ b/modules/events-mod/tsconfig.json @@ -0,0 +1,46 @@ +{ + "$schema": "https://raw.githubusercontent.com/TypeScriptToLua/vscode-typescript-to-lua/master/tsconfig-schema.json", + "compilerOptions": { + "target": "esnext", + "lib": [ + "esnext" + ], + "module": "commonjs", + "moduleResolution": "node", + "types": [ + "@typescript-to-lua/language-extensions", + "lua-types/5.2", + "typed-factorio/runtime", + "typed-factorio/strict-index-types" + ], + "plugins": [ + { + "name": "typescript-tstl-plugin" + } + ], + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "explainFiles": false, + "forceConsistentCasingInFileNames": true, + "listEmittedFiles": true, + "listFiles": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitOverride": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "sourceMap": false, + "strict": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "traceResolution": false + }, + "tstl": { + "luaTarget": "5.2", + "tstlVerbose": false, + "noHeader": true, + "noImplicitSelf": true, + "sourceMapTraceback": false, + "luaLibImport": "require" + } +} diff --git a/modules/events-processor-core/build.gradle.kts b/modules/events-processor-core/build.gradle.kts new file mode 100644 index 0000000..3a2cab4 --- /dev/null +++ b/modules/events-processor-core/build.gradle.kts @@ -0,0 +1,66 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + + +plugins { + id("kafkatorio.conventions.lang.kotlin-jvm") + kotlin("plugin.serialization") +// application +} + + +description = "Shared Kafkatorio processors functionality" + +val projectId: String by project.extra + +val kafkaStateDir: Directory = layout.projectDirectory.dir(".state/kafka") + + +dependencies { + implementation(platform(projects.modules.versionsPlatform)) + + implementation(libs.kafka.streams) + testImplementation(libs.kafka.streamsTestUtils) + + implementation(projects.modules.eventsLibrary) + + implementation(libs.kotlinxSerialization.core) + implementation(libs.kotlinxSerialization.json) + + implementation(libs.kotlinx.coroutines.core) + + implementation(libs.bundles.logging) + + implementation(libs.scrimage.core) + + implementation(libs.okio.core) + + implementation(libs.simpleSyslogParser) + + implementation(libs.kafka.kotkaStreams) + + implementation(libs.bundles.hoplite) + + implementation(libs.ktorServer.authJwt) +// implementation(libs.nimbusJoseJwt) +} + + +//application { +// mainClass.set("dev.adamko.kafkatorio.processor.admin.MainKt") +//} + + +tasks.withType().configureEach { + kotlinOptions.freeCompilerArgs += listOf( + "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + "-opt-in=kotlinx.coroutines.FlowPreview", + "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", + ) +} + + +val createKafkaTopics by tasks.registering(JavaExec::class) { + group = rootProject.name + classpath = sourceSets.main.get().runtimeClasspath + mainClass.set("dev.adamko.kafkatorio.processor.admin.MainKt") +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/admin/KafkatorioKafkaAdmin.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/admin/KafkatorioKafkaAdmin.kt new file mode 100644 index 0000000..889ab1f --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/admin/KafkatorioKafkaAdmin.kt @@ -0,0 +1,76 @@ +package dev.adamko.kafkatorio.processor.admin + +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import dev.adamko.kafkatorio.processor.config.allTopics +import java.util.concurrent.TimeUnit +import mu.KotlinLogging +import org.apache.kafka.clients.admin.Admin +import org.apache.kafka.clients.admin.CreateTopicsResult +import org.apache.kafka.clients.admin.NewTopic +import org.apache.kafka.clients.admin.TopicListing + + +class KafkatorioKafkaAdmin( + appProps: ApplicationProperties, +) { + + private val logger = KotlinLogging.logger {} + + init { + println("Creating KafkatorioKafkaAdmin with config: ${appProps.kafkaAdminConfig}") + } + + private val kafkaAdmin: Admin = Admin.create(appProps.kafkaAdminConfig) + + fun createKafkatorioTopics() { + + val currentTopics = currentTopics().map { it.name() } + + val kafkatorioTopics = allTopics() - currentTopics.toSet() + + if (kafkatorioTopics.isNotEmpty()) { + logger.info("Creating ${kafkatorioTopics.size} topics") + val result = kafkaAdmin.createTopics { kafkatorioTopics } + + // wait for all brokers to become aware of the created topics + Thread.sleep(TimeUnit.SECONDS.toMillis(5)) + + result.values().forEach { + logger.info("Created topic: ${it.key} ${it.value.get()}") + } + + Thread.sleep(TimeUnit.SECONDS.toMillis(5)) + + logger.info("Listing topics") + kafkaAdmin.listTopics() + .listings() + .get() + .forEach { + logger.info("Topic: $it") + } + } + } + + private fun Admin.createTopics( + numPartitions: Int = 3, + replicationFactor: Short = 1, + topicNames: () -> Collection, + ): CreateTopicsResult = + createTopics( + topicNames() + .distinct() + .map { + NewTopic(it, numPartitions, replicationFactor) +// .configs(mapOf("cleanup.policy" to "compact")) + } + ) + + private fun currentTopics(): MutableCollection { + return kafkaAdmin.listTopics() + .listings() + .get() + } + +// fun topicNameBase(packetType: KafkatorioPacketDataType): String = +// "kafkatorio.${packetType.name}" +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/ApplicationProperties.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/ApplicationProperties.kt new file mode 100644 index 0000000..8107790 --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/ApplicationProperties.kt @@ -0,0 +1,46 @@ +package dev.adamko.kafkatorio.processor.config + +import com.sksamuel.hoplite.ConfigLoaderBuilder +import com.sksamuel.hoplite.addEnvironmentSource +import com.sksamuel.hoplite.addResourceOrFileSource +import com.sksamuel.hoplite.sources.UserSettingsPropertySource +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.FactorioServerToken +import dev.adamko.kafkatorio.schema.common.MaskedValue +import java.nio.file.Path + +internal val appProps = ApplicationProperties.load() + +data class ApplicationProperties( + val webPort: PortVal, + val serverDataDir: Path, + val kafkaAdminConfig: Map, + val kafkaStreamsConfig: Map, + + val socketServerHost: String, + val socketServerPort: Int, + + val jwtSecret: MaskedValue, + + val kafkatorioServers: Map +) { + + companion object { + /** use Hoplite to load config from environment variables or properties files */ + fun load(): ApplicationProperties = + ConfigLoaderBuilder.default() + .addDefaults() + .allowUnresolvedSubstitutions() + .allowEmptySources() + .addEnvironmentSource() + .addResourceOrFileSource( + resourceOrFile = "${System.getProperty("user.home")}/.secret.kafkatorio-config.yml", + optional = true, + ) + .addResourceOrFileSource("/.secret.config.yml", optional = true) + .addResourceOrFileSource("/config.yml", optional = false) + .addPropertySource(UserSettingsPropertySource) + .build() + .loadConfigOrThrow() + } +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/PortVal.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/PortVal.kt new file mode 100644 index 0000000..29ebb4f --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/PortVal.kt @@ -0,0 +1,21 @@ +package dev.adamko.kafkatorio.processor.config + + +/** Improved (slightly) version of http4k's `Port`. */ +@JvmInline +value class PortVal(val value: Int) { + + init { + require(value in VALID_RANGE) { + "Out of range. Port: '$value', range: $VALID_RANGE" + } + } + + operator fun invoke(): Int = value + + companion object { + val DEFAULT = PortVal(8080) + val VALID_RANGE: IntRange + get() = (1..65535) // get() is required to prevent init ordering causing NPE + } +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/kafkatorioTopics.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/kafkatorioTopics.kt new file mode 100644 index 0000000..36d70ba --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/kafkatorioTopics.kt @@ -0,0 +1,99 @@ +package dev.adamko.kafkatorio.processor.config + +import dev.adamko.kafkatorio.schema.packets.ConfigurationUpdate +import dev.adamko.kafkatorio.schema.packets.ConsoleChatUpdate +import dev.adamko.kafkatorio.schema.packets.ConsoleCommandUpdate +import dev.adamko.kafkatorio.schema.packets.EntityUpdate +import dev.adamko.kafkatorio.schema.packets.KafkatorioPacketData +import dev.adamko.kafkatorio.schema.packets.KafkatorioPacketDataError +import dev.adamko.kafkatorio.schema.packets.MapChunkEntityUpdate +import dev.adamko.kafkatorio.schema.packets.MapChunkResourceUpdate +import dev.adamko.kafkatorio.schema.packets.MapChunkTileUpdate +import dev.adamko.kafkatorio.schema.packets.PlayerUpdate +import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate +import dev.adamko.kafkatorio.schema.packets.SurfaceUpdate +import kotlin.reflect.KClass + + +private const val DOMAIN = "kafkatorio" + +const val TOPIC_SRC_SERVER_LOG = "$DOMAIN.src.server-log" +const val TOPIC_SRC_SERVER_LOG_DLQ = "$DOMAIN.src.server-log.dlq" + +//const val TOPIC_GROUPED_MAP_CHUNKS_STATE = "$DOMAIN.state.map-chunks.grouped" + +const val TOPIC_MAP_CHUNK_TERRAIN_COLOURED_032_UPDATES = + "$DOMAIN.state-updates.map-chunk-032.terrain.colour" +const val TOPIC_MAP_CHUNK_RESOURCE_COLOURED_032_UPDATES = + "$DOMAIN.state-updates.map-chunk-032.resource.colour" +const val TOPIC_MAP_CHUNK_BUILDING_COLOURED_032_UPDATES = + "$DOMAIN.state-updates.map-chunk-032.building.colour" + +const val TOPIC_MAP_CHUNK_TERRAIN_COLOURED_STATE = "$DOMAIN.state.map-chunk.terrain.colour" +const val TOPIC_MAP_CHUNK_RESOURCE_COLOURED_STATE = "$DOMAIN.state.map-chunk.resource.colour" +const val TOPIC_MAP_CHUNK_BUILDING_COLOURED_STATE = "$DOMAIN.state.map-chunk.building.colour" + +//const val TOPIC_SUBDIVIDED_MAP_TILES = "$DOMAIN.map-tiles.subdivided" +//const val TOPIC_SUBDIVIDED_MAP_TILES_DEBOUNCED = "$TOPIC_SUBDIVIDED_MAP_TILES.debounced" + + +/** Broadcast these events out, via websocket */ +const val TOPIC_BROADCAST_TO_WEBSOCKET = "$DOMAIN.broadcast.websocket" + +fun allTopics(): Set = buildSet { + add(TOPIC_SRC_SERVER_LOG) + add(TOPIC_SRC_SERVER_LOG_DLQ) + +// add(TOPIC_GROUPED_MAP_CHUNKS_STATE) + + add(TOPIC_MAP_CHUNK_TERRAIN_COLOURED_032_UPDATES) + add(TOPIC_MAP_CHUNK_RESOURCE_COLOURED_032_UPDATES) + add(TOPIC_MAP_CHUNK_BUILDING_COLOURED_032_UPDATES) + + add(TOPIC_MAP_CHUNK_TERRAIN_COLOURED_STATE) + add(TOPIC_MAP_CHUNK_RESOURCE_COLOURED_STATE) + add(TOPIC_MAP_CHUNK_BUILDING_COLOURED_STATE) + +// add(TOPIC_SUBDIVIDED_MAP_TILES) +// add(TOPIC_SUBDIVIDED_MAP_TILES_DEBOUNCED) + + add(TOPIC_BROADCAST_TO_WEBSOCKET) + + addAll(packetTopicNames.values) +} + +val KafkatorioPacketData.topicName: String + get() = when (this) { + is ConfigurationUpdate -> packetTopicNames.getValue(ConfigurationUpdate::class) + is ConsoleChatUpdate -> packetTopicNames.getValue(ConsoleChatUpdate::class) + is ConsoleCommandUpdate -> packetTopicNames.getValue(ConsoleCommandUpdate::class) + is PrototypesUpdate -> packetTopicNames.getValue(PrototypesUpdate::class) + is SurfaceUpdate -> packetTopicNames.getValue(SurfaceUpdate::class) + is EntityUpdate -> packetTopicNames.getValue(EntityUpdate::class) + is MapChunkTileUpdate -> packetTopicNames.getValue(MapChunkTileUpdate::class) + is PlayerUpdate -> packetTopicNames.getValue(PlayerUpdate::class) + is KafkatorioPacketDataError -> packetTopicNames.getValue(KafkatorioPacketDataError::class) + is MapChunkEntityUpdate -> packetTopicNames.getValue(MapChunkEntityUpdate::class) + is MapChunkResourceUpdate -> packetTopicNames.getValue(MapChunkResourceUpdate::class) + } + + +private val packetTopicNames: Map, String> = mapOf( + ConfigurationUpdate::class to "configuration", + ConsoleChatUpdate::class to "console-chat", + ConsoleCommandUpdate::class to "console-command", + PrototypesUpdate::class to "prototypes", + SurfaceUpdate::class to "surface", + EntityUpdate::class to "entity", + MapChunkTileUpdate::class to "map-chunk-tile", + PlayerUpdate::class to "player", + MapChunkEntityUpdate::class to "map-chunk-entity", + MapChunkResourceUpdate::class to "map-chunk-resource", + KafkatorioPacketDataError::class to "error", +).mapValues { (_, v) -> + "$DOMAIN.packet.$v" +} + + +val KClass.topicName: String + get() = packetTopicNames.getValue(this) diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/kxsJson.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/kxsJson.kt new file mode 100644 index 0000000..364d089 --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/config/kxsJson.kt @@ -0,0 +1,12 @@ +package dev.adamko.kafkatorio.processor.config + +import dev.adamko.kafkatorio.library.jsonMapperKafkatorio +import kotlinx.serialization.json.Json + + +@PublishedApi +internal val jsonMapper: Json = Json { + prettyPrint = true + prettyPrintIndent = " " + serializersModule = jsonMapperKafkatorio.serializersModule +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/Authenticator.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/Authenticator.kt new file mode 100644 index 0000000..dd842d5 --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/Authenticator.kt @@ -0,0 +1,125 @@ +package dev.adamko.kafkatorio.processor.core + +import com.auth0.jwt.JWT +import com.auth0.jwt.algorithms.Algorithm +import com.auth0.jwt.interfaces.DecodedJWT +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import dev.adamko.kafkatorio.schema.common.FactorioServerToken +import kotlin.reflect.jvm.jvmName +import kotlinx.coroutines.CancellationException +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.Json +import okio.ByteString.Companion.decodeBase64 + + +class Authenticator( + appProps: ApplicationProperties, +) { + private val algorithm: Algorithm = Algorithm.HMAC256(appProps.jwtSecret.value) + + private val verifier = JWT.require(algorithm).build() + + fun verifyJwt(token: String): FactorioServerToken? { + return runCatching { + val decodedJwt: DecodedJWT? = verifier.verify(token) + + val payloadJson = decodedJwt?.payload?.decodeBase64()?.string(Charsets.UTF_8) ?: "{}" + + jsonMapper.decodeFromString( + KafkatorioJwtPayload.serializer(), + payloadJson, + ).serverToken + + }.onFailure { e -> + if (e is CancellationException) throw e + + println("[Authenticator] Could not decode JWT ${e::class.jvmName}: ${e.message}") + }.getOrNull() + } + + companion object { + private val jsonMapper = Json { + ignoreUnknownKeys = true + } + } +} + + +@Serializable +@SerialName("kafkatorio.auth.KafkatorioJwtPayload") +private data class KafkatorioJwtPayload( + @SerialName("sub") + val serverToken: FactorioServerToken, + /** unix epoch seconds*/ + @SerialName("iat") + val issuedAtTime: Long, +) + + +//// https://github.com/auth0/java-jwt/blob/f799e589c3d43de318c7ca0f0c36e462297db973/lib/src/test/java/com/auth0/jwt/PemUtils.java +//private object PemUtils { +// +// fun readPublicKey(filepath: String, algorithm: String): PublicKey { +// val bytes = parsePemFile(File(filepath)) +// return getPublicKey(bytes, algorithm) +// } +// +//// fun readPublicKey(reader: Reader, algorithm: String): PublicKey { +//// return getPublicKey(bytes, algorithm) +//// } +// +// fun readPrivateKey(filepath: String, algorithm: String): PrivateKey { +// val bytes = parsePemFile(File(filepath)) +// return getPrivateKey(bytes, algorithm) +// } +// +// private fun parsePemFile(pemFile: File): ByteArray { +// return when { +// !pemFile.isFile -> +// throw FileNotFoundException("'${pemFile.absolutePath}' is not a file") +// +// !pemFile.exists() -> +// throw FileNotFoundException("The file '${pemFile.absolutePath}' doesn't exist.") +// +// else -> +// PemReader(FileReader(pemFile)).use { reader -> +// reader.readPemObject().content +// } +// } +// } +// +// private fun getPublicKey(keyBytes: ByteArray, algorithm: String): PublicKey = +// getKey(algorithm) { +// val keySpec: EncodedKeySpec = X509EncodedKeySpec(keyBytes) +// generatePublic(keySpec) +// } +// +// private fun getPrivateKey(keyBytes: ByteArray, algorithm: String): PrivateKey = +// getKey(algorithm) { +// val keySpec: EncodedKeySpec = PKCS8EncodedKeySpec(keyBytes) +// generatePrivate(keySpec) +// } +// +// +// private fun getKey( +// algorithm: String, +// generateKey: KeyFactory.() -> K +// ): K = runCatching { +// val kf = KeyFactory.getInstance(algorithm) +// kf.generateKey() +// }.getOrElse { e -> +// when (e) { +// is NoSuchAlgorithmException -> +// throw IllegalStateException( +// "Could not reconstruct key, algorithm '$algorithm' could not be found.", +// e +// ) +// +// is InvalidKeySpecException -> +// throw IllegalStateException("Could not reconstruct key", e) +// +// else -> throw e +// } +// } +//} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/DebounceProcessor.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/DebounceProcessor.kt new file mode 100644 index 0000000..e7aefda --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/DebounceProcessor.kt @@ -0,0 +1,149 @@ +package dev.adamko.kafkatorio.processor.core + +import dev.adamko.kotka.extensions.component1 +import dev.adamko.kotka.extensions.component2 +import dev.adamko.kotka.extensions.component3 +import dev.adamko.kotka.extensions.processor.component1 +import dev.adamko.kotka.extensions.processor.component2 +import dev.adamko.kotka.extensions.processor.component3 +import dev.adamko.kotka.extensions.state.useAll +import kotlin.time.toJavaDuration +import org.apache.kafka.common.serialization.Serde +import org.apache.kafka.streams.Topology +import org.apache.kafka.streams.processor.Cancellable +import org.apache.kafka.streams.processor.PunctuationType +import org.apache.kafka.streams.processor.api.Processor +import org.apache.kafka.streams.processor.api.ProcessorContext +import org.apache.kafka.streams.processor.api.ProcessorSupplier +import org.apache.kafka.streams.processor.api.Record +import org.apache.kafka.streams.state.StoreBuilder +import org.apache.kafka.streams.state.Stores +import org.apache.kafka.streams.state.TimestampedKeyValueStore +import org.apache.kafka.streams.state.ValueAndTimestamp +import kotlin.time.Duration + + +class DebounceProcessor( + private val inactivityDuration: Duration, + private val checkInterval: Duration, + private val storeName: String, +) : Processor { + + private lateinit var state: State + + + override fun init(context: ProcessorContext) { + state = Active(context) + } + + + override fun process(record: Record) { + (state as Active).apply { + val (key, value, _) = record + + val existing: ValueAndTimestamp? = store.get(key) + val newTimestamp = existing?.timestamp() ?: System.currentTimeMillis() + + store.put(key, ValueAndTimestamp.make(value, newTimestamp)) + } + } + + + override fun close() { + (state as? Active)?.schedule?.cancel() + state = Closed() + } + + + private sealed interface State + + + private class Closed : State + + + private inner class Active( + val context: ProcessorContext + ) : State { + val store: TimestampedKeyValueStore = context.getStateStore(storeName) + val schedule: Cancellable = context.schedule( + checkInterval.toJavaDuration(), + PunctuationType.WALL_CLOCK_TIME, + ::checkRecords + ) + + private fun checkRecords(now: Long) { + store.useAll { + forEach { record -> + val (key, value, timestamp) = record + if ((now - timestamp) > inactivityDuration.inWholeMilliseconds) { + context.forward(Record(key, value, timestamp)) + store.delete(key) + } + } + } + } + } + + companion object { + + fun Topology.addDebounceProcessor( + namePrefix: String, + sourceTopic: String, + sinkTopic: String, + + inactivityDuration: Duration, + checkInterval: Duration = inactivityDuration / 10, + keySerde: Serde, + valueSerde: Serde, + storeName: String = "$namePrefix.debounce-store", + ): Topology { + + val sourceName = "$namePrefix.debounce-source" + val processorName = "$namePrefix.debounce-processor" + val sinkName = "$namePrefix.debounce-sink" + + return addSource( + sourceName, + keySerde.deserializer(), + valueSerde.deserializer(), + sourceTopic, + ).addProcessor( + processorName, + Supplier( + inactivityDuration = inactivityDuration, + checkInterval = checkInterval, + storeName = storeName, + keySerde = keySerde, + valueSerde = valueSerde, + ), + sourceName, + ).addSink( + sinkName, + sinkTopic, + keySerde.serializer(), + valueSerde.serializer(), + processorName, + ) + } + + class Supplier( + private val inactivityDuration: Duration, + private val checkInterval: Duration, + private val storeName: String, + private val keySerde: Serde, + private val valueSerde: Serde, + ) : ProcessorSupplier { + + override fun get(): Processor = + DebounceProcessor(inactivityDuration, checkInterval, storeName) + + override fun stores(): Set> = setOf( + Stores.timestampedKeyValueStoreBuilder( + Stores.persistentTimestampedKeyValueStore(storeName), + keySerde, + valueSerde, + ) + ) + } + } +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/StreamsExceptionHandler.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/StreamsExceptionHandler.kt new file mode 100644 index 0000000..f29e953 --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/StreamsExceptionHandler.kt @@ -0,0 +1,15 @@ +package dev.adamko.kafkatorio.processor.core + +import org.apache.kafka.streams.errors.StreamsUncaughtExceptionHandler +import org.apache.kafka.streams.errors.StreamsUncaughtExceptionHandler.StreamThreadExceptionResponse + + +class StreamsExceptionHandler( + val shutdown: (e: Throwable) -> Unit, +) : StreamsUncaughtExceptionHandler { + override fun handle(exception: Throwable): StreamThreadExceptionResponse { + exception.printStackTrace() + shutdown(exception) + return StreamThreadExceptionResponse.SHUTDOWN_APPLICATION + } +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/topologyLauncher.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/topologyLauncher.kt new file mode 100644 index 0000000..5ead349 --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/processor/core/topologyLauncher.kt @@ -0,0 +1,92 @@ +package dev.adamko.kafkatorio.processor.core + +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import java.util.Properties +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException +import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.cancel +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.currentCoroutineContext +import kotlinx.coroutines.job +import kotlinx.coroutines.launch +import kotlinx.coroutines.suspendCancellableCoroutine +import org.apache.kafka.streams.KafkaStreams +import org.apache.kafka.streams.StreamsConfig +import org.apache.kafka.streams.Topology +import org.apache.kafka.streams.TopologyDescription + + +suspend fun launchTopology( + id: String, + topology: Topology, + additionalProperties: Map = mapOf(), + appProps: ApplicationProperties, +): Unit = coroutineScope { + + val props: Properties = appProps.kafkaStreamsConfig.toProperties() + + additionalProperties.forEach { (k, v) -> props.setProperty(k, v) } + + val appId = props.compute(StreamsConfig.APPLICATION_ID_CONFIG) { _, v -> "$v.$id" } as String + props.setProperty(StreamsConfig.APPLICATION_ID_CONFIG, appId) + + launch(CoroutineName(appId)) { + + val streamsState: KafkaStreams.State = suspendCancellableCoroutine { cont -> + + val streams = KafkaStreams(topology, props) + streams.setUncaughtExceptionHandler(StreamsExceptionHandler { e -> + cont.resumeWithException(e) + }) + + streams.setStateListener { newState: KafkaStreams.State, _ -> + when (newState) { + KafkaStreams.State.PENDING_SHUTDOWN, + KafkaStreams.State.NOT_RUNNING, + KafkaStreams.State.PENDING_ERROR, + KafkaStreams.State.ERROR -> if (cont.isActive) cont.resume(newState) + + else -> Unit // do nothing + } + } + + cont.invokeOnCancellation { + println("[$appId] coroutine cancelled -> closing. cause:$it") + streams.close() + } + + printTopologyDescription(appId, topology, appProps) + streams.start() + println("launched Topology $appId") + } + println("exiting Topology $appId: $streamsState") + currentCoroutineContext().job.cancel("$appId: $streamsState") + } +} + + +private fun printTopologyDescription( + appId: String, + topology: Topology, + appProps: ApplicationProperties, +) { + val description: TopologyDescription = topology.describe() + + val descFile = appProps.serverDataDir + .resolve("kafka-streams/$appId.txt") + .toFile().apply { + parentFile.mkdirs() + if (!exists()) createNewFile() + writeText(description.toString()) + } + + println( + """ + |---------------- + |$appId - ${descFile.canonicalPath} + |$description + |---------------- + """.trimMargin() + ) +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/colourMapChunks.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/colourMapChunks.kt new file mode 100644 index 0000000..8675fec --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/colourMapChunks.kt @@ -0,0 +1,329 @@ +package dev.adamko.kafkatorio.server.processor.topology + +import dev.adamko.kafkatorio.library.kxsBinary +import dev.adamko.kafkatorio.library.resize +import dev.adamko.kafkatorio.library.toMapChunkPosition +import dev.adamko.kafkatorio.processor.core.DebounceProcessor.Companion.addDebounceProcessor +import dev.adamko.kafkatorio.schema.common.ChunkSize +import dev.adamko.kafkatorio.schema.common.ColourHex +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.MapTilePosition +import dev.adamko.kafkatorio.schema.common.PrototypeHashCode +import dev.adamko.kafkatorio.schema.common.ServerMapChunkId +import dev.adamko.kafkatorio.schema.common.ServerMapTileLayer +import dev.adamko.kafkatorio.schema.packets.MapChunkTileUpdate +import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate +import dev.adamko.kafkatorio.processor.config.TOPIC_MAP_CHUNK_TERRAIN_COLOURED_032_UPDATES +import dev.adamko.kafkatorio.processor.config.TOPIC_MAP_CHUNK_TERRAIN_COLOURED_STATE +import dev.adamko.kotka.extensions.consumedAs +import dev.adamko.kotka.extensions.groupedAs +import dev.adamko.kotka.extensions.materializedAs +import dev.adamko.kotka.extensions.producedAs +import dev.adamko.kotka.extensions.repartitionedAs +import dev.adamko.kotka.extensions.stream +import dev.adamko.kotka.extensions.streams.filter +import dev.adamko.kotka.extensions.streams.flatMap +import dev.adamko.kotka.extensions.streams.map +import dev.adamko.kotka.extensions.streams.peek +import dev.adamko.kotka.extensions.streams.reduce +import dev.adamko.kotka.extensions.tableJoined +import dev.adamko.kotka.extensions.tables.join +import dev.adamko.kotka.extensions.tables.toStream +import dev.adamko.kotka.kxs.serde +import kotlin.collections.component1 +import kotlin.collections.component2 +import kotlin.time.Duration.Companion.seconds +import org.apache.kafka.streams.StreamsBuilder +import org.apache.kafka.streams.Topology +import org.apache.kafka.streams.kstream.KStream +import org.apache.kafka.streams.kstream.KTable + + +/** Add colour to each [MapChunkTileUpdate] */ +fun colourMapChunks( + builder: StreamsBuilder, + protosStream: KStream +): Topology { + val pid = "colourMapChunks.terrain" + + val mapChunksStream: KStream = builder.streamPacketData() + + val protosTable: KTable = + protosStream.createTilePrototypeTable() + + val chunkTilesColouredTable032: KTable> = + mapChunksStream + .convertToServerMapChunkTiles(pid) + .reduceServerMapChunkTilesToTable(pid) + .enrichWithColourData(pid, protosTable) + + chunkTilesColouredTable032.streamMapChunkColouredTo( + "$pid.${ChunkSize.CHUNK_032}", + TOPIC_MAP_CHUNK_TERRAIN_COLOURED_032_UPDATES, + ) + + val chunkTilesColoured: KStream> = + builder.stream( + consumedAs( + "$pid.consume.map-chunks-debounced", + kxsBinary.serde(ServerMapChunkId.serializer()), + kxsBinary.serde(ServerMapChunkTiles.serializer(ColourHex.serializer())), + ), + TOPIC_MAP_CHUNK_TERRAIN_COLOURED_STATE, + ) + + mapOf( +// ChunkSize.CHUNK_032 to ChunkSize.CHUNK_064, +// ChunkSize.CHUNK_064 to ChunkSize.CHUNK_128, +// ChunkSize.CHUNK_128 to ChunkSize.CHUNK_256, +// ChunkSize.CHUNK_256 to ChunkSize.CHUNK_512, + + ChunkSize.CHUNK_032 to ChunkSize.CHUNK_256, + ChunkSize.CHUNK_256 to ChunkSize.CHUNK_512, + ).forEach { (from, to) -> + chunkTilesColoured + .filter("$pid.combine-chunks.filter-$from-to-$to") { key: ServerMapChunkId, _: ServerMapChunkTiles -> + key.chunkSize == from + }.groupByChunkPosition("$pid.from-$from-to-$to", to) + .streamMapChunkColouredTo( + "$pid.from-$from-to-$to", + TOPIC_MAP_CHUNK_TERRAIN_COLOURED_STATE + ) + } + + return builder.build() + .addDebounceProcessor( + namePrefix = "groupMapChunks.terrain", + sourceTopic = TOPIC_MAP_CHUNK_TERRAIN_COLOURED_032_UPDATES, + sinkTopic = TOPIC_MAP_CHUNK_TERRAIN_COLOURED_STATE, + inactivityDuration = 15.seconds, + keySerde = kxsBinary.serde(ServerMapChunkId.serializer()), + valueSerde = kxsBinary.serde(ServerMapChunkTiles.serializer(ColourHex.serializer())), + ) +} + + +private fun KStream.convertToServerMapChunkTiles( + callerPid: String +): KStream> { + + val pid = "$callerPid.convertToMapTiles" + + return map("$pid.map") { serverId: FactorioServerId, update: MapChunkTileUpdate -> + + val mapTileList = update.tileDictionary?.toMapTileList() ?: emptyList() + + val (validMapTiles, invalidMapTiles) = mapTileList.partition { + it.position in update.key.chunkPosition + } + + if (invalidMapTiles.isNotEmpty()) { + println( + "WARNING [$pid] MapChunkTileUpdate contained ${invalidMapTiles.size} out-of-bounds tiles, " + + "key: ${update.key},\n" + + "invalid tiles:" + invalidMapTiles.joinToString(limit = 10) + ) + } + + val validMapTilesToProtoHashCode = validMapTiles.associate { + it.position to PrototypeHashCode(it.protoId) + } + + val chunkId = ServerMapChunkId( + serverId = serverId, + layer = ServerMapTileLayer.TERRAIN, + chunkPosition = update.key.chunkPosition, + surfaceIndex = update.key.surfaceIndex, + ) + + chunkId to ServerMapChunkTiles(chunkId, validMapTilesToProtoHashCode) + } +} + + +fun KStream>.reduceServerMapChunkTilesToTable( + callerPid: String, +): KTable> { + + val pid = "$callerPid.reduceServerMapChunkTilesToTable" + + return repartition( + repartitionedAs( + "$pid.pre-table-repartition", + kxsBinary.serde(), + kxsBinary.serde>(), + // force, otherwise KTable-KTable FK join doesn't work + numberOfPartitions = 1, + ) + ).groupByKey( + groupedAs( + "$pid.group-by-key", + kxsBinary.serde(), + kxsBinary.serde>(), + ) + ).reduce( + "$pid.reduce", + materializedAs( + "$pid.reduce.store", + kxsBinary.serde(), + kxsBinary.serde>(), + ) + ) { chunkTiles, otherChunkTiles -> + chunkTiles + otherChunkTiles + } +} + + +private fun KTable>.enrichWithColourData( + callerPid: String, + protosTable: KTable, +): KTable> { + + val pid = "$callerPid.enrichWithColourData" + + return join( + other = protosTable, + tableJoined = tableJoined("$pid.join-tiles-with-prototypes"), + materialized = materializedAs( + "$pid.join-tiles-with-prototypes.store", + kxsBinary.serde(), + kxsBinary.serde(), + ), + foreignKeyExtractor = { chunkTiles: ServerMapChunkTiles -> + chunkTiles.chunkId.serverId + } + ) { tiles: ServerMapChunkTiles, colourDict: TileColourDict -> + println("joining tiles:${tiles.map.size} with colourDict:${colourDict.size}") + + val missingProtos = mutableSetOf() + + val tileColours: Map = + tiles.map.mapNotNull { (position, code) -> + when (val colour = colourDict[code]) { + null -> { + missingProtos.add(code) + null + } + else -> position to colour + } + }.toMap() + + if (missingProtos.isNotEmpty()) { + println("[$pid] missing ${missingProtos.size} tile prototypes: ${missingProtos.joinToString { "${it.code}" }}") + } + + println("[$pid] Set ${tileColours.size} tile colours for chunk ${tiles.chunkId}") + + ServerMapChunkTiles(tiles.chunkId, tileColours) + } +} + + +fun KTable>.streamMapChunkColouredTo( + callerPid: String, + outputTopic: String, +) { + val pid = "$callerPid.output-chunk" + + toStream("$pid.stream") + .flatMap("$pid.group-by-chunks") { _: ServerMapChunkId, tiles: ServerMapChunkTiles? -> + reChunkTiles(pid, tiles) + }.peek("$pid.print-group-result") { _, chunkTiles -> + println("[$pid] Grouping map tiles result: ${chunkTiles.chunkId} / size:${chunkTiles.map.size}") + }.to( + outputTopic, + producedAs( + "$pid.grouped-map-chunks", + kxsBinary.serde(), + kxsBinary.serde>(), + ) + ) +} + + +/** + * Group [MapChunkTileUpdate]s by the Chunk position. + * + * They should already be grouped, but do it again to make sure, and to filter out empty updates. + */ +fun KStream>.groupByChunkPosition( + callerPid: String, + targetChunkSize: ChunkSize = ChunkSize.CHUNK_032 +): KTable> { + + val pid = "$callerPid.groupByChunkPosition.${targetChunkSize.name}" + + return flatMap("$pid.change-chunk-size") { _: ServerMapChunkId, chunkTiles: ServerMapChunkTiles? -> +// println("[$pid] changing chunk size for $chunkId") + chunkTiles ?: return@flatMap emptyList() + + val newChunkPosition = chunkTiles.chunkId.chunkPosition.resize(targetChunkSize) + val newId = chunkTiles.chunkId.copy(chunkPosition = newChunkPosition) + val newChunkTiles = chunkTiles.copy(chunkId = newId) + + reChunkTiles(pid, newChunkTiles) + }.groupByKey( + groupedAs( + "$pid.group-by-key", + kxsBinary.serde(), + kxsBinary.serde>(), + ) + ).reduce( + "$pid.reduce", + materializedAs( + "$pid.reduce.store", + kxsBinary.serde(), + kxsBinary.serde>(), + ) + ) { chunkTiles, otherChunkTiles -> + chunkTiles + otherChunkTiles + } +} + + +fun reChunkTiles( + pid: String, + tiles: ServerMapChunkTiles?, +): List>> { + + return when { + tiles == null || tiles.map.isEmpty() -> emptyList() + + tiles.map.keys.all { it in tiles.chunkId.chunkPosition } -> listOf(tiles.chunkId to tiles) + + else -> { + val chunkId = tiles.chunkId + + val (boundedTiles, unboundedTiles) = tiles.map.entries.partition { (position, _) -> + position in chunkId.chunkPosition + } + + if (unboundedTiles.isNotEmpty()) { + val unboundedEntities = unboundedTiles.map { (_, entity) -> entity } + println( + "WARNING [$pid] MapChunkEntityUpdate $chunkId " + + "contained ${unboundedEntities.size} out-of-bounds entities " + + unboundedEntities.joinToString(limit = 10) + ) + } + + // the existing chunkId and its tiles + val boundedTilesChunk = + chunkId to ServerMapChunkTiles(chunkId, boundedTiles.associate { it.key to it.value }) + + // re-calculate a chunk for the out-of-bounds tiles + val chunkedUnboundedTiles = unboundedTiles + .map { it.key to it.value } + .groupBy { (position, _) -> + position.toMapChunkPosition(chunkId.chunkSize) + }.map { (newChunkPosition, tiles) -> + val newChunkId = chunkId.copy(chunkPosition = newChunkPosition) + newChunkId to ServerMapChunkTiles(newChunkId, tiles.toMap()) + } + + println("[$pid] re-bounded ${unboundedTiles.size} tiles into ${chunkedUnboundedTiles.size} chunks in $chunkId") + + listOf(boundedTilesChunk) + chunkedUnboundedTiles + } + } +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/colourResourceChunks.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/colourResourceChunks.kt new file mode 100644 index 0000000..965a47c --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/colourResourceChunks.kt @@ -0,0 +1,272 @@ +package dev.adamko.kafkatorio.server.processor.topology + +import dev.adamko.kafkatorio.library.kxsBinary +import dev.adamko.kafkatorio.library.toMapTilePosition +import dev.adamko.kafkatorio.processor.core.DebounceProcessor.Companion.addDebounceProcessor +import dev.adamko.kafkatorio.schema.common.ChunkSize +import dev.adamko.kafkatorio.schema.common.ColourHex +import dev.adamko.kafkatorio.schema.common.FactorioPrototype +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.MapBoundingBox +import dev.adamko.kafkatorio.schema.common.MapTilePosition +import dev.adamko.kafkatorio.schema.common.PrototypeHashCode +import dev.adamko.kafkatorio.schema.common.ServerMapChunkId +import dev.adamko.kafkatorio.schema.common.ServerMapTileLayer +import dev.adamko.kafkatorio.schema.common.toHex +import dev.adamko.kafkatorio.schema.packets.MapChunkEntityUpdate +import dev.adamko.kafkatorio.schema.packets.MapChunkResourceUpdate +import dev.adamko.kafkatorio.schema.packets.MapChunkTileUpdate +import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate +import dev.adamko.kotka.extensions.consumedAs +import dev.adamko.kotka.extensions.materializedAs +import dev.adamko.kotka.extensions.stream +import dev.adamko.kotka.extensions.streams.filter +import dev.adamko.kotka.extensions.streams.flatMap +import dev.adamko.kotka.extensions.tableJoined +import dev.adamko.kotka.extensions.tables.join +import dev.adamko.kotka.kxs.serde +import kotlin.collections.component1 +import kotlin.collections.component2 +import kotlin.math.floor +import kotlin.time.Duration.Companion.seconds +import org.apache.kafka.streams.StreamsBuilder +import org.apache.kafka.streams.Topology +import org.apache.kafka.streams.kstream.KStream +import org.apache.kafka.streams.kstream.KTable + + +/** + * Add colour to each [MapChunkTileUpdate] + * + * @param[colouredUpdatesStreamTopic] Output topic for the result of converting input updates into 32 sized chunks + * @param[colouredChunkStateTopic] Post-debounce state topic, used to recursively combine chunks + */ +fun colourEntityChunks( + builder: StreamsBuilder, + entityChunksStream: KStream>, + protosStream: KStream, + layer: ServerMapTileLayer, + colouredUpdatesStreamTopic: String, + colouredChunkStateTopic: String, +): Topology { + val pid = "colourEntityChunks.${layer.dir}" + + val protosTable: KTable = + protosStream.createEntityPrototypeMap(pid) + + val chunkEntitiesColouredTable032: KTable> = + entityChunksStream + .reduceServerMapChunkTilesToTable(pid) + .enrichWithColourData(pid, protosTable) + + chunkEntitiesColouredTable032.streamMapChunkColouredTo( + "$pid.${ChunkSize.CHUNK_032}", + colouredUpdatesStreamTopic, + ) + + val chunkTilesColoured: KStream> = + builder.stream( + consumedAs( + "$pid.consume.map-chunks-debounced", + kxsBinary.serde(ServerMapChunkId.serializer()), + kxsBinary.serde(ServerMapChunkTiles.serializer(ColourHex.serializer())), + ), + colouredChunkStateTopic, + ) + + mapOf( +// ChunkSize.CHUNK_032 to ChunkSize.CHUNK_064, +// ChunkSize.CHUNK_064 to ChunkSize.CHUNK_128, +// ChunkSize.CHUNK_128 to ChunkSize.CHUNK_256, +// ChunkSize.CHUNK_256 to ChunkSize.CHUNK_512, + + ChunkSize.CHUNK_032 to ChunkSize.CHUNK_256, + ChunkSize.CHUNK_256 to ChunkSize.CHUNK_512, + ).forEach { (from, to) -> + chunkTilesColoured + .filter("$pid.combine-chunks.filter-$from-to-$to") { key, _ -> + key.chunkSize == from && key.layer == layer + }.groupByChunkPosition(pid, to) + .streamMapChunkColouredTo( + "$pid.from-$from-to-$to", + colouredChunkStateTopic, + ) + } + + return builder.build().addDebounceProcessor( + namePrefix = "groupMapChunks.${layer.dir}", + sourceTopic = colouredUpdatesStreamTopic, + sinkTopic = colouredChunkStateTopic, + inactivityDuration = 15.seconds, + keySerde = kxsBinary.serde(ServerMapChunkId.serializer()), + valueSerde = kxsBinary.serde(ServerMapChunkTiles.serializer(ColourHex.serializer())), + ) +} + + +fun KStream.convertEntityUpdateToServerMapChunkTiles( + callerPid: String, +): KStream> { + + val pid = "$callerPid.convertToServerMapChunkTiles" + + return flatMap("$pid.map") { serverId: FactorioServerId, update: MapChunkEntityUpdate -> + +// +// // TODO There might be multiple resources per tile position, therefore this will arbitrarily +// // exclude resources. Maybe change it from a Map to a List? Or have multiple resources per +// // tile position? +// val mapValidEntitiesToPrototypeHash = validEntityPositions.associate { (pos, resource) -> +// pos to PrototypeHashCode(resource.protoId) +// } + + val entitiesToPrototypeHash = update.entities().associate { entity -> + entity.position.toMapTilePosition() to PrototypeHashCode(entity.protoId) + } + + val chunkId = ServerMapChunkId( + serverId = serverId, + layer = ServerMapTileLayer.BUILDING, + chunkPosition = update.key.chunkPosition, + surfaceIndex = update.key.surfaceIndex, + ) + + val tiles = ServerMapChunkTiles(chunkId, entitiesToPrototypeHash) + + reChunkTiles(pid, tiles) + } +} + + +fun KStream.convertResourceUpdateToServerMapChunkTiles( + callerPid: String, +): KStream> { + + val pid = "$callerPid.convertResourceUpdateToChunkTiles" + + return flatMap("$pid.map") { serverId: FactorioServerId, update: MapChunkResourceUpdate -> + +// // TODO There might be multiple resources per tile position, therefore this will arbitrarily +// // exclude resources. Maybe change it from a Map to a List? Or have multiple resources per +// // tile position? +// val mapValidEntitiesToPrototypeHash = validEntityPositions.associate { (pos, resource) -> +// pos to PrototypeHashCode(resource.protoId) +// } + + val entitiesToPrototypeHash = update.resources().associate { entity -> + entity.position.toMapTilePosition() to PrototypeHashCode(entity.protoId) + } + + val chunkId = ServerMapChunkId( + serverId = serverId, + layer = ServerMapTileLayer.RESOURCE, + chunkPosition = update.key.chunkPosition, + surfaceIndex = update.key.surfaceIndex, + ) + + val tiles = ServerMapChunkTiles(chunkId, entitiesToPrototypeHash) + + reChunkTiles(pid, tiles) + } +} + + +private fun KTable>.enrichWithColourData( + callerPid: String, + protosTable: KTable, +): KTable> { + + val pid = "$callerPid.enrichWithColourData" + + return join( + other = protosTable, + tableJoined = tableJoined("$pid.join-tiles-with-prototypes"), + materialized = materializedAs( + "$pid.join-tiles-with-prototypes.store", + kxsBinary.serde(), + kxsBinary.serde(), + ), + foreignKeyExtractor = { chunkTiles: ServerMapChunkTiles -> + chunkTiles.chunkId.serverId + }) { tiles: ServerMapChunkTiles, prototypes: EntityPrototypeMap -> + println("joining tiles:${tiles.map.size} with prototypes:${prototypes.size}") + + val missingProtos = mutableSetOf() + + val tileColours: Map = buildList { + tiles.map.forEach { (position, code) -> + when (val proto = prototypes[code]) { + + null -> missingProtos += code + + else -> when (val box = proto.collisionBox) { + + null -> add(position to proto.mapColour()) + + else -> box.iterator(position).forEach { entitySubTile -> + add(entitySubTile to proto.mapColour()) + } + } + } + } + }.fold(mapOf()) { acc, (pos, colour) -> + // merge overlapping colours + val newColour = when (val existing = acc[pos]) { + null -> colour + else -> (existing / 2u) + (colour / 2u) + } + acc + (pos to newColour) + } + + if (missingProtos.isNotEmpty()) { + println("[$pid] missing ${missingProtos.size} tile prototypes: ${missingProtos.joinToString { "${it.code}" }}") + } + + println("[$pid] Set ${tileColours.size} tile colours for chunk ${tiles.chunkId}") + + ServerMapChunkTiles(tiles.chunkId, tileColours) + } +} + + +private fun MapBoundingBox.iterator(origin: MapTilePosition): Iterator { + + // check if tile width/height should be divided by 2. I think I read that it's not divided by 2 + // if it's an odd number? + + val xOffset: Int = floor(tileWidth.toDouble() / 2).toInt() + val startX = origin.x - xOffset + val endX = origin.x + xOffset + + val yOffset: Int = floor(tileHeight.toDouble() / 2).toInt() + val startY = origin.y - yOffset + val endY = origin.y + yOffset + + return iterator { + for (x in (startX..endX)) { + for (y in (startY..endY)) { // screen coordinates = +y points to the floor, -y to the ceiling + yield(MapTilePosition(x, y)) + } + } + } +} + + +private fun FactorioPrototype.Entity.mapColour(): ColourHex = + (colour ?: mapColour ?: mapColourFriend)?.toHex() ?: ColourHex.WHITE + + +private operator fun ColourHex.div(divisor: UInt): ColourHex = copy( + red = (red / divisor).toUByte(), + green = (green / divisor).toUByte(), + blue = (blue / divisor).toUByte(), + alpha = (alpha / divisor).toUByte(), +) + + +private operator fun ColourHex.plus(other: ColourHex): ColourHex = copy( + red = (red + other.red).toUByte(), + green = (green + other.green).toUByte(), + blue = (blue + other.blue).toUByte(), + alpha = (alpha + other.alpha).toUByte(), +) diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/factorioServerPackets.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/factorioServerPackets.kt new file mode 100644 index 0000000..1b059a7 --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/factorioServerPackets.kt @@ -0,0 +1,134 @@ +package dev.adamko.kafkatorio.server.processor.topology + +import dev.adamko.kafkatorio.processor.config.TOPIC_SRC_SERVER_LOG +import dev.adamko.kafkatorio.processor.config.jsonMapper +import dev.adamko.kafkatorio.processor.config.topicName +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.Tick +import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket +import dev.adamko.kafkatorio.schema.packets.KafkatorioPacketDataError +import dev.adamko.kotka.extensions.component1 +import dev.adamko.kotka.extensions.component2 +import dev.adamko.kotka.extensions.consumedAs +import dev.adamko.kotka.extensions.producedAs +import dev.adamko.kotka.extensions.streams.mapValues +import dev.adamko.kotka.extensions.streams.to +import dev.adamko.kotka.kxs.serde +import java.util.zip.Inflater +import kotlinx.coroutines.CancellationException +import okio.Buffer +import okio.ByteString +import okio.ByteString.Companion.decodeBase64 +import okio.buffer +import okio.inflate +import org.apache.kafka.common.serialization.Serdes +import org.apache.kafka.streams.StreamsBuilder +import org.apache.kafka.streams.kstream.KStream + + +private const val ENCODED_TAG = "encoded:" + + +fun factorioServerPacketStream( + builder: StreamsBuilder = StreamsBuilder(), +): KStream { + + return builder.stream( + TOPIC_SRC_SERVER_LOG, + consumedAs( + "read-raw-packets-from-server", + jsonMapper.serde(FactorioServerId.serializer()), + Serdes.String(), + ) + ).mapValues("decode-packets") { _: FactorioServerId, value: String? -> + + val packet = decodeKafkatorioPacket(value?.trim()) + + if (packet.data is KafkatorioPacketDataError) { + println("error parsing $TOPIC_SRC_SERVER_LOG message: $packet") + } + + packet + } +} + + +fun splitFactorioServerPacketStream( + factorioServerPacketStream: KStream +) { + factorioServerPacketStream + .to( + producedAs( + "split-server-log", + jsonMapper.serde(), + jsonMapper.serde(), + ) + ) { (_: FactorioServerId, value: KafkatorioPacket) -> +// println("[$key] sending event:${value.eventType} to topic:${value.data.objectName()}") + value.data.topicName + } +} + + +private fun decodeKafkatorioPacket(value: String?): KafkatorioPacket = try { + when { + value.isNullOrBlank() -> + createErrorPacket(message = "null/blank message", rawValue = value) + + else -> { + val packetJson = if (value.startsWith(ENCODED_TAG)) { + val encodedValue = value.substringAfter(ENCODED_TAG) + decodeFactorioEncodedString(encodedValue) + } else { + value + } + jsonMapper.decodeFromString(KafkatorioPacket.serializer(), packetJson) + } + } +} catch (ex: Exception) { + if (ex is CancellationException) throw ex + errorPacket(exception = ex, rawValue = value) +} + + +/** + * Factorio `game.encode_string` zlib encodes a string, then base64's it. Here we do the reverse. + */ +private fun decodeFactorioEncodedString( + source: String +): String { + val bytes: ByteString = source.decodeBase64() ?: error("failed to base64 decode $source") + + return Buffer().write(bytes) + .inflate(Inflater()) + .buffer() + .readString(Charsets.UTF_8) +} + + +private fun createErrorPacket( + message: String, + rawValue: String?, +): KafkatorioPacket = + KafkatorioPacket( + modVersion = "unknown", + tick = Tick(0u), + data = KafkatorioPacketDataError( + message = message, + rawValue = rawValue, + ) + ) + + +private fun errorPacket( + exception: Exception, + rawValue: String?, +): KafkatorioPacket { + val message = """ +${exception::class.qualifiedName} ${exception.message} + +${exception.stackTraceToString()} +""".trimIndent() + + return createErrorPacket(message, rawValue) +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/model.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/model.kt new file mode 100644 index 0000000..e2f158a --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/model.kt @@ -0,0 +1,35 @@ +package dev.adamko.kafkatorio.server.processor.topology + +import com.sksamuel.scrimage.color.RGBColor +import dev.adamko.kafkatorio.schema.common.ColourHex +import dev.adamko.kafkatorio.schema.common.MapTile +import dev.adamko.kafkatorio.schema.common.MapTilePosition +import dev.adamko.kafkatorio.schema.common.ServerMapChunkId +import java.awt.Color +import kotlinx.serialization.Serializable + + +@Serializable +data class ServerMapChunkTiles( + val chunkId: ServerMapChunkId, + val map: Map, +) { + operator fun plus(other: ServerMapChunkTiles) = copy(map = map + other.map) +} + + +val MapTile.position + get() = MapTilePosition(x = x, y = y) + + +val TRANSPARENT_AWT: Color = ColourHex.TRANSPARENT.toRgbColor().awt() + + +fun ColourHex.toRgbColor(): RGBColor { + return RGBColor( + red.toInt(), + green.toInt(), + blue.toInt(), + alpha.toInt(), + ) +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/packetDataStreams.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/packetDataStreams.kt new file mode 100644 index 0000000..3adc34c --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/packetDataStreams.kt @@ -0,0 +1,31 @@ +package dev.adamko.kafkatorio.server.processor.topology + +import dev.adamko.kafkatorio.processor.config.jsonMapper +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket +import dev.adamko.kafkatorio.schema.packets.KafkatorioPacketData +import dev.adamko.kafkatorio.processor.config.topicName +import dev.adamko.kotka.extensions.consumedAs +import dev.adamko.kotka.extensions.streams.filter +import dev.adamko.kotka.extensions.streams.mapValues +import dev.adamko.kotka.kxs.serde +import org.apache.kafka.streams.StreamsBuilder +import org.apache.kafka.streams.kstream.KStream + + +inline fun StreamsBuilder.streamPacketData(): KStream { + + val simpleName = T::class.simpleName!! + val topicName = T::class.topicName + + val taskName = "consume.${simpleName}" + + return stream( + topicName, + consumedAs("$taskName.input", jsonMapper.serde(), jsonMapper.serde()) + ).filter("$taskName.filter-is-instance") { key: FactorioServerId?, value: KafkatorioPacket? -> + key != null && value?.data is T + }.mapValues("$taskName.map-values") { _: FactorioServerId, packet: KafkatorioPacket -> + packet.data as T + } +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/prototypes.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/prototypes.kt new file mode 100644 index 0000000..848ea69 --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/prototypes.kt @@ -0,0 +1,138 @@ +package dev.adamko.kafkatorio.server.processor.topology + +import dev.adamko.kafkatorio.library.kxsBinary +import dev.adamko.kafkatorio.schema.common.ColourHex +import dev.adamko.kafkatorio.schema.common.FactorioEntityData +import dev.adamko.kafkatorio.schema.common.FactorioPrototype +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.PrototypeHashCode +import dev.adamko.kafkatorio.schema.common.PrototypeId +import dev.adamko.kafkatorio.schema.common.toHex +import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate +import dev.adamko.kotka.extensions.groupedAs +import dev.adamko.kotka.extensions.materializedAs +import dev.adamko.kotka.extensions.materializedWith +import dev.adamko.kotka.extensions.* +import dev.adamko.kotka.extensions.streams.* +import dev.adamko.kotka.extensions.streams.mapValues +import dev.adamko.kotka.extensions.streams.toTable +import dev.adamko.kotka.extensions.tables.* +import dev.adamko.kotka.kxs.serde +import kotlinx.serialization.Serializable +import org.apache.kafka.streams.kstream.KStream +import org.apache.kafka.streams.kstream.KTable + + +@JvmInline +@Serializable +value class TileColourDict( + private val map: Map +) : Map by map { + operator fun plus(other: TileColourDict): TileColourDict = TileColourDict(this.map + other.map) +} + + +/** Get the latest map-tile colours per server. */ +fun KStream.createTilePrototypeTable() + : KTable { + + val pid = "createTilePrototypeTable" + + return mapValues( + "$pid.map-values" + ) { _, protoPacket: PrototypesUpdate -> + val map = protoPacket + .prototypes + .filterIsInstance() + .associate { PrototypeHashCode(it) to it.mapColour.toHex() } + + TileColourDict(map) + }.filter("$pid.filterMapTileProtos") { _, dict: TileColourDict -> + dict.isNotEmpty() + }.peek { serverId, dict: TileColourDict -> + println("$pid: server $serverId has TileColourDict[${dict.size}]: ${dict.entries.joinToString()}") + }.repartition( + repartitionedAs( + "$pid.pre-table-repartition", + kxsBinary.serde(), + kxsBinary.serde(), + // force, otherwise KTable-KTable FK join doesn't work + numberOfPartitions = 1, + ) + ).toTable( + "$pid.create-table", + materializedAs( + "$pid.output-store", + kxsBinary.serde(), + kxsBinary.serde(), + ) + ) +} + + +@JvmInline +@Serializable +value class EntityPrototypeMap( + private val map: Map +) : Map by map { + operator fun plus(other: EntityPrototypeMap): EntityPrototypeMap = + EntityPrototypeMap(this.map + other.map) + + operator fun get(protoId: PrototypeId): FactorioPrototype.Entity? = + map[PrototypeHashCode(protoId)] + + operator fun get(entity: FactorioEntityData): FactorioPrototype.Entity? = + map[PrototypeHashCode(entity.protoId)] +} + + +/** Get the latest entity colours per server. */ +fun KStream.createEntityPrototypeMap( + callerPid: String +): KTable { + + val pid = "$callerPid.createEntityPrototypeMap" + + return mapValues("$pid.colour-dict.build") { _, protoPacket: PrototypesUpdate -> + val map = protoPacket + .prototypes + .filterIsInstance() + .associateBy { entityProto -> + PrototypeHashCode(entityProto) + } + + EntityPrototypeMap(map) + }.filter("$pid.filterEntityProtos") { _, dict: EntityPrototypeMap -> + dict.isNotEmpty() + }.groupByKey(groupedAs("$pid.group-by-key")) + .reduce( + "$pid.merge", + materializedWith( + kxsBinary.serde(), + kxsBinary.serde(), + ) + ) { dict1: EntityPrototypeMap, dict2: EntityPrototypeMap -> + dict1 + dict2 + }.toStream("$pid.") + .filter("$pid.not-null.filter") { _, v -> v != null } + .mapValues("$pid.not-null.require") { _, value -> + requireNotNull(value) + }.peek { serverId, dict: EntityPrototypeMap -> + println("$pid: server $serverId has EntityPrototypeMap (size:${dict.size}): ${dict.entries.joinToString()}") + }.repartition( + repartitionedAs( + "$pid.pre-table-repartition", + kxsBinary.serde(), + kxsBinary.serde(), + // force, otherwise KTable-KTable FK join doesn't work + numberOfPartitions = 1, + ) + ).toTable( + "$pid.create-table", + materializedAs( + "$pid.output-store", + kxsBinary.serde(), + kxsBinary.serde(), + ) + ) +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/saveMapTiles.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/saveMapTiles.kt new file mode 100644 index 0000000..d0364a5 --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/saveMapTiles.kt @@ -0,0 +1,159 @@ +package dev.adamko.kafkatorio.server.processor.topology + +import com.sksamuel.scrimage.ImmutableImage +import com.sksamuel.scrimage.ScaleMethod +import com.sksamuel.scrimage.nio.PngWriter +import dev.adamko.kafkatorio.library.kxsBinary +import dev.adamko.kafkatorio.schema.common.ChunkSize +import dev.adamko.kafkatorio.schema.common.ColourHex +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.ServerMapChunkId +import dev.adamko.kafkatorio.schema.common.ServerMapTilePngFilename +import dev.adamko.kafkatorio.schema.packets.EventServerPacket +import dev.adamko.kafkatorio.processor.config.TOPIC_BROADCAST_TO_WEBSOCKET +import dev.adamko.kafkatorio.processor.config.TOPIC_MAP_CHUNK_BUILDING_COLOURED_STATE +import dev.adamko.kafkatorio.processor.config.TOPIC_MAP_CHUNK_RESOURCE_COLOURED_STATE +import dev.adamko.kafkatorio.processor.config.TOPIC_MAP_CHUNK_TERRAIN_COLOURED_STATE +import dev.adamko.kafkatorio.processor.config.jsonMapper +import dev.adamko.kotka.extensions.consumedAs +import dev.adamko.kotka.extensions.producedAs +import dev.adamko.kotka.extensions.stream +import dev.adamko.kotka.extensions.streams.filter +import dev.adamko.kotka.extensions.streams.map +import dev.adamko.kotka.extensions.streams.mapValues +import dev.adamko.kotka.kxs.serde +import java.awt.image.BufferedImage +import java.nio.file.Path +import kotlin.collections.component1 +import kotlin.collections.component2 +import kotlin.io.path.fileSize +import kotlin.math.abs +import org.apache.kafka.streams.StreamsBuilder +import org.apache.kafka.streams.Topology +import org.apache.kafka.streams.kstream.KStream + + +private const val pid = "saveMapTiles" + +private const val WEB_MAP_TILE_SIZE_PX = 256 + + +/** + * @param[serverDataDir] [dev.adamko.kafkatorio.server.config.ApplicationProperties.serverDataDir] + */ +fun saveMapTiles( + builder: StreamsBuilder, + serverDataDir: Path, +) { + + val subdividedMapChunkTilesDebounced: KStream> = + builder.stream( + consumedAs( + "$pid.consume.grouped-map-chunks", + kxsBinary.serde(ServerMapChunkId.serializer()), + kxsBinary.serde(ServerMapChunkTiles.serializer(ColourHex.serializer())), + ), + TOPIC_MAP_CHUNK_TERRAIN_COLOURED_STATE, + TOPIC_MAP_CHUNK_RESOURCE_COLOURED_STATE, + TOPIC_MAP_CHUNK_BUILDING_COLOURED_STATE, + ).filter("$pid.consume.grouped-map-chunks.filter-size") { _, y -> + y.chunkId.chunkSize.lengthInTiles >= ChunkSize.CHUNK_256.lengthInTiles + } + + val savedChunkFilenames: KStream = + subdividedMapChunkTilesDebounced.saveChunkAsImage(serverDataDir) + + savedChunkFilenames.broadcastSavedTileUpdates() +} + + +private fun KStream>.saveChunkAsImage( + tileDirectory: Path, +): KStream = mapValues( + "$pid.save-tiles" +) { chunkId: ServerMapChunkId, tileColours: ServerMapChunkTiles -> + + val chunkImage = ImmutableImage.filled( + chunkId.chunkSize.lengthInTiles, + chunkId.chunkSize.lengthInTiles, + TRANSPARENT_AWT, + BufferedImage.TYPE_INT_ARGB + ) + + val chunkOriginX: Int = chunkId.chunkPosition.x * chunkId.chunkSize.lengthInTiles + val chunkOriginY: Int = chunkId.chunkPosition.y * chunkId.chunkSize.lengthInTiles + + val validPixelRangeX = 0 until chunkImage.width + val validPixelRangeY = 0 until chunkImage.height + + tileColours.map.forEach { (tilePosition, colour) -> + val rgbColour = colour.toRgbColor() + + val pixelX = abs(abs(tilePosition.x) - abs(chunkOriginX)) + val pixelY = abs(abs(tilePosition.y) - abs(chunkOriginY)) + + if (!(pixelX in validPixelRangeX && pixelY in validPixelRangeY)) { + // TODO figure out why buildings on chunk boundaries aren't re-chunked, and so cause this error + println( + "ERROR - pixel XY:[$pixelX,$pixelY] was out of bounds (x:$validPixelRangeX, y:$validPixelRangeY). $tilePosition, $colour, chunkOriginXY[$chunkOriginX,$chunkOriginY], $chunkId" + ) + } else { + try { + chunkImage.setColor(pixelX, pixelY, rgbColour) + } catch (e: Exception) { + println( + "ERROR $e - pixel XY:[$pixelX,$pixelY] (x:$validPixelRangeX, y:$validPixelRangeY). $tilePosition, $colour, chunkOriginXY[$chunkOriginX,$chunkOriginY], $chunkId" + ) + throw e + } + } + } + + val scaledImage = + chunkImage.scaleTo(WEB_MAP_TILE_SIZE_PX, WEB_MAP_TILE_SIZE_PX, ScaleMethod.FastScale) + + val filename = ServerMapTilePngFilename(chunkId) + saveTile(filename, tileDirectory, scaledImage) + filename +} + + +@Synchronized +private fun saveTile( + filename: ServerMapTilePngFilename, + serverDataDir: Path, + img: ImmutableImage, +) { + val chunkImageFile = serverDataDir.resolve(filename.value).toFile() + if (chunkImageFile.parentFile.mkdirs()) { + println("created new map tile parentFile directory ${chunkImageFile.absolutePath}") + } + val sizeBefore = chunkImageFile.takeIf { it.exists() }?.toPath()?.fileSize() + + val savedTile = img.output(PngWriter.NoCompression, chunkImageFile) + + val sizeAfter = savedTile.takeIf { it.exists() }?.toPath()?.fileSize() + + val sizeDescription = if (sizeBefore != sizeAfter && sizeBefore != null) { + "$sizeBefore/$sizeAfter" + } else { + "$sizeAfter" + } + println("savedTile $sizeDescription: $savedTile") +} + + +private fun KStream.broadcastSavedTileUpdates() { + map( + "$pid.broadcast.filename-update.convert", + ) { id, filename -> + id.serverId to EventServerPacket.ChunkTileSaved(id, filename) + }.to( + TOPIC_BROADCAST_TO_WEBSOCKET, + producedAs( + "$pid.broadcast.filename-update.send", + jsonMapper.serde(FactorioServerId.serializer()), + jsonMapper.serde(EventServerPacket.serializer()), + ) + ) +} diff --git a/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/websocketBroadcaster.kt b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/websocketBroadcaster.kt new file mode 100644 index 0000000..5fc2d85 --- /dev/null +++ b/modules/events-processor-core/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/websocketBroadcaster.kt @@ -0,0 +1,101 @@ +package dev.adamko.kafkatorio.server.processor.topology + +import dev.adamko.kafkatorio.library.jsonMapperKafkatorio +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.packets.EventServerPacket +import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket +import dev.adamko.kafkatorio.schema.packets.PlayerUpdate +import dev.adamko.kafkatorio.schema.packets.SurfaceUpdate +import dev.adamko.kafkatorio.processor.config.TOPIC_BROADCAST_TO_WEBSOCKET +import dev.adamko.kafkatorio.processor.config.topicName +import dev.adamko.kotka.extensions.consumedAs +import dev.adamko.kotka.extensions.producedAs +import dev.adamko.kotka.extensions.stream +import dev.adamko.kotka.extensions.streams.forEach +import dev.adamko.kotka.extensions.streams.map +import dev.adamko.kotka.extensions.streams.to +import dev.adamko.kotka.kxs.serde +import kotlinx.coroutines.runBlocking +import kotlinx.serialization.encodeToString +import kotlinx.serialization.json.Json +import org.apache.kafka.streams.StreamsBuilder + + +private val jsonMapper: Json = Json { + prettyPrint = false + serializersModule = jsonMapperKafkatorio.serializersModule +} + + +private const val pid = "websocketBroadcast" + + +interface WebsocketBroadcaster { + suspend fun sendMessageToClients(message: String) +} + + +fun broadcastToWebsocket( + websocketBroadcaster: WebsocketBroadcaster, + builder: StreamsBuilder, +) { + + builder.broadcastKafkatorioPackets() + + builder.stream( + TOPIC_BROADCAST_TO_WEBSOCKET, + consumedAs("$pid.packets-to-broadcast.consume", jsonMapper.serde(), jsonMapper.serde()), + ).forEach( + "$pid.websocket-server.send-message" + ) { _, esPacket -> + runBlocking { + websocketBroadcaster.sendMessageToClients(jsonMapper.encodeToString(esPacket)) + } + } +} + + +private fun StreamsBuilder.broadcastKafkatorioPackets() { + val playerUpdatesStream = stream( + consumedAs( + "$pid.player-updates", + jsonMapper.serde(FactorioServerId.serializer()), + jsonMapper.serde(KafkatorioPacket.serializer()), + ), + PlayerUpdate::class.topicName, + SurfaceUpdate::class.topicName, + ) + + playerUpdatesStream.map( + "$pid.packet-updates.convert" + ) { serverId, packet -> + serverId to EventServerPacket.Kafkatorio(packet) + }.to( + producedAs( + "$pid.event-server-packets.produce", + jsonMapper.serde(FactorioServerId.serializer()), + jsonMapper.serde(EventServerPacket.serializer()), + ) + ) { TOPIC_BROADCAST_TO_WEBSOCKET } +} + + +private fun StreamsBuilder.prepareServerUpdateBroadcast() { + + val surfaceUpdatesStream = stream( + SurfaceUpdate::class.topicName, + consumedAs("$pid.surface-updates", jsonMapper.serde(), jsonMapper.serde()), + ) + + surfaceUpdatesStream.map( + "$pid.surface-updates.convert" + ) { serverId, serverUpdatePacket -> + serverId to EventServerPacket.Kafkatorio(serverUpdatePacket) + }.to( + producedAs( + "$pid.player-updates.stream", + jsonMapper.serde(FactorioServerId.serializer()), + jsonMapper.serde(EventServerPacket.serializer()), + ) + ) { TOPIC_BROADCAST_TO_WEBSOCKET } +} diff --git a/modules/events-processor-core/src/main/resources/config.yml b/modules/events-processor-core/src/main/resources/config.yml new file mode 100644 index 0000000..c74f9b5 --- /dev/null +++ b/modules/events-processor-core/src/main/resources/config.yml @@ -0,0 +1,67 @@ +# Factorio Events Processor config + +web-port: ${WEB_SERVER_PORT:-8080} +server-data-dir: ${SERVER_DATA_DIR:-./server-data} + + +socket-server-host: ${SOCKET_SERVER_HOST:-0.0.0.0} +socket-server-port: ${SOCKET_SERVER_PORT:-12092} + + +kafka-admin-config: + client.id: kafkatorio.events-server-admin + bootstrap.servers: ${KAFKA_BOOTSTRAP_SERVERS:-localhost:9092} + + +kafka-streams-config: + application.id: kafkatorio-events-processor + bootstrap.servers: ${KAFKA_BOOTSTRAP_SERVERS:-localhost:9092} + state.dir: ${KAFKA_STREAMS_STATE_DIR:-.state/kafka} + num.stream.threads: 1 + processing.guarantee: exactly_once_v2 + auto.offset.reset: earliest + default.key.serde: org.apache.kafka.common.serialization.Serdes$StringSerde + default.value.serde: org.apache.kafka.common.serialization.Serdes$StringSerde + + # default.deserialization.exception.handler: org.apache.kafka.streams.errors.LogAndContinueExceptionHandler + + #buffered.records.per.partition: 0 + #poll.ms: 10000 + + # 31457280 : 30MB + max.request.size: 31457280 + buffer.memory: 31457280 + + compression.type: snappy + # linger.ms=5 + + # fetch.message.max.bytes=31457280 + # 100mb 104857600 + + +#kafka: +# bootstrap-servers: +# - "http://localhost:9092" +# config: | +# application.id=kafkatorio-events-processor +# bootstrap.servers={{bootstrap-servers}} +# state.dir=./kafka-state +# num.stream.threads=1 +# processing.guarantee=exactly_once_v2 +# auto.offset.reset=earliest +# default.key.serde=org.apache.kafka.common.serialization.Serdes$StringSerde +# default.value.serde=org.apache.kafka.common.serialization.Serdes$StringSerde +# default.deserialization.exception.handler=org.apache.kafka.streams.errors.LogAndContinueExceptionHandler +# #buffered.records.per.partition=0 +# #poll.ms=10000 +# +# # 31457280 = 30MB +# max.request.size=31457280 +# buffer.memory=31457280 +# +# compression.type=snappy +# # linger.ms=5 +# +# # fetch.message.max.bytes=31457280 +# # 100mb 104857600 +# diff --git a/modules/events-processor-core/src/main/resources/external-annotations/org/apache/kafka/streams/state/annotations.xml b/modules/events-processor-core/src/main/resources/external-annotations/org/apache/kafka/streams/state/annotations.xml new file mode 100644 index 0000000..2c28db5 --- /dev/null +++ b/modules/events-processor-core/src/main/resources/external-annotations/org/apache/kafka/streams/state/annotations.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/modules/events-processor-core/src/main/resources/logback.xml b/modules/events-processor-core/src/main/resources/logback.xml new file mode 100644 index 0000000..b53b7f5 --- /dev/null +++ b/modules/events-processor-core/src/main/resources/logback.xml @@ -0,0 +1,21 @@ + + + + false + + + %cyan(%d{HH:mm:ss.SSS}) %white([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n + + + + + + + + + + + + + diff --git a/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/AuthenticatorTest.kt b/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/AuthenticatorTest.kt new file mode 100644 index 0000000..c58ccf1 --- /dev/null +++ b/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/AuthenticatorTest.kt @@ -0,0 +1,61 @@ +package dev.adamko.kafkatorio.processor.core + +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import dev.adamko.kafkatorio.processor.config.PortVal +import dev.adamko.kafkatorio.schema.common.MaskedValue +import io.kotest.core.spec.style.FunSpec +import io.kotest.matchers.nulls.shouldBeNull +import io.kotest.matchers.nulls.shouldNotBeNull +import kotlin.io.path.Path + + +class AuthenticatorTest : FunSpec({ + + test("verify correct JWT is verified") { + + val authenticator = Authenticator( + testApplicationProperties( + jwtSecret = "123 456 789" + ) + ) + + val result = authenticator.verifyJwt(jwtMessage) + + result.shouldNotBeNull() + } + + test("verify invalid JWT returns null") { + + val authenticator = Authenticator( + testApplicationProperties( + jwtSecret = "wrong" + ) + ) + + val result = authenticator.verifyJwt(jwtMessage) + + result.shouldBeNull() + } + +}) { + + companion object { + /** Key: `123 465 789` */ + private val jwtMessage = """ + eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.ToFLkPBs_EKF4B2bRQyVPfkKrB-x6WgyAq6KsR9oHwg + """.trimIndent() + + private fun testApplicationProperties( + jwtSecret: String, + ) = ApplicationProperties( + webPort = PortVal.DEFAULT, + serverDataDir = Path(""), + kafkaAdminConfig = emptyMap(), + kafkaStreamsConfig = emptyMap(), + socketServerHost = "", + socketServerPort = 9999, + jwtSecret = MaskedValue(jwtSecret), + kafkatorioServers = emptyMap(), + ) + } +} diff --git a/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/misc/serdeSize.kt b/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/misc/serdeSize.kt new file mode 100644 index 0000000..7c96280 --- /dev/null +++ b/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/misc/serdeSize.kt @@ -0,0 +1,64 @@ +package dev.adamko.kafkatorio.processor.misc + +import dev.adamko.kafkatorio.library.kxsBinary +import dev.adamko.kafkatorio.schema.common.ServerMapChunkId +import dev.adamko.kafkatorio.schema.common.ChunkSize +import dev.adamko.kafkatorio.schema.common.ColourHex +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.MapChunkPosition +import dev.adamko.kafkatorio.schema.common.MapTilePosition +import dev.adamko.kafkatorio.schema.common.ServerMapTileLayer +import dev.adamko.kafkatorio.schema.common.SurfaceIndex +import dev.adamko.kafkatorio.server.processor.topology.ServerMapChunkTiles +import java.util.UUID +import kotlinx.serialization.encodeToByteArray +import org.junit.jupiter.api.Test + + +class Blah { + + @Test + fun asdad() { + + val tiles = ServerMapChunkTiles( + chunkId = ServerMapChunkId( + serverId = FactorioServerId(UUID.randomUUID().toString()), + layer = ServerMapTileLayer.BUILDING, + chunkPosition = MapChunkPosition(Int.MAX_VALUE, Int.MAX_VALUE, ChunkSize.MAX), + surfaceIndex = SurfaceIndex(UInt.MAX_VALUE), + ), + buildMap { + repeat(512) { x -> + repeat(512) { y -> + put(MapTilePosition(x, y), ColourHex(255u, 255u, 255u, 255u)) + } + } + } + ) + + val encode = kxsBinary.encodeToByteArray(tiles) + + encode.inputStream() + val size = encode.size * Byte.SIZE_BYTES + + println(size) + + + val map2 = buildList { + repeat(512) { x -> + repeat(512) { y -> + val element = (x to y) to Int.MAX_VALUE + add(element) + } + } + } +// .toTypedArray() + val encode2 = kxsBinary.encodeToByteArray(map2) + + encode2.inputStream() + val size2 = encode2.size * Byte.SIZE_BYTES + + println(size2) + + } +} diff --git a/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/topology/FactorioServerPacketsTest.kt b/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/topology/FactorioServerPacketsTest.kt new file mode 100644 index 0000000..a357b58 --- /dev/null +++ b/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/topology/FactorioServerPacketsTest.kt @@ -0,0 +1,50 @@ +package dev.adamko.kafkatorio.processor.core.topology + +import dev.adamko.kafkatorio.library.kxsBinary +import dev.adamko.kafkatorio.schema.common.ColourHex +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.ServerMapChunkId +import dev.adamko.kafkatorio.server.processor.topology.ServerMapChunkTiles +import dev.adamko.kafkatorio.server.processor.topology.factorioServerPacketStream +import dev.adamko.kotka.kxs.serde +import io.kotest.core.spec.style.FunSpec +import kotlin.time.Duration +import kotlin.time.toJavaDuration +import org.apache.kafka.streams.StreamsBuilder +import org.apache.kafka.streams.TestInputTopic +import org.apache.kafka.streams.TopologyTestDriver + +class FactorioServerPacketsTest : FunSpec({ + + +}) + +private class Scenario( + streamsBuilder: StreamsBuilder = StreamsBuilder(), + + groupedMapChunksInputTopicName: String = "kafkatorio.state.map-chunk.terrain.colour", + + val serverId: FactorioServerId = FactorioServerId("test-server-id"), +) : AutoCloseable { + + init { + factorioServerPacketStream(streamsBuilder) + } + + private val testDriver: TopologyTestDriver = TopologyTestDriver(streamsBuilder.build()) + + val groupedMapChunksInputTopic: TestInputTopic> = + testDriver.createInputTopic( + groupedMapChunksInputTopicName, + kxsBinary.serde().serializer(), + kxsBinary.serde>().serializer(), + ) + + operator fun plusAssign(wallClockTime: Duration) { + testDriver.advanceWallClockTime(wallClockTime.toJavaDuration()) + } + + override fun close() { + testDriver.close() + } +} diff --git a/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/topology/GroupMapChunksTest.kt b/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/topology/GroupMapChunksTest.kt new file mode 100644 index 0000000..5dc33de --- /dev/null +++ b/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/topology/GroupMapChunksTest.kt @@ -0,0 +1,2280 @@ +package dev.adamko.kafkatorio.processor.core.topology + +//import dev.adamko.kafkatorio.server.processor.TOPIC_GROUPED_MAP_CHUNKS_STATE +//import dev.adamko.kafkatorio.processor.config.getJsonMapper +//import dev.adamko.kafkatorio.library.getKxsBinary +//import dev.adamko.kafkatorio.schema.common.Colour +//import dev.adamko.kafkatorio.schema.common.ColourHex +//import dev.adamko.kafkatorio.schema.common.MapChunkPosition +//import dev.adamko.kafkatorio.schema.common.MapTileDictionary +//import dev.adamko.kafkatorio.schema.common.MapTileDictionary.PrototypeKey +//import dev.adamko.kafkatorio.schema.common.MapTilePosition +//import dev.adamko.kafkatorio.schema.common.PrototypeName +//import dev.adamko.kafkatorio.schema.common.SurfaceIndex +//import dev.adamko.kafkatorio.schema.common.Tick +//import dev.adamko.kafkatorio.schema.common.toHex +//import dev.adamko.kafkatorio.schema.packets.KafkatorioPacket +//import dev.adamko.kafkatorio.schema.packets.MapChunkUpdate +//import dev.adamko.kafkatorio.schema.packets.MapChunkUpdateKey +//import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate +//import dev.adamko.kafkatorio.schema.common.FactorioPrototype +//import dev.adamko.kotka.kxs.serde +//import io.kotest.assertions.withClue +//import io.kotest.core.spec.style.FunSpec +//import io.kotest.matchers.collections.shouldContainAnyOf +//import io.kotest.matchers.collections.shouldHaveSize +//import io.kotest.matchers.equality.shouldBeEqualToComparingFields +//import io.kotest.matchers.nulls.shouldNotBeNull +//import io.kotest.matchers.should +//import kotlinx.serialization.decodeFromString +//import org.apache.kafka.streams.StreamsBuilder +//import org.apache.kafka.streams.TestInputTopic +//import org.apache.kafka.streams.TestOutputTopic +//import org.apache.kafka.streams.TopologyTestDriver +// +// +//class GroupMapChunksTest : FunSpec({ +// +// test("proto, then map chunk") { +// +// val scenario = Scenario() +// +// scenario.pipePrototypePacket( +// PrototypesUpdate(listOf(testMockTile)) +// ) +// +// scenario.pipeMapChunkPacket(testMapChunkUpdate) +// +// val records = scenario.mapTilesOutputTopic.readRecordsToList() +// +// withClue(records) { +// records shouldHaveSize 1 +// +// records.map { it.key to it.value }.first() should { (key, value) -> +// key.shouldNotBeNull() +// key shouldBeEqualToComparingFields ServerMapChunkId( +// serverId = FactorioServerId("test-server-id"), +// chunkPosition = MapChunkPosition(0, 0), +// surfaceIndex = SurfaceIndex(1u), +// chunkSize = ChunkSize.CHUNK_512, +// ) +// value.shouldNotBeNull() +// value shouldBeEqualToComparingFields ServerMapChunkTiles( +// chunkId = key, +// map = mapOf( +// MapTilePosition(1, 2) to ColourHex(76u, 51u, 25u, 255u) +// ) +// ) +// } +// } +// } +// +// test("raw actual JSON messages") { +// +// val scenario = Scenario() +// +// val prototypesPacket: KafkatorioPacket = jsonMapper.decodeFromString(rawPrototypesJson) +// scenario.prototypesInputTopic.pipeInput(scenario.serverId, prototypesPacket) +// +// val mapChunkPacket: KafkatorioPacket = jsonMapper.decodeFromString(rawMapChunkUpdateJson) +// scenario.mapChunkInputTopic.pipeInput(scenario.serverId, mapChunkPacket) +// +// val records = scenario.mapTilesOutputTopic.readRecordsToList() +// +// records shouldHaveSize 1 +// +// records.map { it.key to it.value }.first() should { (key, value) -> +// key.shouldNotBeNull() +// key shouldBeEqualToComparingFields ServerMapChunkId( +// serverId = FactorioServerId("test-server-id"), +// chunkPosition = MapChunkPosition(-1, -1), +// surfaceIndex = SurfaceIndex(1u), +// chunkSize = ChunkSize.CHUNK_512, +// ) +// value.shouldNotBeNull() +// +// value.chunkId shouldBeEqualToComparingFields key +// +// value.map.values.toSet().shouldContainAnyOf( +// (prototypesPacket.data as PrototypesUpdate).prototypes +// .filterIsInstance() +// .map { +// it.mapColour.toHex() +// }.toSet() +// ) +// +// val top: Int = value.map.keys.minOf { it.y } +// val bottom = value.map.keys.maxOf { it.y } +// val left = value.map.keys.minOf { it.x } +// val right = value.map.keys.maxOf { it.x } +// +// val colours: MutableMap = mutableMapOf(null to " ") +// +// val mapRepresentation = buildString { +// (top..bottom).forEach { y -> +// (left..right).forEach { x -> +// val colour = value.map[MapTilePosition(x, y)] +// val a = colours.getOrPut(colour) { "${colours.size}" } +// append(a) +// } +// appendLine() +// } +// } +// println(mapRepresentation) +// +// +//// value shouldBeEqualToComparingFields ServerMapChunkTiles( +//// chunkId = key, +//// map = mapOf( +//// MapTilePosition(x=-224, y=-224) to ColourHex(red=91u, green=63u, blue=38u, alpha=255u), +//// MapTilePosition(x=-224, y=-223) to ColourHex(red=91u, green=63u, blue=38u, alpha=255u), +//// MapTilePosition(x=-224, y=-222) to ColourHex(red=91u, green=63u, blue=38u, alpha=255u), +//// MapTilePosition(x=-224, y=-221) to ColourHex(red=66u, green=57u, blue=15u, alpha=255u), +//// MapTilePosition(x=-224, y=-220) to ColourHex(red=66u, green=57u, blue=15u, alpha=255u), +//// MapTilePosition(x=-224, y=-219) to ColourHex(red=66u, green=57u, blue=15u, alpha=255u), +//// MapTilePosition(x=-224, y=-218) to ColourHex(red=66u, green=57u, blue=15u, alpha=255u), +//// MapTilePosition(x=-224, y=-217) to ColourHex(red=66u, green=57u, blue=15u, alpha=255u), +//// MapTilePosition(x=-224, y=-216) to ColourHex(red=66u, green=57u, blue=15u, alpha=255u), +//// MapTilePosition(x=-224, y=-215) to ColourHex(red=66u, green=57u, blue=15u, alpha=255u), +//// ) +//// ) +// } +// } +// +// test("map chunk, then proto") { +// +// val scenario = Scenario() +// +// scenario.pipePrototypePacket( +// PrototypesUpdate(listOf(testMockTile.copy(mapColour = COLOUR_ONE))) +// ) +// +// scenario.pipeMapChunkPacket(testMapChunkUpdate) +// +// var records = scenario.mapTilesOutputTopic.readRecordsToList() +// +// withClue(records) { +// records shouldHaveSize 1 +// +// records.map { it.key to it.value }.first() should { (key, value) -> +// key.shouldNotBeNull() +// key shouldBeEqualToComparingFields ServerMapChunkId( +// serverId = FactorioServerId("test-server-id"), +// chunkPosition = MapChunkPosition(0, 0), +// surfaceIndex = SurfaceIndex(1u), +// chunkSize = ChunkSize.CHUNK_512, +// ) +// value.shouldNotBeNull() +// value shouldBeEqualToComparingFields ServerMapChunkTiles( +// chunkId = key, +// map = mapOf( +// MapTilePosition(1, 2) to ColourHex(25u, 25u, 25u, 25u) +// ) +// ) +// } +// } +// +// scenario.pipePrototypePacket( +// PrototypesUpdate(listOf(testMockTile.copy(mapColour = COLOUR_TWO))) +// ) +// +// records = scenario.mapTilesOutputTopic.readRecordsToList() +// +// withClue(records) { +// records shouldHaveSize 1 +// +// records.map { it.key to it.value }.first() should { (key, value) -> +// key.shouldNotBeNull() +// key shouldBeEqualToComparingFields ServerMapChunkId( +// serverId = FactorioServerId("test-server-id"), +// chunkPosition = MapChunkPosition(0, 0), +// surfaceIndex = SurfaceIndex(1u), +// chunkSize = ChunkSize.CHUNK_512, +// ) +// value.shouldNotBeNull() +// value shouldBeEqualToComparingFields ServerMapChunkTiles( +// chunkId = key, +// map = mapOf( +// MapTilePosition(1, 2) to ColourHex(51u, 51u, 51u, 51u) +// ) +// ) +// } +// } +// } +//}) { +// +// class Scenario( +// streamsBuilder: StreamsBuilder = StreamsBuilder(), +// +// prototypesTopicName: String = "kafkatorio.packet.prototypes", +// mapChunkUpdatesTopicName: String = "kafkatorio.packet.map-chunk", +// +// val serverId: FactorioServerId = FactorioServerId("test-server-id"), +// ) { +// private val topology = groupMapChunks(streamsBuilder) +// private val testDriver: TopologyTestDriver = TopologyTestDriver(topology) +// +// val prototypesInputTopic: TestInputTopic = +// testDriver.createInputTopic( +// prototypesTopicName, +// jsonMapper.serde().serializer(), +// jsonMapper.serde().serializer(), +// ) +// +// val mapChunkInputTopic: TestInputTopic = +// testDriver.createInputTopic( +// mapChunkUpdatesTopicName, +// jsonMapper.serde().serializer(), +// jsonMapper.serde().serializer(), +// ) +// +// val mapTilesOutputTopic: TestOutputTopic> = +// testDriver.createOutputTopic( +// TOPIC_GROUPED_MAP_CHUNKS_STATE, +// kxsBinary.serde().deserializer(), +// kxsBinary.serde>().deserializer(), +// ) +// +// fun pipePrototypePacket(prototypeUpdate: PrototypesUpdate) { +// prototypesInputTopic.pipeInput( +// serverId, +// KafkatorioPacket( +// modVersion = "1.2.3", +// tick = Tick(22u), +// data = prototypeUpdate, +// ) +// ) +// } +// +// fun pipeMapChunkPacket(mapChunkUpdate: MapChunkUpdate) { +// mapChunkInputTopic.pipeInput( +// serverId, +// KafkatorioPacket( +// modVersion = "1.2.3", +// tick = Tick(44u), +// data = mapChunkUpdate +// ) +// ) +// } +// } +// +// companion object { +// val COLOUR_ONE = Colour(0.1f, 0.1f, 0.1f, 0.1f) +// val COLOUR_TWO = Colour(0.2f, 0.2f, 0.2f, 0.2f) +// +// val testMockTile = FactorioPrototype.MapTile( +// PrototypeName("fake-proto"), +// layer = 1u, +// mapColour = Colour(0.3f, 0.2f, 0.1f, 1.0f), +// collisionMasks = listOf("fake-mask"), +// order = "fake-order", +// canBeMined = false, +// ) +// +// val testMapChunkUpdate = MapChunkUpdate( +// key = MapChunkUpdateKey( +// MapChunkPosition(11, 22), +// SurfaceIndex(1u), +// ), +// tileDictionary = MapTileDictionary( +// tilesXY = mapOf( +// "1" to mapOf("2" to PrototypeKey(33)) +// ), +// protos = mapOf(PrototypeName("fake-proto") to PrototypeKey(33)) +// ) +// ) +// +// const val rawMapChunkUpdateJson = """ +// { +// "modVersion": "0.4.0", +// "tick": 36, +// "data": { +// "type": "kafkatorio.packet.keyed.MapChunkUpdate", +// "key": { +// "chunkPosition": [ +// -7, +// -7 +// ], +// "surfaceIndex": 1 +// }, +// "events": { +// "on_chunk_generated": [1] +// }, +// "tileDictionary": { +// "tilesXY": { +// "-224": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 1, +// "-220": 1, +// "-219": 1, +// "-218": 1, +// "-217": 1, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 2, +// "-206": 2, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-223": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 1, +// "-218": 1, +// "-217": 1, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 2, +// "-206": 2, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-222": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 1, +// "-217": 1, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 2, +// "-206": 2, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-221": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 1, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 2, +// "-206": 2, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 1 +// }, +// "-220": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 2, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-219": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 0, +// "-210": 0, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 2, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-218": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 0, +// "-210": 0, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-217": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 0, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-216": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-215": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-214": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-213": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 1, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 1 +// }, +// "-212": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 0, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 1, +// "-202": 1, +// "-201": 1, +// "-200": 2, +// "-199": 2, +// "-198": 0, +// "-197": 0, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 1 +// }, +// "-211": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 0, +// "-210": 0, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 1, +// "-202": 1, +// "-201": 1, +// "-200": 1, +// "-199": 2, +// "-198": 0, +// "-197": 0, +// "-196": 2, +// "-195": 1, +// "-194": 1, +// "-193": 1 +// }, +// "-210": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 0, +// "-210": 0, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 0, +// "-205": 0, +// "-204": 1, +// "-203": 1, +// "-202": 1, +// "-201": 1, +// "-200": 1, +// "-199": 1, +// "-198": 2, +// "-197": 2, +// "-196": 1, +// "-195": 1, +// "-194": 1, +// "-193": 1 +// }, +// "-209": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 0, +// "-210": 0, +// "-209": 0, +// "-208": 1, +// "-207": 1, +// "-206": 0, +// "-205": 0, +// "-204": 0, +// "-203": 1, +// "-202": 1, +// "-201": 1, +// "-200": 1, +// "-199": 1, +// "-198": 2, +// "-197": 2, +// "-196": 1, +// "-195": 1, +// "-194": 1, +// "-193": 1 +// }, +// "-208": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 0, +// "-210": 0, +// "-209": 0, +// "-208": 1, +// "-207": 1, +// "-206": 0, +// "-205": 0, +// "-204": 0, +// "-203": 1, +// "-202": 1, +// "-201": 1, +// "-200": 1, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 1, +// "-195": 1, +// "-194": 1, +// "-193": 1 +// }, +// "-207": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 0, +// "-212": 0, +// "-211": 0, +// "-210": 0, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 1, +// "-202": 1, +// "-201": 1, +// "-200": 1, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 1, +// "-195": 1, +// "-194": 1, +// "-193": 1 +// }, +// "-206": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 0, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 1, +// "-202": 1, +// "-201": 1, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 1, +// "-196": 1, +// "-195": 1, +// "-194": 1, +// "-193": 1 +// }, +// "-205": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 1, +// "-202": 1, +// "-201": 1, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 1, +// "-196": 1, +// "-195": 1, +// "-194": 1, +// "-193": 2 +// }, +// "-204": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 1, +// "-202": 1, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 1, +// "-196": 1, +// "-195": 1, +// "-194": 1, +// "-193": 2 +// }, +// "-203": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 1, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 1, +// "-202": 1, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 1, +// "-194": 2, +// "-193": 2 +// }, +// "-202": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 1, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 1, +// "-202": 1, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-201": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 3, +// "-217": 1, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 1, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-200": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 3, +// "-218": 3, +// "-217": 3, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 1, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-199": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 3, +// "-218": 3, +// "-217": 3, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-198": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 3, +// "-218": 3, +// "-217": 3, +// "-216": 1, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 1, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-197": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 3, +// "-218": 3, +// "-217": 0, +// "-216": 0, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 1, +// "-211": 1, +// "-210": 1, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-196": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 1, +// "-214": 1, +// "-213": 1, +// "-212": 2, +// "-211": 2, +// "-210": 2, +// "-209": 1, +// "-208": 1, +// "-207": 1, +// "-206": 1, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-195": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 1, +// "-213": 1, +// "-212": 2, +// "-211": 2, +// "-210": 2, +// "-209": 2, +// "-208": 2, +// "-207": 2, +// "-206": 1, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-194": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 1, +// "-213": 2, +// "-212": 2, +// "-211": 2, +// "-210": 2, +// "-209": 2, +// "-208": 2, +// "-207": 2, +// "-206": 2, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// }, +// "-193": { +// "-224": 0, +// "-223": 0, +// "-222": 0, +// "-221": 0, +// "-220": 0, +// "-219": 0, +// "-218": 0, +// "-217": 0, +// "-216": 0, +// "-215": 0, +// "-214": 2, +// "-213": 2, +// "-212": 2, +// "-211": 2, +// "-210": 2, +// "-209": 2, +// "-208": 2, +// "-207": 2, +// "-206": 2, +// "-205": 2, +// "-204": 2, +// "-203": 2, +// "-202": 2, +// "-201": 2, +// "-200": 2, +// "-199": 2, +// "-198": 2, +// "-197": 2, +// "-196": 2, +// "-195": 2, +// "-194": 2, +// "-193": 2 +// } +// }, +// "protos": { +// "dirt-5": 0, +// "grass-2": 1, +// "dirt-6": 2, +// "red-desert-0": 3 +// } +// } +// } +// } +// """ +// +// const val rawPrototypesJson = """ +// { +// "modVersion": "0.4.0", +// "tick": 4352, +// "data": { +// "type": "kafkatorio.packet.instant.PrototypesUpdate", +// "prototypes": [ +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "stone-path", +// "layer": 60, +// "mapColour": [ +// 86, +// 82, +// 74, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-a[tier-1]-a[stone-path]", +// "canBeMined": true +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "concrete", +// "layer": 61, +// "mapColour": [ +// 63, +// 61, +// 59, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-b[tier-2]-a[concrete]", +// "canBeMined": true +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "hazard-concrete-left", +// "layer": 62, +// "mapColour": [ +// 176, +// 142, +// 39, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-b[tier-2]-b[hazard-concrete-left]", +// "canBeMined": true +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "hazard-concrete-right", +// "layer": 62, +// "mapColour": [ +// 176, +// 142, +// 39, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-b[tier-2]-c[hazard-concrete-right]", +// "canBeMined": true +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "refined-concrete", +// "layer": 64, +// "mapColour": [ +// 49, +// 48, +// 45, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-c[tier-3]-a[refined-concrete]", +// "canBeMined": true +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "refined-hazard-concrete-left", +// "layer": 65, +// "mapColour": [ +// 116, +// 94, +// 26, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-c[tier-3]-b[refined-hazard-concrete-left]", +// "canBeMined": true +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "refined-hazard-concrete-right", +// "layer": 65, +// "mapColour": [ +// 116, +// 94, +// 26, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-c[tier-3]-c[refined-hazard-concrete-right]", +// "canBeMined": true +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "landfill", +// "layer": 57, +// "mapColour": [ +// 57, +// 39, +// 26, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-d[utility]-a[landfill]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "acid-refined-concrete", +// "layer": 97, +// "mapColour": [ +// 142, +// 194, +// 40, +// 127 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-e[color-concrete]-acid", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "black-refined-concrete", +// "layer": 88, +// "mapColour": [ +// 25, +// 25, +// 25, +// 127 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-e[color-concrete]-black", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "blue-refined-concrete", +// "layer": 73, +// "mapColour": [ +// 39, +// 137, +// 228, +// 127 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-e[color-concrete]-blue", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "brown-refined-concrete", +// "layer": 91, +// "mapColour": [ +// 76, +// 29, +// 0, +// 127 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-e[color-concrete]-brown", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "cyan-refined-concrete", +// "layer": 94, +// "mapColour": [ +// 70, +// 192, +// 181, +// 127 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-e[color-concrete]-cyan", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "green-refined-concrete", +// "layer": 70, +// "mapColour": [ +// 23, +// 195, +// 43, +// 127 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-e[color-concrete]-green", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "orange-refined-concrete", +// "layer": 76, +// "mapColour": [ +// 221, +// 127, +// 33, +// 127 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-e[color-concrete]-orange", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "pink-refined-concrete", +// "layer": 82, +// "mapColour": [ +// 236, +// 98, +// 131, +// 127 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-e[color-concrete]-pink", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "purple-refined-concrete", +// "layer": 85, +// "mapColour": [ +// 123, +// 28, +// 168, +// 127 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-e[color-concrete]-purple", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "red-refined-concrete", +// "layer": 67, +// "mapColour": [ +// 207, +// 6, +// 0, +// 127 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-e[color-concrete]-red", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "yellow-refined-concrete", +// "layer": 79, +// "mapColour": [ +// 212, +// 169, +// 19, +// 127 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "a[artificial]-e[color-concrete]-yellow", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "grass-1", +// "layer": 26, +// "mapColour": [ +// 55, +// 53, +// 11, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-a[grass]-a[grass-1]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "grass-2", +// "layer": 28, +// "mapColour": [ +// 66, +// 57, +// 15, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-a[grass]-b[grass-2]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "grass-3", +// "layer": 29, +// "mapColour": [ +// 65, +// 52, +// 28, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-a[grass]-c[grass-3]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "grass-4", +// "layer": 30, +// "mapColour": [ +// 59, +// 40, +// 18, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-a[grass]-d[grass-4]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "dry-dirt", +// "layer": 18, +// "mapColour": [ +// 94, +// 66, +// 37, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-b[dirt]-a[dry-dirt]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "dirt-1", +// "layer": 19, +// "mapColour": [ +// 141, +// 104, +// 60, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-b[dirt]-b[dirt-1]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "dirt-2", +// "layer": 20, +// "mapColour": [ +// 136, +// 96, +// 59, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-b[dirt]-c[dirt-2]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "dirt-3", +// "layer": 21, +// "mapColour": [ +// 133, +// 92, +// 53, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-b[dirt]-d[dirt-3]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "dirt-4", +// "layer": 22, +// "mapColour": [ +// 103, +// 72, +// 43, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-b[dirt]-e[dirt-4]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "dirt-5", +// "layer": 23, +// "mapColour": [ +// 91, +// 63, +// 38, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-b[dirt]-f[dirt-5]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "dirt-6", +// "layer": 24, +// "mapColour": [ +// 80, +// 55, +// 31, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-b[dirt]-g[dirt-6]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "dirt-7", +// "layer": 25, +// "mapColour": [ +// 80, +// 54, +// 28, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-b[dirt]-h[dirt-7]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "sand-1", +// "layer": 8, +// "mapColour": [ +// 138, +// 103, +// 58, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-c[sand]-a[sand-1]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "sand-2", +// "layer": 9, +// "mapColour": [ +// 128, +// 93, +// 52, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-c[sand]-b[sand-2]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "sand-3", +// "layer": 10, +// "mapColour": [ +// 115, +// 83, +// 47, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-c[sand]-c[sand-3]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "red-desert-0", +// "layer": 31, +// "mapColour": [ +// 103, +// 70, +// 32, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-d[red-desert]-a[red-desert-0]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "red-desert-1", +// "layer": 14, +// "mapColour": [ +// 116, +// 81, +// 39, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-d[red-desert]-b[red-desert-1]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "red-desert-2", +// "layer": 15, +// "mapColour": [ +// 116, +// 84, +// 43, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-d[red-desert]-c[red-desert-2]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "red-desert-3", +// "layer": 16, +// "mapColour": [ +// 128, +// 93, +// 52, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "b[natural]-d[red-desert]-d[red-desert-3]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "water", +// "layer": 3, +// "mapColour": [ +// 51, +// 83, +// 95, +// 255 +// ], +// "collisionMasks": [ +// "doodad-layer", +// "item-layer", +// "player-layer", +// "resource-layer", +// "water-tile" +// ], +// "order": "c[water]-a[water]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "deepwater", +// "layer": 3, +// "mapColour": [ +// 38, +// 64, +// 73, +// 255 +// ], +// "collisionMasks": [ +// "doodad-layer", +// "item-layer", +// "player-layer", +// "resource-layer", +// "water-tile" +// ], +// "order": "c[water]-b[deep-water]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "water-green", +// "layer": 3, +// "mapColour": [ +// 31, +// 48, +// 18, +// 255 +// ], +// "collisionMasks": [ +// "doodad-layer", +// "item-layer", +// "player-layer", +// "resource-layer", +// "water-tile" +// ], +// "order": "c[water]-c[water-green]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "deepwater-green", +// "layer": 3, +// "mapColour": [ +// 23, +// 37, +// 16, +// 255 +// ], +// "collisionMasks": [ +// "doodad-layer", +// "item-layer", +// "player-layer", +// "resource-layer", +// "water-tile" +// ], +// "order": "c[water]-d[deepwater-green]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "water-shallow", +// "layer": 6, +// "mapColour": [ +// 82, +// 98, +// 92, +// 255 +// ], +// "collisionMasks": [ +// "item-layer", +// "object-layer", +// "resource-layer", +// "water-tile" +// ], +// "order": "c[water]-e[water-shallow]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "water-mud", +// "layer": 7, +// "mapColour": [ +// 65, +// 89, +// 90, +// 255 +// ], +// "collisionMasks": [ +// "item-layer", +// "object-layer", +// "resource-layer", +// "water-tile" +// ], +// "order": "c[water]-g[water-mud]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "nuclear-ground", +// "layer": 33, +// "mapColour": [ +// 48, +// 40, +// 35, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "d[destruction]-a[nuclear]-a[nuclear-ground]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "water-wube", +// "layer": 2, +// "mapColour": [ +// 0, +// 0, +// 0, +// 255 +// ], +// "collisionMasks": [ +// "doodad-layer", +// "item-layer", +// "player-layer", +// "resource-layer", +// "water-tile" +// ], +// "order": "x[wube]-a[water-wube]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "tile-unknown", +// "layer": 0, +// "mapColour": [ +// 0, +// 0, +// 0, +// 255 +// ], +// "collisionMasks": {}, +// "order": "z-a", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "out-of-map", +// "layer": 0, +// "mapColour": [ +// 0, +// 0, +// 0, +// 255 +// ], +// "collisionMasks": [ +// "doodad-layer", +// "floor-layer", +// "ground-tile", +// "item-layer", +// "object-layer", +// "player-layer", +// "resource-layer", +// "water-tile" +// ], +// "order": "z[other]-a[out-of-map]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "lab-dark-1", +// "layer": 70, +// "mapColour": [ +// 49, +// 49, +// 49, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "z[other]-b[lab]-a[lab-dark-1]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "lab-dark-2", +// "layer": 70, +// "mapColour": [ +// 0, +// 0, +// 0, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "z[other]-b[lab]-b[lab-dark-2]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "lab-white", +// "layer": 70, +// "mapColour": [ +// 255, +// 255, +// 255, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "z[other]-b[lab]-c[lab-white]", +// "canBeMined": false +// }, +// { +// "type": "kafkatorio.prototype.MapTile", +// "name": "tutorial-grid", +// "layer": 55, +// "mapColour": [ +// 122, +// 122, +// 122, +// 255 +// ], +// "collisionMasks": [ +// "ground-tile" +// ], +// "order": "z[other]-c[tutorial]-a[tutorial-grid]", +// "canBeMined": false +// } +// ] +// } +// } +// """ +// } +//} diff --git a/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/topology/SaveMapChunksTest.kt b/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/topology/SaveMapChunksTest.kt new file mode 100644 index 0000000..ff66f41 --- /dev/null +++ b/modules/events-processor-core/src/test/kotlin/dev/adamko/kafkatorio/processor/core/topology/SaveMapChunksTest.kt @@ -0,0 +1,191 @@ +package dev.adamko.kafkatorio.processor.core.topology + +import dev.adamko.kafkatorio.library.iterateTiles +import dev.adamko.kafkatorio.library.kxsBinary +import dev.adamko.kafkatorio.library.toMapChunkPosition +import dev.adamko.kafkatorio.schema.common.ChunkSize +import dev.adamko.kafkatorio.schema.common.ColourHex +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.MapChunkPosition +import dev.adamko.kafkatorio.schema.common.MapTilePosition +import dev.adamko.kafkatorio.schema.common.ServerMapChunkId +import dev.adamko.kafkatorio.schema.common.ServerMapTileLayer +import dev.adamko.kafkatorio.schema.common.SurfaceIndex +import dev.adamko.kafkatorio.server.processor.topology.ServerMapChunkTiles +import dev.adamko.kafkatorio.server.processor.topology.saveMapTiles +import dev.adamko.kotka.kxs.serde +import io.kotest.core.spec.style.FunSpec +import io.kotest.property.Arb +import io.kotest.property.PropTestConfig +import io.kotest.property.RandomSource +import io.kotest.property.arbitrary.arbitrary +import io.kotest.property.arbitrary.int +import io.kotest.property.arbitrary.uByte +import io.kotest.property.checkAll +import java.nio.file.Path +import java.time.LocalTime +import java.time.format.DateTimeFormatter +import kotlin.io.path.Path +import kotlin.io.path.absolutePathString +import kotlin.time.Duration +import kotlin.time.Duration.Companion.minutes +import kotlin.time.Duration.Companion.seconds +import kotlin.time.toJavaDuration +import kotlinx.coroutines.delay +import org.apache.kafka.streams.StreamsBuilder +import org.apache.kafka.streams.TestInputTopic +import org.apache.kafka.streams.TopologyTestDriver + + +class SaveMapChunksTest : FunSpec({ + + test("save tile") { + + Scenario().use { scenario -> + + val chunkTilesArb = serverMapChunkTilesArb(scenario.serverId) + + checkAll( + config = PropTestConfig(iterations = 1), + chunkTilesArb, + ) { chunkTiles -> + + scenario.groupedMapChunksInputTopic.pipeInput( + chunkTiles.chunkId, + chunkTiles, + ) + + scenario += 1.minutes + delay(5.seconds) + scenario += 1.minutes + // delay(5.seconds) + scenario += 1.minutes + // delay(5.seconds) + scenario += 1.minutes + // delay(5.seconds) + + println("file:///${scenario.outputDir.absolutePathString()}") + } + } + } + +}) { + + class Scenario( + streamsBuilder: StreamsBuilder = StreamsBuilder(), + + groupedMapChunksInputTopicName: String = "kafkatorio.state.map-chunk.terrain.colour", + + val serverId: FactorioServerId = FactorioServerId("test-server-id"), + ) : AutoCloseable { + + val outputDir: Path = run { + val now = LocalTime.now().format(DateTimeFormatter.ISO_TIME).filter { it.isLetterOrDigit() } + Path("build/test/save-map-chunks-${now}") + } + private val testDriver: TopologyTestDriver + + init { + saveMapTiles(streamsBuilder, outputDir) + testDriver = TopologyTestDriver(streamsBuilder.build()) + } + + val groupedMapChunksInputTopic: TestInputTopic> = + testDriver.createInputTopic( + groupedMapChunksInputTopicName, + kxsBinary.serde().serializer(), + kxsBinary.serde>().serializer(), + ) + + operator fun plusAssign(wallClockTime: Duration) { + testDriver.advanceWallClockTime(wallClockTime.toJavaDuration()) + } + + override fun close() { + testDriver.close() + } + } + + companion object { + + private fun mapChunkPositionArb( + xArb: Arb = Arb.int(-10..10), + yArb: Arb = Arb.int(-10..10), + chunkSize: ChunkSize = ChunkSize.MAX, + ): Arb = arbitrary { + MapChunkPosition(xArb.bind(), yArb.bind(), chunkSize) + } + + private fun colourHexArb( + redArb: Arb = Arb.uByte(), + greenArb: Arb = Arb.uByte(), + blueArb: Arb = Arb.uByte(), + alphaArb: Arb = Arb.uByte(), + ): Arb = arbitrary { + ColourHex( + redArb.bind(), + greenArb.bind(), + blueArb.bind(), + alphaArb.bind(), + ) + } + + private fun serverMapChunkIdArb( + serverId: FactorioServerId, + chunkSize: ChunkSize = ChunkSize.MAX, + chunkPosition: Arb = mapChunkPositionArb(chunkSize = chunkSize), + surfaceIndex: SurfaceIndex = SurfaceIndex(1u), + ): Arb = arbitrary { + ServerMapChunkId( + serverId = serverId, + layer = ServerMapTileLayer.RESOURCE, + chunkPosition = chunkPosition.bind(), + surfaceIndex = surfaceIndex, + ) + } + + private fun tilesInChunkArb( + chunkId: ServerMapChunkId + ): Arb> = arbitrary { + + val tileColours = mutableMapOf() + + println("chunk size: ${chunkId.chunkSize} ${chunkId.chunkSize.lengthInTiles}") + + val map = chunkId.chunkPosition + .iterateTiles() + .asSequence() + .map { tilePos -> + val colour = + tileColours.getOrPut(tilePos.toMapChunkPosition(ChunkSize.MIN)) { + colourHexArb().sample(RandomSource.default()).value + } + tilePos to colour + } +// .take(100) + .toMap() + + println(map.size) + + map + } + + fun serverMapChunkTilesArb( + serverId: FactorioServerId, + ): Arb> { + + val serverMapChunkId = serverMapChunkIdArb(serverId) + + return arbitrary { + val chunkId = serverMapChunkId.bind() + + val tileColoursArb = tilesInChunkArb(chunkId) + + ServerMapChunkTiles( + chunkId = chunkId, + map = tileColoursArb.bind() + ) + } + } + } +} diff --git a/modules/events-processors/build.gradle.kts b/modules/events-processors/build.gradle.kts new file mode 100644 index 0000000..fff7f2c --- /dev/null +++ b/modules/events-processors/build.gradle.kts @@ -0,0 +1,106 @@ +import kafkatorio.extensions.dropDirectory +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("kafkatorio.conventions.lang.kotlin-jvm") + id("dev.adamko.geedeecee") + kotlin("plugin.serialization") + application +} + + +description = "processors for Kafkatorio packets" + +val projectId: String by project.extra + + +dependencies { + implementation(platform(projects.modules.versionsPlatform)) + + implementation(libs.kafka.streams) + implementation(kotlin("reflect")) + + testImplementation(libs.kafka.streamsTestUtils) + + implementation(projects.modules.eventsLibrary) + implementation(projects.modules.eventsProcessorCore) + + implementation(libs.kotlinxSerialization.core) + implementation(libs.kotlinxSerialization.json) + + implementation(libs.kotlinx.coroutines.core) + + implementation(libs.bundles.logging) + + implementation(libs.scrimage.core) + + implementation(libs.okio.core) + + implementation(libs.simpleSyslogParser) + + implementation(libs.kafka.kotkaStreams) +} + + +application { + mainClass.set("dev.adamko.kafkatorio.processors.MainKt") +} + + +tasks.withType().configureEach { + kotlinOptions.freeCompilerArgs += listOf( + "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + "-opt-in=kotlinx.coroutines.FlowPreview", + "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", + ) +} + + +//val startScriptEntitiesProcessor = registerStartScriptTask("EntitiesProcessor") { +// mainClass.set("dev.adamko.kafkatorio.processors.EntitiesProcessorKt") +//} +// +//val startScriptPacketsProcessor = registerStartScriptTask("PacketsProcessor") { +// mainClass.set("dev.adamko.kafkatorio.processors.PacketsProcessorKt") +//} +// +//val startScriptTilesProcessor = registerStartScriptTask("TilesProcessor") { +// mainClass.set("dev.adamko.kafkatorio.processors.TilesProcessorKt") +//} +// +// +//application.applicationDistribution.into("bin") { +// from(startScriptEntitiesProcessor) +// from(startScriptPacketsProcessor) +// from(startScriptTilesProcessor) +// fileMode = 0b000_111_101_101 // 0755 +// duplicatesStrategy = DuplicatesStrategy.EXCLUDE +//} + +tasks.named("run") { + val kafkaStateDir: Directory = layout.projectDirectory.dir(".state/kafka/") + + doFirst { + kafkaStateDir.asFile.mkdirs() + } +} + + +val runEventsProcessors by tasks.registering { + group = rootProject.name + + dependsOn(tasks.run) +} + + +tasks.dockerContextPrepareFiles { + from(zipTree(tasks.distZip.flatMap { it.archiveFile })) { + eachFile { + relativePath = relativePath.dropDirectory() + + if (!isDirectory && relativePath.pathString.matches("""bin\/.+""".toRegex())) { + name = name.replace(file.nameWithoutExtension, "run") + } + } + } +} diff --git a/modules/events-processors/docker/Dockerfile b/modules/events-processors/docker/Dockerfile new file mode 100644 index 0000000..265c100 --- /dev/null +++ b/modules/events-processors/docker/Dockerfile @@ -0,0 +1,15 @@ +# syntax=docker/dockerfile:1 + +FROM eclipse-temurin:11-jdk-jammy +ARG KAFKATORIO_VERSION +ARG APP_FILES="build/" + + +ENV SERVER_DATA_DIR="/app/data" \ + KAFKA_STREAMS_STATE_DIR="/app/state/kafka" + + +COPY ${APP_FILES} /app/ + + +ENTRYPOINT /app/bin/run diff --git a/modules/events-processors/docker/docker-compose.yml b/modules/events-processors/docker/docker-compose.yml new file mode 100644 index 0000000..fc976f6 --- /dev/null +++ b/modules/events-processors/docker/docker-compose.yml @@ -0,0 +1,34 @@ +version: "3.9" + +services: + + events-processors: + image: ${REGISTRY_HOST}/${APP_GROUP}/${APP_NAME}:${KAFKATORIO_VERSION} + container_name: ${APP_NAME} + restart: unless-stopped + build: + context: . + dockerfile: Dockerfile + args: + KAFKATORIO_VERSION: ${KAFKATORIO_VERSION} + APP_FILES: "./build/" + environment: + KAFKA_BOOTSTRAP_SERVERS: "http://kafka:29092" + # KAFKA_STREAMS_STATE_DIR: "" + networks: + - "kafka-nw" + - "kafkatorio-nw" + - "traefik-nw" +# labels: +# - "traefik.enable=true" + +networks: + kafka-nw: + name: "kafka-nw" + external: true + kafkatorio-nw: + name: "kafkatorio-nw" + external: true + traefik-nw: + name: "traefik-nw" + external: true diff --git a/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/createTopics.kt b/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/createTopics.kt new file mode 100644 index 0000000..535d2ef --- /dev/null +++ b/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/createTopics.kt @@ -0,0 +1,11 @@ +package dev.adamko.kafkatorio.processors + +import dev.adamko.kafkatorio.processor.admin.KafkatorioKafkaAdmin +import dev.adamko.kafkatorio.processor.config.ApplicationProperties + +fun createTopics( + appProps: ApplicationProperties = ApplicationProperties.load(), +) { + val admin = KafkatorioKafkaAdmin(appProps) + admin.createKafkatorioTopics() +} diff --git a/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/groupEntitiesMapChunks.kt b/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/groupEntitiesMapChunks.kt new file mode 100644 index 0000000..740b38f --- /dev/null +++ b/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/groupEntitiesMapChunks.kt @@ -0,0 +1,56 @@ +package dev.adamko.kafkatorio.processors + +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import dev.adamko.kafkatorio.processor.core.launchTopology +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.PrototypeHashCode +import dev.adamko.kafkatorio.schema.common.ServerMapChunkId +import dev.adamko.kafkatorio.schema.common.ServerMapTileLayer +import dev.adamko.kafkatorio.schema.packets.MapChunkEntityUpdate +import dev.adamko.kafkatorio.schema.packets.MapChunkResourceUpdate +import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate +import dev.adamko.kafkatorio.server.processor.topology.ServerMapChunkTiles +import dev.adamko.kafkatorio.server.processor.topology.colourEntityChunks +import dev.adamko.kafkatorio.server.processor.topology.convertEntityUpdateToServerMapChunkTiles +import dev.adamko.kafkatorio.server.processor.topology.convertResourceUpdateToServerMapChunkTiles +import dev.adamko.kafkatorio.server.processor.topology.streamPacketData +import org.apache.kafka.streams.StreamsBuilder +import org.apache.kafka.streams.kstream.KStream + + +/** Building and resource tiles */ +suspend fun groupEntitiesMapChunks( + layer: ServerMapTileLayer, + colouredUpdatesStreamTopic: String, + colouredChunkStateTopic: String, + appProps: ApplicationProperties = ApplicationProperties.load(), +) { + val builder = StreamsBuilder() + + val entityChunksStream: KStream> = + when (layer) { + ServerMapTileLayer.TERRAIN -> return + + ServerMapTileLayer.RESOURCE -> + builder.streamPacketData() + .convertResourceUpdateToServerMapChunkTiles("groupEntitiesMapChunks.${layer.dir}") + + ServerMapTileLayer.BUILDING -> + builder.streamPacketData() + .convertEntityUpdateToServerMapChunkTiles("groupEntitiesMapChunks.${layer.dir}") + } + + val protosStream: KStream = + builder.streamPacketData() + + val topology = colourEntityChunks( + builder, + entityChunksStream, + protosStream, + layer, + colouredUpdatesStreamTopic, + colouredChunkStateTopic, + ) + + launchTopology("groupTilesMapChunks.${layer.dir}", topology, appProps = appProps) +} diff --git a/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/groupTilesMapChunks.kt b/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/groupTilesMapChunks.kt new file mode 100644 index 0000000..e95e026 --- /dev/null +++ b/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/groupTilesMapChunks.kt @@ -0,0 +1,30 @@ +package dev.adamko.kafkatorio.processors + +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import dev.adamko.kafkatorio.processor.core.launchTopology +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.ServerMapTileLayer +import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate +import dev.adamko.kafkatorio.server.processor.topology.colourMapChunks +import dev.adamko.kafkatorio.server.processor.topology.streamPacketData +import org.apache.kafka.streams.StreamsBuilder +import org.apache.kafka.streams.kstream.KStream + + +/** Terrain tiles */ +suspend fun groupTilesMapChunks( + appProps: ApplicationProperties = ApplicationProperties.load(), +) { + val builder = StreamsBuilder() + + val protosStream: KStream = + builder.streamPacketData() + + val topology = colourMapChunks(builder, protosStream) + + launchTopology( + id = "groupTilesMapChunks.${ServerMapTileLayer.TERRAIN.dir}", + topology = topology, + appProps = appProps + ) +} diff --git a/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/main.kt b/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/main.kt new file mode 100644 index 0000000..c046990 --- /dev/null +++ b/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/main.kt @@ -0,0 +1,39 @@ +package dev.adamko.kafkatorio.processors + +import dev.adamko.kafkatorio.processor.config.TOPIC_MAP_CHUNK_BUILDING_COLOURED_032_UPDATES +import dev.adamko.kafkatorio.processor.config.TOPIC_MAP_CHUNK_BUILDING_COLOURED_STATE +import dev.adamko.kafkatorio.processor.config.TOPIC_MAP_CHUNK_RESOURCE_COLOURED_032_UPDATES +import dev.adamko.kafkatorio.processor.config.TOPIC_MAP_CHUNK_RESOURCE_COLOURED_STATE +import dev.adamko.kafkatorio.schema.common.ServerMapTileLayer +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch + + +suspend fun main(): Unit = coroutineScope { + + createTopics() + + launch { + splitPackets() + } + + launch { + groupTilesMapChunks() + } + + launch { + groupEntitiesMapChunks( + layer = ServerMapTileLayer.BUILDING, + colouredUpdatesStreamTopic = TOPIC_MAP_CHUNK_BUILDING_COLOURED_032_UPDATES, + colouredChunkStateTopic = TOPIC_MAP_CHUNK_BUILDING_COLOURED_STATE, + ) + } + + launch { + groupEntitiesMapChunks( + layer = ServerMapTileLayer.RESOURCE, + colouredUpdatesStreamTopic = TOPIC_MAP_CHUNK_RESOURCE_COLOURED_032_UPDATES, + colouredChunkStateTopic = TOPIC_MAP_CHUNK_RESOURCE_COLOURED_STATE, + ) + } +} diff --git a/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/splitPackets.kt b/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/splitPackets.kt new file mode 100644 index 0000000..7c4dd21 --- /dev/null +++ b/modules/events-processors/src/main/kotlin/dev/adamko/kafkatorio/processors/splitPackets.kt @@ -0,0 +1,20 @@ +package dev.adamko.kafkatorio.processors + +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import dev.adamko.kafkatorio.processor.core.launchTopology +import dev.adamko.kafkatorio.server.processor.topology.factorioServerPacketStream +import dev.adamko.kafkatorio.server.processor.topology.splitFactorioServerPacketStream +import org.apache.kafka.streams.StreamsBuilder + + +suspend fun splitPackets( + appProps: ApplicationProperties = ApplicationProperties.load(), +) { + val builder = StreamsBuilder() + val packets = factorioServerPacketStream(builder) + splitFactorioServerPacketStream(packets) + + val topology = builder.build() + + launchTopology("splitPackets", topology, appProps = appProps) +} diff --git a/modules/events-server-syslog/build.gradle.kts b/modules/events-server-syslog/build.gradle.kts new file mode 100644 index 0000000..3e9dbf2 --- /dev/null +++ b/modules/events-server-syslog/build.gradle.kts @@ -0,0 +1,102 @@ +import kafkatorio.extensions.dropDirectory +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + + +plugins { + id("kafkatorio.conventions.lang.kotlin-jvm") + id("dev.adamko.geedeecee") + kotlin("plugin.serialization") + application +} + + +description = "Provides a Syslog server that receives Kafkatorio packets and forwards them to Kafka" + +val projectId: String by project.extra + + +dependencies { + implementation(platform(projects.modules.versionsPlatform)) + + implementation(libs.kafka.streams) + testImplementation(libs.kafka.streamsTestUtils) + + implementation(projects.modules.eventsLibrary) + implementation(projects.modules.eventsProcessorCore) + + implementation(libs.kotlinxSerialization.core) + implementation(libs.kotlinxSerialization.json) + + implementation(libs.kotlinx.coroutines.core) + + implementation(libs.bundles.logging) + + implementation(libs.scrimage.core) + + implementation(libs.okio.core) + + // + implementation(libs.ktorSerialization.kotlinxJson) + + with(libs.ktorServer) { + implementation(auth) + implementation(authJwt) + implementation(core) + implementation(callId) + implementation(callLogging) + implementation(contentNegotiaion) + implementation(cio) + implementation(autoHeadResponse) + implementation(partialContent) + implementation(resources) + implementation(statusPages) + implementation(websockets) + implementation(compression) + } + + with(libs.ktorNetwork) { + implementation(core) + implementation(tls) + } + // + + implementation(libs.simpleSyslogParser) + +// implementation(libs.nimbusJoseJwt) + + implementation(libs.kafka.kotkaStreams) + + implementation(libs.bundles.hoplite) +} + + +application { + mainClass.set("dev.adamko.kafkatorio.processor.syslog.SyslogMainKt") +} + + +tasks.withType().configureEach { + kotlinOptions.freeCompilerArgs += listOf( + "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + "-opt-in=kotlinx.coroutines.FlowPreview", + "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", + ) +} + + +val runSyslogServer by tasks.registering { + group = rootProject.name + dependsOn(tasks.run) +} + +tasks.dockerContextPrepareFiles { + from(zipTree(tasks.distZip.flatMap { it.archiveFile })) { + eachFile { + relativePath = relativePath.dropDirectory() + + if (!isDirectory && relativePath.pathString.matches("""bin\/.+""".toRegex())) { + name = name.replace(file.nameWithoutExtension, "run") + } + } + } +} diff --git a/modules/events-server-syslog/docker/Dockerfile b/modules/events-server-syslog/docker/Dockerfile new file mode 100644 index 0000000..350fa3a --- /dev/null +++ b/modules/events-server-syslog/docker/Dockerfile @@ -0,0 +1,20 @@ +# syntax=docker/dockerfile:1 + +FROM eclipse-temurin:11-jdk-jammy +ARG KAFKATORIO_VERSION +ARG APP_FILES="build/" + + +ENV SERVER_DATA_DIR="/app/data" \ + KAFKA_STREAMS_STATE_DIR="/app/state/kafka" \ + SOCKET_SERVER_HOST=0.0.0.0 \ + SOCKET_SERVER_PORT=9002 + + +EXPOSE $SOCKET_SERVER_PORT + + +COPY ${APP_FILES} /app/ + + +ENTRYPOINT /app/bin/run diff --git a/modules/events-server-syslog/docker/docker-compose.yml b/modules/events-server-syslog/docker/docker-compose.yml new file mode 100644 index 0000000..1fc4743 --- /dev/null +++ b/modules/events-server-syslog/docker/docker-compose.yml @@ -0,0 +1,38 @@ +version: "3.9" + +services: + + events-server-syslog: + image: ${REGISTRY_HOST}/${APP_GROUP}/${APP_NAME}:${KAFKATORIO_VERSION} + container_name: ${APP_NAME} + restart: unless-stopped + build: + context: . + dockerfile: Dockerfile + args: + KAFKATORIO_VERSION: ${KAFKATORIO_VERSION} + APP_FILES: "./build/" + environment: + KAFKA_BOOTSTRAP_SERVERS: "http://kafka:29092" + # KAFKA_STREAMS_STATE_DIR: "" + SERVER_PORT: "8080" + SOCKET_SERVER_PORT: "9002" + ports: + - "12034:9002" # syslog socket + networks: + - "kafka-nw" + - "kafkatorio-nw" + - "traefik-nw" +# labels: +# - "traefik.enable=true" + +networks: + kafka-nw: + name: "kafka-nw" + external: true + kafkatorio-nw: + name: "kafkatorio-nw" + external: true + traefik-nw: + name: "traefik-nw" + external: true diff --git a/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/KafkatorioPacketKafkaProducer.kt b/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/KafkatorioPacketKafkaProducer.kt new file mode 100644 index 0000000..f75ab4b --- /dev/null +++ b/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/KafkatorioPacketKafkaProducer.kt @@ -0,0 +1,190 @@ +package dev.adamko.kafkatorio.processor.syslog + +import com.github.palindromicity.syslog.dsl.SyslogFieldKeys +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import dev.adamko.kafkatorio.processor.config.TOPIC_SRC_SERVER_LOG +import dev.adamko.kafkatorio.processor.config.TOPIC_SRC_SERVER_LOG_DLQ +import dev.adamko.kafkatorio.processor.core.Authenticator +import dev.adamko.kafkatorio.processor.syslog.config.jsonMapper +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kotka.kxs.kafkaSerializer +import java.util.Properties +import kotlin.coroutines.coroutineContext +import kotlinx.coroutines.flow.collect +import kotlinx.coroutines.flow.filter +import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.job +import org.apache.kafka.clients.producer.KafkaProducer +import org.apache.kafka.clients.producer.ProducerRecord +import org.apache.kafka.common.header.internals.RecordHeader +import org.apache.kafka.common.serialization.Serdes +import org.apache.kafka.streams.StreamsConfig + + +/** + * Consume Syslog messages, verifies each, and forwards them to a Kafka topic. + */ +class KafkatorioPacketKafkaProducer( + private val appProps: ApplicationProperties, + private val syslogServer: SyslogSocketServer, + private val authenticator: Authenticator, +) : AutoCloseable { + + private val props: Properties = appProps.kafkaStreamsConfig.toProperties() + + init { + props.updateValue(StreamsConfig.APPLICATION_ID_CONFIG) { "$it.KafkatorioPacketKafkaProducer" } + } + + private val producer: KafkaProducer = KafkaProducer( + props.apply { + updateValue(StreamsConfig.APPLICATION_ID_CONFIG) { "$it.KafkatorioPacketKafkaProducer" } + }, + jsonMapper.kafkaSerializer(FactorioServerId.serializer()), + Serdes.String().serializer(), + ) + + private val dlqProducer: KafkaProducer = KafkaProducer( + props.apply { + updateValue(StreamsConfig.APPLICATION_ID_CONFIG) { "$it.KafkatorioPacketKafkaProducer.dlq" } + }, + Serdes.String().serializer(), + Serdes.String().serializer(), + ) + + + suspend fun launch() { + coroutineContext.job.invokeOnCompletion { + val cause = if (it != null) "(cause: ${it::class.java.name} ${it.message})" else "" + log("Closing KafkatorioPacketKafkaProducer $cause") + this@KafkatorioPacketKafkaProducer.close() + } + + syslogServer.messages + .filter { + (it.message ?: "").run { + startsWith("KafkatorioPacket:::") + } + }.onEach { syslog -> + val serverId = getFactorioServerId(syslog) + if (serverId != null) { + produceMessage(serverId, syslog) + } + }.collect() + } + + + private fun getFactorioServerId(syslog: SyslogMsg): FactorioServerId? { + val token = syslog.headerAppName + if (token.isNullOrBlank()) { + produceDlqMessage(syslog, "no token in syslog message. msg: ${syslog.src}") + return null + } + + val serverToken = authenticator.verifyJwt(token) + if (serverToken.isNullOrBlank()) { + produceDlqMessage(syslog, "could not decode token $token. msg: ${syslog.src}") + return null + } + + val serverId = appProps.kafkatorioServers[serverToken] + if (serverId.isNullOrBlank()) { + produceDlqMessage(syslog, "no server ID for token $serverToken. msg: ${syslog.src}") + return null + } + + return serverId + } + + + private fun produceMessage( + serverId: FactorioServerId, + syslog: SyslogMsg, + ) { + val syslogMessage = syslog.message?.trim() + + if (syslogMessage.isNullOrBlank()) { + // ignore blank messages + return + } + + if (!syslogMessage.startsWith(KAFKATORIO_MESSAGE_TAG)) { + // ignore non-Kafkatorio message + return + } + + val kafkatorioMessage = syslogMessage.substringAfter(KAFKATORIO_MESSAGE_TAG) + + if (kafkatorioMessage.isBlank()) { + produceDlqMessage(syslog, "error - Kafkatorio message was blank $syslogMessage") + return + } + + val record = ProducerRecord( + TOPIC_SRC_SERVER_LOG, + serverId, + kafkatorioMessage, + ) + + syslog.copyHeadersTo(record) + + producer.send(record) + } + + + private fun produceDlqMessage(syslog: SyslogMsg, errorMessage: String) { + log("error: $errorMessage, $syslog") + + val record = ProducerRecord( + TOPIC_SRC_SERVER_LOG_DLQ, + "unknown", + errorMessage, + ) + + syslog.copyHeadersTo(record) + + dlqProducer.send(record) + } + + + override fun close() { + producer.close() + } + + + companion object { + private const val KAFKATORIO_MESSAGE_TAG = "KafkatorioPacket:::" + + + private fun log(msg: String) = println("[KafkatorioPacketKafkaProducer] $msg") + + + private fun Properties.updateValue( + key: String, + update: (oldValue: String) -> String + ) { + val newValue = update(getValue(key) as String) + setProperty(key, newValue) + } + + + private fun SyslogMsg.copyHeadersTo(record: ProducerRecord<*, *>) { + val headers = SyslogFieldKeys.values() + .filter { "HEADER_" in it.name } + .mapNotNull { headerKey -> + val headerValue = src[headerKey.field] + when { + headerValue.isNullOrBlank() -> null + else -> RecordHeader( + headerKey.field, + headerValue.toByteArray() + ) + } + } + + headers.forEach { header -> + record.headers().add(header) + } + } + } +} diff --git a/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/SyslogMsg.kt b/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/SyslogMsg.kt new file mode 100644 index 0000000..42bb7ea --- /dev/null +++ b/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/SyslogMsg.kt @@ -0,0 +1,51 @@ +package dev.adamko.kafkatorio.processor.syslog + +import com.github.palindromicity.syslog.dsl.SyslogFieldKeys + +data class SyslogMsg( + val src: Map, +) { + + val message: String? + get() = src[SyslogFieldKeys.MESSAGE.field] + + val headerAppName: String? + get() = src[SyslogFieldKeys.HEADER_APPNAME.field] + + val headerHostName: String? + get() = src[SyslogFieldKeys.HEADER_HOSTNAME.field] + + val headerPri: String? + get() = src[SyslogFieldKeys.HEADER_PRI.field] + + val headerPriSeverity: String? + get() = src[SyslogFieldKeys.HEADER_PRI_SEVERITY.field] + + val headerPriFacility: String? + get() = src[SyslogFieldKeys.HEADER_PRI_FACILITY.field] + + val headerProcId: String? + get() = src[SyslogFieldKeys.HEADER_PROCID.field] + + val headerTimestamp: String? + get() = src[SyslogFieldKeys.HEADER_TIMESTAMP.field] + + val headerMsgId: String? + get() = src[SyslogFieldKeys.HEADER_MSGID.field] + + val headerVersion: String? + get() = src[SyslogFieldKeys.HEADER_VERSION.field] + + val structuredBase: String? + get() = src[SyslogFieldKeys.STRUCTURED_BASE.field] + + val structuredElementIdFmt: String? + get() = src[SyslogFieldKeys.STRUCTURED_ELEMENT_ID_FMT.field] + + val structuredElementIdPnameFmt: String? + get() = src[SyslogFieldKeys.STRUCTURED_ELEMENT_ID_PNAME_FMT.field] + + val structuredElementIdPnamePattern: String? + get() = src[SyslogFieldKeys.STRUCTURED_ELEMENT_ID_PNAME_PATTERN.field] + +} diff --git a/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/SyslogSocketServer.kt b/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/SyslogSocketServer.kt new file mode 100644 index 0000000..38253a4 --- /dev/null +++ b/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/SyslogSocketServer.kt @@ -0,0 +1,112 @@ +package dev.adamko.kafkatorio.processor.syslog + +import com.github.palindromicity.syslog.AllowableDeviations +import com.github.palindromicity.syslog.DefaultKeyProvider +import com.github.palindromicity.syslog.Flat5424MessageHandler +import com.github.palindromicity.syslog.NilPolicy +import com.github.palindromicity.syslog.SyslogParser +import com.github.palindromicity.syslog.SyslogParserBuilder +import com.github.palindromicity.syslog.SyslogSpecification +import com.github.palindromicity.syslog.dsl.ParseException +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import io.ktor.network.selector.SelectorManager +import io.ktor.network.sockets.Socket +import io.ktor.network.sockets.aSocket +import io.ktor.network.sockets.openReadChannel +import io.ktor.utils.io.readUTF8Line +import java.util.EnumSet +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.coroutines.supervisorScope +import kotlinx.coroutines.withContext +import kotlinx.coroutines.yield + + +class SyslogSocketServer( + appProps: ApplicationProperties, +) { + + /** Incoming messages */ + private val serverSocketTcp = aSocket(SelectorManager(Dispatchers.IO)) + .tcp() + .bind( + appProps.socketServerHost, + appProps.socketServerPort, + ) + + + private val syslogParser: SyslogParser> = + SyslogParserBuilder>() + .forSpecification(SyslogSpecification.RFC_5424) + .withSyslogBuilder( + Flat5424MessageHandler( + DefaultKeyProvider(), + NilPolicy.OMIT, + EnumSet.of(AllowableDeviations.PRIORITY, AllowableDeviations.VERSION), + ) + ).build() + + + private val _messages: MutableSharedFlow = MutableSharedFlow() + val messages: SharedFlow + get() = _messages.asSharedFlow() + + + suspend fun start(): Unit = withContext(Dispatchers.IO) { + log("started listening: ${serverSocketTcp.localAddress}") + + while (isActive) { + val socket: Socket = serverSocketTcp.accept() + launch { + log("new socket ${socket.description()}") + handleConnection(socket) + } + yield() + } + } + + + private suspend fun handleConnection( + socket: Socket + ): Unit = supervisorScope { + try { + val channel = socket.openReadChannel() + while (socket.socketContext.isActive && !channel.isClosedForRead) { + + val line = channel.readUTF8Line() + + requireNotNull(line) { "received 'null' line from ${socket.description()}" } + + try { + val messageContents = syslogParser.parseLine(line) + val syslog = SyslogMsg(messageContents) + _messages.emit(syslog) + } catch (ex: ParseException) { + log("ignoring non-syslog message: $line") + } + + yield() + } + } catch (ex: Throwable) { + withContext(Dispatchers.IO) { socket.close() } + if (ex is CancellationException) { + throw ex + } else { + log("closing socket ${socket.description()}, cause: ${ex::class.qualifiedName} ${ex.message}") + ex.printStackTrace() + } + } + } + + + companion object { + private fun log(msg: String) = println("[SyslogSocketServer] $msg") + + private fun Socket.description(): String = "Socket[local:$localAddress, remote:$remoteAddress]" + } +} diff --git a/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/config/kxsJson.kt b/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/config/kxsJson.kt new file mode 100644 index 0000000..f638397 --- /dev/null +++ b/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/config/kxsJson.kt @@ -0,0 +1,11 @@ +package dev.adamko.kafkatorio.processor.syslog.config + +import dev.adamko.kafkatorio.library.jsonMapperKafkatorio +import kotlinx.serialization.json.Json + + +internal val jsonMapper: Json = Json { + prettyPrint = true + prettyPrintIndent = " " + serializersModule = jsonMapperKafkatorio.serializersModule +} diff --git a/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/syslogMain.kt b/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/syslogMain.kt new file mode 100644 index 0000000..6667561 --- /dev/null +++ b/modules/events-server-syslog/src/main/kotlin/dev/adamko/kafkatorio/processor/syslog/syslogMain.kt @@ -0,0 +1,20 @@ +package dev.adamko.kafkatorio.processor.syslog + +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import dev.adamko.kafkatorio.processor.core.Authenticator +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch + + +/** Receive log messages from the syslog socket, and send them to a Kafka topic */ +suspend fun main(): Unit = coroutineScope { + + val appProps = ApplicationProperties.load() + val syslogServer = SyslogSocketServer(appProps) + val authenticator = Authenticator(appProps) + + val producer = KafkatorioPacketKafkaProducer(appProps, syslogServer, authenticator) + + launch { syslogServer.start() } + launch { producer.launch() } +} diff --git a/modules/events-server-web/build.gradle.kts b/modules/events-server-web/build.gradle.kts new file mode 100644 index 0000000..7b1b8c2 --- /dev/null +++ b/modules/events-server-web/build.gradle.kts @@ -0,0 +1,105 @@ +import kafkatorio.extensions.dropDirectory +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + + +plugins { + id("kafkatorio.conventions.lang.kotlin-jvm") + id("dev.adamko.geedeecee") + kotlin("plugin.serialization") + application +} + + +description = "serves Kafkatorio content over web APIs" + +val projectId: String by project.extra + +val kafkaStateDir: Directory = layout.projectDirectory.dir(".state/kafka") + + +dependencies { + implementation(platform(projects.modules.versionsPlatform)) + + implementation(libs.kafka.streams) + testImplementation(libs.kafka.streamsTestUtils) + + implementation(projects.modules.eventsLibrary) + implementation(projects.modules.eventsProcessorCore) + + implementation(libs.kotlinxSerialization.core) + implementation(libs.kotlinxSerialization.json) + + implementation(libs.kotlinx.coroutines.core) + + implementation(libs.bundles.logging) + + implementation(libs.scrimage.core) + + implementation(libs.okio.core) + + // + implementation(libs.ktorSerialization.kotlinxJson) + + with(libs.ktorServer) { + implementation(auth) + implementation(authJwt) + implementation(core) + implementation(callId) + implementation(callLogging) + implementation(contentNegotiaion) + implementation(cio) + implementation(autoHeadResponse) + implementation(partialContent) + implementation(resources) + implementation(statusPages) + implementation(websockets) + implementation(compression) + } + + with(libs.ktorNetwork) { + implementation(core) + implementation(tls) + } + // + + implementation(libs.simpleSyslogParser) + +// implementation(libs.nimbusJoseJwt) + + implementation(libs.kafka.kotkaStreams) + + implementation(libs.bundles.hoplite) +} + + +application { + mainClass.set("dev.adamko.kafkatorio.server.web.MainKt") +} + + +tasks.withType().configureEach { + kotlinOptions.freeCompilerArgs += listOf( + "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + "-opt-in=kotlinx.coroutines.FlowPreview", + "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", + ) +} + + +val runEventsWebServer by tasks.registering { + group = rootProject.name + + dependsOn(tasks.run) +} + +tasks.dockerContextPrepareFiles { + from(zipTree(tasks.distZip.flatMap { it.archiveFile })) { + eachFile { + relativePath = relativePath.dropDirectory() + + if (!isDirectory && relativePath.pathString.matches("""bin\/.+""".toRegex())) { + name = name.replace(file.nameWithoutExtension, "run") + } + } + } +} diff --git a/modules/events-server-web/docker/Dockerfile b/modules/events-server-web/docker/Dockerfile new file mode 100644 index 0000000..5a0c7f7 --- /dev/null +++ b/modules/events-server-web/docker/Dockerfile @@ -0,0 +1,19 @@ +# syntax=docker/dockerfile:1 + +FROM eclipse-temurin:11-jdk-jammy +ARG KAFKATORIO_VERSION +ARG APP_FILES="build/" + + +ENV SERVER_DATA_DIR="/app/data" \ + KAFKA_STREAMS_STATE_DIR="/app/state/kafka" \ + WEB_SERVER_PORT=80 + + +EXPOSE $WEB_SERVER_PORT + + +COPY ${APP_FILES} /app/ + + +ENTRYPOINT /app/bin/run diff --git a/modules/events-server-web/docker/docker-compose.yml b/modules/events-server-web/docker/docker-compose.yml new file mode 100644 index 0000000..59abd6c --- /dev/null +++ b/modules/events-server-web/docker/docker-compose.yml @@ -0,0 +1,37 @@ +version: "3.9" + +services: + + events-server-web: + image: ${REGISTRY_HOST}/${APP_GROUP}/${APP_NAME}:${KAFKATORIO_VERSION} + container_name: ${APP_NAME} + restart: unless-stopped + build: + context: . + dockerfile: Dockerfile + args: + KAFKATORIO_VERSION: ${KAFKATORIO_VERSION} + APP_FILES: "./build/" + environment: + KAFKA_BOOTSTRAP_SERVERS: "http://kafka:29092" + # KAFKA_STREAMS_STATE_DIR: "" + WEB_SERVER_PORT: "80" + ports: + - "12080:80" # http and ws + networks: + - "kafka-nw" + - "kafkatorio-nw" + - "traefik-nw" + labels: + - "traefik.enable=true" + +networks: + kafka-nw: + name: "kafka-nw" + external: true + kafkatorio-nw: + name: "kafkatorio-nw" + external: true + traefik-nw: + name: "traefik-nw" + external: true diff --git a/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/config/kxsJson.kt b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/config/kxsJson.kt new file mode 100644 index 0000000..da63668 --- /dev/null +++ b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/config/kxsJson.kt @@ -0,0 +1,11 @@ +package dev.adamko.kafkatorio.server.web.config + +import dev.adamko.kafkatorio.library.jsonMapperKafkatorio +import kotlinx.serialization.json.Json + + +internal val jsonMapper: Json = Json { + prettyPrint = true + prettyPrintIndent = " " + serializersModule = jsonMapperKafkatorio.serializersModule +} diff --git a/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/main.kt b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/main.kt new file mode 100644 index 0000000..572a854 --- /dev/null +++ b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/main.kt @@ -0,0 +1,69 @@ +package dev.adamko.kafkatorio.server.web + +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import dev.adamko.kafkatorio.processor.core.launchTopology +import dev.adamko.kafkatorio.server.processor.topology.broadcastToWebsocket +import dev.adamko.kafkatorio.server.processor.topology.saveMapTiles +import dev.adamko.kafkatorio.server.web.websocket.WebmapWebsocketServer +import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.seconds +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch +import org.apache.kafka.clients.producer.ProducerConfig +import org.apache.kafka.streams.StreamsBuilder +import org.apache.kafka.streams.StreamsConfig + +internal val appProps = ApplicationProperties.load() + +suspend fun main(): Unit = coroutineScope { + val wsServer = WebmapWebsocketServer() + + launch { + websocketBroadcaster(wsServer) + } + +// launch { +// broadcastToWebsocket(wsServer, StreamsBuilder()) +// } + + launch { + saveTiles(appProps) + } + + launch { + startWebServer( + appProps = appProps, + wsServer = wsServer, + ) + } +} + +private suspend fun websocketBroadcaster(wsServer: WebmapWebsocketServer) { + val builder = StreamsBuilder() + + broadcastToWebsocket(wsServer, builder) + + val topology = builder.build() + + launchTopology( + id = "websocketBroadcaster", + topology = topology, + additionalProperties = mapOf( + StreamsConfig.COMMIT_INTERVAL_MS_CONFIG to "${1.seconds.inWholeMilliseconds}", + StreamsConfig.producerPrefix(ProducerConfig.LINGER_MS_CONFIG) to "${1.milliseconds.inWholeMilliseconds}", + ), + appProps = appProps, + ) +} + +private suspend fun saveTiles( + appProps: ApplicationProperties +) { + val builder = StreamsBuilder() + saveMapTiles(builder, appProps.serverDataDir) + launchTopology( + id = "saveTiles", + topology = builder.build(), + appProps = appProps + ) +} diff --git a/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/rest/factorioServersRoutes.kt b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/rest/factorioServersRoutes.kt new file mode 100644 index 0000000..082fcde --- /dev/null +++ b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/rest/factorioServersRoutes.kt @@ -0,0 +1,129 @@ +package dev.adamko.kafkatorio.server.web.rest + +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.PlayerIndex +import dev.adamko.kafkatorio.schema.common.ServerMapTileLayer +import dev.adamko.kafkatorio.schema.common.ServerMapTilePngFilename +import dev.adamko.kafkatorio.schema.common.SurfaceIndex +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import dev.adamko.kafkatorio.server.web.config.jsonMapper +import io.ktor.http.HttpStatusCode +import io.ktor.http.content.EntityTagVersion +import io.ktor.http.content.versions +import io.ktor.resources.Resource +import io.ktor.server.application.ApplicationCall +import io.ktor.server.application.call +import io.ktor.server.http.content.LastModifiedVersion +import io.ktor.server.resources.get +import io.ktor.server.response.respond +import io.ktor.server.response.respondFile +import io.ktor.server.routing.Routing +import io.ktor.util.combineSafe +import io.ktor.util.pipeline.PipelineContext +import kotlin.io.path.Path +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.encodeToJsonElement + + +internal fun Routing.factorioServersRoutes( + appProps: ApplicationProperties, +) { + + get { + val serverIds = appProps.kafkatorioServers.values.toSet().sortedBy { it.id } + val serverIdsJson = jsonMapper.encodeToJsonElement(serverIds) + call.respond(serverIdsJson) + } + + get { tile -> + handleTileRequest(tile, appProps) + } +} + + +private suspend fun PipelineContext.handleTileRequest( + tile: FactorioServer.MapData.Tile, + appProps: ApplicationProperties, +) { + + val tileFilename = ServerMapTilePngFilename( + tile.serverId, + tile.layer, + tile.surfaceIndex, + tile.zoomLevel, + tile.chunkX, + tile.chunkY, + ) + + val tileFile = appProps.serverDataDir.combineSafe(Path(tileFilename.value)) + + if (tileFile.exists()) { + call.respondFile(tileFile) { + versions = versions + listOf( + EntityTagVersion(tileFile.lastModified().hashCode().toString()), + LastModifiedVersion(tileFile.lastModified()), + ) + } + } else { + // It's not a client or server error to request a non-existent tile, it just doesn't exist + // (yet). So return 304. + call.respond(HttpStatusCode.NotModified) + } +} + + +@Serializable +@Resource("kafkatorio/data/servers") +private class FactorioServers + + +@Serializable +@Resource("kafkatorio/data/servers/{factorioServerId}") +data class FactorioServer( + val factorioServerId: FactorioServerId, +) { + + @Serializable + @Resource("map") + data class MapData( + val server: FactorioServer, + ) { + + @Serializable + @Resource("layers/{layer}/s{surfaceIndex}/z{zoomLevel}/x{chunkX}/y{chunkY}.png") + data class Tile( + val mapData: MapData, + + val layer: ServerMapTileLayer, + val surfaceIndex: SurfaceIndex, + val zoomLevel: Int, + val chunkX: Int, + val chunkY: Int, + ) + + @Serializable + @Resource("buildings/s{surfaceIndex}") + data class Buildings( + val mapData: MapData, + val surfaceIndex: SurfaceIndex, + // a list of buildings... (Sealed interface, different types?) + ) + } + + @Serializable + @Resource("players") + data class Players( + val server: FactorioServer, + ) + + @Serializable + @Resource("{playerId}") + data class Player( + val server: FactorioServer, + val playerIndex: PlayerIndex, + ) +} + + +private val FactorioServer.MapData.Tile.serverId: FactorioServerId + get() = mapData.server.factorioServerId diff --git a/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/rest/restApi.kt b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/rest/restApi.kt new file mode 100644 index 0000000..22f8e3e --- /dev/null +++ b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/rest/restApi.kt @@ -0,0 +1,56 @@ +package dev.adamko.kafkatorio.server.web.rest + +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import io.ktor.http.ContentType +import io.ktor.http.HttpStatusCode +import io.ktor.http.isSuccess +import io.ktor.serialization.kotlinx.json.json +import io.ktor.server.application.Application +import io.ktor.server.application.install +import io.ktor.server.application.log +import io.ktor.server.plugins.autohead.AutoHeadResponse +import io.ktor.server.plugins.callloging.CallLogging +import io.ktor.server.plugins.compression.Compression +import io.ktor.server.plugins.compression.excludeContentType +import io.ktor.server.plugins.compression.minimumSize +import io.ktor.server.plugins.conditionalheaders.ConditionalHeaders +import io.ktor.server.plugins.contentnegotiation.ContentNegotiation +import io.ktor.server.plugins.partialcontent.PartialContent +import io.ktor.server.plugins.statuspages.StatusPages +import io.ktor.server.resources.Resources +import io.ktor.server.response.respondText +import io.ktor.server.routing.routing + + +internal fun Application.webmapTileServer(appProps: ApplicationProperties) { + + install(AutoHeadResponse) + install(CallLogging) { + filter { call -> + // only log failures + !(call.response.status()?.isSuccess() ?: false) + } + } + install(Compression) { + default() + minimumSize(1024) + excludeContentType(ContentType.Video.Any) + } + install(ConditionalHeaders) + install(ContentNegotiation) { + json() + } + install(PartialContent) + install(Resources) + + install(StatusPages) { + exception { call, cause -> + this@webmapTileServer.log.error("$call caused exception - returning 500", cause) + call.respondText(text = "500: $cause", status = HttpStatusCode.InternalServerError) + } + } + + routing { + factorioServersRoutes(appProps) + } +} diff --git a/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/webServer.kt b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/webServer.kt new file mode 100644 index 0000000..6792e02 --- /dev/null +++ b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/webServer.kt @@ -0,0 +1,28 @@ +package dev.adamko.kafkatorio.server.web + + +import dev.adamko.kafkatorio.processor.config.ApplicationProperties +import dev.adamko.kafkatorio.server.web.rest.webmapTileServer +import dev.adamko.kafkatorio.server.web.websocket.WebmapWebsocketServer +import dev.adamko.kafkatorio.server.web.websocket.webmapWebsocketServer +import io.ktor.server.cio.CIO +import io.ktor.server.engine.embeddedServer +import kotlinx.coroutines.coroutineScope + + +internal suspend fun startWebServer( + appProps: ApplicationProperties, + wsServer: WebmapWebsocketServer, +): Unit = coroutineScope { + + embeddedServer( + factory = CIO, + port = appProps.webPort.value, + ) { + + webmapWebsocketServer(wsServer) + + webmapTileServer(appProps) + + }.start(wait = true) +} diff --git a/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/websocket/WebmapWebsocketServer.kt b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/websocket/WebmapWebsocketServer.kt new file mode 100644 index 0000000..c704411 --- /dev/null +++ b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/websocket/WebmapWebsocketServer.kt @@ -0,0 +1,130 @@ +package dev.adamko.kafkatorio.server.web.websocket + +import dev.adamko.kafkatorio.server.processor.topology.WebsocketBroadcaster +import io.ktor.websocket.CloseReason +import io.ktor.websocket.DefaultWebSocketSession +import io.ktor.websocket.Frame +import io.ktor.websocket.send +import java.util.concurrent.atomic.AtomicInteger +import kotlin.time.Duration.Companion.seconds +import kotlin.time.TimeSource +import kotlinx.coroutines.CancellationException +import kotlinx.coroutines.cancel +import kotlinx.coroutines.channels.BufferOverflow +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.flow.receiveAsFlow +import kotlinx.coroutines.flow.update +import kotlinx.coroutines.isActive +import kotlinx.coroutines.job +import kotlinx.coroutines.launch +import kotlinx.coroutines.yield + + +class WebmapWebsocketServer : WebsocketBroadcaster { + + private val startTime = TimeSource.Monotonic.markNow() + + private val clients: MutableStateFlow> = MutableStateFlow(emptyList()) + + private val messagesToClients: MutableSharedFlow = MutableSharedFlow( + extraBufferCapacity = Int.MAX_VALUE, + onBufferOverflow = BufferOverflow.DROP_OLDEST + ) + + private val messagesFromClients: MutableSharedFlow = MutableSharedFlow( + extraBufferCapacity = Int.MAX_VALUE, + onBufferOverflow = BufferOverflow.DROP_OLDEST + ) + + + suspend fun bindClient(session: DefaultWebSocketSession): Unit = coroutineScope { + val client = WSConnection(session) + + clients.update { clients -> clients + client } + + client.coroutineContext.job.invokeOnCompletion { e -> + log("client ${client.name} completed ${e ?: "successfully"}") + clients.update { clients -> + (clients - client).filter { it.isActive } + } + } + + messagesToClients.onEach { msg -> + runCatching { + if (client.isActive) { + client.outgoing.send(Frame.Text(msg)) + } + }.onFailure { e -> + if (e is CancellationException) throw e + } + }.launchIn(client) + + client.launch { + client.incoming.receiveAsFlow().collect(messagesFromClients) + } + + client.launch { + while (isActive) { + runCatching { + client.send("elapsed ${startTime.elapsedNow()}") + }.onFailure { e -> + if (e is CancellationException) throw e + } + delay(10.seconds) + yield() + } + } + + log("client ${client.name} is up and running...") + val closedReason: CloseReason? = client.closeReason.await() + + log("client ${client.name} closed ${closedReason ?: "successfully"}") + + coroutineContext.cancel() + } + + + override suspend fun sendMessageToClients(message: String) { + log("sending message to clients: $message") + messagesToClients.emit(message) + } + + + private data class WSConnection( + private val session: DefaultWebSocketSession, + ) : DefaultWebSocketSession by session { + val name: String = "user${lastId.getAndIncrement()}" + + override suspend fun send(frame: Frame): Unit = runCatching { + super.send(frame) + }.fold( + onSuccess = { +// log("sent message to client $name: $frame") + }, + onFailure = { e -> + if (e is CancellationException) throw e + + log("failed to send message to client $name: $e") + } + ) + + override fun equals(other: Any?): Boolean = name == other + override fun hashCode(): Int = name.hashCode() + + companion object { + private val lastId = AtomicInteger(0) + } + } + + + companion object { + + private fun log(msg: String) = println("[WebmapWebsocketServer] $msg") + + } +} diff --git a/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/websocket/wsServer.kt b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/websocket/wsServer.kt new file mode 100644 index 0000000..ea2b51e --- /dev/null +++ b/modules/events-server-web/src/main/kotlin/dev/adamko/kafkatorio/server/web/websocket/wsServer.kt @@ -0,0 +1,34 @@ +package dev.adamko.kafkatorio.server.web.websocket + +import io.ktor.server.application.Application +import io.ktor.server.application.install +import io.ktor.server.routing.routing +import io.ktor.server.websocket.WebSockets +import io.ktor.server.websocket.webSocket +import io.ktor.websocket.WebSocketDeflateExtension +import java.util.zip.Deflater + + +fun Application.webmapWebsocketServer( + wsServer: WebmapWebsocketServer, +) { + install(WebSockets) { + extensions { + install(WebSocketDeflateExtension) { + // Compression level to use for java.util.zip.Deflater + compressionLevel = Deflater.DEFAULT_COMPRESSION + + // Prevent compressing small outgoing frames + compressIfBiggerThan(bytes = 4 * 1024) + } + } + } + + routing { + // TODO only send a ws client message for a single Factorio-sever. Make the URL server specific. + // /kafkatorio/data/servers/{serverId}/ws + webSocket("kafkatorio/ws") { + wsServer.bindClient(this) + } + } +} diff --git a/modules/events-server/.gitignore b/modules/events-server/.gitignore new file mode 100644 index 0000000..09eceef --- /dev/null +++ b/modules/events-server/.gitignore @@ -0,0 +1,2 @@ +kafka-state/ +server-data/ diff --git a/modules/events-server/build.gradle.kts b/modules/events-server/build.gradle.kts new file mode 100644 index 0000000..32abda4 --- /dev/null +++ b/modules/events-server/build.gradle.kts @@ -0,0 +1,123 @@ +import kafkatorio.tasks.DockerEnvUpdateTask +import kafkatorio.tasks.KafkaConsumerGroupsTask +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + + +plugins { + dev.adamko.kafkatorio.lang.`kotlin-jvm` + kotlin("plugin.serialization") + application +} + + +description = "deprecated - this was split up into separate modules" + +val projectId: String by project.extra + +val kafkaStateDir: Directory = layout.projectDirectory.dir(".state/kafka") + + +dependencies { + implementation(platform(projects.modules.versionsPlatform)) + + implementation(libs.kafka.streams) + testImplementation(libs.kafka.streamsTestUtils) + + implementation(projects.modules.eventsLibrary) + + implementation(libs.kotlinxSerialization.core) + implementation(libs.kotlinxSerialization.json) + + implementation(libs.kotlinx.coroutines.core) + + implementation(libs.bundles.logging) + + implementation(libs.scrimage.core) + + implementation(libs.okio.core) + + // + implementation(libs.ktorSerialization.kotlinxJson) + + with(libs.ktorServer) { + implementation(auth) + implementation(authJwt) + implementation(core) + implementation(callId) + implementation(callLogging) + implementation(contentNegotiaion) + implementation(cio) + implementation(autoHeadResponse) + implementation(partialContent) + implementation(resources) + implementation(statusPages) + implementation(websockets) + implementation(compression) + } + + with(libs.ktorNetwork) { + implementation(core) + implementation(tls) + } + // + + implementation(libs.simpleSyslogParser) + +// // https://search.maven.org/artifact/org.bouncycastle/bcprov-jdk15on +// implementation("org.bouncycastle:bcprov-jdk15on:1.70") +// implementation("com.brendangoldberg:kotlin-jwt:1.1.0") +// implementation("com.auth0:java-jwt:4.0.0") + +// implementation(libs.nimbusJoseJwt) + + implementation(libs.kafka.kotkaStreams) + + implementation(libs.bundles.hoplite) +} + + +application { + mainClass.set("dev.adamko.kafkatorio.server.EventsServerKt") +} + + +tasks.withType().configureEach { + kotlinOptions.freeCompilerArgs += listOf( + "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + "-opt-in=kotlinx.coroutines.FlowPreview", + "-opt-in=kotlinx.serialization.ExperimentalSerializationApi", + ) +} + + +val kafkaStateDirDelete by tasks.registering(Delete::class) { + group = project.name + mustRunAfter(kafkaConsumersDelete) + delete(kafkaStateDir) +} + + +val kafkaConsumersDelete by tasks.registering(KafkaConsumerGroupsTask.DeleteAll::class) { + group = project.name +} + + +idea { + module { + excludeDirs = excludeDirs + listOf( + kafkaStateDir.asFile, + file("server-data"), + ) + } +} + + +val dockerEnvUpdate by tasks.registering(DockerEnvUpdateTask::class) { + dotEnvFile.set(layout.projectDirectory.file("docker/.env")) + + properties( + "COMPOSE_PROJECT_NAME" to rootProject.name, + "KAFKATORIO_VERSION" to project.version, + ) +} +tasks.assemble { dependsOn(dockerEnvUpdate) } diff --git a/modules/events-server/docker/.dockerignore b/modules/events-server/docker/.dockerignore new file mode 100644 index 0000000..f9f2ef3 --- /dev/null +++ b/modules/events-server/docker/.dockerignore @@ -0,0 +1,21 @@ +# +## exclude hidden dirs .git etc. +#.* +# +## ignore any files that start with '.secret' +##.secret.* +# +#### Gradle ### +#build/ +#!build/distributions +# +#src +# +#kafkatorio-tiles/ +#kafka-state/ +##.gradle +# +## IntelliJ +##.idea/ +##out/ +##*.iml diff --git a/modules/events-server/docker/.env b/modules/events-server/docker/.env new file mode 100644 index 0000000..1eb5f42 --- /dev/null +++ b/modules/events-server/docker/.env @@ -0,0 +1,3 @@ +# Do not edit manually. This file was created with task 'dockerEnvUpdate' +COMPOSE_PROJECT_NAME=kafkatorio +KAFKATORIO_VERSION=0.9.0 diff --git a/modules/events-server/docker/Dockerfile b/modules/events-server/docker/Dockerfile new file mode 100644 index 0000000..ccfdae5 --- /dev/null +++ b/modules/events-server/docker/Dockerfile @@ -0,0 +1,20 @@ +# syntax=docker/dockerfile:1 + +FROM eclipse-temurin:11-jdk-jammy +ARG KAFKATORIO_VERSION + + +ENV SERVER_DATA_DIR="/app/data" \ + KAFKA_STREAMS_STATE_DIR="/app/state/kafka" \ + SERVER_PORT=8080 \ + SOCKET_SERVER_PORT=9002 + + +EXPOSE $SERVER_PORT \ + $SOCKET_SERVER_PORT + + +COPY ${APP_FILES} /app/ + + +ENTRYPOINT /app/bin/run diff --git a/modules/events-server/docker/docker-compose.yml b/modules/events-server/docker/docker-compose.yml new file mode 100644 index 0000000..b4400f0 --- /dev/null +++ b/modules/events-server/docker/docker-compose.yml @@ -0,0 +1,39 @@ +version: "3.9" + +services: + + events-server: + image: ${REGISTRY_HOST}/${APP_GROUP}/${APP_NAME}:${KAFKATORIO_VERSION} + container_name: ${APP_NAME} + restart: unless-stopped + build: + context: . + dockerfile: Dockerfile + args: + KAFKATORIO_VERSION: ${KAFKATORIO_VERSION} + APP_FILES: "./build/" + environment: + KAFKA_BOOTSTRAP_SERVERS: "http://kafka:29092" + # KAFKA_STREAMS_STATE_DIR: "" + SERVER_PORT: "8080" + SOCKET_SERVER_PORT: "9002" + ports: + - "12080:8080" # http and ws + - "12034:9002" # syslog socket + networks: + - "kafka-nw" + - "kafkatorio-nw" + - "traefik-nw" +# labels: +# - "traefik.enable=true" + +networks: + kafka-nw: + name: "kafka-nw" + external: true + kafkatorio-nw: + name: "kafkatorio-nw" + external: true + traefik-nw: + name: "traefik-nw" + external: true diff --git a/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/eventsServer.kt b/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/eventsServer.kt new file mode 100644 index 0000000..bc3c1d6 --- /dev/null +++ b/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/eventsServer.kt @@ -0,0 +1,32 @@ +package dev.adamko.kafkatorio.server + +//import dev.adamko.kafkatorio.server.config.ApplicationProperties +//import dev.adamko.kafkatorio.server.processor.eventsProcessor +//import dev.adamko.kafkatorio.server.security.Authenticator +//import dev.adamko.kafkatorio.server.socket.SyslogSocketServer +//import dev.adamko.kafkatorio.server.web.startWebServer +//import dev.adamko.kafkatorio.server.web.websocket.WebmapWebsocketServer +//import kotlinx.coroutines.coroutineScope +//import kotlinx.coroutines.launch + + +//suspend fun main(): Unit = coroutineScope { +// +// val appProps = ApplicationProperties.load() +// +// val websocketServer = WebmapWebsocketServer() +// val syslogSocketServer = SyslogSocketServer(appProps) +// val authenticator = Authenticator(appProps) +// +// launch { +// startWebServer(appProps, websocketServer) +// } +// +// launch { +// syslogSocketServer.start() +// } +// +// launch { +// eventsProcessor(appProps, syslogSocketServer, websocketServer, authenticator) +// } +//} diff --git a/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/processor/KafkatorioTopology.kt b/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/processor/KafkatorioTopology.kt new file mode 100644 index 0000000..abdc507 --- /dev/null +++ b/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/processor/KafkatorioTopology.kt @@ -0,0 +1,243 @@ +package dev.adamko.kafkatorio.server.processor + +//import dev.adamko.kafkatorio.schema.common.FactorioServerId +//import dev.adamko.kafkatorio.schema.common.PrototypeHashCode +//import dev.adamko.kafkatorio.schema.common.ServerMapChunkId +//import dev.adamko.kafkatorio.schema.common.ServerMapTileLayer +//import dev.adamko.kafkatorio.schema.packets.MapChunkEntityUpdate +//import dev.adamko.kafkatorio.schema.packets.MapChunkResourceUpdate +//import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate +//import dev.adamko.kafkatorio.server.config.ApplicationProperties +//import dev.adamko.kafkatorio.server.processor.topology.ServerMapChunkTiles +//import dev.adamko.kafkatorio.server.processor.topology.broadcastToWebsocket +//import dev.adamko.kafkatorio.server.processor.topology.colourEntityChunks +//import dev.adamko.kafkatorio.server.processor.topology.colourMapChunks +//import dev.adamko.kafkatorio.server.processor.topology.convertEntityUpdateToServerMapChunkTiles +//import dev.adamko.kafkatorio.server.processor.topology.convertResourceUpdateToServerMapChunkTiles +//import dev.adamko.kafkatorio.server.processor.topology.factorioServerPacketStream +//import dev.adamko.kafkatorio.server.processor.topology.saveMapTiles +//import dev.adamko.kafkatorio.server.processor.topology.splitFactorioServerPacketStream +//import dev.adamko.kafkatorio.server.processor.topology.streamPacketData +//import dev.adamko.kafkatorio.server.socket.SyslogSocketServer +//import dev.adamko.kafkatorio.server.web.websocket.WebmapWebsocketServer +//import java.util.Properties +//import kotlin.coroutines.resume +//import kotlin.coroutines.resumeWithException +//import kotlin.io.path.Path +//import kotlin.time.Duration.Companion.milliseconds +//import kotlin.time.Duration.Companion.seconds +//import kotlinx.coroutines.CoroutineName +//import kotlinx.coroutines.CoroutineScope +//import kotlinx.coroutines.cancel +//import kotlinx.coroutines.currentCoroutineContext +//import kotlinx.coroutines.job +//import kotlinx.coroutines.launch +//import kotlinx.coroutines.suspendCancellableCoroutine +//import org.apache.kafka.clients.producer.ProducerConfig +//import org.apache.kafka.streams.KafkaStreams +//import org.apache.kafka.streams.StreamsBuilder +//import org.apache.kafka.streams.StreamsConfig +//import org.apache.kafka.streams.Topology +//import org.apache.kafka.streams.TopologyDescription +//import org.apache.kafka.streams.kstream.KStream + + +internal class KafkatorioTopology( +// private val appProps: ApplicationProperties, +// private val wsServer: WebmapWebsocketServer, +// private val syslogServer: SyslogSocketServer, +// private val kafkatorioPacketKafkaProducer: KafkatorioPacketKafkaProducer, +) { + +// private val builderScope = CoroutineScope(CoroutineName("KafkaTopology")) + + +// suspend fun start() = builderScope.launch { +// splitPackets() +// +// groupTilesMapChunks() +// +//// groupEntitiesMapChunks( +//// layer = ServerMapTileLayer.BUILDING, +//// colouredUpdatesStreamTopic = TOPIC_MAP_CHUNK_BUILDING_COLOURED_032_UPDATES, +//// colouredChunkStateTopic = TOPIC_MAP_CHUNK_BUILDING_COLOURED_STATE, +//// ) +// +//// groupEntitiesMapChunks( +//// layer = ServerMapTileLayer.RESOURCE, +//// colouredUpdatesStreamTopic = TOPIC_MAP_CHUNK_RESOURCE_COLOURED_032_UPDATES, +//// colouredChunkStateTopic = TOPIC_MAP_CHUNK_RESOURCE_COLOURED_STATE, +//// ) +// +// saveTiles() +// +// websocketBroadcaster() +// +// syslogProducer() +// } + + +// private suspend fun splitPackets() { +// val builder = StreamsBuilder() +// val packets = factorioServerPacketStream(builder) +// splitFactorioServerPacketStream(packets) +// +// val topology = builder.build() +// +// launchTopology("splitPackets", topology) +// } + + +// /** Terrain tiles */ +// private suspend fun groupTilesMapChunks() { +// val builder = StreamsBuilder() +// +// val protosStream: KStream = +// builder.streamPacketData() +// +// val topology = colourMapChunks(builder, protosStream) +// +// launchTopology("groupTilesMapChunks.${ServerMapTileLayer.TERRAIN.dir}", topology) +// } + +// +// /** Building and resource tiles */ +// private suspend fun groupEntitiesMapChunks( +// layer: ServerMapTileLayer, +// colouredUpdatesStreamTopic: String, +// colouredChunkStateTopic: String, +// ) { +// val builder = StreamsBuilder() +// +// val entityChunksStream: KStream> = +// when (layer) { +// ServerMapTileLayer.TERRAIN -> return +// +// ServerMapTileLayer.RESOURCE -> +// builder.streamPacketData() +// .convertResourceUpdateToServerMapChunkTiles("groupEntitiesMapChunks.${layer.dir}") +// +// ServerMapTileLayer.BUILDING -> +// builder.streamPacketData() +// .convertEntityUpdateToServerMapChunkTiles("groupEntitiesMapChunks.${layer.dir}") +// } +// +// val protosStream: KStream = +// builder.streamPacketData() +// +// val topology = colourEntityChunks( +// builder, +// entityChunksStream, +// protosStream, +// layer, +// colouredUpdatesStreamTopic, +// colouredChunkStateTopic, +// ) +// +// launchTopology("groupTilesMapChunks.${layer.dir}", topology) +// } + + +// private suspend fun saveTiles() { +// val builder = StreamsBuilder() +// val topology = saveMapTiles(builder, appProps.serverDataDir) +// launchTopology("saveTiles", topology) +// } + + +// private suspend fun websocketBroadcaster() { +// val builder = StreamsBuilder() +// broadcastToWebsocket(wsServer, builder) +// +// val topology = builder.build() +// +// launchTopology( +// "websocketBroadcaster", topology, mapOf( +// StreamsConfig.COMMIT_INTERVAL_MS_CONFIG to "${1.seconds.inWholeMilliseconds}", +// StreamsConfig.producerPrefix(ProducerConfig.LINGER_MS_CONFIG) to "${1.milliseconds.inWholeMilliseconds}" +// ) +// ) +// } + + +// /** Receive log messages from the syslog socket, and send them to a Kafka topic */ +// private fun syslogProducer() { +// builderScope.launch { +// kafkatorioPacketKafkaProducer.launch() +// } +// } + + +// private suspend fun launchTopology( +// id: String, +// topology: Topology, +// additionalProperties: Map = mapOf(), +// ) { +// +// val props: Properties = appProps.kafkaStreamsConfig.toProperties() +// +// additionalProperties.forEach { (k, v) -> props.setProperty(k, v) } +// +// val appId = props.compute(StreamsConfig.APPLICATION_ID_CONFIG) { _, v -> "$v.$id" } as String +// props.setProperty(StreamsConfig.APPLICATION_ID_CONFIG, appId) +// +// builderScope.launch(CoroutineName(appId)) { +// +// val streamsState: KafkaStreams.State = suspendCancellableCoroutine { cont -> +// +// val streams = KafkaStreams(topology, props) +// streams.setUncaughtExceptionHandler(StreamsExceptionHandler { e -> +// cont.resumeWithException(e) +// }) +// +// streams.setStateListener { newState: KafkaStreams.State, _ -> +// when (newState) { +// KafkaStreams.State.NOT_RUNNING, +// KafkaStreams.State.ERROR -> if (cont.isActive) cont.resume(newState) +// +// else -> Unit // do nothing +// } +// } +// +// cont.invokeOnCancellation { +// println("[$appId] coroutine cancelled -> closing. cause:$it") +// streams.close() +// } +// +// printTopologyDescription(appId, topology) +// streams.start() +// println("launched Topology $appId") +// } +// println("exiting Topology $appId: $streamsState") +// currentCoroutineContext().job.cancel("$appId: $streamsState") +// } +// } + + +// private fun printTopologyDescription(appId: String, topology: Topology) { +// val description: TopologyDescription = topology.describe() +// +// val descFile = Path("./build/$appId.txt").toFile().apply { +// parentFile.mkdirs() +// if (!exists()) createNewFile() +// writeText(description.toString()) +// } +// +// println( +// """ +// |---------------- +// |$appId - ${descFile.canonicalPath} +// |$description +// |---------------- +// """.trimMargin() +// ) +// } + + +// companion object { +// private fun Map.toProperties(): Properties = +// entries.fold(Properties()) { props, (k, v) -> +// props.apply { setProperty(k, v) } +// } +// } +} diff --git a/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/processor/eventProcessor.kt b/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/processor/eventProcessor.kt new file mode 100644 index 0000000..7e0b2a3 --- /dev/null +++ b/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/processor/eventProcessor.kt @@ -0,0 +1,35 @@ +package dev.adamko.kafkatorio.server.processor + + +//import dev.adamko.kafkatorio.server.config.ApplicationProperties +//import dev.adamko.kafkatorio.server.processor.admin.KafkatorioKafkaAdmin +//import dev.adamko.kafkatorio.server.security.Authenticator +//import dev.adamko.kafkatorio.server.socket.SyslogSocketServer +//import dev.adamko.kafkatorio.server.web.websocket.WebmapWebsocketServer +//import kotlinx.coroutines.awaitCancellation +//import kotlinx.coroutines.coroutineScope +//import kotlinx.coroutines.launch +// +// +//suspend fun eventsProcessor( +// appProps: ApplicationProperties, +// syslogServer: SyslogSocketServer, +// wsServer: WebmapWebsocketServer, +// authenticator: Authenticator, +//): Unit = coroutineScope { +// +// val admin = KafkatorioKafkaAdmin(appProps) +// admin.createKafkatorioTopics() +// +// val kafkatorioPacketKafkaProducer = KafkatorioPacketKafkaProducer(appProps, syslogServer, authenticator) +// +// val topology = KafkatorioTopology(appProps, wsServer, syslogServer, kafkatorioPacketKafkaProducer) +// +// launch { +// topology.start() +// +// println("launched KafkatorioTopology") +// +// awaitCancellation() +// } +//} diff --git a/modules/infra-factorio-client/build.gradle.kts b/modules/infra-factorio-client/build.gradle.kts new file mode 100644 index 0000000..7b7844f --- /dev/null +++ b/modules/infra-factorio-client/build.gradle.kts @@ -0,0 +1,61 @@ +import dev.adamko.gradle.factorio.FactorioModPlugin +import kafkatorio.tasks.ProcessRunningSpec +import org.gradle.kotlin.dsl.support.serviceOf +import org.jetbrains.kotlin.util.parseSpaceSeparatedArgs + +plugins { + id("kafkatorio.conventions.infra.process-runner") + id("dev.adamko.factorio-mod") +} + +description = "Manage the Factorio game client" + +val clientModsDirectory: DirectoryProperty = objects.directoryProperty().apply { + val modDir = File("""D:\Users\Adam\AppData\Roaming\Factorio\mods""") + if (modDir.exists()) { + set(modDir) + } +} + +dependencies { + factorioMod(projects.modules.eventsMod) +} + + +fun ExecOperations.isFactorioRunning(): Spec = ProcessRunningSpec(this, "factorio.exe") + + +val clientKill by tasks.registering(Exec::class) { + description = "Stop the local Factorio Steam game client" + group = FactorioModPlugin.TASK_GROUP + + onlyIf(serviceOf().isFactorioRunning()) + + commandLine = parseSpaceSeparatedArgs(""" taskkill /im factorio.exe """) + doFirst { logger.lifecycle("Killing factorio.exe") } +} + + +tasks.register(FactorioModPlugin.PUBLISH_MOD_LOCAL_TASK_NAME) { + group = FactorioModPlugin.TASK_GROUP +// dependsOn(deployModToLocalClient) +} + + +tasks.processRun { + dependsOn( +// deployModToLocalClient, + tasks.launchFactorioClient, + ) +} + +tasks.processKill { + dependsOn(clientKill) +} + + +val runFactorioClient by tasks.registering { + group = rootProject.name + + dependsOn(tasks.processRun) +} diff --git a/modules/infra-factorio-server/build.gradle.kts b/modules/infra-factorio-server/build.gradle.kts new file mode 100644 index 0000000..00d184f --- /dev/null +++ b/modules/infra-factorio-server/build.gradle.kts @@ -0,0 +1,83 @@ +import dev.adamko.gradle.factorio.FactorioModPlugin + +plugins { + id("kafkatorio.conventions.base") + id("dev.adamko.geedeecee") + id("dev.adamko.factorio-mod-library") + idea +} + + +geedeecee { + srcDir.set(layout.projectDirectory.dir("src")) +} + +val factorioServerDataDir: DirectoryProperty = objects.directoryProperty() + .convention(geedeecee.srcDir.dir("factorio-server")) + +dependencies { + factorioMod(projects.modules.eventsMod) +} + + +val deployModToLocalServer by tasks.registering(Copy::class) { + description = "Copy the mod to the Factorio Docker server" + group = FactorioModPlugin.TASK_GROUP + + dependsOn(configurations.factorioMod) + +// from( +// provider { factorioMod.incoming.artifacts.artifactFiles.files } +// ) + from(configurations.factorioMod.map { it.incoming.artifactView { lenient(true) }.files }) + into(factorioServerDataDir.dir("mods")) + + doLast { + logger.lifecycle("Copying mods ${source.files} into $destinationDir") + } +} + + +//tasks.dockerComposeDown { +// commandLine = parseSpaceSeparatedArgs(""" docker-compose stop """) +//} + + +tasks.dockerComposeUp { + dependsOn( + deployModToLocalServer, + ":modules:infra-kafka-cluster:processRun", + ) +} + + +val kafkatorioServerToken: String? by project + + +tasks.dockerComposeEnvUpdate { + envProperties { + put("FACTORIO_VERSION", libs.versions.factorio) + kafkatorioServerToken?.let { token -> + put("KAFKATORIO_TOKEN", token) + } + } +} + + +tasks.register(FactorioModPlugin.PUBLISH_MOD_LOCAL_TASK_NAME) { + group = FactorioModPlugin.TASK_GROUP + dependsOn(deployModToLocalServer) +} + + +idea { + module { + excludeDirs.add(file("src/factorio-server")) + } +} + +val runFactorioServer by tasks.registering { + group = rootProject.name + + dependsOn(tasks.dockerComposeUp) +} diff --git a/modules/infra-factorio-server/factorio-and-kpipe-server/factorioEvents.Dockerfile b/modules/infra-factorio-server/factorio-and-kpipe-server/factorioEvents.Dockerfile new file mode 100644 index 0000000..4e639bd --- /dev/null +++ b/modules/infra-factorio-server/factorio-and-kpipe-server/factorioEvents.Dockerfile @@ -0,0 +1,27 @@ +# syntax=docker/dockerfile:1 + +ARG factorioVersion=1.1.42 + + +FROM factoriotools/factorio:$factorioVersion + +# In progress +# The intention is to remove kafka-pipe and have a +# pre-preared Factorio Docker container than can +# just run, without needing an additional +# container with kcat. + +#RUN apk add --update \ +# curl \ +# kafkacat \ +# ; + +ENV KCAT_CONFIG="/kcat.conf" + + +RUN apt-get update && apt-get install -y \ + kafkacat \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR / +COPY kafka-pipe.sh kafka-pipe.sh diff --git a/modules/infra-factorio-server/factorio-and-kpipe-server/kafka-pipe.sh b/modules/infra-factorio-server/factorio-and-kpipe-server/kafka-pipe.sh new file mode 100644 index 0000000..75dace3 --- /dev/null +++ b/modules/infra-factorio-server/factorio-and-kpipe-server/kafka-pipe.sh @@ -0,0 +1,24 @@ +#!/usr/bin/bash + +# Pipe Docker logs from a Factorio server to a Kafka topic + +echo "Piping logs from $FACTORIO_SERVER_CONTAINER_NAME to $KAFKA_HOST" + +# generate some distinctive key for messages from this server +SERVER_HASH=openssl dgst -sha3-512 "$CONFIG/server-settings.json" + +trap endProcess SIGINT +endProcess() { + echo "Exiting Factorio Events Kafka Pipe" + exit +} + +while :; do + + sed -n -e 's/^FactorioEvent: //p' | + kafkacat -F "$KCAT_PROP_FILE" + + echo "Error - retrying in 10 seconds" + + sleep 10 +done diff --git a/modules/infra-factorio-server/factorio-and-kpipe-server/kcat.conf b/modules/infra-factorio-server/factorio-and-kpipe-server/kcat.conf new file mode 100644 index 0000000..998c885 --- /dev/null +++ b/modules/infra-factorio-server/factorio-and-kpipe-server/kcat.conf @@ -0,0 +1 @@ +enable.idempotence=true diff --git a/modules/infra-factorio-server/src/.gitignore b/modules/infra-factorio-server/src/.gitignore new file mode 100644 index 0000000..545275d --- /dev/null +++ b/modules/infra-factorio-server/src/.gitignore @@ -0,0 +1,4 @@ +factorio-server/ + +# .env contains secret token +.env diff --git a/modules/infra-factorio-server/src/docker-compose.yml b/modules/infra-factorio-server/src/docker-compose.yml new file mode 100644 index 0000000..df48a83 --- /dev/null +++ b/modules/infra-factorio-server/src/docker-compose.yml @@ -0,0 +1,42 @@ +version: "3.9" + +services: + + factorio-server: + image: factoriotools/factorio:${FACTORIO_VERSION} + container_name: "factorio-server" + restart: "no" + networks: + - "kafkatorio-nw" + - "traefik-nw" + labels: + - "traefik.enable=true" + ports: + - "34197:34197/udp" # factorio + - "27015:27015/tcp" # rcon + volumes: + - "./factorio-server:/factorio" + logging: + driver: syslog + options: + syslog-address: "tcp://host.docker.internal:12034" # pc +# syslog-address: "tcp://localhost:12034" # nuc + syslog-format: "rfc5424" + tag: ${KAFKATORIO_TOKEN} + + # environment: + # RCON_PORT: 27715 + # environment: + # - PUID=1000 + # - PGID=1000 + # - UPDATE_MODS_ON_START=true + # - USERNAME=FactorioUsername + # - TOKEN=FactorioToken + +networks: + kafkatorio-nw: + name: "kafkatorio-nw" + external: true + traefik-nw: + name: "traefik-nw" + external: true diff --git a/modules/infra-kafka-cluster/build.gradle.kts b/modules/infra-kafka-cluster/build.gradle.kts new file mode 100644 index 0000000..d968456 --- /dev/null +++ b/modules/infra-kafka-cluster/build.gradle.kts @@ -0,0 +1,42 @@ +plugins { + id("kafkatorio.conventions.base") + id("dev.adamko.geedeecee") +} + +description = "Kafka cluster" + +geedeecee { + srcDir.set(layout.projectDirectory.dir("src")) +} + +tasks.dockerComposeEnvUpdate { + envProperties { + put("GRAFANA_VERSION", libs.versions.grafana) + put("PROMETHEUS_VERSION", libs.versions.prometheus) + put("KAFKA_VERSION", libs.versions.kafka) + put("KAFKA_DL_URL", libs.versions.kafka.map { ver -> + "https://dlcdn.apache.org/kafka/$ver/kafka_2.13-$ver.tgz" + }) + put("APP_NAME", "kafka-kraft") + } + + // Limit JVM Heap Size +// "KAFKA_BROKER_HEAP_OPTS" to "-XX:MaxRAMPercentage=70.0", +// "KAFKA_CONNECT_HEAP_OPTS" to "-XX:MaxRAMPercentage=70.0", +// "SCHEMA_REGISTRY_HEAP_OPTS" to "-XX:MaxRAMPercentage=70.0", +// "KAFKA_KSQL_HEAP_OPTS" to "-XX:MaxRAMPercentage=70.0", +// "PROMETHEUS_JMX_AGENT_JVM_OPTS" to "-Xmx128M", + +// // Limit container resources +// "KAFKA_BROKER_MEM_LIMIT" to "512m", +// "KAFKA_CONNECT_MEM_LIMIT" to "512m", +// "KAFKA_KSQL_MEM_LIMIT" to "256m", +// "SCHEMA_REGISTRY_MEM_LIMIT" to "256m", +// ) +} + +val runKafkaCluster by tasks.registering { + group = rootProject.name + + dependsOn(tasks.dockerComposeUp) +} diff --git a/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_hard_disk_usage.json b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_hard_disk_usage.json new file mode 100644 index 0000000..0ff0182 --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_hard_disk_usage.json @@ -0,0 +1,378 @@ +{ + "__inputs": [ + { + "name": "Prometheus", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "5.2.1" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "5.0.0" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "5.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1540328526402, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 2, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sort": "current", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "sum(kafka_log_size{env=\"$env\"}) by (topic)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{topic}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Global Topics Size (including replicas)", + "tooltip": { + "shared": true, + "sort": 1, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 0 + }, + "id": 5, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(sum(kafka_log_size{env=\"$env\"}) by (topic, partition) / sum(kafka_cluster_partition_replicascount{env=\"$env\"}) by(partition, topic)) by (topic)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{topic}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Global Topics Size (without replication)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 9 + }, + "id": 3, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "sum(kafka_log_size{env=\"$env\"}) by (instance)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Logs Size Per Broker (including replicas)", + "tooltip": { + "shared": true, + "sort": 1, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 16, + "style": "dark", + "tags": [ + "kafka", + "topics", + "disk" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "Prometheus", + "hide": 0, + "includeAll": false, + "label": "Env", + "multi": false, + "name": "env", + "options": [], + "query": "label_values(kafka_log_size, env)", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "Kafka / Hard Disk Usage", + "uid": "zApgMBbik", + "version": 1 +} \ No newline at end of file diff --git a/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_jvm_os.json b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_jvm_os.json new file mode 100644 index 0000000..8fad773 --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_jvm_os.json @@ -0,0 +1,801 @@ +{ + "__inputs": [ + { + "name": "prometheus", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "5.2.1" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "5.0.0" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "5.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "Java Virtual Machine Memory and OS metrics", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1540307470986, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 7, + "w": 7, + "x": 0, + "y": 0 + }, + "id": 8, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_jvm_non_heap_usage{env=\"$env\", type=\"used\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}} ", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "JVM Memory Used (Non-Heap)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 7, + "w": 8, + "x": 7, + "y": 0 + }, + "id": 6, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_jvm_heap_usage{env=\"$env\", type=\"used\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "JVM Memory Used (Heap)", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 7, + "w": 9, + "x": 15, + "y": 0 + }, + "id": 10, + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_jvm_gc_collection_time{env=\"$env\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}} / {{name}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "GC Process Time", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 5, + "w": 12, + "x": 0, + "y": 7 + }, + "id": 4, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_jvm_os_systemcpuload{env=\"$env\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "CPU", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "percentunit", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 5, + "w": 12, + "x": 12, + "y": 7 + }, + "id": 11, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_jvm_os_processcpuload{env=\"$env\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Process CPU", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "percentunit", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 5, + "w": 12, + "x": 0, + "y": 12 + }, + "id": 2, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_jvm_os_openfiledescriptorcount{env=\"$env\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Open File Descriptors", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "description": "The amount of free physical memory in bytes.", + "fill": 1, + "gridPos": { + "h": 5, + "w": 6, + "x": 12, + "y": 12 + }, + "id": 13, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_jvm_os_freephysicalmemorysize{env=\"$env\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Free Physical Memory", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "description": "The amount of virtual memory that is guaranteed to be available to the running process in bytes", + "fill": 1, + "gridPos": { + "h": 5, + "w": 6, + "x": 18, + "y": 12 + }, + "id": 14, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_jvm_os_committedvirtualmemorysize{env=\"$env\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Available Virtual Memory", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "decbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "decimals": null, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 16, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "Prometheus", + "hide": 0, + "includeAll": false, + "label": "Env", + "multi": false, + "name": "env", + "options": [], + "query": "label_values(kafka_jvm_os_openfiledescriptorcount, env)", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "Kafka / Brokers JVM & OS", + "uid": "AdG9A1xmk", + "version": 3 +} \ No newline at end of file diff --git a/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_performance.json b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_performance.json new file mode 100644 index 0000000..fd95efb --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_performance.json @@ -0,0 +1,1532 @@ +{ + "__inputs": [ + { + "name": "Prometheus", + "label": "prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "5.2.1" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "5.0.0" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "5.0.0" + }, + { + "type": "panel", + "id": "singlestat", + "name": "Singlestat", + "version": "5.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1532113327583, + "links": [], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 17, + "panels": [], + "repeat": "instance", + "title": "Request Latency : $request ($instance)", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 8, + "w": 15, + "x": 0, + "y": 1 + }, + "id": 1, + "isNew": true, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"Mean\", scope=~\"Total\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{ aggregate}}", + "refId": "A", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"99thPercentile\", scope=~\"Total\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{ aggregate}}", + "refId": "B", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"75thPercentile\", scope=~\"Total\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{ aggregate}}", + "refId": "C", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Request Total Time Ms", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "Prometheus", + "decimals": null, + "editable": true, + "error": false, + "format": "percentunit", + "gauge": { + "maxValue": 1, + "minValue": 0, + "show": true, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 15, + "y": 1 + }, + "id": 16, + "interval": null, + "isNew": true, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "kafka_network_socket_server_processor_avg_idle_percent{instance=~\"$instance\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "refId": "A", + "step": 60 + } + ], + "thresholds": "0.3,0.5,0.8", + "title": "Network Socket Avg Idle Percent", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "Prometheus", + "decimals": null, + "editable": true, + "error": false, + "format": "percentunit", + "gauge": { + "maxValue": 1, + "minValue": 0, + "show": true, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 18, + "y": 1 + }, + "id": 15, + "interval": null, + "isNew": true, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "kafka_server_request_handler_avg_idle_percent{instance=~\"$instance\", aggregate=~\"OneMinuteRate\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "refId": "A", + "step": 60 + } + ], + "thresholds": "0.3,0.5,0.8", + "title": "Request Handler Avg Idle Percent", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "Prometheus", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 21, + "y": 1 + }, + "id": 12, + "interval": null, + "isNew": true, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "kafka_network_request_per_sec{aggregate=~\"OneMinuteRate\",instance=~\"$instance\",request=~\"$request\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "", + "metric": "", + "refId": "A", + "step": 60 + } + ], + "thresholds": "", + "title": "Requests Per Sec", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "Prometheus", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 15, + "y": 5 + }, + "id": 10, + "interval": null, + "isNew": true, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "kafka_network_request_channel_queue_size{instance=~\"$instance\", queue=~\"Response\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}}", + "metric": "", + "refId": "A", + "step": 60 + } + ], + "thresholds": "0,50,1000", + "title": "Response Queue Size", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "datasource": "Prometheus", + "editable": true, + "error": false, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 18, + "y": 5 + }, + "id": 9, + "interval": null, + "isNew": true, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "kafka_network_request_channel_queue_size{instance=~\"$instance\", queue=~\"Request\", env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}}", + "metric": "", + "refId": "A", + "step": 60 + } + ], + "thresholds": "0,50,1000", + "title": "Request Queue Size", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "avg" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 9 + }, + "id": 2, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"Mean\", scope=~\"RequestQueue\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "A", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"75thPercentile\", scope=~\"RequestQueue\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "B", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"99thPercentile\", scope=~\"RequestQueue\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "C", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Request Queue Time(Ms)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 9 + }, + "id": 3, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"Mean\", scope=~\"Local\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "A", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"75thPercentile\", scope=~\"Local\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "B", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"99thPercentile\", scope=~\"Local\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "C", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Local Time(Ms)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 9 + }, + "id": 4, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"Mean\", scope=~\"Remote\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "A", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"75thPercentile\", scope=~\"Remote\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "B", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"99thPercentile\", scope=~\"Remote\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "C", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Remote Time(Ms)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 16 + }, + "id": 5, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"Mean\", scope=~\"Throttle\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "A", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"75thPercentile\", scope=~\"Throttle\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "B", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"99thPercentile\", scope=~\"Throttle\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "C", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Throttle Time(Ms)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 16 + }, + "id": 6, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"Mean\", scope=~\"ResponseQueue\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "A", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"75thPercentile\", scope=~\"ResponseQueue\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "B", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"99thPercentile\", scope=~\"ResponseQueue\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "C", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Response Queue Time(Ms)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 16 + }, + "id": 7, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"Mean\", scope=~\"ResponseSend\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "A", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"75thPercentile\", scope=~\"ResponseSend\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "B", + "step": 10 + }, + { + "expr": "kafka_network_request_metrics_time_ms{instance=~\"$instance\", request=~\"$request\", aggregate=~\"99thPercentile\", scope=~\"ResponseSend\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}} / {{aggregate}}", + "refId": "C", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Response Send Time(Ms)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 23 + }, + "id": 8, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_network_processor_idle_percent{instance=~\"$instance\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{processor}}", + "metric": "kafka_network_processor_idle_percent", + "refId": "A", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Network Processor Idle Percent", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percentunit", + "label": "", + "logBase": 1, + "max": 1, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 23 + }, + "id": 14, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_request_handler_avg_idle_percent{instance=~\"$instance\", aggregate=~\"OneMinuteRate\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{processor}}", + "metric": "kafka_network_processor_idle_percent", + "refId": "A", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Request Handler Avg Idle Percent", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percentunit", + "label": "", + "logBase": 1, + "max": 1, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 16, + "style": "dark", + "tags": [ + "kafka", + "broker", + "troubleshoot" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "Prometheus", + "hide": 0, + "includeAll": false, + "label": "Envrionment", + "multi": false, + "name": "env", + "options": [], + "query": "label_values(kafka_server_brokerstate, env)", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "Prometheus", + "hide": 0, + "includeAll": true, + "label": "Broker Host", + "multi": true, + "name": "instance", + "options": [], + "query": "label_values(kafka_network_request_metrics_time_ms{env=\"$env\"}, instance)", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "Prometheus", + "hide": 0, + "includeAll": false, + "label": "Request Type", + "multi": false, + "name": "request", + "options": [], + "query": "label_values(kafka_network_request_metrics_time_ms, request)", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Kafka Broker / Performance & Latency", + "uid": "aRNaJwOmk", + "version": 8 +} diff --git a/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_zookeeper.json b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_zookeeper.json new file mode 100644 index 0000000..156b989 --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_broker_zookeeper.json @@ -0,0 +1,688 @@ +{ + "__inputs": [ + { + "name": "Prometheus", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "5.2.1" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "5.0.0" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "5.0.0" + }, + { + "type": "panel", + "id": "text", + "name": "Text", + "version": "5.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1539721769054, + "links": [], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 8, + "panels": [], + "title": "Kafka/Zookeeper Session Expire Listener", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 1 + }, + "id": 1, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_zookeeper_session_expire_listener_zookeepersyncconnectspersec{aggregate=\"OneMinute\", env=\"$env\"}", + "intervalFactor": 2, + "legendFormat": "{{instance}}", + "refId": "A", + "step": 4 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Zookeeper Sync Connects Per Sec", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 1 + }, + "id": 2, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_zookeeper_session_expire_listener_zookeeperdisconnectspersec{env=\"$env\", aggregate=\"OneMinute\"}", + "intervalFactor": 2, + "legendFormat": "{{instance}}", + "refId": "A", + "step": 4 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Zookeeper Disconnects Per Sec", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "content": "The ZooKeeper session has expired. **When a session expires, we can have leader changes and even a new controller.**\n\nIt is important to keep an eye on the number of such events across a Kafka cluster and if the overall number is high, then we have a few recommendations:\n\n* Check the health of your network\n* Check for garbage collection issues and tune it accordingly\n * If necessary, increase the session time out by setting the value of zookeeper.connection.timeout.ms.\n\nDocumentation : [monitoring.html#zookeeper-metrics](http://docs.confluent.io/current/kafka/monitoring.html#zookeeper-metrics)\n", + "editable": true, + "error": false, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 1 + }, + "id": 7, + "isNew": true, + "links": [], + "mode": "markdown", + "title": "The ZooKeeper session has expired ?", + "transparent": true, + "type": "text" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 5, + "w": 8, + "x": 0, + "y": 8 + }, + "id": 4, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_zookeeper_session_expire_listener_zookeeperreadonlyconnectspersec{env=\"$env\", aggregate=\"OneMinute\"}", + "intervalFactor": 2, + "legendFormat": "{{instance}}", + "refId": "A", + "step": 4 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Zookeeper Read Only Connects Per Sec", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 5, + "w": 8, + "x": 8, + "y": 8 + }, + "id": 3, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_zookeeper_session_expire_listener_zookeeperexpirespersec{env=\"$env\", aggregate=\"OneMinute\"}", + "intervalFactor": 2, + "legendFormat": "{{instance}}", + "refId": "A", + "step": 4 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Zookeeper Expires Per Sec", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 5, + "w": 8, + "x": 0, + "y": 13 + }, + "id": 6, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_zookeeper_session_expire_listener_zookeeperauthfailurespersec{env=\"$env\", aggregate=\"OneMinute\"}", + "intervalFactor": 2, + "legendFormat": "{{instance}}", + "refId": "A", + "step": 4 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Zookeeper SASL Authentications Per Sec", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 5, + "w": 8, + "x": 8, + "y": 13 + }, + "id": 5, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_zookeeper_session_expire_listener_zookeeperauthfailurespersec{env=\"$env\", aggregate=\"OneMinute\"}", + "intervalFactor": 2, + "legendFormat": "{{instance}}", + "refId": "A", + "step": 4 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Zookeeper Auth Failures Per Sec", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 16, + "style": "dark", + "tags": [ + "kafka", + "zookeeper" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "Prometheus", + "hide": 0, + "includeAll": false, + "label": "Env", + "multi": false, + "name": "env", + "options": [], + "query": "label_values(kafka_server_brokerstate, env)", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Kafka Broker / Zookeeper Connection", + "uid": "142Xi34mk", + "version": 1 +} \ No newline at end of file diff --git a/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_client_consumers_fetch_lag.json b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_client_consumers_fetch_lag.json new file mode 100644 index 0000000..a6703b4 --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_client_consumers_fetch_lag.json @@ -0,0 +1,492 @@ +{ + "__inputs": [ + { + "name": "Prometheus", + "label": "prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "5.2.1" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "5.0.0" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "5.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1532113236152, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "description": "The latest lag of each client", + "fill": 1, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 8, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "sum(kafka_consumer_fetch_manager_metrics_records_lag{env=\"$env\", topic=\"$topic\"}) by(topic, client_id, instance)", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{client_id}} ({{instance}})", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Consumer Client Lag", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "description": "The average number of bytes fetched per request for a topic", + "fill": 1, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 0 + }, + "id": 10, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_consumer_fetch_manager_metrics_fetch_size_avg{env=\"$env\", topic=\"$topic\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{client_id}} ({{instance}})", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Fetch Bytes Per Request", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "decbytes", + "label": "", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "description": "The average number of bytes consumed per second", + "fill": 1, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 6 + }, + "id": 3, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_consumer_fetch_manager_metrics_bytes_consumed_rate{env=\"$env\", topic=\"$topic\"}", + "format": "time_series", + "hide": false, + "instant": false, + "intervalFactor": 1, + "legendFormat": "{{client_id}} ({{instance}})", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Consumed Bytes Rate Per Second", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "description": "The average number of records consumed per second", + "fill": 1, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 6 + }, + "id": 2, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_consumer_fetch_manager_metrics_records_consumed_rate{env=\"$env\", topic=\"$topic\"}", + "format": "time_series", + "hide": false, + "intervalFactor": 1, + "legendFormat": "{{client_id}} ({{instance}})", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Consumed Records Rate Per Second", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "rps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 16, + "style": "dark", + "tags": [ + "kafka", + "clients" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "Prometheus", + "hide": 0, + "includeAll": false, + "label": "env", + "multi": false, + "name": "env", + "options": [], + "query": "label_values(kafka_consumer_fetch_manager_metrics_records_consumed_rate, env)", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "Prometheus", + "hide": 0, + "includeAll": false, + "label": "topic", + "multi": false, + "name": "topic", + "options": [], + "query": "label_values(kafka_consumer_fetch_manager_metrics_records_consumed_rate, topic)", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Kafka Consumers / Fetch Rate & Records Lag", + "uid": "Ni95Y3dmz", + "version": 20 +} diff --git a/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_cluster_healthcheck.json b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_cluster_healthcheck.json new file mode 100644 index 0000000..78cae0d --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_cluster_healthcheck.json @@ -0,0 +1,1887 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "iteration": 1540310392981, + "links": [], + "panels": [ + { + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 29, + "title": "Healthcheck", + "type": "row" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": "Prometheus", + "description": "Number of active controllers in the cluster. Alert if the aggregated sum across all brokers in the cluster is anything other than 1 because there should be exactly one controller per cluster.", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 0, + "y": 1 + }, + "id": 31, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_controller_activecontrollercount{env=\"$env\"})", + "format": "time_series", + "instant": true, + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "0,1", + "title": "Active Controller", + "type": "singlestat", + "valueFontSize": "120%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "description": "Number of partitions that don’t have an active leader and are hence not writable or readable. Alert if value is greater than 0.", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 3, + "y": 1 + }, + "id": 32, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_controller_offlinepartitionscount{env=\"$env\"})", + "format": "time_series", + "instant": false, + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "1,1", + "title": "Offline Partitions Count", + "type": "singlestat", + "valueFontSize": "120%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "description": "Number of under-replicated partitions (| ISR | < | all replicas |). Alert if value is greater than 0.", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 7, + "y": 1 + }, + "id": 33, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_server_replica_manager_underreplicatedpartitions{env=\"$env\"})", + "format": "time_series", + "instant": false, + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "1,1", + "title": "Under Replicated Partitions", + "type": "singlestat", + "valueFontSize": "120%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "description": "Number of under-replicated partitions (| ISR | < | min.insync.replicas |). Alert if value is greater than 0.", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 11, + "y": 1 + }, + "id": 36, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_cluster_partition_underminisr{env=\"$env\"})", + "format": "time_series", + "instant": true, + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "1,1", + "title": "Partitions Under Min ISR", + "type": "singlestat", + "valueFontSize": "120%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "description": "", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 15, + "y": 1 + }, + "id": 34, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_controller_preferredreplicaimbalancecount{env=\"$env\"})", + "format": "time_series", + "instant": true, + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": "1,1", + "title": "Preferred Replica Imbalance", + "type": "singlestat", + "valueFontSize": "120%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "content": "\"Apache\n\n

You're using Apache Kafka, an open-source distributed and fault-tolerant streaming platform originally built at LinkedIn. For more information, check out the kafka.apache.org", + "gridPos": { + "h": 6, + "w": 5, + "x": 19, + "y": 1 + }, + "id": 46, + "links": [], + "mode": "html", + "title": "", + "transparent": true, + "type": "text" + }, + { + "cacheTimeout": null, + "colorBackground": true, + "colorValue": false, + "colors": [ + "#d44a3a", + "rgba(237, 129, 40, 0.89)", + "#299c46" + ], + "datasource": "Prometheus", + "decimals": 0, + "description": "Total number of brokers with a state running (i.e 3)", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 0, + "y": 4 + }, + "id": 44, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "count((kafka_server_brokerstate{env=\"$env\"}) == 3 or (kafka_server_brokerstate{env=\"$env\"}) == 4)", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "1,3", + "title": "Brokers Running(>=3)", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "decimals": 0, + "description": "Total number of producer requests per second", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 3, + "y": 4 + }, + "id": 39, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_network_request_per_sec{aggregate=~\"OneMinuteRate\",request=~\"Produce\",env=\"$env\"})", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Produce Req Per Sec", + "type": "singlestat", + "valueFontSize": "150%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "decimals": 0, + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 7, + "y": 4 + }, + "id": 40, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_network_request_per_sec{aggregate=~\"OneMinuteRate\",request=~\"FetchConsumer\",env=\"$env\"})", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Fetch Consumer Req Per Sec", + "type": "singlestat", + "valueFontSize": "150%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "decimals": 0, + "description": "Number of metadata requests per sec", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 11, + "y": 4 + }, + "id": 41, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_network_request_per_sec{aggregate=~\"OneMinuteRate\",request=~\"Metadata\",env=\"$env\"})", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Metadata Req Per Sec", + "type": "singlestat", + "valueFontSize": "150%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 3, + "w": 4, + "x": 15, + "y": 4 + }, + "id": 42, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_network_request_per_sec{aggregate=~\"OneMinuteRate\",request=~\"OffsetCommit\",env=\"$env\"})", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Offset Commit Req Per Sec", + "type": "singlestat", + "valueFontSize": "150%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 7 + }, + "id": 27, + "panels": [], + "title": "Throughput In/Out", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "description": "Aggregate incoming message rate.", + "fill": 1, + "gridPos": { + "h": 12, + "w": 19, + "x": 0, + "y": 8 + }, + "id": 19, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "sideWidth": 250, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "sum(kafka_server_broker_topic_metrics_messagesinpersec_rate{topic!=\"\"}) by(topic)", + "format": "time_series", + "instant": false, + "intervalFactor": 1, + "legendFormat": "{{topic}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Messages In Per Topics", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "wps", + "label": "Msg/sec", + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "decimals": 2, + "description": "Aggregate incoming message rate.", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 5, + "x": 19, + "y": 8 + }, + "id": 37, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_server_broker_topic_metrics_messagesinpersec_rate{topic=\"\"}) by (broker)", + "format": "time_series", + "instant": false, + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Messages In per sec", + "type": "singlestat", + "valueFontSize": "120%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "decimals": 2, + "format": "Bps", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 5, + "x": 19, + "y": 12 + }, + "id": 24, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_server_broker_topic_metrics_bytesinpersec_rate{topic=\"\"}) by (broker)", + "format": "time_series", + "instant": false, + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Bytes In per sec", + "type": "singlestat", + "valueFontSize": "120%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "decimals": 2, + "format": "Bps", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 5, + "x": 19, + "y": 16 + }, + "id": 25, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_server_broker_topic_metrics_bytesoutpersec_rate{topic=\"\"}) by (broker)", + "format": "time_series", + "instant": false, + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Bytes Out per sec", + "type": "singlestat", + "valueFontSize": "120%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 20 + }, + "id": 21, + "panels": [], + "title": "In-Sync Replica / Leaders Election", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "description": "When a broker is brought up after a failure, it starts catching up by reading from the leader. Once it is caught up, it gets added back to the ISR.", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 21 + }, + "id": 11, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_replica_manager_isrexpandspersec{aggregate=\"OneMinute\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "Broker={{instance}}", + "metric": "kafka_server_replication_isrexpandspersec", + "refId": "A", + "step": 20 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "In-Sync Replica Expands Rate", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ops", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "description": "If a broker goes down, ISR for some of the partitions will shrink. When that broker is up again, ISR will be expanded once the replicas are fully caught up. Other than that, the expected value for both ISR shrink rate and expansion rate is 0.", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 21 + }, + "id": 10, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_replica_manager_isrshrinkspersec{aggregate=\"OneMinute\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "Broker={{instance}}", + "metric": "kafka_server_replication_isrshrinkspersec", + "refId": "A", + "step": 20 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "In-Sync Replica Shrinks Rate", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "ops", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "description": "Leader election rate and latency.", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 28 + }, + "id": 8, + "isNew": true, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "hideEmpty": false, + "hideZero": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_controller_stats_leaderelectionrateandtimems{aggregate=~\"Mean\",env=\"$env\"}", + "format": "time_series", + "hide": true, + "intervalFactor": 2, + "legendFormat": "Broker={{instance}} / {{aggregate}}", + "metric": "kafka_controller_stats_leader_election_rate_and_time_ms", + "refId": "A", + "step": 10 + }, + { + "expr": "kafka_controller_stats_leaderelectionrateandtimems{aggregate=~\"75thPercentile\",env=\"$env\"}", + "format": "time_series", + "hide": true, + "intervalFactor": 2, + "legendFormat": "Broker={{instance}} / {{aggregate}}", + "refId": "B", + "step": 10 + }, + { + "expr": "kafka_controller_stats_leaderelectionrateandtimems{aggregate=~\"99thPercentile\",env=\"$env\"}", + "format": "time_series", + "hide": true, + "intervalFactor": 2, + "legendFormat": "Broker={{instance}} / {{aggregate}}", + "refId": "C", + "step": 10 + }, + { + "expr": "kafka_controller_stats_leaderelectionrateandtimems{aggregate=\"OneMinuteRate\", env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "Broker={{instance}} / {{aggregate}}", + "refId": "D", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Leader Election Rate (ms/1MinuteRate)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 1, + "value_type": "cumulative" + }, + "transparent": false, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "ms", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 28 + }, + "id": 9, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_controller_stats_uncleanleaderelectionspersec{aggregate=\"OneMinuteRate\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "Broker={{instance}} / {{aggregate}}", + "metric": "kafka_controller_stats_unclean_leader_elections_per_sec", + "refId": "A", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Unclean Leader Election Rate (should be < 0)", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 0, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "description": "Number of leaders on each broker. This should be mostly even across all brokers. If not, set auto.leader.rebalance.enable to true on all brokers in the cluster.", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 35 + }, + "id": 14, + "isNew": true, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 2, + "points": true, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_replica_manager_leadercount{env=\"$env\"}", + "format": "time_series", + "instant": false, + "intervalFactor": 2, + "legendFormat": "Broker={{instance}}", + "metric": "kafka_server_replication_leadercount", + "refId": "A", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Leader Count Per Broker", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 35 + }, + "id": 15, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 2, + "points": true, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_replica_manager_partitioncount{env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "Broker={{instance}}", + "metric": "kafka_server_replication_leadercount", + "refId": "A", + "step": 10 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Number of Partitions Per Broker", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "none", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 16, + "style": "dark", + "tags": [ + "kafka", + "broker", + "healthcheck" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "text": "docker", + "value": "docker" + }, + "datasource": "Prometheus", + "hide": 0, + "includeAll": false, + "label": "Environment", + "multi": false, + "name": "env", + "options": [], + "query": "label_values(kafka_server_brokerstate, env)", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Kafka Cluster / Global HealthCheck", + "uid": "e-6AJQOik", + "version": 1 +} \ No newline at end of file diff --git a/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_cluster_replication.json b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_cluster_replication.json new file mode 100644 index 0000000..97b06fb --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_cluster_replication.json @@ -0,0 +1,574 @@ +{ + "__inputs": [ + { + "name": "Prometheus", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "5.2.1" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "5.0.0" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "5.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1540330422283, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 8, + "x": 0, + "y": 0 + }, + "id": 1, + "isNew": true, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "hideEmpty": false, + "hideZero": true, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_broker_topic_metrics_replicationbytesinpersec_rate{aggregate=\"OneMinute\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}}", + "refId": "A", + "step": 60 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Replication BytesIn/Sec", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 1, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 7, + "w": 8, + "x": 8, + "y": 0 + }, + "id": 2, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "hideEmpty": false, + "hideZero": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_broker_topic_metrics_replicationbytesoutpersec_rate{aggregate=\"OneMinute\",env=\"$env\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "{{instance}}", + "refId": "A", + "step": 60 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Replication BytesOut/Sec", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 1, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": 0, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 7, + "w": 8, + "x": 16, + "y": 0 + }, + "id": 6, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_replica_fetcher_manager_maxlag_value{env=\"$env\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Replication Max Lag Per Broker", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "decimals": null, + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 7 + }, + "id": 3, + "isNew": true, + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_fetcher_stats_bytespersec{env=\"$env\", aggregate=\"OneMinute\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "Host {{instance}}, client_id={{client_id}} / {{broker_host}}:{{broker_port}}", + "refId": "A", + "step": 60 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Fetch Bytes/sec Per Replication thread", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "decimals": null, + "editable": true, + "error": false, + "fill": 1, + "grid": {}, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 12 + }, + "id": 4, + "isNew": true, + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": true, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_fetcher_stats_requestspersec{env=\"$env\", aggregate=\"OneMinute\"}", + "format": "time_series", + "intervalFactor": 2, + "legendFormat": "Host {{instance}}, client_id={{client_id}} / {{broker_host}}:{{broker_port}}", + "refId": "A", + "step": 60 + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Fetch Requests/sec Per Replication thread", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "reqps", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 16, + "style": "dark", + "tags": [ + "kafka", + "broker", + "replication" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "Prometheus", + "hide": 0, + "includeAll": false, + "label": "Env", + "multi": false, + "name": "env", + "options": [], + "query": "label_values(kafka_server_brokerstate, env)", + "refresh": 1, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "browser", + "title": "Kafka Cluster / Replication", + "uid": "E9bXmq4ik", + "version": 2 +} \ No newline at end of file diff --git a/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_topics_logs.json b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_topics_logs.json new file mode 100644 index 0000000..4f91add --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/grafana/dashboards/grafana_dashboard_topics_logs.json @@ -0,0 +1,876 @@ +{ + "__inputs": [ + { + "name": "Prometheus", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "5.2.1" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "5.0.0" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "5.0.0" + }, + { + "type": "panel", + "id": "singlestat", + "name": "Singlestat", + "version": "5.0.0" + }, + { + "type": "panel", + "id": "table", + "name": "Table", + "version": "5.0.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "iteration": 1540331963544, + "links": [], + "panels": [ + { + "collapsed": false, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 4, + "panels": [], + "repeat": "topic", + "title": "$topic", + "type": "row" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "format": "decbytes", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 0, + "y": 1 + }, + "id": 2, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_log_size{env=\"$env\", topic=\"$topic\"})", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Total Log Size", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": false, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 3, + "y": 1 + }, + "id": 11, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "count_values(\"partition\", kafka_log_numlogsegments{topic=\"$topic\"})", + "format": "time_series", + "instant": true, + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "", + "title": "Total Number of Replicas", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "description": "should alert if > 0", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 6, + "y": 1 + }, + "id": 12, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_cluster_partition_underminisr{env=\"$env\", topic=\"$topic\"})", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "1", + "title": "Number of Partitions Under Min ISR", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": [ + "#299c46", + "rgba(237, 129, 40, 0.89)", + "#d44a3a" + ], + "datasource": "Prometheus", + "description": "should alert if > 0", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 9, + "y": 1 + }, + "id": 13, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "postfix": "", + "postfixFontSize": "50%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": false + }, + "tableColumn": "", + "targets": [ + { + "expr": "sum(kafka_cluster_partition_underreplicated{env=\"$env\", topic=\"$topic\"})", + "format": "time_series", + "intervalFactor": 1, + "refId": "A" + } + ], + "thresholds": "1", + "title": "Under Replicated Partitions", + "type": "singlestat", + "valueFontSize": "80%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "current" + }, + { + "columns": [], + "datasource": "Prometheus", + "fontSize": "100%", + "gridPos": { + "h": 4, + "w": 12, + "x": 12, + "y": 1 + }, + "id": 6, + "links": [], + "pageSize": null, + "scroll": true, + "showHeader": true, + "sort": { + "col": 5, + "desc": true + }, + "styles": [ + { + "alias": "Time", + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "link": false, + "pattern": "Time", + "type": "hidden" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "Time", + "thresholds": [], + "type": "hidden", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "__name__", + "thresholds": [], + "type": "hidden", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "job", + "thresholds": [], + "type": "hidden", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "topic", + "thresholds": [], + "type": "hidden", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "service", + "thresholds": [], + "type": "hidden", + "unit": "short" + }, + { + "alias": "", + "colorMode": null, + "colors": [ + "rgba(245, 54, 54, 0.9)", + "rgba(237, 129, 40, 0.89)", + "rgba(50, 172, 45, 0.97)" + ], + "dateFormat": "YYYY-MM-DD HH:mm:ss", + "decimals": 2, + "mappingType": 1, + "pattern": "env", + "thresholds": [], + "type": "hidden", + "unit": "short" + } + ], + "targets": [ + { + "expr": "kafka_log_numlogsegments{topic=\"$topic\", env=\"$env\"}", + "format": "table", + "instant": true, + "intervalFactor": 1, + "legendFormat": "", + "refId": "A" + } + ], + "title": "Number of Segment Files Per Broker", + "transform": "table", + "type": "table" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 6, + "w": 8, + "x": 0, + "y": 5 + }, + "id": 8, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_broker_topic_metrics_messagesinpersec_rate{topic=\"$topic\", env=\"$env\", aggregate=\"OneMinute\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "Messages In Per Sec (OneMinuteRate)", + "tooltip": { + "shared": true, + "sort": 1, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "wps", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 6, + "w": 8, + "x": 8, + "y": 5 + }, + "id": 10, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_broker_topic_metrics_bytesinpersec_rate{topic=\"$topic\", env=\"$env\", aggregate=\"OneMinute\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "BytesInPerSec (OneMinuteRate)", + "tooltip": { + "shared": true, + "sort": 1, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Prometheus", + "fill": 1, + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 5 + }, + "id": 9, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "expr": "kafka_server_broker_topic_metrics_bytesoutpersec_rate{topic=\"$topic\", env=\"$env\", aggregate=\"OneMinute\"}", + "format": "time_series", + "intervalFactor": 1, + "legendFormat": "{{instance}}", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeShift": null, + "title": "BytesOutPerSec (OneMinuteRate)", + "tooltip": { + "shared": true, + "sort": 1, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "Bps", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 16, + "style": "dark", + "tags": [ + "kafka", + "topics" + ], + "templating": { + "list": [ + { + "allValue": null, + "current": {}, + "datasource": "Prometheus", + "hide": 0, + "includeAll": false, + "label": "Cluster", + "multi": false, + "name": "env", + "options": [], + "query": "label_values(kafka_log_size, env)", + "refresh": 2, + "regex": "", + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": null, + "current": {}, + "datasource": "Prometheus", + "hide": 0, + "includeAll": false, + "label": "Topics", + "multi": true, + "name": "topic", + "options": [], + "query": "label_values(kafka_log_size, topic)", + "refresh": 2, + "regex": "", + "sort": 5, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ] + }, + "timezone": "", + "title": "Kafka Topics / Logs", + "uid": "1vR8sjAmk", + "version": 1 +} \ No newline at end of file diff --git a/modules/infra-kafka-cluster/src/config/grafana/provisioning/dashboards/kafka.yaml b/modules/infra-kafka-cluster/src/config/grafana/provisioning/dashboards/kafka.yaml new file mode 100644 index 0000000..2053d55 --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/grafana/provisioning/dashboards/kafka.yaml @@ -0,0 +1,12 @@ +apiVersion: 1 + +providers: +- name: 'default' + orgId: 1 + folder: '' + type: file + disableDeletion: false + editable: true + updateIntervalSeconds: 3 #how often Grafana will scan for changed dashboards + options: + path: /var/lib/grafana/dashboards diff --git a/modules/infra-kafka-cluster/src/config/grafana/provisioning/datasources/datasource.yaml b/modules/infra-kafka-cluster/src/config/grafana/provisioning/datasources/datasource.yaml new file mode 100644 index 0000000..a8984ad --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/grafana/provisioning/datasources/datasource.yaml @@ -0,0 +1,50 @@ +# config file version +apiVersion: 1 + +# list of datasources that should be deleted from the database +deleteDatasources: + - name: Prometheus + orgId: 1 + +# list of datasources to insert/update depending +# what's available in the database +datasources: + # name of the datasource. Required +- name: Prometheus + # datasource type. Required + type: prometheus + # access mode. proxy or direct (Server or Browser in the UI). Required + access: proxy + # org id. will default to orgId 1 if not specified + orgId: 1 + # url + url: http://prometheus:9090 +# # database password, if used +# password: +# # database user, if used +# user: +# # database name, if used +# database: +# # enable/disable basic auth +# basicAuth: +# # basic auth username +# basicAuthUser: +# # basic auth password +# basicAuthPassword: +# # enable/disable with credentials headers +# withCredentials: + # mark as default datasource. Max one per org + isDefault: true +# # fields that will be converted to json and stored in json_data +# jsonData: +# graphiteVersion: "1.1" +# tlsAuth: true +# tlsAuthWithCACert: true +# # json object of data that will be encrypted. +# secureJsonData: +# tlsCACert: "..." +# tlsClientCert: "..." +# tlsClientKey: "..." + version: 1 + # allow users to edit datasources from the UI. + editable: true diff --git a/modules/infra-kafka-cluster/src/config/jmx_exporter_kafka_broker.yml b/modules/infra-kafka-cluster/src/config/jmx_exporter_kafka_broker.yml new file mode 100644 index 0000000..da74442 --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/jmx_exporter_kafka_broker.yml @@ -0,0 +1,505 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#--------------------------------------------------------------------------------------------------------- +# Kafka Broker JMX Metrics : +# Compatible with version Apache Kafka v2.x.x / Confluent Platform 5.x.x +#--------------------------------------------------------------------------------------------------------- +hostPort: kafka:9991 +lowercaseOutputName: true +lowercaseOutputLabelNames: true + +#Whitelist is used to reduce scrapping time +whitelistObjectNames: + - java.lang:* + - kafka.cluster:* + - kafka.controller:* + - kafka.log:* + - kafka.server:type=KafkaServer,name=BrokerState + - kafka.server:type=KafkaRequestHandlerPool,* + - kafka.server:type=BrokerTopicMetrics,* +# - kafka.server:type=DelayedFetchMetrics,* +# - kafka.server:type=DelayedOperationPurgatory,* + - kafka.server:type=FetcherLagMetrics,* + - kafka.server:type=FetcherStats,* + - kafka.server:type=Request,* + - kafka.server:type=Fetch,* + - kafka.server:type=Produce,* + - kafka.server:type=ReplicaManager,* + - kafka.server:type=ReplicaFetcherManager,* + - kafka.server:type=SessionExpireListener,* + - kafka.server:type=controller-channel-metrics,* + - kafka.server:type=socket-server-metrics,* + - kafka.network:type=RequestChannel,* + - kafka.network:type=Processor,* + - kafka.network:type=SocketServer,* + - kafka.network:type=RequestMetrics,* +# - kafka.network:type=RequestMetrics,name=*,request=OffsetCommit,version=* +# - kafka.network:type=RequestMetrics,name=*,request=FetchConsumer,version=* +# - kafka.network:type=RequestMetrics,name=*,request=FetchFollower,version=* +# - kafka.network:type=RequestMetrics,name=*,request=Produce,version=* +# - kafka.network:type=RequestMetrics,name=*,request=Metadata,version=* + - kafka.coordinator.group:* +blacklistObjectNames: + - java.lang:type=ClassLoading,* + - java.lang:type=Compilation,* + - java.lang:type=MemoryManager,* + - kafka.utils:* + - kafka.controller:type=ControllerChannelManager,name=QueueSize,* + # Following metrics are exposed per topics + - kafka.log:type=Log,name=LogEndOffset,* + - kafka.log:type=Log,name=LogStartOffset,* + - kafka.cluster:type=Partition,name=InSyncReplicasCount,* + - kafka.cluster:type=Partition,name=LastStableOffsetLag,* + - kafka.cluster:type=Partition,name=ReplicasCounts,* + - kafka.cluster:type=Partition,name=UnderReplicated,* + - kafka.server:type=BrokerTopicMetrics,name=TotalFetchRequestsPerSec,* + - kafka.server:type=BrokerTopicMetrics,name=TotalProduceRequestsPerSec,* + - kafka.server:type=BrokerTopicMetrics,name=FailedProduceRequestsPerSec,* + - kafka.server:type=BrokerTopicMetrics,name=FailedFetchRequestsPerSec,* + - kafka.server:type=BrokerTopicMetrics,name=BytesRejectedPerSec,* + +rules: + #------------------------------------------------------------------------------------------------------- + # KafkaServers : State of broker server + # + # - BrokerState + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>Value + name: kafka_server_brokerstate + labels: + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # Partition : Number of partitions for each broker + # - InSyncReplicasCount + # - LastStableOffsetLag + # - ReplicasCount + # - UnderReplicated + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.cluster<>Value + name: kafka_cluster_partition_$1 + labels: + topic: $2 + partition: $3 + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # KafkaController : + # + # - ActiveControllerCount, OfflinePartitionsCount, PreferredReplicaImbalanceCount + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.controller<>Value + name: kafka_controller_$1 + labels: + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # ControllerStats : The event that is currently being processed by the elected broker controller. + # + # - LeaderElectionRateAndtimeMs, UncleanLeaderElectionsPerSec, AutoLeaderBalanceRateAndTimeMs, ManualLeaderBalanceRateAndTimeMs + # - ControllerChangeRateAndTimeMs, + # - TopicChangeRateAndTimeMs, TopicDeletionRateAndTimeMs, PartitionReassignmentRateAndTimeMs + # - IsrChangeRateAndTimeMs + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.controller<>(OneMinuteRate|Mean|75thPercentile|99thPercentile) + name: kafka_controller_stats_$1 + labels: + aggregate: $2 + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # Coordinator : GroupMetadataManager + # + # - NumGroups, NumOffsets + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.coordinator.group<>(Value) + name: kafka_coordinator_group_metadata_manager_$1 + labels: + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # Logs : + # + # - LogEndOffset, LogStartOffset, NumLogSegments, Size + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.log<>Value + name: kafka_log_$1 + labels: + topic: $2 + partition: $3 + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # LogCleaner : + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.log<>(Value) + name: kafka_log_cleaner_recopy_percent + labels: + service: kafka-broker + env: kafkatorio + + - pattern: kafka.log<>(Value) + name: kafka_log_cleaner_max_clean_time_secs + labels: + service: kafka-broker + env: kafkatorio + + - pattern: kafka.log<>(Value) + name: kafka_log_cleaner_max_buffer_utilization_percent + labels: + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # LogCleanerManager : + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.log<>(Value) + name: kafka_log_cleaner_manager_max_dirty_percent + labels: + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # LogFlushStats : + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.log<>(\w+) + name: kafka_log_flush_stats_rate_and_time_ms + labels: + aggregate: $1 + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # KafkaRequestHandlerPool : Latency + # + # - KafkaRequestHandlerPool + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>(\w+) + name: kafka_server_request_handler_avg_idle_percent + labels: + aggregate: $1 + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # Network Socket Server : Latency + # + # - NetworkProcessorAvgIdlePercent + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.network<>(Value) + name: kafka_network_socket_server_processor_avg_idle_percent + labels: + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # Network Processor : Latency + # + # - IdlePercent + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.network<>(Value) + name: kafka_network_processor_idle_percent + labels: + processor: $1 + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # Network KafkaRequestChannel : + # + # - RequestQueueSize, ResponseQueueSize + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.network<>Value + name: kafka_network_request_channel_queue_size + labels: + queue: $1 + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # Network KafkaRequest : + # + # - RequestPerSec, + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.network<>(OneMinuteRate|Mean) + name: kafka_network_request_per_sec + labels: + request: $1 + version: $2 + aggregate: $3 + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # Network KafkaRequestMetrics : + # + # - LocalTimeMs, RemoteTimeMs, + # - RequestQueueTimeMs, + # - ResponseQueueTimeMs, ResponseSendTimeMs + # - ThrottleTimeMs + # - TotalTimeMs + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.network<>(OneMinuteRate|Mean|75thPercentile|99thPercentile) + name: kafka_network_request_metrics_time_ms + labels: + scope: $1 + request: $2 + aggregate: $3 + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # KafkaServer / BrokerTopicMetrics - I/O metrics : + # + # - BytesInPerSec, BytesOutPerSec, BytesRejectedPerSec, + # - FailedFetchRequestsPerSec, FailedProduceRequestsPerSec,MessagesInPerSec, + # - TotalFetchRequestPerSec, TotalProduceRequestPerSec, ReplicationBytesInPerSec, ReplicationBytesOutPerSec + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>(OneMinute)Rate + name: kafka_server_broker_topic_metrics_$1_rate + labels: + aggregate: $2 + service: kafka-broker + env: kafkatorio + + - pattern: kafka.server<>(OneMinute)Rate + name: kafka_server_broker_topic_metrics_$1_rate + labels: + topic: $2 + aggregate: $3 + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # KafkaServer / DelayedFetchMetrics : + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>([^,]+)Rate + name: kafka_server_delayed_fetch_expires_per_sec + labels: + fetcher_type: $1 + aggregate: $2 + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # KafkaServer / DelayedOperationPurgatory : + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>Value + name: kafka_server_delayed_operation_purgatory_$1 + labels: + operation: $2 + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # FetcherLagMetrics : Lag in number of messages per follower replica + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>Value + name: kafka_server_fetcher_lag_$1 + labels: + client_id: $2 + topic: $3 + partition: $4 + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # FetcherStats : Replica Fetcher Thread stats + # - BytesPerSec / RequestsPerSec + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>([^,]+)Rate + name: kafka_server_fetcher_stats_$1 + labels: + client_id: $2 + broker_host: $3 + broker_port: $4 + aggregate: $5 + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # KafkaServer Request : + # - request-time - Tracking request-time per user/client-id + # - throttle-time - Tracking average throttle-time per user/client-id + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>(request-time|throttle-time) + name: kafka_server_request_$2 + labels: + client_id: $1 + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # KafkaServer Fetcher/Producer : + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>(byte-rate|throttle-time) + name: kafka_server_fetch_client_$2 + labels: + client_id: $1 + service: kafka-broker + env: kafkatorio + + - pattern: kafka.server<>(byte-rate|throttle-time) + name: kafka_server_produce_client_$2 + labels: + client_id: $1 + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # ReplicaManager : + # - IsrExpandsPerSec, IsrShrinksPerSec, FailedIsrUpdatesPerSec + # - LeaderCount, PartitionCount, UnderReplicatedPartitions) + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>([^,]+)Rate + name: kafka_server_replica_manager_$1 + labels: + aggregate: $2 + service: kafka-broker + env: kafkatorio + + - pattern: kafka.server<>(Value) + name: kafka_server_replica_manager_$1 + labels: + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # ReplicaFetcherManager : + # - MaxLag, MinFetchRate + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>(Value) + name: kafka_server_replica_fetcher_manager_$1_value + labels: + client_id: $2 + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # Zookeeper / SessionExpireListener : + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>([^,]+)Rate + name: kafka_zookeeper_session_expire_listener_$1 + labels: + aggregate: $2 + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # ControllerChannelMetrics: + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>(\w*) + name: kafka_server_controller_channel_metrics_$2 + labels: + broker_id: $1 + service: kafka-broker + env: kafkatorio + + #------------------------------------------------------------------------------------------------------- + # KafkaServer / Socket Server Metrics + #------------------------------------------------------------------------------------------------------- + - pattern: kafka.server<>(\w*) + name: kafka_server_socket_server_metrics_$2 + labels: + network_processor: $1 + service: kafka-broker + env: kafkatorio + #------------------------------------------------------------------------------------------------------- + # + # Broker / JVM + #------------------------------------------------------------------------------------------------------- + # JVM GarbageCollector + # + - pattern: 'java.lang<>CollectionCount' + name: kafka_jvm_gc_collection_count + labels: + name: $1 + service: kafka-broker + env: kafkatorio + + - pattern: 'java.lang<>CollectionTime' + name: kafka_jvm_gc_collection_time + labels: + name: $1 + service: kafka-broker + env: kafkatorio + + - pattern: java.lang + name: kafka_jvm_last_gc_duration + labels: + name: $1 + service: kafka-broker + env: kafkatorio + attrNameSnakeCase: true + + - pattern: 'java.lang(\w+)' + name: kafka_jvm_last_gc_memory_usage_$4 + labels: + name: $1 + space: $2 + type: $4 + service: kafka-broker + env: kafkatorio + attrNameSnakeCase: true + + # JVM Memory + - pattern: java.lang(\w*) + name: kafka_jvm_heap_usage + labels: + type: $1 + service: kafka-broker + env: kafkatorio + attrNameSnakeCase: true + + - pattern: java.lang(\w*) + name: kafka_jvm_non_heap_usage + labels: + type: $1 + service: kafka-broker + env: kafkatorio + attrNameSnakeCase: true + + - pattern: 'java.lang(\w*)' + name: kafka_jvm_memory_pool_collection_usage + labels: + name: $1 + type: $2 + service: kafka-broker + env: kafkatorio + - pattern: 'java.lang(\w*)' + name: kafka_jvm_memory_pool_usage + labels: + name: $1 + type: $2 + service: kafka-broker + env: kafkatorio + - pattern: 'java.lang(\w*)' + name: kafka_jvm_memory_pool_peak_usage + labels: + name: $1 + type: $2 + service: kafka-broker + env: kafkatorio + + # JVM Thread + - pattern: java.lang<>(\w*thread_count) + name: kafka_jvm_$1 + labels: + service: kafka-broker + env: kafkatorio + attrNameSnakeCase: true + + # Operating System + - pattern: java.lang<>(\w*) + name: kafka_jvm_os_$1 + labels: + service: kafka-broker + env: kafkatorio diff --git a/modules/infra-kafka-cluster/src/config/prometheus.yml b/modules/infra-kafka-cluster/src/config/prometheus.yml new file mode 100644 index 0000000..dae03d5 --- /dev/null +++ b/modules/infra-kafka-cluster/src/config/prometheus.yml @@ -0,0 +1,29 @@ +# my global config +global: + scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. + evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. + # scrape_timeout is set to the global default (10s). + +# Alertmanager configuration +alerting: + alertmanagers: + - static_configs: + - targets: + # - alertmanager:9093 + +# Load rules once and periodically evaluate them according to the global 'evaluation_interval'. +rule_files: +# - "first_rules.yml" +# - "second_rules.yml" + +# A scrape configuration containing exactly one endpoint to scrape: +# Here it's Prometheus itself. +scrape_configs: + # The job name is added as a label `job=` to any timeseries scraped from this config. + - job_name: 'kafka' + + # metrics_path defaults to '/metrics' + # scheme defaults to 'http'. + + static_configs: + - targets: [ 'jmx-kafka:5556' ] diff --git a/modules/infra-kafka-cluster/src/docker-compose.yml b/modules/infra-kafka-cluster/src/docker-compose.yml new file mode 100644 index 0000000..10764ad --- /dev/null +++ b/modules/infra-kafka-cluster/src/docker-compose.yml @@ -0,0 +1,99 @@ +version: "3.9" + +services: + + kafka: + image: ${REGISTRY_HOST}/${APP_GROUP}/${APP_NAME}:${KAFKATORIO_VERSION} + container_name: "kafka" + restart: "unless-stopped" + build: + dockerfile: "kafka.Dockerfile" + context: "." + target: "kafka-kraft" + args: + KAFKA_DL_URL: "https://dlcdn.apache.org/kafka/${KAFKA_VERSION}/kafka_2.13-${KAFKA_VERSION}.tgz" + volumes: + - "./kafka-server.properties:/kafka/server.properties" +# - "./kafka-data:/tmp/kraft-combined-logs" # see Dockerfile + environment: + JMX_PORT: "9991" + # KAFKA_JMX_OPTS: "9991" + KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka -Dcom.sun.management.jmxremote.rmi.port=9991" + + networks: + - "kafka-nw" + - "kafkatorio-nw" + ports: + # note: other Docker containers should use 29092 + - "9092:9092" + - "9093:9093" + + kafka-ui: + image: provectuslabs/kafka-ui:v0.4.0 + container_name: "kafka-ui" + restart: "unless-stopped" + networks: + - "kafka-nw" + - "traefik-nw" + labels: + - "traefik.enable=true" + ports: + - "18090:8080" + environment: + KAFKA_CLUSTERS_0_NAME: "${COMPOSE_PROJECT_NAME}" + KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: "kafka:29092" + + KAFKA_CLUSTERS_0_KAFKACONNECT_0_NAME: "kafkatorio-connect" + KAFKA_CLUSTERS_0_KAFKACONNECT_0_ADDRESS: "http://connect:8083" +# - KAFKA_CLUSTERS_0_ZOOKEEPER=kafka:9093 + +# grafana: +# image: "grafana/grafana:${GRAFANA_VERSION}" +# container_name: "grafana" +# ports: +# - "3000:3000" +# environment: +# GF_PATHS_DATA : /var/lib/grafana +# GF_SECURITY_ADMIN_PASSWORD : kafka +# volumes: +# - "./config/grafana/provisioning:/etc/grafana/provisioning" +# - "./config/grafana/dashboards:/var/lib/grafana/dashboards" +# depends_on: +# - prometheus +# networks: +# - "kafka-nw" +# +# prometheus: +# image: "prom/prometheus:${PROMETHEUS_VERSION}" +# container_name: "prometheus" +# ports: +# - "9090:9090" +# volumes: +# - "./config/prometheus.yml:/etc/prometheus/prometheus.yml" +# command: "--config.file=/etc/prometheus/prometheus.yml" +# networks: +# - "kafka-nw" +# +# jmx-kafka: +# image: "sscaling/jmx-prometheus-exporter" +# container_name: "jmx-kafka" +# ports: +# - "5556:5556" +# environment: +# CONFIG_YML : "/etc/jmx_exporter/config.yml" +## JVM_OPTS: "-XX:MaxRAMPercentage=70.0" +# volumes: +# - "./config/jmx_exporter_kafka_broker.yml:/etc/jmx_exporter/config.yml" +# depends_on: +# - kafka +# networks: +# - "kafka-nw" + +networks: + kafka-nw: + name: "kafka-nw" + kafkatorio-nw: + name: "kafkatorio-nw" + traefik-nw: + name: "traefik-nw" + external: true diff --git a/modules/infra-kafka-cluster/src/entrypoint.sh b/modules/infra-kafka-cluster/src/entrypoint.sh new file mode 100644 index 0000000..7caa39e --- /dev/null +++ b/modules/infra-kafka-cluster/src/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Format storage directories +./bin/kafka-storage.sh format \ + --ignore-formatted \ + --config ./server.properties \ + --cluster-id "$(cat cluster_id)" + +./bin/kafka-server-start.sh ./server.properties diff --git a/modules/infra-kafka-cluster/src/kafka-server.properties b/modules/infra-kafka-cluster/src/kafka-server.properties new file mode 100644 index 0000000..dd3de1f --- /dev/null +++ b/modules/infra-kafka-cluster/src/kafka-server.properties @@ -0,0 +1,130 @@ +# This configuration file is intended for use in KRaft mode, where +# Apache ZooKeeper is not present. See config/kraft/README.md for details. + +############################# Server Basics ############################# + +# The role of this server. Setting this puts us in KRaft mode +process.roles=broker,controller + +# The node id associated with this instance's roles +node.id=1 + +# The connect string for the controller quorum +controller.quorum.voters=1@localhost:9093 + +############################# Socket Server Settings ############################# + +# The address the socket server listens on. It will get the value returned from +# java.net.InetAddress.getCanonicalHostName() if not configured. +# FORMAT: +# listeners = listener_name://host_name:port +# EXAMPLE: +# listeners = PLAINTEXT://your.host.name:9092 +#listeners=PLAINTEXT://:9092,CONTROLLER://:9093 +#listeners=PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092,CONTROLLER://localhost:9093 +listeners=PLAINTEXT://:29092,PLAINTEXT_HOST://:9092,CONTROLLER://:9093 + +inter.broker.listener.name=PLAINTEXT +#KAFKA_INTER_BROKER_LISTENER_NAME: "PLAINTEXT" + +# Hostname and port the broker will advertise to producers and consumers. If not set, +# it uses the value for "listeners" if configured. Otherwise, it will use the value +# returned from java.net.InetAddress.getCanonicalHostName(). +#advertised.listeners=PLAINTEXT://localhost:9092 +advertised.listeners=PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092 + +# Listener, host name, and port for the controller to advertise to the brokers. If +# this server is a controller, this listener must be configured. +controller.listener.names=CONTROLLER + +# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details +#listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL +listener.security.protocol.map=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT +# ,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL + +# The number of threads that the server uses for receiving requests from the network and sending responses to the network +num.network.threads=3 + +# The number of threads that the server uses for processing requests, which may include disk I/O +num.io.threads=8 + +# The send buffer (SO_SNDBUF) used by the socket server +socket.send.buffer.bytes=102400 + +# The receive buffer (SO_RCVBUF) used by the socket server +socket.receive.buffer.bytes=102400 + +# The maximum size of a request that the socket server will accept (protection against OOM) +socket.request.max.bytes=104857600 + + +############################# Log Basics ############################# + +# A comma separated list of directories under which to store log files +log.dirs=/tmp/kraft-combined-logs + +# The default number of log partitions per topic. More partitions allow greater +# parallelism for consumption, but this will also result in more files across +# the brokers. +num.partitions=3 + +# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown. +# This value is recommended to be increased for installations with data dirs located in RAID array. +num.recovery.threads.per.data.dir=1 + +############################# Internal Topic Settings ############################# +# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state" +# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3. +offsets.topic.replication.factor=1 +transaction.state.log.replication.factor=1 +transaction.state.log.min.isr=1 + +############################# Log Flush Policy ############################# + +# Messages are immediately written to the filesystem but by default we only fsync() to sync +# the OS cache lazily. The following configurations control the flush of data to disk. +# There are a few important trade-offs here: +# 1. Durability: Unflushed data may be lost if you are not using replication. +# 2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush. +# 3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks. +# The settings below allow one to configure the flush policy to flush data after a period of time or +# every N messages (or both). This can be done globally and overridden on a per-topic basis. + +# The number of messages to accept before forcing a flush of data to disk +#log.flush.interval.messages=10000 + +# The maximum amount of time a message can sit in a log before we force a flush +#log.flush.interval.ms=1000 + +############################# Log Retention Policy ############################# + +# The following configurations control the disposal of log segments. The policy can +# be set to delete segments after a period of time, or after a given size has accumulated. +# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens +# from the end of the log. + +# The minimum age of a log file to be eligible for deletion due to age +log.retention.hours=168 + +# A size-based retention policy for logs. Segments are pruned from the log unless the remaining +# segments drop below log.retention.bytes. Functions independently of log.retention.hours. +#log.retention.bytes=1073741824 + +# The maximum size of a log segment file. When this size is reached a new log segment will be created. +log.segment.bytes=1073741824 + +# The interval at which log segments are checked to see if they can be deleted according +# to the retention policies +log.retention.check.interval.ms=300000 + +### Compression ### +#compression.type=snappy +#linger.ms=5 + + +### record size ### +message.max.bytes=10485760 +replica.fetch.max.bytes=10485760 + +#log.cleanup.policy=compact +#auto.create.topics.enable=false diff --git a/modules/infra-kafka-cluster/src/kafka.Dockerfile b/modules/infra-kafka-cluster/src/kafka.Dockerfile new file mode 100644 index 0000000..0a5e1b7 --- /dev/null +++ b/modules/infra-kafka-cluster/src/kafka.Dockerfile @@ -0,0 +1,44 @@ +# syntax=docker/dockerfile:1 + +ARG KAFKA_DL_URL=https://dlcdn.apache.org/kafka/3.1.0/kafka_2.13-3.1.0.tgz + +## builder ## +FROM debian:11-slim as Kafka-Download +ARG KAFKA_DL_URL + +WORKDIR /kafka + +RUN apt-get update && apt-get install -y \ + curl \ + && rm -rf /var/lib/apt/lists/* + +RUN echo "Downloading Kafka from $KAFKA_DL_URL" \ + && curl "$KAFKA_DL_URL" | tar --strip-components=1 -xz \ + && echo "Finished Kafka download" \ + && ls -la + + +## Kafka ## +# KRaft (aka KIP-500) mode Preview Release +# https://github.com/apache/kafka/blob/041b76dc57f096be2a2d7532d917122992bff6e2/config/kraft/README.md +FROM openjdk:11 as kafka-kraft + +WORKDIR /kafka + +COPY --from=Kafka-Download /kafka . + +# hardcoded for now, based on values from './config/kraft/server.properties' +# log.dirs +VOLUME /tmp/kraft-combined-logs +# listeners, controller.quorum.voters +EXPOSE 9092 9093 + +# Generate a cluster ID (must use this .sh to generate a UUID) +RUN ./bin/kafka-storage.sh random-uuid > cluster_id \ + && echo "Generated a Kafka Cluster ID: $(cat cluster_id)" + +COPY ./kafka-server.properties ./server.properties +COPY --chmod=755 ./entrypoint.sh ./entrypoint.sh + +# launch the broker in KRaft mode, which means that it runs without ZooKeeper +ENTRYPOINT ["/kafka/entrypoint.sh"] diff --git a/modules/infra-kafka-pipe/build.gradle.kts b/modules/infra-kafka-pipe/build.gradle.kts new file mode 100644 index 0000000..e0380dd --- /dev/null +++ b/modules/infra-kafka-pipe/build.gradle.kts @@ -0,0 +1,17 @@ +plugins { + id("kafkatorio.conventions.base") + id("dev.adamko.geedeecee") +} + +description = "Send events from a Factorio server to a Kafka topic " + + +geedeecee { + srcDir.set(layout.projectDirectory.dir("src")) +} + +//val dockerSrcDir: Directory by extra + +tasks.dockerComposeUp { + dependsOn(":modules:infra-kafka-cluster:dockerUp") +} diff --git a/modules/infra-kafka-pipe/readme.md b/modules/infra-kafka-pipe/readme.md new file mode 100644 index 0000000..64f2ed8 --- /dev/null +++ b/modules/infra-kafka-pipe/readme.md @@ -0,0 +1,52 @@ +### Setup notes + +Kafka must be connectable from both `localhost` (for cli) and `kafa` (the docker container name). + +### Useful commands + +#### Powershell + +```shell +# might help with mounting the unix socket on Windows? +$Env:COMPOSE_CONVERT_WINDOWS_PATHS=1 + +# full rebuild +docker-compose down; docker-compose build; docker-compose up -d; docker-compose logs -f + +``` + +#### zsh + +```shell +# listen to events from factorio-server +docker logs --tail 0 -f factorio-server | sed -n -e 's/^FactorioEvent: //p' + +# tail logs with docker api (except it doesn't work) +curl -vvv \ + --unix-socket /var/run/docker.sock \ + --no-buffer \ + --header "Connection: Upgrade" \ + --header "Upgrade: websocket" \ + --header "Host: localhost:80" \ + --header "Origin: http://localhost:80" \ + --header "Sec-WebSocket-Version: 13" \ + --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \ + "http://localhost:80/v1.41/containers/factorio-server/attach/ws?stream=true&logs=true&stdout=true" + +# tail logs +curl --no-buffer -sS --unix-socket /var/run/docker.sock \ + --get --data-urlencode 'filters={"container":["my-service"]}' \ + "http://localhost/v1.41/events" | jq --unbuffered + +# get logs from Kafka +kafkacat -u -C -b localhost -t factorio-server-log | jq --unbuffered + +# stream logs, and try trimming first 8 bytes (the header) but it doesn't work +curl \ + -sS \ + --unix-socket /var/run/docker.sock \ + -X POST \ + --insecure "http://localhost/v1.41/containers/factorio-server/attach?logs=true&stream=true&stdout=true&follow=true" | + tail -c+9 + +``` diff --git a/modules/infra-kafka-pipe/src/docker-compose.yml b/modules/infra-kafka-pipe/src/docker-compose.yml new file mode 100644 index 0000000..a564e8a --- /dev/null +++ b/modules/infra-kafka-pipe/src/docker-compose.yml @@ -0,0 +1,36 @@ +version: "3.9" + +services: + kafka-pipe: + image: ${REGISTRY_HOST}/${APP_GROUP}/${APP_NAME}:${KAFKATORIO_VERSION} + container_name: ${APP_NAME} + build: + dockerfile: "kafka-pipe.Dockerfile" + context: "." + args: + APP_NAME: ${APP_NAME} + restart: "unless-stopped" + privileged: true + networks: + - "kafkatorio-nw" + environment: + KAFKATORIO_VERSION: $KAFKATORIO_VERSION + # message IDs + INSTANCE_ID: "test-server" + # name of the docker container + FACTORIO_SERVER_CONTAINER_NAME: "factorio-server" + KAFKA_HOST: "kafka:29092" + volumes: + # Windows (requires privileged/root) + - "//var/run/docker.sock:/var/run/docker.sock" + + # Rootless: +# - "/run/user/1000/docker.sock:/var/run/docker.sock" + + # Unix? + # - "/var/run/docker.sock:/var/run/docker.sock" + +networks: + kafkatorio-nw: + name: "kafkatorio-nw" + external: true diff --git a/modules/infra-kafka-pipe/src/kafka-pipe.Dockerfile b/modules/infra-kafka-pipe/src/kafka-pipe.Dockerfile new file mode 100644 index 0000000..2b6b849 --- /dev/null +++ b/modules/infra-kafka-pipe/src/kafka-pipe.Dockerfile @@ -0,0 +1,18 @@ +# syntax=docker/dockerfile:1 + +FROM docker:dind-rootless + +ENV FACTORIO_SERVER_CONTAINER_NAME="factorio-server" +ENV KAFKA_HOST="kafka" + +# root is required for installing dependencies and +# using the docker socket (listening to logs) +USER root +RUN apk add --update \ + curl \ + kcat +#USER rootless + +COPY kafka-pipe.sh kafka-pipe.sh + +ENTRYPOINT [ "/bin/sh", "/kafka-pipe.sh" ] diff --git a/modules/infra-kafka-pipe/src/kafka-pipe.sh b/modules/infra-kafka-pipe/src/kafka-pipe.sh new file mode 100644 index 0000000..3c16fe8 --- /dev/null +++ b/modules/infra-kafka-pipe/src/kafka-pipe.sh @@ -0,0 +1,37 @@ +#!/usr/bin/bash + +# Pipe Docker logs from a Factorio server to a Kafka topic + +echo "Kafkatorio-Pipe version $KAFKATORIO_VERSION" +echo "Piping logs from $FACTORIO_SERVER_CONTAINER_NAME to $KAFKA_HOST" + +trap endProcess SIGINT +endProcess() { + echo "Exiting Factorio Events Kafka Pipe" + exit +} + +# some random ID, to use as a message key +#INSTANCE_ID="${INSTANCE_ID}"$(cat /proc/sys/kernel/random/uuid) +KEY="${INSTANCE_ID:-none}" + +while :; do + docker logs --tail 0 -f "$FACTORIO_SERVER_CONTAINER_NAME" | + sed -n -e 's/^KafkatorioPacket::://p' | + kcat -P \ + -b "$KAFKA_HOST" \ + -t kafkatorio.src.server-log \ + -k "$KEY" \ + -H "KAFKA-PIPE-VERSION=$KAFKATORIO_VERSION" +# -T \ + +# -P producer mode +# -T echo to stdout +# -t the topic name +# -k the key of the message +# -H add a header + + echo "Error - retrying in 10 seconds" + sleep 10 + +done diff --git a/modules/kt-rcon/build.gradle.kts b/modules/kt-rcon/build.gradle.kts new file mode 100644 index 0000000..c25f5b7 --- /dev/null +++ b/modules/kt-rcon/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + id("kafkatorio.conventions.lang.kotlin-jvm") +} + +dependencies { + implementation(platform(projects.modules.versionsPlatform)) + + implementation(libs.kotlinx.coroutines.core) + + implementation("io.ktor:ktor-network") +} diff --git a/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient.kt b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient.kt new file mode 100644 index 0000000..93f5672 --- /dev/null +++ b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient.kt @@ -0,0 +1,116 @@ +package dev.adamko.ktrcon + +import java.net.Socket +import kotlin.random.Random +import kotlin.random.nextUInt +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel +import kotlinx.coroutines.flow.asFlow +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.supervisorScope +import kotlinx.coroutines.withContext + +class KtRconClient( + private val host: String, + private val port: Int, + private val password: Password, +) : AutoCloseable { + + private val rconClientScope = CoroutineScope(SupervisorJob()) + + private val socket: Socket = Socket(host, port) + + init { + + runBlocking { + send(PacketType.AUTH_REQUEST, password()) + } + + require(socket.isConnected) { "Socket must connect" } + + println("socket.isConnected: ${socket.isConnected}") + +// val j = rconClientScope.launch { + + runCatching { + val reader = socket.getInputStream() + .bufferedReader() + .lineSequence() + .asFlow() + .onEach { + println("socket response: [$it]") + } + .launchIn(rconClientScope) + +// while (socket.isConnected) { +// println("response: ${input.read().toByte().toInt().toChar()}") + + println("is listener active? ${reader.isActive}") + + reader.invokeOnCompletion { + println("cancelled input stream job") + } + + } +// } +// yield() +// } +// } + + + } + + suspend fun send(type: PacketType, body: String) = supervisorScope { + + val p = Packet(Random.nextUInt(), type, body) + + println("Sending packet: $p - totalSize: ${p.totalSize}") + println("p.size: ${p.size}") + println("p.id: ${p.id}") + println("p.type.value: ${p.type.value}") +// println("p.bodyBytes: ${p.bodyBytes} / ${p.body}") +// println("p.terminator: ${p.terminator} / ${p.terminator.decodeToString()}") + +// println("p.byteArray: ${p.toByteArray()}") + + val bb = p.toByteBuffer2() +// ByteBuffer.wrap(p.toByteArray()) +// bb.order(ByteOrder.LITTLE_ENDIAN) + +// val bb = ByteBuffer.allocate(p.totalSize * 2).apply { +// order(ByteOrder.LITTLE_ENDIAN) +// putInt(p.size) +// putInt(p.id.toInt()) +// putInt(p.type.value) +// put(p.bodyBytes) +// put(p.terminator) +// } + + withContext(Dispatchers.IO) { + socket.getOutputStream().use { os -> + os.write(bb.array()) + os.flush() + } + } +// socket.channel.finishConnect() +// socket.getInputStream().use { input -> +// println("running inputddd") +//// while (true) { +// println("response: ${input.readAllBytes().decodeToString()}") +// +//// yield() +//// } +// } + } + + override fun close() { + rconClientScope.cancel("Closing ${this::class}") + socket.close() + } + + +} diff --git a/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient2.kt b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient2.kt new file mode 100644 index 0000000..d74447d --- /dev/null +++ b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient2.kt @@ -0,0 +1,89 @@ +package dev.adamko.ktrcon + +import java.net.InetSocketAddress +import java.nio.ByteBuffer +import java.nio.channels.AsynchronousSocketChannel +import kotlin.random.Random +import kotlin.random.nextUInt +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel +import kotlinx.coroutines.delay +import kotlinx.coroutines.supervisorScope + +class KtRconClient2( + private val host: String, + private val port: Int, + private val password: Password, +) : AutoCloseable { + + private val rconClientScope = CoroutineScope(SupervisorJob()) + + private val client: AsynchronousSocketChannel by lazy { + println("Initialising client") + + val client = AsynchronousSocketChannel.open() + val address = InetSocketAddress(host, port) + val result = client.connect(address) + result.get() //.get(2, TimeUnit.SECONDS) + + println("connected to async - $address") + require(client.isOpen) { "Require client is open" } + + client + } + + init { + } + + suspend fun send(type: PacketType, body: String) = supervisorScope { + + val p = Packet(Random.nextUInt(1u..100u), type, body) + + println("Sending packet: $p - totalSize: ${p.totalSize}") + println("p.size: ${p.size}") + println("p.totalSize: ${p.totalSize}") + println("p.id: ${p.id}") + println("p.type.value: ${p.type.value}") +// println("p.bodyBytes: ${p.bodyBytes} / ${p.body}") +// println("p.terminator: ${p.terminator} / ${p.terminator.decodeToString()}") + +// println("p.byteArray: ${p.toByteArray()}") +// println("p.byteArray: ${p.toByteBuffer().array()}") + + + runCatching { + val bb = p.toByteBuffer2() +// ByteBuffer.wrap(p.toByteArray()) +// bb.order(ByteOrder.LITTLE_ENDIAN) + + println("writing bb to client") + + val future = client.write(bb) + + delay(2000) + + val writeResult = future.get() //.get(2, TimeUnit.SECONDS) + delay(2000) + + println("write result: $writeResult") + + + val response = ByteBuffer.allocate(Int.SIZE_BYTES) + val responseStatus = runCatching { + client.read(response).get() //.get(2, TimeUnit.SECONDS) + } + println("responseStatus: $responseStatus") + println("response from server: ${response.array().decodeToString()}") + delay(2000) + } + + } + + override fun close() { + rconClientScope.cancel("Closing ${this::class}") + client.shutdownInput() + client.close() + } + +} diff --git a/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient3.kt b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient3.kt new file mode 100644 index 0000000..04fa2d4 --- /dev/null +++ b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/KtRconClient3.kt @@ -0,0 +1,111 @@ +package dev.adamko.ktrcon + +import io.ktor.network.selector.ActorSelectorManager +import io.ktor.network.sockets.InetSocketAddress +import io.ktor.network.sockets.aSocket +import io.ktor.network.sockets.openReadChannel +import io.ktor.network.sockets.openWriteChannel +import io.ktor.utils.io.ByteReadChannel +import io.ktor.utils.io.ByteWriteChannel +import io.ktor.utils.io.core.isNotEmpty +import io.ktor.utils.io.core.readBytes +import kotlin.random.Random +import kotlin.random.nextUInt +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.supervisorScope +import kotlinx.coroutines.yield + +class KtRconClient3( + private val host: String, + private val port: Int, + private val password: Password, +) : AutoCloseable { + + private val rconClientJob = SupervisorJob() + private val rconClientScope = CoroutineScope(rconClientJob) + + private val input: ByteReadChannel + private val output: ByteWriteChannel + + init { + val socket = runBlocking { + val selector = ActorSelectorManager(rconClientJob) + aSocket(selector) + .tcp() + .connect(InetSocketAddress(host, port)) + } + input = socket.openReadChannel() + output = socket.openWriteChannel() + +// runBlocking { +// output.writeStringUtf8("test") +// output.flush() +// delay(1000) +// println("availableForRead: ${input.availableForRead}") +// +// } + + rconClientScope.launch { + while (!input.isClosedForRead) { + val packet = input.readRemaining(1) + while (packet.isNotEmpty) { + val bytes = packet.readBytes() + println( + "received ${bytes.size} bytes: ${bytes.joinToString { "$it" }} - ${bytes.decodeToString()}" + ) + yield() + } + yield() + } + } + } + + suspend fun send(type: PacketType, body: String) = supervisorScope { + + val p = Packet(Random.nextUInt(1u..100u), type, body) + + println("Sending packet: $p - totalSize: ${p.totalSize}") + println("p.size: ${p.size}") + println("p.totalSize: ${p.totalSize}") + println("p.id: ${p.id}") + println("p.type.value: ${p.type.value}") +// println("p.bodyBytes: ${p.bodyBytes} / ${p.body}") +// println("p.terminator: ${p.terminator} / ${p.terminator.decodeToString()}") + +// println("p.byteArray: ${p.toByteArray()}") + println("p.byteArray: ${p.toByteBuffer2().array().joinToString { it.toString() }}") + + + val bb = p.toByteBuffer2() + println("bb: ${bb.position()} - ${bb.toString()}") + + bb.array().forEach { + print("-$it") + output.writeByte(it) + } +// output.writeFully(bb) +// output.writeFully(bb) + output.flush() + println("finished writing") + +// if (type == PacketType.EXEC_COMMAND) { +// println("awaiting response from server") +// input.read(0) { +// println("server response: ${it.array()}") +// } +//// val response = input.readUTF8Line() +//// println("Server said $response") +// } + + } + + override fun close() { + rconClientJob.complete() + rconClientScope.cancel("Closing ${this::class}") + } + +} diff --git a/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/Packet.kt b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/Packet.kt new file mode 100644 index 0000000..eacc965 --- /dev/null +++ b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/Packet.kt @@ -0,0 +1,151 @@ +package dev.adamko.ktrcon + +import java.nio.ByteBuffer +import java.nio.ByteOrder + + +/** + * @param[size] The packet size field is a 32-bit little endian integer, representing the length of the + * request in bytes. Note that the packet size field itself is not included when determining the + * size of the packet, so the value of this field is always 4 less than the packet's actual + * length. + * + * The minimum possible value for packet size is 10. The maximum possible value of packet size + * is 4096. If the response is too large to fit into one packet, it will be split and sent as + * multiple packets. + * + * @param[id] The packet id field is a 32-bit little endian integer chosen by the client for each + * request. It may be set to any positive integer. When the server responds to the request, the + * response packet will have the same packet id as the original request (unless it is a failed + * [PacketType.AUTH_RESPONSE] packet.) It need not be unique, but if a unique packet id is + * assigned, it can be used to match incoming responses to their corresponding requests. + * + * @param[type] See [PacketType] + * + * @param[body] The packet body field is a null-terminated string encoded in ASCII (i.e. ASCIIZ). + * Depending on the packet type, it may contain either the RCON password for the server, the command + * to be executed, or the server's response to a request. + */ +data class Packet( + val id: UInt, + val type: PacketType, + val bodyRaw: String, +) { + private val bodyTerminator: Byte = NULL_CHAR_BYTE + + private val body: ByteArray = bodyRaw.toByteArray(Charsets.UTF_8) + +// val bodyBytes = body.toByteArray(Charsets.UTF_8) + /** The size of this packet (note that the size itself is excluded from the calculation.) */ + val size: Int = run { + val idSize = 1 * Int.SIZE_BYTES + val typeSize = 1 * Int.SIZE_BYTES + val bodySize = body.size * Byte.SIZE_BYTES + val bodyTerminatorSize = 1 * Byte.SIZE_BYTES + val packetTerminatorSize = 1 * Byte.SIZE_BYTES + val total = idSize + typeSize + bodySize + bodyTerminatorSize + packetTerminatorSize + println( + "packetSize: $total = $idSize + $typeSize + $bodySize + $bodyTerminatorSize + $packetTerminatorSize" + ) + + total + } + + val totalSize: Int = size + Int.SIZE_BYTES + + init { + println("totalSize: $totalSize") + println("body: ${body.joinToString { it.toString() }}") + } + +// fun toByteArray(): ByteArray { +// val array = buildList { +// add(this@Packet.size.toByte()) +// add(id.toByte()) +// add(type.value.toByte()) +// addAll(body.toByteArray(Charsets.UTF_8).asIterable()) +// add(bodyTerminator) +// add(RCON_PACKET_TERMINATOR) +// }.toByteArray() +// +// println(array.joinToString { it.toInt().toChar().toString().padStart(3, ' ') }) +// println(array.joinToString { it.toInt().toString().padStart(3, ' ') }) +// println(array.joinToString { it.toUInt().toString().padStart(3, ' ') }) +// println(array.joinToString { it.toString().padStart(3, ' ') }) +// +//// require(array.size == totalSize) { "${array.size} == $totalSize" } +// return array +// } + + fun toByteBuffer2(): ByteBuffer { + + return ByteBuffer + .allocate(totalSize) + .order(ByteOrder.LITTLE_ENDIAN) + // size + .putInt(size) + // ID + .putInt(id.toInt()) + // type + .putInt(type.value) + // body + .put(body) + // body terminator + .put(bodyTerminator) + // packet terminator + .put(RCON_PACKET_TERMINATOR) +// .asReadOnlyBuffer() + + + } + +// fun toByteBuffer(): ByteBuffer { +// +// +// val bodyBA = buildList { +// add(id.toByte()) +// add(type.value.toByte()) +// addAll(bodyBytes.asIterable()) +// add(bodyTerminator) +// add(RCON_PACKET_TERMINATOR) +// }.toByteArray() +//// +//// +//// val body = ByteBuffer.allocate(totalSize + 15).apply { +//// order(ByteOrder.LITTLE_ENDIAN) +////// putInt(this@Packet.size) +//// putInt(this@Packet.id.toInt()) +//// putInt(this@Packet.type.value) +//// put(this@Packet.bodyBytes) +//// put(this@Packet.terminator) +//// } +// +// val bodySize = bodyBA.size //* Byte.SIZE_BYTES +// println("bodySize: $bodySize") +// +// val bb = ByteBuffer.allocate(bodySize + Int.SIZE_BYTES).apply { +// order(ByteOrder.LITTLE_ENDIAN) +// putInt(bodySize) +//// put(body.array()) +// put(bodyBA) +// } +// +// require( +// bb.array().size == totalSize) { "${bb.array().size} == $totalSize ($size + ${Int.SIZE_BYTES})" } +// +// return bb +// } + + companion object { + /** [Char.MIN_VALUE] = null char */ + const val NULL_CHAR_BYTE = Char.MIN_VALUE.code.toByte() + + /** + * The end of a Source RCON Protocol packet is marked by an empty ASCIIZ string - + * essentially just 8 bits of 0. In languages that do not null-terminate strings automatically, + * you can simply write 16 bits of 0 immediately after the packet body (8 to terminate the + * packet body and 8 for the empty string afterwards). + */ + const val RCON_PACKET_TERMINATOR = NULL_CHAR_BYTE + } +} diff --git a/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/PacketType.kt b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/PacketType.kt new file mode 100644 index 0000000..f2878a1 --- /dev/null +++ b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/PacketType.kt @@ -0,0 +1,31 @@ +package dev.adamko.ktrcon +/** + * The packet type field is a 32-bit little endian integer, which indicates the purpose of the + * packet. Its value will always be either 0, 2, or 3, depending on which of the request/response + * types the packet represents. + */ +enum class PacketType( + val value: Int, + val descriptor: String, +) { + + /** + * Typically, the first packet sent by the client will be a [AUTH_RESPONSE] packet, which is + * used to authenticate the connection with the server. + * + * The value of the packet's fields are as follows: + * + * * **ID** - any positive integer, chosen by the client + * (will be mirrored back in the server's response) + * * **Type** - 3 + * * **Body** - the RCON password of the server (if this matches the server's *rcon_password* + * cvar, the auth will succeed) + * + * If the rcon_password cvar is not set, or if it is set to empty string, all + * [AUTH_RESPONSE] requests will be refused. + */ + AUTH_REQUEST(3, "SERVERDATA_AUTH"), + AUTH_RESPONSE(2, "SERVERDATA_AUTH_RESPONSE"), + EXEC_COMMAND(2, "SERVERDATA_EXECCOMMAND"), + RESPONSE_VALUE(0, "SERVERDATA_RESPONSE_VALUE"), +} diff --git a/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/Password.kt b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/Password.kt new file mode 100644 index 0000000..8b8b9b2 --- /dev/null +++ b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/Password.kt @@ -0,0 +1,16 @@ +package dev.adamko.ktrcon + +class Password constructor(password: String) { + private val password: ByteArray = password.encodeToByteArray() + private val hashcode: Int = password.hashCode() + + operator fun invoke() = password.decodeToString() + + fun access(accessor: (password: String) -> Unit) { + accessor(password.decodeToString()) + } + + override fun equals(other: Any?) = (other as? Password)?.hashcode == this.hashcode + + override fun hashCode() = hashcode +} \ No newline at end of file diff --git a/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/main.kt b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/main.kt new file mode 100644 index 0000000..0852797 --- /dev/null +++ b/modules/kt-rcon/src/main/kotlin/dev/adamko/ktrcon/main.kt @@ -0,0 +1,22 @@ +package dev.adamko.ktrcon + +import kotlin.time.Duration.Companion.seconds +import kotlinx.coroutines.delay +import kotlinx.coroutines.runBlocking + +fun main(): Unit = runBlocking { + KtRconClient3( + "localhost", + 27015, + Password("chofeengook8Shu") + ).use { client -> + +// client.send(PacketType.AUTH_REQUEST, "passwrd") + client.send(PacketType.AUTH_REQUEST, "chofeengook8Shu") + delay(10.seconds) + + client.send(PacketType.EXEC_COMMAND, "/help") + + delay(10.seconds) + } +} diff --git a/modules/modules.md b/modules/modules.md new file mode 100644 index 0000000..de6bd3d --- /dev/null +++ b/modules/modules.md @@ -0,0 +1,36 @@ +```mermaid +flowchart TD + +events-library-->events-processors & events-mod & web-map & events-server-web + +kafka[(Kafka)] + + +events-mod-->infra-factorio-client + + +subgraph Kafka Workers +events-processor-core --> events-processor-syslog & events-processors +end + +kafka<==>events-processors + +subgraph infra +subgraph factorio +infra-factorio-client<-->infra-factorio-server +end +infra-factorio-server-->infra-kafka-pipe +infra-kafka-pipe-->kafka +infra-kafka-cluster-->kafka +end + +kafka-->events-server-web + +events-server-web-->web-map + +versions-platform + +subgraph experiments +kt-rcon +end +``` diff --git a/modules/versions-platform/build.gradle.kts b/modules/versions-platform/build.gradle.kts new file mode 100644 index 0000000..7368657 --- /dev/null +++ b/modules/versions-platform/build.gradle.kts @@ -0,0 +1,44 @@ +plugins { + id("kafkatorio.conventions.base") + `java-platform` +} + + +javaPlatform { + allowDependencies() +} + + +dependencies { + api(platform(libs.kotlin.bom)) + api(platform(libs.kotlinx.coroutines.bom)) + api(platform(libs.kotlinxSerialization.bom)) + api(platform(libs.kotlin.jsWrappers.bom)) + + + api(platform(libs.http4k.bom)) + + api(platform(libs.okio.bom)) + + api(platform(libs.ktor.bom)) + + api(platform(libs.kotest.bom)) + + constraints { + api(libs.kafka.kotkaStreams) + api(libs.kafka.streams) + api(libs.kafka.streamsTestUtils) + + api(libs.kotlinxSerialization.charleskornKaml) + api(libs.kotlinxSerialization.mamoeYamlkt) + api(libs.kotlinxSerialization.kxsTsGen) + + api(libs.okio.core) + + api(libs.scrimage.core) + + api(libs.skrapeit) + + api(libs.mockk) + } +} diff --git a/modules/web-map/.gettext.json b/modules/web-map/.gettext.json new file mode 100644 index 0000000..796d539 --- /dev/null +++ b/modules/web-map/.gettext.json @@ -0,0 +1,39 @@ +{ + "js": { + "parsers": [ + { + "expression": "tr", + "arguments": { + "text": 0 + } + }, + { + "expression": "ntr", + "arguments": { + "text": 0, + "textPlural": 1 + } + }, + { + "expression": "gettext", + "arguments": { + "text": 0 + } + }, + { + "expression": "ngettext", + "arguments": { + "text": 0, + "textPlural": 1 + } + } + ], + "glob": { + "pattern": "src/**/*.kt" + } + }, + "headers": { + "Language": "" + }, + "output": "src/main/resources/i18n/messages.pot" +} diff --git a/modules/web-map/.gitignore b/modules/web-map/.gitignore new file mode 100644 index 0000000..b1959ee --- /dev/null +++ b/modules/web-map/.gitignore @@ -0,0 +1,8 @@ +.*/ +build/ +out/ +/refresh.sh +*.imp +*.ipr +*.iws +*.idea diff --git a/modules/web-map/build.gradle.kts b/modules/web-map/build.gradle.kts new file mode 100644 index 0000000..e8175a8 --- /dev/null +++ b/modules/web-map/build.gradle.kts @@ -0,0 +1,152 @@ +import io.kvision.gradle.KVisionPlugin +import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler +import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig + + +plugins { + id("kafkatorio.conventions.lang.kotlin-js") + id("io.kvision") + kotlin("plugin.serialization") + id("dev.adamko.geedeecee") +} + + +kvision { + enableHiddenKotlinJsStore.set(false) +} + + +kotlin { + js(IR) { + browser { + binaries.executable() + + runTask { + outputFileName = "main.bundle.js" + sourceMaps = false + devServer = KotlinWebpackConfig.DevServer( + open = false, + port = 3000, + proxy = mutableMapOf( + "/kafkatorio/data/servers" to mapOf( + "target" to "http://localhost:12080", + "secure" to false, + "changeOrigin" to true, + ), + "/kafkatorio/ws" to mapOf( + "target" to "ws://localhost:12080", + "ws" to true, + ), + ), + static = mutableListOf("$buildDir/processedResources/js/main") + ) + } + webpackTask { + outputFileName = "main.bundle.js" + } + testTask { + useKarma { + useChromeHeadless() + } + } + } + } + + sourceSets { + + configureEach { + languageSettings { + optIn("kotlin.RequiresOptIn") + optIn("kotlinx.serialization.ExperimentalSerializationApi") + } + } + + + main { + dependencies { + implementation(dependencies.platform(projects.modules.versionsPlatform)) + + implementation(libs.kotlinx.coroutines.core) + + implementation(projects.modules.eventsLibrary) + + implementation(libs.kotlinx.html) + + implementation(libs.kotlinx.nodejs) + implementation(libs.kotlinx.html) + + implementation(kvision()) + implementation(kvision("bootstrap")) + implementation(kvision("bootstrap-css")) + implementation(kvision("bootstrap-icons")) + implementation(kvision("fontawesome")) + implementation(kvision("state")) + implementation(kvision("chart")) + implementation(kvision("maps")) + implementation(kvision("rest")) + implementation(kvision("redux")) + implementation(kvision("state-flow")) + implementation(kvision("routing-navigo-ng")) + } + + resources.srcDir("src/main/web") + } + + + test { + dependencies { + implementation(kotlin("test")) + + implementation(kvision("testutils")) + // implementation(npm("karma", "^6.3.16")) + } + } + } +} + + +@Suppress("UnusedReceiverParameter") // just for scoping - this function doesn't need to be used everywhere +fun KotlinDependencyHandler.kvision( + module: String? = null, + version: Provider = libs.versions.kvision, +): String { + val prefixedModule = if (module == null) "kvision" else "kvision-$module" + return "io.kvision:$prefixedModule:${version.get()}" +} + + +val installBootstrapThemeCss by tasks.registering(Copy::class) { + group = KVisionPlugin.KVISION_TASK_GROUP + val bootswatchThemeMinCss = resources.text.fromUri( + libs.versions.npm.bootswatch.map { bootswatch -> + "https://cdn.jsdelivr.net/npm/bootswatch@$bootswatch/dist/darkly/bootstrap.min.css" + } + ) + from(bootswatchThemeMinCss) { + rename { "bootstrap.min.css" } + } + into(layout.projectDirectory.dir("src/main/resources/css")) +} + + +tasks.withName("processResources").configureEach { + dependsOn(installBootstrapThemeCss) +} + + +val runWebMap by tasks.registering { + group = rootProject.name + + dependsOn(tasks.withName("browserDevelopmentRun")) +} + + +tasks.zip { + dependsOn(tasks.withName("browserWebpack")) + from(layout.buildDirectory.dir("distributions")) +} + + +tasks.dockerContextPrepareFiles { + from(zipTree(tasks.zip.flatMap { it.archiveFile })) +} diff --git a/modules/web-map/docker/Dockerfile b/modules/web-map/docker/Dockerfile new file mode 100644 index 0000000..3cae269 --- /dev/null +++ b/modules/web-map/docker/Dockerfile @@ -0,0 +1,10 @@ +# syntax=docker/dockerfile:1 + +FROM nginx +ARG APP_FILES="build/" + +EXPOSE 80 + +COPY ./nginx.conf /etc/nginx/nginx.conf + +COPY $APP_FILES /usr/share/nginx/html diff --git a/modules/web-map/docker/docker-compose.yml b/modules/web-map/docker/docker-compose.yml new file mode 100644 index 0000000..1170228 --- /dev/null +++ b/modules/web-map/docker/docker-compose.yml @@ -0,0 +1,29 @@ +version: "3.9" + +services: + + kafkatorio-web-map: + image: ${REGISTRY_HOST}/${APP_GROUP}/${APP_NAME}:${KAFKATORIO_VERSION} + container_name: ${APP_NAME} + restart: unless-stopped + build: + context: . + dockerfile: Dockerfile + args: + KAFKATORIO_VERSION: ${KAFKATORIO_VERSION} + APP_FILES: "./build/" + ports: + - "12081:80" + networks: + - "kafkatorio-nw" + - "traefik-nw" + labels: + - "traefik.enable=true" + +networks: + kafkatorio-nw: + name: "kafkatorio-nw" + external: true + traefik-nw: + name: "traefik-nw" + external: true diff --git a/modules/web-map/docker/nginx.conf b/modules/web-map/docker/nginx.conf new file mode 100644 index 0000000..6d57bca --- /dev/null +++ b/modules/web-map/docker/nginx.conf @@ -0,0 +1,27 @@ +events {} + +http { + include mime.types; + default_type application/octet-stream; + + # Sets the path, format, and configuration for a buffered log write + #log_format compression '$remote_addr - $remote_user [$time_local] ' + #'"$request" $status $upstream_addr ' + #'"$http_referer" "$http_user_agent"'; + + server { + listen 80; + + root /usr/share/nginx/html; + + index index.html; + + location / { + # First attempt to serve request as file, then + # as directory, then fall back to redirecting to index.html + try_files $uri $uri/ $uri.html /index.html; + + include mime.types; + } + } +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/App.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/App.kt new file mode 100644 index 0000000..f88e2ff --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/App.kt @@ -0,0 +1,111 @@ +package dev.adamko.kafkatorio.webmap + +import dev.adamko.kafkatorio.schema.packets.EventServerPacket +import dev.adamko.kafkatorio.webmap.layout.headerNav +import dev.adamko.kafkatorio.webmap.layout.homePage +import dev.adamko.kafkatorio.webmap.layout.servers.serverPage +import dev.adamko.kafkatorio.webmap.routing.SiteRouter +import dev.adamko.kafkatorio.webmap.routing.SiteView +import dev.adamko.kafkatorio.webmap.services.WebsocketService +import dev.adamko.kafkatorio.webmap.state.SiteAction +import dev.adamko.kafkatorio.webmap.state.SiteState +import io.kvision.Application +import io.kvision.BootstrapIconsModule +import io.kvision.BootstrapModule +import io.kvision.ChartModule +import io.kvision.CoreModule +import io.kvision.FontAwesomeModule +import io.kvision.html.Link +import io.kvision.html.div +import io.kvision.html.header +import io.kvision.html.main +import io.kvision.module +import io.kvision.panel.root +import io.kvision.redux.ReduxStore +import io.kvision.redux.createReduxStore +import io.kvision.require +import io.kvision.startApplication +import io.kvision.state.bind +import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.cancel +import kotlinx.coroutines.cancelChildren +import kotlinx.coroutines.flow.filterIsInstance +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach + + + +object App : Application() { + + private val coroutineScope: CoroutineScope = CoroutineScope( + Dispatchers.Default + + SupervisorJob(rootJob) + + CoroutineName("WebMapApp") + ) + + private var appState: MutableMap = mutableMapOf() + + var siteStateStore: ReduxStore by appState + private set + + + init { + this.siteStateStore = createReduxStore(SiteState::plus, SiteState()) + + require("./css/kafkatorio.css") + +// WebsocketService.packetsFlow +// .filterIsInstance() +// .onEach { tileSavedEvent -> +//// println("[packetsFlow] triggering tile refresh ${tileSavedEvent.filename.value}") +//// siteStateStore.dispatch(SiteAction.EventServerUpdate(tileSavedEvent)) +// siteStateStore.getState().factorioGameState?.map?.refreshUpdatedTilePng(tileSavedEvent.filename) +// }.launchIn(coroutineScope) + } + + + override fun start(state: Map) { + SiteRouter.init() + + this.appState = state.toMutableMap() + + root("kvapp") { + header().bind(siteStateStore) { state -> + headerNav(state) + } + + main().bind(siteStateStore) { state -> + div(className = "container-fluid") { + when (state.view) { + SiteView.HOME -> homePage(state) + SiteView.SERVER -> serverPage(state) + } + } + SiteRouter.updatePageLinks() + } + } + +// kvMaps.leafletMap { +// invalidateSize(true) +// eachLayer({ +// if (it is GridLayer<*>) { +// it.redraw() +// } +// }) +// } + + } + + + override fun dispose(): Map { + rootJob.cancelChildren() + rootJob.cancel("app dispose") + rootJob.complete() + return appState + } + +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/FactorioMap.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/FactorioMap.kt new file mode 100644 index 0000000..de99c9d --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/FactorioMap.kt @@ -0,0 +1,195 @@ +package dev.adamko.kafkatorio.webmap + +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.ServerMapTileLayer +import dev.adamko.kafkatorio.schema.common.ServerMapTilePngFilename +import dev.adamko.kafkatorio.schema.packets.EventServerPacket +import dev.adamko.kafkatorio.webmap.externals.TileOnLoadFn +import dev.adamko.kafkatorio.webmap.externals.tileOnLoad +import dev.adamko.kafkatorio.webmap.services.WebsocketService +import io.kvision.maps.Maps +import io.kvision.maps.Maps.Companion.L +import io.kvision.maps.externals.leaflet.DoneCallback +import io.kvision.maps.externals.leaflet.control.Control +import io.kvision.maps.externals.leaflet.control.Layers +import io.kvision.maps.externals.leaflet.control.set +import io.kvision.maps.externals.leaflet.geo.CRS +import io.kvision.maps.externals.leaflet.geo.LatLng +import io.kvision.maps.externals.leaflet.layer.LayerGroup +import io.kvision.maps.externals.leaflet.layer.tile.TileLayer +import io.kvision.utils.px +import js.core.jso +import kotlinx.browser.document +import kotlinx.browser.window +import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.await +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.flow.filterIsInstance +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach +import kotlinx.coroutines.launch +import org.w3c.dom.HTMLElement +import org.w3c.dom.Image +import org.w3c.dom.asList +import org.w3c.fetch.NO_CORS +import org.w3c.fetch.RELOAD +import org.w3c.fetch.RequestCache +import org.w3c.fetch.RequestInit +import org.w3c.fetch.RequestMode + + +class FactorioMap( + private val serverId: FactorioServerId, +) { + + private val coroutineScope: CoroutineScope = CoroutineScope( + Dispatchers.Default + + SupervisorJob(rootJob) + + CoroutineName("FactorioMap") + ) + + val kvMap: Maps = Maps { + minHeight = 800.px + minWidth = 800.px +// width = 100.vh +// height = 100.vh + margin = 10.px + } + + private val terrainTileLayer: TileLayer<*> = createServerTileLayer(ServerMapTileLayer.TERRAIN) + private val resourcesTileLayer: TileLayer<*> = createServerTileLayer(ServerMapTileLayer.RESOURCE) + private val buildingsTileLayer: TileLayer<*> = createServerTileLayer(ServerMapTileLayer.BUILDING) + + val playerIconsLayer: LayerGroup = LayerGroup() + + init { + + val baseLayers: Control.LayersObject = jso { + set("Terrain", terrainTileLayer) + } + + val overlays: Control.LayersObject = jso { + set("Players", playerIconsLayer) + set("Resources", resourcesTileLayer) + set("Buildings", buildingsTileLayer) + } + + val layersControl = Layers( + baseLayers = baseLayers, + overlays = overlays, + options = jso { + sortLayers = true + } + ) + + kvMap.configureLeafletMap { + setView(center = LatLng(0, 0), zoom = 0) + + L.scale { + metric = true + imperial = false + }.addTo(this) + + options.crs = CRS.Simple + options.zoomSnap = 0 + options.zoomDelta = 0.1 +// options.fadeAnimation = false + addControl(layersControl) + + terrainTileLayer.addTo(this) + resourcesTileLayer.addTo(this) + buildingsTileLayer.addTo(this) + + playerIconsLayer.addTo(this) + } + + + WebsocketService.packetsFlow + .filterIsInstance() + .onEach { tileSavedEvent -> +// println("[packetsFlow] triggering tile refresh ${tileSavedEvent.filename.value}") +// siteStateStore.dispatch(SiteAction.EventServerUpdate(tileSavedEvent)) + refreshUpdatedTilePng(tileSavedEvent.filename) + }.launchIn(coroutineScope) + } + + + suspend fun refreshUpdatedTilePng( + tilePngFilename: ServerMapTilePngFilename, + ): Unit = coroutineScope { + document + .querySelectorAll("img.leaflet-tile-loaded") + .asList() + .filterIsInstance() + .filter { img -> tilePngFilename.value in img.src } + .forEach { img -> + val imgSrc = img.src + + launch { + window.fetch( + imgSrc, + RequestInit( + cache = RequestCache.RELOAD, + mode = RequestMode.NO_CORS, + ) + ).then { + window.requestAnimationFrame { + println("[refreshUpdatedTilePng] updating $imgSrc") + img.setAttribute(DYNAMIC_RELOAD_ATT, "true") + img.src = imgSrc + } + }.await() + } + } + } + + + private fun createServerTileLayer( + layer: ServerMapTileLayer + ): TileLayer { + + val urlTemplate: String = tileLayerUrlTemplate(layer) + + val baseTileLayer = L.tileLayer( + urlTemplate + ) { + attribution = "kafkatorio" + tileSize = 256 + tms = true + + minZoom = -2 + maxZoom = 6 + + maxNativeZoom = 0 + minNativeZoom = -1 + + noWrap = true + updateWhenIdle = false + updateWhenZooming = true + } + + val currentTileOnLoad: TileOnLoadFn? = baseTileLayer.tileOnLoad + + if (currentTileOnLoad != null) { + baseTileLayer.tileOnLoad = { done: DoneCallback, tile: HTMLElement -> + if (!tile.hasAttribute(DYNAMIC_RELOAD_ATT)) { + currentTileOnLoad(done, tile) + } + tile.removeAttribute(DYNAMIC_RELOAD_ATT) + } + } + + return baseTileLayer + } + + private fun tileLayerUrlTemplate(layer: ServerMapTileLayer): String = + "/kafkatorio/data/servers/${serverId.id}/map/layers/${layer.dir}/s1/z{z}/x{x}/y{y}.png" + + companion object { + /** Add this attribute to `` tiles that need to be dynamically refreshed. */ + const val DYNAMIC_RELOAD_ATT = "dynamic-reload" + } +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/config/ApplicationProperties.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/config/ApplicationProperties.kt new file mode 100644 index 0000000..652481c --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/config/ApplicationProperties.kt @@ -0,0 +1,15 @@ +package dev.adamko.kafkatorio.webmap.config + +import kotlinx.browser.window + + +object ApplicationProperties { + + /** Determine the WebSocket URL based on the window location URL. */ + @Suppress("HttpUrlsUsage") + val websocketServerUrl: String + get() = window.location.origin + .replace("http://", "ws://") + .replace("https://", "wss://") + + "/kafkatorio/ws" +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/config/json.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/config/json.kt new file mode 100644 index 0000000..1b9be5b --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/config/json.kt @@ -0,0 +1,9 @@ +package dev.adamko.kafkatorio.webmap.config + +import dev.adamko.kafkatorio.library.jsonMapperKafkatorio +import kotlinx.serialization.json.Json + +val jsonMapper = Json { + prettyPrint = true + serializersModule = jsonMapperKafkatorio.serializersModule +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/externals/leaflet.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/externals/leaflet.kt new file mode 100644 index 0000000..b72d539 --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/externals/leaflet.kt @@ -0,0 +1,45 @@ +package dev.adamko.kafkatorio.webmap.externals + +import io.kvision.maps.externals.leaflet.DoneCallback +import io.kvision.maps.externals.leaflet.geo.LatLng +import io.kvision.maps.externals.leaflet.layer.tile.TileLayer +import io.kvision.maps.externals.leaflet.layer.vector.Polyline +import org.w3c.dom.HTMLElement + + +inline var TileLayer.tileOnLoad: TileOnLoadFn? + get() = asDynamic()._tileOnLoad as TileOnLoadFn + set(value) { + asDynamic()._tileOnLoad = value + } + + +/** @see [tileOnLoad] */ +typealias TileOnLoadFn = (done: DoneCallback, tile: HTMLElement) -> Unit + + +sealed interface PolylinePathPoints { + value class D1(val points: List) : PolylinePathPoints { + constructor(points: Array) + : this(points.toList()) + } + + value class D2(val points: List>) : PolylinePathPoints { + constructor(points: Array>) + : this(points.map { x -> x.toList() }.toList()) + } + + value class D3(val points: List>>) : PolylinePathPoints { + constructor(points: Array>>) + : this(points.map { x -> x.map { y -> y.toList() } }.toList()) + } +} + +inline fun Polyline<*>.getLatLngs2(): PolylinePathPoints? { + return when (val points = this.getLatLngs()) { + is Array -> PolylinePathPoints.D1(points.unsafeCast>()) + is Array> -> PolylinePathPoints.D2(points.unsafeCast>>()) + is Array>> -> PolylinePathPoints.D3(points.unsafeCast>>>()) + else -> null + } +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/layout/headerNav.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/layout/headerNav.kt new file mode 100644 index 0000000..a419b67 --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/layout/headerNav.kt @@ -0,0 +1,16 @@ +package dev.adamko.kafkatorio.webmap.layout + +import dev.adamko.kafkatorio.webmap.routing.SiteView +import dev.adamko.kafkatorio.webmap.state.SiteState +import io.kvision.core.Container +import io.kvision.navbar.nav +import io.kvision.navbar.navbar + + +fun Container.headerNav(state: SiteState) { + navbar(label = "Kafkatorio", link = SiteView.HOME.path) { + nav { +// navLink("Home", SiteView.HOME.path) + } + } +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/layout/homePage.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/layout/homePage.kt new file mode 100644 index 0000000..799dd7a --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/layout/homePage.kt @@ -0,0 +1,113 @@ +package dev.adamko.kafkatorio.webmap.layout + +import dev.adamko.kafkatorio.webmap.state.SiteState +import io.kvision.core.Container +import io.kvision.html.ListType +import io.kvision.html.div +import io.kvision.html.h5 +import io.kvision.html.li +import io.kvision.html.link +import io.kvision.html.listTag +import io.kvision.html.p + + +fun Container.homePage(state: SiteState) { + div(className = "home-page") { + introduction() + servers(state) + } +} + + +private fun Container.introduction() { + div { + h5("Introduction") + // Kafkatorio + p( + """ + Kafkatorio is a platform used for creating + Factorio mods that require communication with an external server. + """.trimIndent(), + rich = true, + ) + p( + """ + It was created to explore the possibilities of using + Apache Kafka + to process updates from a Factorio server. + """.trimIndent(), + rich = true, + ) + p("To keep up to date on progress, check out:") + listTag(ListType.UL) { + link( + label = "Factorio Mod Portal", + url = "https://mods.factorio.com/mod/kafkatorio-events", + target = "_blank" + ) + link( + label = "Factorio forum discussion", + url = "https://forums.factorio.com/viewtopic.php?f=190&t=102841&p=570598#p570598", + target = "_blank" + ) + } + p( + """ + Development is ongoing. Presently it used to create a live-updating web-map of a Factorio + server. + """.trimIndent(), + rich = true, + ) + } +} + + +private fun Container.servers(state: SiteState) { + div(className = "servers") { + h5("Factorio Servers Live maps") + if (state.serverIds != null) { + p("View live-updating maps of the following Factorio servers") + p("Available servers: ${state.serverIds.size}") + listTag(ListType.UL) { + state.serverIds.forEach { serverId -> + li { + div { + link( + label = "$serverId", + url = "/servers/$serverId", +// url = routing.link("servers/$serverId"), + ) + } + } + } + } + +// div { +// state.serverIds.forEach { serverId -> +// div { +// link( +// label = "$serverId", +// dataNavigo = true, +// url = "/servers/$serverId", +// ) { +//// onClick { +//// SiteRouting.serverView(serverId) +//// } +// } +// } +// +// button(text = "$serverId", className = "btn btn-link") { +// style = ButtonStyle.PRIMARY +// size = ButtonSize.SMALL +// +// onClick { +// SiteRouting.serverView(serverId) +// } +// } +// } +// } + } else { + div("no servers available") + } + } +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/layout/servers/serverPage.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/layout/servers/serverPage.kt new file mode 100644 index 0000000..b377249 --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/layout/servers/serverPage.kt @@ -0,0 +1,30 @@ +package dev.adamko.kafkatorio.webmap.layout.servers + +import dev.adamko.kafkatorio.webmap.state.SiteState +import io.kvision.core.Container +import io.kvision.html.div +import io.kvision.maps.externals.leaflet.layer.tile.GridLayer + + +fun Container.serverPage(state: SiteState) { + val factorioGameState = state.factorioGameState + + div(className = "server-page container-fluid") { + if (factorioGameState != null) { + + add(factorioGameState.map.kvMap) + } + } + + +// TODO figure out how to run this after adding kvMap to the container... +// (doing it now causes an NPE because kvMap isn't added to the DOM yet +// factorioGameState?.map?.kvMap?.leafletMap { +// invalidateSize(true) +// eachLayer({ +// if (it is GridLayer<*>) { +// it.redraw() +// } +// }) +// } +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/main.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/main.kt new file mode 100644 index 0000000..05fbac7 --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/main.kt @@ -0,0 +1,31 @@ +package dev.adamko.kafkatorio.webmap + +import io.kvision.BootstrapIconsModule +import io.kvision.BootstrapModule +import io.kvision.ChartModule +import io.kvision.CoreModule +import io.kvision.FontAwesomeModule +import io.kvision.html.Link +import io.kvision.module +import io.kvision.startApplication +import kotlinx.coroutines.Job + + +val rootJob = Job() + + +fun main() { + startApplication( + { + Link.useDataNavigoForLinks = true + App + }, + module.hot, + BootstrapModule, +// BootstrapCssModule, + BootstrapIconsModule, + FontAwesomeModule, + ChartModule, + CoreModule, + ) +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/routing/SiteRouter.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/routing/SiteRouter.kt new file mode 100644 index 0000000..a0108f4 --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/routing/SiteRouter.kt @@ -0,0 +1,87 @@ +package dev.adamko.kafkatorio.webmap.routing + +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.webmap.App +import dev.adamko.kafkatorio.webmap.state.SiteAction +import dev.adamko.kafkatorio.webmap.rootJob +import dev.adamko.kafkatorio.webmap.services.EventsServerClient +import io.kvision.navigo.Match +import io.kvision.navigo.Navigo +import io.kvision.routing.Routing +import io.kvision.routing.Strategy +import kotlin.coroutines.CoroutineContext +import kotlinx.browser.window +import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.launch + + +object SiteRouter : CoroutineScope { + + override val coroutineContext: CoroutineContext = + Dispatchers.Default + SupervisorJob(rootJob) + CoroutineName("SiteRouting") + + + private val navigo: Routing = Routing( + root = "/", + useHash = false, + strategy = Strategy.ONE + ) + + + fun init() { + navigo + .on(SiteView.HOME) { + log("routing.on HOME") + homepageView() + } + .on(SiteView.SERVER) { match -> + println("routing.on SERVER ${JSON.stringify(match)}") + val serverId = match.data["serverId"] as? String ?: error("invalid server id") + println("routing.on SERVER serverId:$serverId") + serverView(FactorioServerId(serverId)) + } + .resolve() + + log("routing.lastResolved(): " + JSON.stringify(navigo.lastResolved())) + } + + + fun updatePageLinks() { + window.setTimeout( + handler = { + log("updating page links") + navigo.updatePageLinks() + }, + timeout = 0, + ) + } + + + fun homepageView() { + App.siteStateStore.dispatch(SiteAction.HomePage) + launch { + val serverIds = EventsServerClient.serverIds() + log("loaded server IDs $serverIds") + App.siteStateStore.dispatch(SiteAction.ServerIdsLoaded(serverIds)) + } + } + + + fun serverView(serverId: FactorioServerId) { + App.siteStateStore.dispatch(SiteAction.ServerPage(serverId)) + } + + + private fun log(message: String) = println("[SiteRouting] $message") +} + + +private fun Navigo.on(view: SiteView, handler: (Match) -> Unit): Navigo { + return when (view) { + is SiteView.StaticPath -> on(view.path, { match: Match -> handler(match) }) + is SiteView.DynamicPath -> on(view.path, { match: Match -> handler(match) }) + } +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/routing/SiteView.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/routing/SiteView.kt new file mode 100644 index 0000000..fb4020f --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/routing/SiteView.kt @@ -0,0 +1,22 @@ +package dev.adamko.kafkatorio.webmap.routing + + +sealed interface SiteView { + + sealed interface StaticPath : SiteView { + val path: String + } + + sealed interface DynamicPath : SiteView { + val path: String + } + + + object HOME : StaticPath { + override val path: String = "/" + } + + object SERVER : DynamicPath { + override val path: String = "/servers/:serverId/" + } +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/services/EventsServerClient.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/services/EventsServerClient.kt new file mode 100644 index 0000000..bc61491 --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/services/EventsServerClient.kt @@ -0,0 +1,25 @@ +package dev.adamko.kafkatorio.webmap.services + +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import io.kvision.rest.RestClient +import io.kvision.rest.call +import kotlinx.browser.window +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.await + +object EventsServerClient : + CoroutineScope by CoroutineScope(Dispatchers.Default + SupervisorJob()) { + + private val restClient = RestClient() + + + /** Fetch all possible server IDs. */ + suspend fun serverIds(): List = + restClient + .call>(window.location.origin + "/kafkatorio/data/servers") + .await() + + +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/services/WebsocketService.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/services/WebsocketService.kt new file mode 100644 index 0000000..64ea1cc --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/services/WebsocketService.kt @@ -0,0 +1,109 @@ +package dev.adamko.kafkatorio.webmap.services + +import dev.adamko.kafkatorio.schema.packets.ConfigurationUpdate +import dev.adamko.kafkatorio.schema.packets.ConsoleChatUpdate +import dev.adamko.kafkatorio.schema.packets.ConsoleCommandUpdate +import dev.adamko.kafkatorio.schema.packets.EntityUpdate +import dev.adamko.kafkatorio.schema.packets.EventServerPacket +import dev.adamko.kafkatorio.schema.packets.KafkatorioPacketDataError +import dev.adamko.kafkatorio.schema.packets.MapChunkEntityUpdate +import dev.adamko.kafkatorio.schema.packets.MapChunkResourceUpdate +import dev.adamko.kafkatorio.schema.packets.MapChunkTileUpdate +import dev.adamko.kafkatorio.schema.packets.PlayerUpdate +import dev.adamko.kafkatorio.schema.packets.PrototypesUpdate +import dev.adamko.kafkatorio.schema.packets.SurfaceUpdate +import dev.adamko.kafkatorio.webmap.App +import dev.adamko.kafkatorio.webmap.state.SiteAction +import dev.adamko.kafkatorio.webmap.config.ApplicationProperties +import dev.adamko.kafkatorio.webmap.config.jsonMapper +import dev.adamko.kafkatorio.webmap.rootJob +import kotlin.coroutines.CoroutineContext +import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.SharedFlow +import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.launch +import org.w3c.dom.MessageEvent +import org.w3c.dom.WebSocket +import org.w3c.dom.events.Event + + +object WebsocketService : CoroutineScope { + + override val coroutineContext: CoroutineContext = + Dispatchers.Default + CoroutineName("WebsocketService") + Job(rootJob) + + private val ws = WebSocket(ApplicationProperties.websocketServerUrl) + + private val packetsMutableFlow = MutableSharedFlow() + val packetsFlow: SharedFlow + get() = packetsMutableFlow.asSharedFlow() + + init { + ws.onmessage = ::handleMessageEvent + ws.onerror = ::handleError + + println("[WebsocketService] init ${ws.url}, ${ws.protocol}") + } + + private fun handleMessageEvent(msg: MessageEvent) { + + val data = (msg.data as? String)?.trim() + + if ( + data != null + && data.startsWith("{") + && data.endsWith("}") + ) { + + println("[WebsocketService.handleMessageEvent] ${data.replace('\n', ' ')}") + + val packet: EventServerPacket? = runCatching { + jsonMapper.decodeFromString(EventServerPacket.serializer(), data) + }.getOrElse { + null + } + + if (packet != null) { + + launch { packetsMutableFlow.emit(packet) } + + when (packet) { + is EventServerPacket.ChunkTileSaved -> {} + + is EventServerPacket.Kafkatorio -> + when (val packetData = packet.packet.data) { + is PlayerUpdate -> + App.siteStateStore.dispatch( + SiteAction.FactorioUpdate.Player(packet.packet.tick, packetData) + ) + + is ConfigurationUpdate, + is ConsoleChatUpdate, + is ConsoleCommandUpdate, + is EntityUpdate, + is MapChunkEntityUpdate, + is MapChunkResourceUpdate, + is MapChunkTileUpdate, + is PrototypesUpdate, + is SurfaceUpdate, + is KafkatorioPacketDataError -> { + // to be continued... + } + } + } + } else { + println("[WebsocketService.handleMessageEvent] unknown json message ${msg.data}") + } + } else { + println("[WebsocketService.handleMessageEvent] non-json message ${msg.data}") + } + } + + private fun handleError(error: Event) { + println("ws error: ${JSON.stringify(error)}") + } +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/services/converters.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/services/converters.kt new file mode 100644 index 0000000..9b4753a --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/services/converters.kt @@ -0,0 +1,10 @@ +package dev.adamko.kafkatorio.webmap.services + +import dev.adamko.kafkatorio.schema.common.MapEntityPosition +import dev.adamko.kafkatorio.schema.packets.PlayerUpdate +import io.kvision.maps.Maps +import io.kvision.maps.externals.leaflet.geo.LatLng + +fun PlayerUpdate.latLng(): LatLng? = position?.latLng() + +fun MapEntityPosition.latLng(): LatLng = Maps.L.latLng((this.y * -1) to this.x) diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/FactorioGameState.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/FactorioGameState.kt new file mode 100644 index 0000000..f4a0946 --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/FactorioGameState.kt @@ -0,0 +1,47 @@ +package dev.adamko.kafkatorio.webmap.state + +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.PlayerIndex +import dev.adamko.kafkatorio.webmap.FactorioMap +import io.kvision.maps.externals.leaflet.layer.LayerGroup + + +data class FactorioGameState( + val serverId: FactorioServerId, + val map: FactorioMap = FactorioMap(serverId), + val players: Map = emptyMap(), +) { + + val playerIconsLayer: LayerGroup + get() = map.playerIconsLayer + + operator fun plus(action: SiteAction.FactorioUpdate): FactorioGameState = + when (action) { + is SiteAction.FactorioUpdate.Player -> handlePlayerUpdate(action) + } +} + + +private fun FactorioGameState.handlePlayerUpdate( + update: SiteAction.FactorioUpdate.Player, +): FactorioGameState { + + val previous = players[update.data.key.index] + ?: PlayerState(update.data.key.index, update.tick) + + val updated = previous.update(update.tick, update.data) + + if (previous.mapMarker != updated.mapMarker) { + if (previous.mapMarker != null) { + println("removing player icon ${previous.index}") + playerIconsLayer.removeLayer(previous.mapMarker) + } + if (updated.mapMarker != null) { + println("adding player icon ${updated.index}") + playerIconsLayer.addLayer(updated.mapMarker) + } + } + + val updatedPlayersState = players + (previous.index to updated) + return copy(players = updatedPlayersState) +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/PlayerProperties.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/PlayerProperties.kt new file mode 100644 index 0000000..94e25d2 --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/PlayerProperties.kt @@ -0,0 +1,82 @@ +package dev.adamko.kafkatorio.webmap.state + + +import dev.adamko.kafkatorio.schema.common.Colour +import dev.adamko.kafkatorio.schema.common.MapEntityPosition +import dev.adamko.kafkatorio.schema.common.SurfaceIndex +import dev.adamko.kafkatorio.schema.common.toHexString +import dev.adamko.kafkatorio.schema.packets.PlayerUpdate +import dev.adamko.kafkatorio.webmap.services.latLng +import io.kvision.maps.externals.leaflet.geo.LatLng + +sealed interface PlayerProperties { + + val position: MapEntityPosition? + val surfaceIndex: SurfaceIndex? + val colour: Colour? + val name: String? + val latLng: LatLng? + val isConnected: Boolean + val isShowOnMap: Boolean + + + data class Partial( + override val position: MapEntityPosition? = null, + override val surfaceIndex: SurfaceIndex? = null, + override val colour: Colour? = null, + override val name: String? = null, + override val isConnected: Boolean = false, + override val isShowOnMap: Boolean = false, + ) : PlayerProperties { + override val latLng: LatLng? = null + } + + + data class Complete( + override val position: MapEntityPosition, + override val surfaceIndex: SurfaceIndex, + override val colour: Colour, + override val name: String, + override val isConnected: Boolean = false, + override val isShowOnMap: Boolean = false, + ) : PlayerProperties { + override val latLng: LatLng = position.latLng() + val hexColour: String = colour.toHexString(false) + } + + + fun update(update: PlayerUpdate): PlayerProperties { + + val position = update.position ?: this.position + val surfaceIndex = update.surfaceIndex ?: this.surfaceIndex + val colour = update.colour ?: this.colour + val name = update.name ?: this.name + val isConnected = update.isConnected + val isShowOnMap = update.isShowOnMap + + return when { + position != null + && surfaceIndex != null + && colour != null + && name != null -> + Complete( + position = position, + surfaceIndex = surfaceIndex, + colour = colour, + name = name, + isConnected = isConnected, + isShowOnMap = isShowOnMap, + ) + + else -> + Partial( + position = position, + surfaceIndex = surfaceIndex, + colour = colour, + name = name, + isConnected = isConnected, + isShowOnMap = isShowOnMap, + ) + } + } +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/PlayerState.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/PlayerState.kt new file mode 100644 index 0000000..8497df7 --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/PlayerState.kt @@ -0,0 +1,74 @@ +package dev.adamko.kafkatorio.webmap.state + +import dev.adamko.kafkatorio.schema.common.PlayerIndex +import dev.adamko.kafkatorio.schema.common.Tick +import dev.adamko.kafkatorio.schema.packets.PlayerUpdate +import io.kvision.maps.Maps +import io.kvision.maps.externals.leaflet.layer.vector.CircleMarker +import js.core.jso + +data class PlayerState( + val index: PlayerIndex, + val lastTick: Tick, + val playerDetails: PlayerProperties = PlayerProperties.Partial(), + val mapMarker: CircleMarker? = null, +) { + + fun update(tick: Tick, update: PlayerUpdate): PlayerState { + + if (lastTick.value > tick.value) { + println("discarding old PlayerUpdate, ${lastTick.value} > ${tick.value}") + return this + } + + val newState = this.copy( + lastTick = tick, + playerDetails = playerDetails.update(update), + mapMarker = updateMapMarker() + ) + println("updated PlayerState index:${newState.index}, name:${newState.playerDetails.name}") + return newState + } + + + private fun updateMapMarker(): CircleMarker? { + return when (playerDetails) { + + is PlayerProperties.Partial -> { + println("removing player $index map marker") + null + } + + is PlayerProperties.Complete -> { + + val mapMarker = mapMarker ?: createMapMarker(playerDetails) + + mapMarker.apply { + options.color = playerDetails.hexColour + options.fillColor = playerDetails.hexColour + + val lat = playerDetails.latLng.lat.toInt() + val lng = playerDetails.latLng.lng.toInt() + + setTooltipContent("${playerDetails.name} [$lat, $lng]") + setLatLng(playerDetails.latLng) + } + } + } + } + + + companion object { + private fun createMapMarker(playerDetails: PlayerProperties.Complete): CircleMarker = + Maps.L.circleMarker(playerDetails.latLng) { + fillOpacity = 1f + radius = 10 + className = "player-marker" +// interactive = false + }.also { circle -> + circle.bindTooltip("", jso { +// interactive = false + }) + } + } +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/SiteAction.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/SiteAction.kt new file mode 100644 index 0000000..d5dd841 --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/SiteAction.kt @@ -0,0 +1,24 @@ +package dev.adamko.kafkatorio.webmap.state + +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.common.Tick +import dev.adamko.kafkatorio.schema.packets.EventServerPacket +import dev.adamko.kafkatorio.schema.packets.PlayerUpdate +import io.kvision.redux.RAction + + +sealed interface SiteAction : RAction { + object HomePage : SiteAction + data class ServerPage(val serverId: FactorioServerId) : SiteAction + + + data class ServerIdsLoaded(val serverIds: List) : SiteAction + + + /** Updates from `events-server` */ + sealed class FactorioUpdate : SiteAction { + data class Player(val tick: Tick, val data: PlayerUpdate) : FactorioUpdate() + } + + data class EventServerUpdate(val packet: EventServerPacket) : SiteAction +} diff --git a/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/SiteState.kt b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/SiteState.kt new file mode 100644 index 0000000..ecb2894 --- /dev/null +++ b/modules/web-map/src/main/kotlin/dev/adamko/kafkatorio/webmap/state/SiteState.kt @@ -0,0 +1,55 @@ +package dev.adamko.kafkatorio.webmap.state + +import dev.adamko.kafkatorio.schema.common.FactorioServerId +import dev.adamko.kafkatorio.schema.packets.EventServerPacket +import dev.adamko.kafkatorio.webmap.rootJob +import dev.adamko.kafkatorio.webmap.routing.SiteView +import kotlin.coroutines.CoroutineContext +import kotlinx.coroutines.CoroutineName +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.launch + + +data class SiteState( + val view: SiteView = SiteView.HOME, + + val serverIds: List? = null, + + val factorioGameState: FactorioGameState? = null, +) : CoroutineScope { + + override val coroutineContext: CoroutineContext = + Dispatchers.Default + SupervisorJob(rootJob) + CoroutineName("SiteState") + + operator fun plus(action: SiteAction): SiteState = when (action) { + is SiteAction.HomePage -> copy(view = SiteView.HOME) + + is SiteAction.ServerPage -> copy( + view = SiteView.SERVER, + factorioGameState = FactorioGameState(action.serverId), + ) + + is SiteAction.ServerIdsLoaded -> copy(serverIds = action.serverIds) + + is SiteAction.FactorioUpdate -> copy( + factorioGameState = factorioGameState?.let { it + action } + ) + + is SiteAction.EventServerUpdate -> when (action.packet) { + is EventServerPacket.ChunkTileSaved -> { + if (factorioGameState?.map != null) { + launch { + factorioGameState.map.refreshUpdatedTilePng(action.packet.filename) + } + } + this + } + + is EventServerPacket.Kafkatorio -> { + this + } + } + } +} diff --git a/modules/web-map/src/main/resources/css/bootstrap.min.css b/modules/web-map/src/main/resources/css/bootstrap.min.css new file mode 100644 index 0000000..daca156 --- /dev/null +++ b/modules/web-map/src/main/resources/css/bootstrap.min.css @@ -0,0 +1,12 @@ +@charset "UTF-8";/*! + * Bootswatch v5.2.2 (https://bootswatch.com) + * Theme: darkly + * Copyright 2012-2022 Thomas Park + * Licensed under MIT + * Based on Bootstrap +*//*! + * Bootstrap v5.2.2 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors + * Copyright 2011-2022 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */@import url(https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;1,400&display=swap);:root{--bs-blue:#375a7f;--bs-indigo:#6610f2;--bs-purple:#6f42c1;--bs-pink:#e83e8c;--bs-red:#e74c3c;--bs-orange:#fd7e14;--bs-yellow:#f39c12;--bs-green:#00bc8c;--bs-teal:#20c997;--bs-cyan:#3498db;--bs-black:#000;--bs-white:#fff;--bs-gray:#888;--bs-gray-dark:#303030;--bs-gray-100:#f8f9fa;--bs-gray-200:#ebebeb;--bs-gray-300:#dee2e6;--bs-gray-400:#ced4da;--bs-gray-500:#adb5bd;--bs-gray-600:#888;--bs-gray-700:#444;--bs-gray-800:#303030;--bs-gray-900:#222;--bs-primary:#375a7f;--bs-secondary:#444;--bs-success:#00bc8c;--bs-info:#3498db;--bs-warning:#f39c12;--bs-danger:#e74c3c;--bs-light:#adb5bd;--bs-dark:#303030;--bs-primary-rgb:55,90,127;--bs-secondary-rgb:68,68,68;--bs-success-rgb:0,188,140;--bs-info-rgb:52,152,219;--bs-warning-rgb:243,156,18;--bs-danger-rgb:231,76,60;--bs-light-rgb:173,181,189;--bs-dark-rgb:48,48,48;--bs-white-rgb:255,255,255;--bs-black-rgb:0,0,0;--bs-body-color-rgb:255,255,255;--bs-body-bg-rgb:34,34,34;--bs-font-sans-serif:Lato,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";--bs-font-monospace:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--bs-gradient:linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));--bs-body-font-family:var(--bs-font-sans-serif);--bs-body-font-size:1rem;--bs-body-font-weight:400;--bs-body-line-height:1.5;--bs-body-color:#fff;--bs-body-bg:#222;--bs-border-width:1px;--bs-border-style:solid;--bs-border-color:#dee2e6;--bs-border-color-translucent:rgba(0, 0, 0, 0.175);--bs-border-radius:0.375rem;--bs-border-radius-sm:0.25rem;--bs-border-radius-lg:0.5rem;--bs-border-radius-xl:1rem;--bs-border-radius-2xl:2rem;--bs-border-radius-pill:50rem;--bs-link-color:#00bc8c;--bs-link-hover-color:#009670;--bs-code-color:#e83e8c;--bs-highlight-bg:#fdebd0}*,::after,::before{box-sizing:border-box}@media (prefers-reduced-motion:no-preference){:root{scroll-behavior:smooth}}body{margin:0;font-family:var(--bs-body-font-family);font-size:var(--bs-body-font-size);font-weight:var(--bs-body-font-weight);line-height:var(--bs-body-line-height);color:var(--bs-body-color);text-align:var(--bs-body-text-align);background-color:var(--bs-body-bg);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}hr{margin:1rem 0;color:inherit;border:0;border-top:1px solid;opacity:.25}.h1,.h2,.h3,.h4,.h5,.h6,h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem;font-weight:500;line-height:1.2}.h1,h1{font-size:calc(1.425rem + 2.1vw)}@media (min-width:1200px){.h1,h1{font-size:3rem}}.h2,h2{font-size:calc(1.375rem + 1.5vw)}@media (min-width:1200px){.h2,h2{font-size:2.5rem}}.h3,h3{font-size:calc(1.325rem + .9vw)}@media (min-width:1200px){.h3,h3{font-size:2rem}}.h4,h4{font-size:calc(1.275rem + .3vw)}@media (min-width:1200px){.h4,h4{font-size:1.5rem}}.h5,h5{font-size:1.25rem}.h6,h6{font-size:1rem}p{margin-top:0;margin-bottom:1rem}abbr[title]{-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}ol,ul{padding-left:2rem}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}.small,small{font-size:.875em}.mark,mark{padding:.1875em;background-color:var(--bs-highlight-bg)}sub,sup{position:relative;font-size:.75em;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:var(--bs-link-color);text-decoration:underline}a:hover{color:var(--bs-link-hover-color)}a:not([href]):not([class]),a:not([href]):not([class]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:var(--bs-font-monospace);font-size:1em}pre{display:block;margin-top:0;margin-bottom:1rem;overflow:auto;font-size:.875em;color:inherit}pre code{font-size:inherit;color:inherit;word-break:normal}code{font-size:.875em;color:var(--bs-code-color);word-wrap:break-word}a>code{color:inherit}kbd{padding:.1875rem .375rem;font-size:.875em;color:var(--bs-body-bg);background-color:var(--bs-body-color);border-radius:.25rem}kbd kbd{padding:0;font-size:1em}figure{margin:0 0 1rem}img,svg{vertical-align:middle}table{caption-side:bottom;border-collapse:collapse}caption{padding-top:.5rem;padding-bottom:.5rem;color:#888;text-align:left}th{text-align:inherit;text-align:-webkit-match-parent}tbody,td,tfoot,th,thead,tr{border-color:inherit;border-style:solid;border-width:0}label{display:inline-block}button{border-radius:0}button:focus:not(:focus-visible){outline:0}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,select{text-transform:none}[role=button]{cursor:pointer}select{word-wrap:normal}select:disabled{opacity:1}[list]:not([type=date]):not([type=datetime-local]):not([type=month]):not([type=week]):not([type=time])::-webkit-calendar-picker-indicator{display:none!important}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}::-moz-focus-inner{padding:0;border-style:none}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{float:left;width:100%;padding:0;margin-bottom:.5rem;font-size:calc(1.275rem + .3vw);line-height:inherit}@media (min-width:1200px){legend{font-size:1.5rem}}legend+*{clear:left}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-fields-wrapper,::-webkit-datetime-edit-hour-field,::-webkit-datetime-edit-minute,::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-text,::-webkit-datetime-edit-year-field{padding:0}::-webkit-inner-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:textfield}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-color-swatch-wrapper{padding:0}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}::file-selector-button{font:inherit;-webkit-appearance:button}output{display:inline-block}iframe{border:0}summary{display:list-item;cursor:pointer}progress{vertical-align:baseline}[hidden]{display:none!important}.lead{font-size:1.25rem;font-weight:300}.display-1{font-size:calc(1.625rem + 4.5vw);font-weight:300;line-height:1.2}@media (min-width:1200px){.display-1{font-size:5rem}}.display-2{font-size:calc(1.575rem + 3.9vw);font-weight:300;line-height:1.2}@media (min-width:1200px){.display-2{font-size:4.5rem}}.display-3{font-size:calc(1.525rem + 3.3vw);font-weight:300;line-height:1.2}@media (min-width:1200px){.display-3{font-size:4rem}}.display-4{font-size:calc(1.475rem + 2.7vw);font-weight:300;line-height:1.2}@media (min-width:1200px){.display-4{font-size:3.5rem}}.display-5{font-size:calc(1.425rem + 2.1vw);font-weight:300;line-height:1.2}@media (min-width:1200px){.display-5{font-size:3rem}}.display-6{font-size:calc(1.375rem + 1.5vw);font-weight:300;line-height:1.2}@media (min-width:1200px){.display-6{font-size:2.5rem}}.list-unstyled{padding-left:0;list-style:none}.list-inline{padding-left:0;list-style:none}.list-inline-item{display:inline-block}.list-inline-item:not(:last-child){margin-right:.5rem}.initialism{font-size:.875em;text-transform:uppercase}.blockquote{margin-bottom:1rem;font-size:1.25rem}.blockquote>:last-child{margin-bottom:0}.blockquote-footer{margin-top:-1rem;margin-bottom:1rem;font-size:.875em;color:#888}.blockquote-footer::before{content:"— "}.img-fluid{max-width:100%;height:auto}.img-thumbnail{padding:.25rem;background-color:#222;border:1px solid var(--bs-border-color);border-radius:.375rem;max-width:100%;height:auto}.figure{display:inline-block}.figure-img{margin-bottom:.5rem;line-height:1}.figure-caption{font-size:.875em;color:#888}.container,.container-fluid,.container-lg,.container-md,.container-sm,.container-xl,.container-xxl{--bs-gutter-x:1.5rem;--bs-gutter-y:0;width:100%;padding-right:calc(var(--bs-gutter-x) * .5);padding-left:calc(var(--bs-gutter-x) * .5);margin-right:auto;margin-left:auto}@media (min-width:576px){.container,.container-sm{max-width:540px}}@media (min-width:768px){.container,.container-md,.container-sm{max-width:720px}}@media (min-width:992px){.container,.container-lg,.container-md,.container-sm{max-width:960px}}@media (min-width:1200px){.container,.container-lg,.container-md,.container-sm,.container-xl{max-width:1140px}}@media (min-width:1400px){.container,.container-lg,.container-md,.container-sm,.container-xl,.container-xxl{max-width:1320px}}.row{--bs-gutter-x:1.5rem;--bs-gutter-y:0;display:flex;flex-wrap:wrap;margin-top:calc(-1 * var(--bs-gutter-y));margin-right:calc(-.5 * var(--bs-gutter-x));margin-left:calc(-.5 * var(--bs-gutter-x))}.row>*{flex-shrink:0;width:100%;max-width:100%;padding-right:calc(var(--bs-gutter-x) * .5);padding-left:calc(var(--bs-gutter-x) * .5);margin-top:var(--bs-gutter-y)}.col{flex:1 0 0%}.row-cols-auto>*{flex:0 0 auto;width:auto}.row-cols-1>*{flex:0 0 auto;width:100%}.row-cols-2>*{flex:0 0 auto;width:50%}.row-cols-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-4>*{flex:0 0 auto;width:25%}.row-cols-5>*{flex:0 0 auto;width:20%}.row-cols-6>*{flex:0 0 auto;width:16.6666666667%}.col-auto{flex:0 0 auto;width:auto}.col-1{flex:0 0 auto;width:8.33333333%}.col-2{flex:0 0 auto;width:16.66666667%}.col-3{flex:0 0 auto;width:25%}.col-4{flex:0 0 auto;width:33.33333333%}.col-5{flex:0 0 auto;width:41.66666667%}.col-6{flex:0 0 auto;width:50%}.col-7{flex:0 0 auto;width:58.33333333%}.col-8{flex:0 0 auto;width:66.66666667%}.col-9{flex:0 0 auto;width:75%}.col-10{flex:0 0 auto;width:83.33333333%}.col-11{flex:0 0 auto;width:91.66666667%}.col-12{flex:0 0 auto;width:100%}.offset-1{margin-left:8.33333333%}.offset-2{margin-left:16.66666667%}.offset-3{margin-left:25%}.offset-4{margin-left:33.33333333%}.offset-5{margin-left:41.66666667%}.offset-6{margin-left:50%}.offset-7{margin-left:58.33333333%}.offset-8{margin-left:66.66666667%}.offset-9{margin-left:75%}.offset-10{margin-left:83.33333333%}.offset-11{margin-left:91.66666667%}.g-0,.gx-0{--bs-gutter-x:0}.g-0,.gy-0{--bs-gutter-y:0}.g-1,.gx-1{--bs-gutter-x:0.25rem}.g-1,.gy-1{--bs-gutter-y:0.25rem}.g-2,.gx-2{--bs-gutter-x:0.5rem}.g-2,.gy-2{--bs-gutter-y:0.5rem}.g-3,.gx-3{--bs-gutter-x:1rem}.g-3,.gy-3{--bs-gutter-y:1rem}.g-4,.gx-4{--bs-gutter-x:1.5rem}.g-4,.gy-4{--bs-gutter-y:1.5rem}.g-5,.gx-5{--bs-gutter-x:3rem}.g-5,.gy-5{--bs-gutter-y:3rem}@media (min-width:576px){.col-sm{flex:1 0 0%}.row-cols-sm-auto>*{flex:0 0 auto;width:auto}.row-cols-sm-1>*{flex:0 0 auto;width:100%}.row-cols-sm-2>*{flex:0 0 auto;width:50%}.row-cols-sm-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-sm-4>*{flex:0 0 auto;width:25%}.row-cols-sm-5>*{flex:0 0 auto;width:20%}.row-cols-sm-6>*{flex:0 0 auto;width:16.6666666667%}.col-sm-auto{flex:0 0 auto;width:auto}.col-sm-1{flex:0 0 auto;width:8.33333333%}.col-sm-2{flex:0 0 auto;width:16.66666667%}.col-sm-3{flex:0 0 auto;width:25%}.col-sm-4{flex:0 0 auto;width:33.33333333%}.col-sm-5{flex:0 0 auto;width:41.66666667%}.col-sm-6{flex:0 0 auto;width:50%}.col-sm-7{flex:0 0 auto;width:58.33333333%}.col-sm-8{flex:0 0 auto;width:66.66666667%}.col-sm-9{flex:0 0 auto;width:75%}.col-sm-10{flex:0 0 auto;width:83.33333333%}.col-sm-11{flex:0 0 auto;width:91.66666667%}.col-sm-12{flex:0 0 auto;width:100%}.offset-sm-0{margin-left:0}.offset-sm-1{margin-left:8.33333333%}.offset-sm-2{margin-left:16.66666667%}.offset-sm-3{margin-left:25%}.offset-sm-4{margin-left:33.33333333%}.offset-sm-5{margin-left:41.66666667%}.offset-sm-6{margin-left:50%}.offset-sm-7{margin-left:58.33333333%}.offset-sm-8{margin-left:66.66666667%}.offset-sm-9{margin-left:75%}.offset-sm-10{margin-left:83.33333333%}.offset-sm-11{margin-left:91.66666667%}.g-sm-0,.gx-sm-0{--bs-gutter-x:0}.g-sm-0,.gy-sm-0{--bs-gutter-y:0}.g-sm-1,.gx-sm-1{--bs-gutter-x:0.25rem}.g-sm-1,.gy-sm-1{--bs-gutter-y:0.25rem}.g-sm-2,.gx-sm-2{--bs-gutter-x:0.5rem}.g-sm-2,.gy-sm-2{--bs-gutter-y:0.5rem}.g-sm-3,.gx-sm-3{--bs-gutter-x:1rem}.g-sm-3,.gy-sm-3{--bs-gutter-y:1rem}.g-sm-4,.gx-sm-4{--bs-gutter-x:1.5rem}.g-sm-4,.gy-sm-4{--bs-gutter-y:1.5rem}.g-sm-5,.gx-sm-5{--bs-gutter-x:3rem}.g-sm-5,.gy-sm-5{--bs-gutter-y:3rem}}@media (min-width:768px){.col-md{flex:1 0 0%}.row-cols-md-auto>*{flex:0 0 auto;width:auto}.row-cols-md-1>*{flex:0 0 auto;width:100%}.row-cols-md-2>*{flex:0 0 auto;width:50%}.row-cols-md-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-md-4>*{flex:0 0 auto;width:25%}.row-cols-md-5>*{flex:0 0 auto;width:20%}.row-cols-md-6>*{flex:0 0 auto;width:16.6666666667%}.col-md-auto{flex:0 0 auto;width:auto}.col-md-1{flex:0 0 auto;width:8.33333333%}.col-md-2{flex:0 0 auto;width:16.66666667%}.col-md-3{flex:0 0 auto;width:25%}.col-md-4{flex:0 0 auto;width:33.33333333%}.col-md-5{flex:0 0 auto;width:41.66666667%}.col-md-6{flex:0 0 auto;width:50%}.col-md-7{flex:0 0 auto;width:58.33333333%}.col-md-8{flex:0 0 auto;width:66.66666667%}.col-md-9{flex:0 0 auto;width:75%}.col-md-10{flex:0 0 auto;width:83.33333333%}.col-md-11{flex:0 0 auto;width:91.66666667%}.col-md-12{flex:0 0 auto;width:100%}.offset-md-0{margin-left:0}.offset-md-1{margin-left:8.33333333%}.offset-md-2{margin-left:16.66666667%}.offset-md-3{margin-left:25%}.offset-md-4{margin-left:33.33333333%}.offset-md-5{margin-left:41.66666667%}.offset-md-6{margin-left:50%}.offset-md-7{margin-left:58.33333333%}.offset-md-8{margin-left:66.66666667%}.offset-md-9{margin-left:75%}.offset-md-10{margin-left:83.33333333%}.offset-md-11{margin-left:91.66666667%}.g-md-0,.gx-md-0{--bs-gutter-x:0}.g-md-0,.gy-md-0{--bs-gutter-y:0}.g-md-1,.gx-md-1{--bs-gutter-x:0.25rem}.g-md-1,.gy-md-1{--bs-gutter-y:0.25rem}.g-md-2,.gx-md-2{--bs-gutter-x:0.5rem}.g-md-2,.gy-md-2{--bs-gutter-y:0.5rem}.g-md-3,.gx-md-3{--bs-gutter-x:1rem}.g-md-3,.gy-md-3{--bs-gutter-y:1rem}.g-md-4,.gx-md-4{--bs-gutter-x:1.5rem}.g-md-4,.gy-md-4{--bs-gutter-y:1.5rem}.g-md-5,.gx-md-5{--bs-gutter-x:3rem}.g-md-5,.gy-md-5{--bs-gutter-y:3rem}}@media (min-width:992px){.col-lg{flex:1 0 0%}.row-cols-lg-auto>*{flex:0 0 auto;width:auto}.row-cols-lg-1>*{flex:0 0 auto;width:100%}.row-cols-lg-2>*{flex:0 0 auto;width:50%}.row-cols-lg-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-lg-4>*{flex:0 0 auto;width:25%}.row-cols-lg-5>*{flex:0 0 auto;width:20%}.row-cols-lg-6>*{flex:0 0 auto;width:16.6666666667%}.col-lg-auto{flex:0 0 auto;width:auto}.col-lg-1{flex:0 0 auto;width:8.33333333%}.col-lg-2{flex:0 0 auto;width:16.66666667%}.col-lg-3{flex:0 0 auto;width:25%}.col-lg-4{flex:0 0 auto;width:33.33333333%}.col-lg-5{flex:0 0 auto;width:41.66666667%}.col-lg-6{flex:0 0 auto;width:50%}.col-lg-7{flex:0 0 auto;width:58.33333333%}.col-lg-8{flex:0 0 auto;width:66.66666667%}.col-lg-9{flex:0 0 auto;width:75%}.col-lg-10{flex:0 0 auto;width:83.33333333%}.col-lg-11{flex:0 0 auto;width:91.66666667%}.col-lg-12{flex:0 0 auto;width:100%}.offset-lg-0{margin-left:0}.offset-lg-1{margin-left:8.33333333%}.offset-lg-2{margin-left:16.66666667%}.offset-lg-3{margin-left:25%}.offset-lg-4{margin-left:33.33333333%}.offset-lg-5{margin-left:41.66666667%}.offset-lg-6{margin-left:50%}.offset-lg-7{margin-left:58.33333333%}.offset-lg-8{margin-left:66.66666667%}.offset-lg-9{margin-left:75%}.offset-lg-10{margin-left:83.33333333%}.offset-lg-11{margin-left:91.66666667%}.g-lg-0,.gx-lg-0{--bs-gutter-x:0}.g-lg-0,.gy-lg-0{--bs-gutter-y:0}.g-lg-1,.gx-lg-1{--bs-gutter-x:0.25rem}.g-lg-1,.gy-lg-1{--bs-gutter-y:0.25rem}.g-lg-2,.gx-lg-2{--bs-gutter-x:0.5rem}.g-lg-2,.gy-lg-2{--bs-gutter-y:0.5rem}.g-lg-3,.gx-lg-3{--bs-gutter-x:1rem}.g-lg-3,.gy-lg-3{--bs-gutter-y:1rem}.g-lg-4,.gx-lg-4{--bs-gutter-x:1.5rem}.g-lg-4,.gy-lg-4{--bs-gutter-y:1.5rem}.g-lg-5,.gx-lg-5{--bs-gutter-x:3rem}.g-lg-5,.gy-lg-5{--bs-gutter-y:3rem}}@media (min-width:1200px){.col-xl{flex:1 0 0%}.row-cols-xl-auto>*{flex:0 0 auto;width:auto}.row-cols-xl-1>*{flex:0 0 auto;width:100%}.row-cols-xl-2>*{flex:0 0 auto;width:50%}.row-cols-xl-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-xl-4>*{flex:0 0 auto;width:25%}.row-cols-xl-5>*{flex:0 0 auto;width:20%}.row-cols-xl-6>*{flex:0 0 auto;width:16.6666666667%}.col-xl-auto{flex:0 0 auto;width:auto}.col-xl-1{flex:0 0 auto;width:8.33333333%}.col-xl-2{flex:0 0 auto;width:16.66666667%}.col-xl-3{flex:0 0 auto;width:25%}.col-xl-4{flex:0 0 auto;width:33.33333333%}.col-xl-5{flex:0 0 auto;width:41.66666667%}.col-xl-6{flex:0 0 auto;width:50%}.col-xl-7{flex:0 0 auto;width:58.33333333%}.col-xl-8{flex:0 0 auto;width:66.66666667%}.col-xl-9{flex:0 0 auto;width:75%}.col-xl-10{flex:0 0 auto;width:83.33333333%}.col-xl-11{flex:0 0 auto;width:91.66666667%}.col-xl-12{flex:0 0 auto;width:100%}.offset-xl-0{margin-left:0}.offset-xl-1{margin-left:8.33333333%}.offset-xl-2{margin-left:16.66666667%}.offset-xl-3{margin-left:25%}.offset-xl-4{margin-left:33.33333333%}.offset-xl-5{margin-left:41.66666667%}.offset-xl-6{margin-left:50%}.offset-xl-7{margin-left:58.33333333%}.offset-xl-8{margin-left:66.66666667%}.offset-xl-9{margin-left:75%}.offset-xl-10{margin-left:83.33333333%}.offset-xl-11{margin-left:91.66666667%}.g-xl-0,.gx-xl-0{--bs-gutter-x:0}.g-xl-0,.gy-xl-0{--bs-gutter-y:0}.g-xl-1,.gx-xl-1{--bs-gutter-x:0.25rem}.g-xl-1,.gy-xl-1{--bs-gutter-y:0.25rem}.g-xl-2,.gx-xl-2{--bs-gutter-x:0.5rem}.g-xl-2,.gy-xl-2{--bs-gutter-y:0.5rem}.g-xl-3,.gx-xl-3{--bs-gutter-x:1rem}.g-xl-3,.gy-xl-3{--bs-gutter-y:1rem}.g-xl-4,.gx-xl-4{--bs-gutter-x:1.5rem}.g-xl-4,.gy-xl-4{--bs-gutter-y:1.5rem}.g-xl-5,.gx-xl-5{--bs-gutter-x:3rem}.g-xl-5,.gy-xl-5{--bs-gutter-y:3rem}}@media (min-width:1400px){.col-xxl{flex:1 0 0%}.row-cols-xxl-auto>*{flex:0 0 auto;width:auto}.row-cols-xxl-1>*{flex:0 0 auto;width:100%}.row-cols-xxl-2>*{flex:0 0 auto;width:50%}.row-cols-xxl-3>*{flex:0 0 auto;width:33.3333333333%}.row-cols-xxl-4>*{flex:0 0 auto;width:25%}.row-cols-xxl-5>*{flex:0 0 auto;width:20%}.row-cols-xxl-6>*{flex:0 0 auto;width:16.6666666667%}.col-xxl-auto{flex:0 0 auto;width:auto}.col-xxl-1{flex:0 0 auto;width:8.33333333%}.col-xxl-2{flex:0 0 auto;width:16.66666667%}.col-xxl-3{flex:0 0 auto;width:25%}.col-xxl-4{flex:0 0 auto;width:33.33333333%}.col-xxl-5{flex:0 0 auto;width:41.66666667%}.col-xxl-6{flex:0 0 auto;width:50%}.col-xxl-7{flex:0 0 auto;width:58.33333333%}.col-xxl-8{flex:0 0 auto;width:66.66666667%}.col-xxl-9{flex:0 0 auto;width:75%}.col-xxl-10{flex:0 0 auto;width:83.33333333%}.col-xxl-11{flex:0 0 auto;width:91.66666667%}.col-xxl-12{flex:0 0 auto;width:100%}.offset-xxl-0{margin-left:0}.offset-xxl-1{margin-left:8.33333333%}.offset-xxl-2{margin-left:16.66666667%}.offset-xxl-3{margin-left:25%}.offset-xxl-4{margin-left:33.33333333%}.offset-xxl-5{margin-left:41.66666667%}.offset-xxl-6{margin-left:50%}.offset-xxl-7{margin-left:58.33333333%}.offset-xxl-8{margin-left:66.66666667%}.offset-xxl-9{margin-left:75%}.offset-xxl-10{margin-left:83.33333333%}.offset-xxl-11{margin-left:91.66666667%}.g-xxl-0,.gx-xxl-0{--bs-gutter-x:0}.g-xxl-0,.gy-xxl-0{--bs-gutter-y:0}.g-xxl-1,.gx-xxl-1{--bs-gutter-x:0.25rem}.g-xxl-1,.gy-xxl-1{--bs-gutter-y:0.25rem}.g-xxl-2,.gx-xxl-2{--bs-gutter-x:0.5rem}.g-xxl-2,.gy-xxl-2{--bs-gutter-y:0.5rem}.g-xxl-3,.gx-xxl-3{--bs-gutter-x:1rem}.g-xxl-3,.gy-xxl-3{--bs-gutter-y:1rem}.g-xxl-4,.gx-xxl-4{--bs-gutter-x:1.5rem}.g-xxl-4,.gy-xxl-4{--bs-gutter-y:1.5rem}.g-xxl-5,.gx-xxl-5{--bs-gutter-x:3rem}.g-xxl-5,.gy-xxl-5{--bs-gutter-y:3rem}}.table{--bs-table-color:var(--bs-body-color);--bs-table-bg:transparent;--bs-table-border-color:#444;--bs-table-accent-bg:transparent;--bs-table-striped-color:var(--bs-body-color);--bs-table-striped-bg:rgba(0, 0, 0, 0.05);--bs-table-active-color:var(--bs-body-color);--bs-table-active-bg:rgba(0, 0, 0, 0.1);--bs-table-hover-color:var(--bs-body-color);--bs-table-hover-bg:rgba(0, 0, 0, 0.075);width:100%;margin-bottom:1rem;color:var(--bs-table-color);vertical-align:top;border-color:var(--bs-table-border-color)}.table>:not(caption)>*>*{padding:.5rem .5rem;background-color:var(--bs-table-bg);border-bottom-width:1px;box-shadow:inset 0 0 0 9999px var(--bs-table-accent-bg)}.table>tbody{vertical-align:inherit}.table>thead{vertical-align:bottom}.table-group-divider{border-top:2px solid currentcolor}.caption-top{caption-side:top}.table-sm>:not(caption)>*>*{padding:.25rem .25rem}.table-bordered>:not(caption)>*{border-width:1px 0}.table-bordered>:not(caption)>*>*{border-width:0 1px}.table-borderless>:not(caption)>*>*{border-bottom-width:0}.table-borderless>:not(:first-child){border-top-width:0}.table-striped>tbody>tr:nth-of-type(odd)>*{--bs-table-accent-bg:var(--bs-table-striped-bg);color:var(--bs-table-striped-color)}.table-striped-columns>:not(caption)>tr>:nth-child(even){--bs-table-accent-bg:var(--bs-table-striped-bg);color:var(--bs-table-striped-color)}.table-active{--bs-table-accent-bg:var(--bs-table-active-bg);color:var(--bs-table-active-color)}.table-hover>tbody>tr:hover>*{--bs-table-accent-bg:var(--bs-table-hover-bg);color:var(--bs-table-hover-color)}.table-primary{--bs-table-color:#fff;--bs-table-bg:#375a7f;--bs-table-border-color:#4b6b8c;--bs-table-striped-bg:#416285;--bs-table-striped-color:#fff;--bs-table-active-bg:#4b6b8c;--bs-table-active-color:#fff;--bs-table-hover-bg:#466689;--bs-table-hover-color:#fff;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-secondary{--bs-table-color:#fff;--bs-table-bg:#444444;--bs-table-border-color:#575757;--bs-table-striped-bg:#4d4d4d;--bs-table-striped-color:#fff;--bs-table-active-bg:#575757;--bs-table-active-color:#fff;--bs-table-hover-bg:#525252;--bs-table-hover-color:#fff;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-success{--bs-table-color:#fff;--bs-table-bg:#00bc8c;--bs-table-border-color:#1ac398;--bs-table-striped-bg:#0dbf92;--bs-table-striped-color:#fff;--bs-table-active-bg:#1ac398;--bs-table-active-color:#fff;--bs-table-hover-bg:#13c195;--bs-table-hover-color:#fff;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-info{--bs-table-color:#fff;--bs-table-bg:#3498db;--bs-table-border-color:#48a2df;--bs-table-striped-bg:#3e9ddd;--bs-table-striped-color:#fff;--bs-table-active-bg:#48a2df;--bs-table-active-color:#fff;--bs-table-hover-bg:#43a0de;--bs-table-hover-color:#fff;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-warning{--bs-table-color:#fff;--bs-table-bg:#f39c12;--bs-table-border-color:#f4a62a;--bs-table-striped-bg:#f4a11e;--bs-table-striped-color:#fff;--bs-table-active-bg:#f4a62a;--bs-table-active-color:#fff;--bs-table-hover-bg:#f4a324;--bs-table-hover-color:#fff;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-danger{--bs-table-color:#fff;--bs-table-bg:#e74c3c;--bs-table-border-color:#e95e50;--bs-table-striped-bg:#e85546;--bs-table-striped-color:#fff;--bs-table-active-bg:#e95e50;--bs-table-active-color:#fff;--bs-table-hover-bg:#e9594b;--bs-table-hover-color:#fff;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-light{--bs-table-color:#fff;--bs-table-bg:#adb5bd;--bs-table-border-color:#b5bcc4;--bs-table-striped-bg:#b1b9c0;--bs-table-striped-color:#fff;--bs-table-active-bg:#b5bcc4;--bs-table-active-color:#fff;--bs-table-hover-bg:#b3bbc2;--bs-table-hover-color:#fff;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-dark{--bs-table-color:#fff;--bs-table-bg:#303030;--bs-table-border-color:#454545;--bs-table-striped-bg:#3a3a3a;--bs-table-striped-color:#fff;--bs-table-active-bg:#454545;--bs-table-active-color:#fff;--bs-table-hover-bg:#404040;--bs-table-hover-color:#fff;color:var(--bs-table-color);border-color:var(--bs-table-border-color)}.table-responsive{overflow-x:auto;-webkit-overflow-scrolling:touch}@media (max-width:575.98px){.table-responsive-sm{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width:767.98px){.table-responsive-md{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width:991.98px){.table-responsive-lg{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width:1199.98px){.table-responsive-xl{overflow-x:auto;-webkit-overflow-scrolling:touch}}@media (max-width:1399.98px){.table-responsive-xxl{overflow-x:auto;-webkit-overflow-scrolling:touch}}.form-label{margin-bottom:.5rem}.col-form-label{padding-top:calc(.375rem + 1px);padding-bottom:calc(.375rem + 1px);margin-bottom:0;font-size:inherit;line-height:1.5}.col-form-label-lg{padding-top:calc(.5rem + 1px);padding-bottom:calc(.5rem + 1px);font-size:1.25rem}.col-form-label-sm{padding-top:calc(.25rem + 1px);padding-bottom:calc(.25rem + 1px);font-size:.875rem}.form-text{margin-top:.25rem;font-size:.875em;color:#888}.form-control{display:block;width:100%;padding:.375rem .75rem;font-size:1rem;font-weight:400;line-height:1.5;color:#303030;background-color:#fff;background-clip:padding-box;border:1px solid #222;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-radius:.375rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out}@media (prefers-reduced-motion:reduce){.form-control{transition:none}}.form-control[type=file]{overflow:hidden}.form-control[type=file]:not(:disabled):not([readonly]){cursor:pointer}.form-control:focus{color:#303030;background-color:#fff;border-color:#9badbf;outline:0;box-shadow:0 0 0 .25rem rgba(55,90,127,.25)}.form-control::-webkit-date-and-time-value{height:1.5em}.form-control::-moz-placeholder{color:#888;opacity:1}.form-control::placeholder{color:#888;opacity:1}.form-control:disabled{background-color:#ebebeb;opacity:1}.form-control::-webkit-file-upload-button{padding:.375rem .75rem;margin:-.375rem -.75rem;-webkit-margin-end:.75rem;margin-inline-end:.75rem;color:#fff;background-color:#444;pointer-events:none;border-color:inherit;border-style:solid;border-width:0;border-inline-end-width:1px;border-radius:0;-webkit-transition:color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;transition:color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out}.form-control::file-selector-button{padding:.375rem .75rem;margin:-.375rem -.75rem;-webkit-margin-end:.75rem;margin-inline-end:.75rem;color:#fff;background-color:#444;pointer-events:none;border-color:inherit;border-style:solid;border-width:0;border-inline-end-width:1px;border-radius:0;transition:color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out}@media (prefers-reduced-motion:reduce){.form-control::-webkit-file-upload-button{-webkit-transition:none;transition:none}.form-control::file-selector-button{transition:none}}.form-control:hover:not(:disabled):not([readonly])::-webkit-file-upload-button{background-color:#414141}.form-control:hover:not(:disabled):not([readonly])::file-selector-button{background-color:#414141}.form-control-plaintext{display:block;width:100%;padding:.375rem 0;margin-bottom:0;line-height:1.5;color:#fff;background-color:transparent;border:solid transparent;border-width:1px 0}.form-control-plaintext:focus{outline:0}.form-control-plaintext.form-control-lg,.form-control-plaintext.form-control-sm{padding-right:0;padding-left:0}.form-control-sm{min-height:calc(1.5em + .5rem + 2px);padding:.25rem .5rem;font-size:.875rem;border-radius:.25rem}.form-control-sm::-webkit-file-upload-button{padding:.25rem .5rem;margin:-.25rem -.5rem;-webkit-margin-end:.5rem;margin-inline-end:.5rem}.form-control-sm::file-selector-button{padding:.25rem .5rem;margin:-.25rem -.5rem;-webkit-margin-end:.5rem;margin-inline-end:.5rem}.form-control-lg{min-height:calc(1.5em + 1rem + 2px);padding:.5rem 1rem;font-size:1.25rem;border-radius:.5rem}.form-control-lg::-webkit-file-upload-button{padding:.5rem 1rem;margin:-.5rem -1rem;-webkit-margin-end:1rem;margin-inline-end:1rem}.form-control-lg::file-selector-button{padding:.5rem 1rem;margin:-.5rem -1rem;-webkit-margin-end:1rem;margin-inline-end:1rem}textarea.form-control{min-height:calc(1.5em + .75rem + 2px)}textarea.form-control-sm{min-height:calc(1.5em + .5rem + 2px)}textarea.form-control-lg{min-height:calc(1.5em + 1rem + 2px)}.form-control-color{width:3rem;height:calc(1.5em + .75rem + 2px);padding:.375rem}.form-control-color:not(:disabled):not([readonly]){cursor:pointer}.form-control-color::-moz-color-swatch{border:0!important;border-radius:.375rem}.form-control-color::-webkit-color-swatch{border-radius:.375rem}.form-control-color.form-control-sm{height:calc(1.5em + .5rem + 2px)}.form-control-color.form-control-lg{height:calc(1.5em + 1rem + 2px)}.form-select{display:block;width:100%;padding:.375rem 2.25rem .375rem .75rem;-moz-padding-start:calc(0.75rem - 3px);font-size:1rem;font-weight:400;line-height:1.5;color:#303030;background-color:#fff;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23303030' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right .75rem center;background-size:16px 12px;border:1px solid #222;border-radius:.375rem;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;-webkit-appearance:none;-moz-appearance:none;appearance:none}@media (prefers-reduced-motion:reduce){.form-select{transition:none}}.form-select:focus{border-color:#9badbf;outline:0;box-shadow:0 0 0 .25rem rgba(55,90,127,.25)}.form-select[multiple],.form-select[size]:not([size="1"]){padding-right:.75rem;background-image:none}.form-select:disabled{background-color:#ebebeb}.form-select:-moz-focusring{color:transparent;text-shadow:0 0 0 #303030}.form-select-sm{padding-top:.25rem;padding-bottom:.25rem;padding-left:.5rem;font-size:.875rem;border-radius:.25rem}.form-select-lg{padding-top:.5rem;padding-bottom:.5rem;padding-left:1rem;font-size:1.25rem;border-radius:.5rem}.form-check{display:block;min-height:1.5rem;padding-left:1.5em;margin-bottom:.125rem}.form-check .form-check-input{float:left;margin-left:-1.5em}.form-check-reverse{padding-right:1.5em;padding-left:0;text-align:right}.form-check-reverse .form-check-input{float:right;margin-right:-1.5em;margin-left:0}.form-check-input{width:1em;height:1em;margin-top:.25em;vertical-align:top;background-color:#fff;background-repeat:no-repeat;background-position:center;background-size:contain;border:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-print-color-adjust:exact;color-adjust:exact;print-color-adjust:exact}.form-check-input[type=checkbox]{border-radius:.25em}.form-check-input[type=radio]{border-radius:50%}.form-check-input:active{filter:brightness(90%)}.form-check-input:focus{border-color:#9badbf;outline:0;box-shadow:0 0 0 .25rem rgba(55,90,127,.25)}.form-check-input:checked{background-color:#375a7f;border-color:#375a7f}.form-check-input:checked[type=checkbox]{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e")}.form-check-input:checked[type=radio]{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e")}.form-check-input[type=checkbox]:indeterminate{background-color:#375a7f;border-color:#375a7f;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/%3e%3c/svg%3e")}.form-check-input:disabled{pointer-events:none;filter:none;opacity:.5}.form-check-input:disabled~.form-check-label,.form-check-input[disabled]~.form-check-label{cursor:default;opacity:.5}.form-switch{padding-left:2.5em}.form-switch .form-check-input{width:2em;margin-left:-2.5em;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280, 0, 0, 0.25%29'/%3e%3c/svg%3e");background-position:left center;border-radius:2em;transition:background-position .15s ease-in-out}@media (prefers-reduced-motion:reduce){.form-switch .form-check-input{transition:none}}.form-switch .form-check-input:focus{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%239badbf'/%3e%3c/svg%3e")}.form-switch .form-check-input:checked{background-position:right center;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e")}.form-switch.form-check-reverse{padding-right:2.5em;padding-left:0}.form-switch.form-check-reverse .form-check-input{margin-right:-2.5em;margin-left:0}.form-check-inline{display:inline-block;margin-right:1rem}.btn-check{position:absolute;clip:rect(0,0,0,0);pointer-events:none}.btn-check:disabled+.btn,.btn-check[disabled]+.btn{pointer-events:none;filter:none;opacity:.65}.form-range{width:100%;height:1.5rem;padding:0;background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none}.form-range:focus{outline:0}.form-range:focus::-webkit-slider-thumb{box-shadow:0 0 0 1px #222,0 0 0 .25rem rgba(55,90,127,.25)}.form-range:focus::-moz-range-thumb{box-shadow:0 0 0 1px #222,0 0 0 .25rem rgba(55,90,127,.25)}.form-range::-moz-focus-outer{border:0}.form-range::-webkit-slider-thumb{width:1rem;height:1rem;margin-top:-.25rem;background-color:#375a7f;border:0;border-radius:1rem;-webkit-transition:background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;transition:background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;-webkit-appearance:none;appearance:none}@media (prefers-reduced-motion:reduce){.form-range::-webkit-slider-thumb{-webkit-transition:none;transition:none}}.form-range::-webkit-slider-thumb:active{background-color:#c3ced9}.form-range::-webkit-slider-runnable-track{width:100%;height:.5rem;color:transparent;cursor:pointer;background-color:#dee2e6;border-color:transparent;border-radius:1rem}.form-range::-moz-range-thumb{width:1rem;height:1rem;background-color:#375a7f;border:0;border-radius:1rem;-moz-transition:background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;transition:background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;-moz-appearance:none;appearance:none}@media (prefers-reduced-motion:reduce){.form-range::-moz-range-thumb{-moz-transition:none;transition:none}}.form-range::-moz-range-thumb:active{background-color:#c3ced9}.form-range::-moz-range-track{width:100%;height:.5rem;color:transparent;cursor:pointer;background-color:#dee2e6;border-color:transparent;border-radius:1rem}.form-range:disabled{pointer-events:none}.form-range:disabled::-webkit-slider-thumb{background-color:#adb5bd}.form-range:disabled::-moz-range-thumb{background-color:#adb5bd}.form-floating{position:relative}.form-floating>.form-control,.form-floating>.form-control-plaintext,.form-floating>.form-select{height:calc(3.5rem + 2px);line-height:1.25}.form-floating>label{position:absolute;top:0;left:0;width:100%;height:100%;padding:1rem .75rem;overflow:hidden;text-align:start;text-overflow:ellipsis;white-space:nowrap;pointer-events:none;border:1px solid transparent;transform-origin:0 0;transition:opacity .1s ease-in-out,transform .1s ease-in-out}@media (prefers-reduced-motion:reduce){.form-floating>label{transition:none}}.form-floating>.form-control,.form-floating>.form-control-plaintext{padding:1rem .75rem}.form-floating>.form-control-plaintext::-moz-placeholder,.form-floating>.form-control::-moz-placeholder{color:transparent}.form-floating>.form-control-plaintext::placeholder,.form-floating>.form-control::placeholder{color:transparent}.form-floating>.form-control-plaintext:not(:-moz-placeholder-shown),.form-floating>.form-control:not(:-moz-placeholder-shown){padding-top:1.625rem;padding-bottom:.625rem}.form-floating>.form-control-plaintext:focus,.form-floating>.form-control-plaintext:not(:placeholder-shown),.form-floating>.form-control:focus,.form-floating>.form-control:not(:placeholder-shown){padding-top:1.625rem;padding-bottom:.625rem}.form-floating>.form-control-plaintext:-webkit-autofill,.form-floating>.form-control:-webkit-autofill{padding-top:1.625rem;padding-bottom:.625rem}.form-floating>.form-select{padding-top:1.625rem;padding-bottom:.625rem}.form-floating>.form-control:not(:-moz-placeholder-shown)~label{opacity:.65;transform:scale(.85) translateY(-.5rem) translateX(.15rem)}.form-floating>.form-control-plaintext~label,.form-floating>.form-control:focus~label,.form-floating>.form-control:not(:placeholder-shown)~label,.form-floating>.form-select~label{opacity:.65;transform:scale(.85) translateY(-.5rem) translateX(.15rem)}.form-floating>.form-control:-webkit-autofill~label{opacity:.65;transform:scale(.85) translateY(-.5rem) translateX(.15rem)}.form-floating>.form-control-plaintext~label{border-width:1px 0}.input-group{position:relative;display:flex;flex-wrap:wrap;align-items:stretch;width:100%}.input-group>.form-control,.input-group>.form-floating,.input-group>.form-select{position:relative;flex:1 1 auto;width:1%;min-width:0}.input-group>.form-control:focus,.input-group>.form-floating:focus-within,.input-group>.form-select:focus{z-index:5}.input-group .btn{position:relative;z-index:2}.input-group .btn:focus{z-index:5}.input-group-text{display:flex;align-items:center;padding:.375rem .75rem;font-size:1rem;font-weight:400;line-height:1.5;color:#adb5bd;text-align:center;white-space:nowrap;background-color:#444;border:1px solid #222;border-radius:.375rem}.input-group-lg>.btn,.input-group-lg>.form-control,.input-group-lg>.form-select,.input-group-lg>.input-group-text{padding:.5rem 1rem;font-size:1.25rem;border-radius:.5rem}.input-group-sm>.btn,.input-group-sm>.form-control,.input-group-sm>.form-select,.input-group-sm>.input-group-text{padding:.25rem .5rem;font-size:.875rem;border-radius:.25rem}.input-group-lg>.form-select,.input-group-sm>.form-select{padding-right:3rem}.input-group:not(.has-validation)>.dropdown-toggle:nth-last-child(n+3),.input-group:not(.has-validation)>.form-floating:not(:last-child)>.form-control,.input-group:not(.has-validation)>.form-floating:not(:last-child)>.form-select,.input-group:not(.has-validation)>:not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating){border-top-right-radius:0;border-bottom-right-radius:0}.input-group.has-validation>.dropdown-toggle:nth-last-child(n+4),.input-group.has-validation>.form-floating:nth-last-child(n+3)>.form-control,.input-group.has-validation>.form-floating:nth-last-child(n+3)>.form-select,.input-group.has-validation>:nth-last-child(n+3):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating){border-top-right-radius:0;border-bottom-right-radius:0}.input-group>:not(:first-child):not(.dropdown-menu):not(.valid-tooltip):not(.valid-feedback):not(.invalid-tooltip):not(.invalid-feedback){margin-left:-1px;border-top-left-radius:0;border-bottom-left-radius:0}.input-group>.form-floating:not(:first-child)>.form-control,.input-group>.form-floating:not(:first-child)>.form-select{border-top-left-radius:0;border-bottom-left-radius:0}.valid-feedback{display:none;width:100%;margin-top:.25rem;font-size:.875em;color:#00bc8c}.valid-tooltip{position:absolute;top:100%;z-index:5;display:none;max-width:100%;padding:.25rem .5rem;margin-top:.1rem;font-size:.875rem;color:#fff;background-color:rgba(0,188,140,.9);border-radius:.375rem}.is-valid~.valid-feedback,.is-valid~.valid-tooltip,.was-validated :valid~.valid-feedback,.was-validated :valid~.valid-tooltip{display:block}.form-control.is-valid,.was-validated .form-control:valid{border-color:#00bc8c;padding-right:calc(1.5em + .75rem);background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2300bc8c' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right calc(.375em + .1875rem) center;background-size:calc(.75em + .375rem) calc(.75em + .375rem)}.form-control.is-valid:focus,.was-validated .form-control:valid:focus{border-color:#00bc8c;box-shadow:0 0 0 .25rem rgba(0,188,140,.25)}.was-validated textarea.form-control:valid,textarea.form-control.is-valid{padding-right:calc(1.5em + .75rem);background-position:top calc(.375em + .1875rem) right calc(.375em + .1875rem)}.form-select.is-valid,.was-validated .form-select:valid{border-color:#00bc8c}.form-select.is-valid:not([multiple]):not([size]),.form-select.is-valid:not([multiple])[size="1"],.was-validated .form-select:valid:not([multiple]):not([size]),.was-validated .form-select:valid:not([multiple])[size="1"]{padding-right:4.125rem;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23303030' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"),url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2300bc8c' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");background-position:right .75rem center,center right 2.25rem;background-size:16px 12px,calc(.75em + .375rem) calc(.75em + .375rem)}.form-select.is-valid:focus,.was-validated .form-select:valid:focus{border-color:#00bc8c;box-shadow:0 0 0 .25rem rgba(0,188,140,.25)}.form-control-color.is-valid,.was-validated .form-control-color:valid{width:calc(3rem + calc(1.5em + .75rem))}.form-check-input.is-valid,.was-validated .form-check-input:valid{border-color:#00bc8c}.form-check-input.is-valid:checked,.was-validated .form-check-input:valid:checked{background-color:#00bc8c}.form-check-input.is-valid:focus,.was-validated .form-check-input:valid:focus{box-shadow:0 0 0 .25rem rgba(0,188,140,.25)}.form-check-input.is-valid~.form-check-label,.was-validated .form-check-input:valid~.form-check-label{color:#00bc8c}.form-check-inline .form-check-input~.valid-feedback{margin-left:.5em}.input-group>.form-control:not(:focus).is-valid,.input-group>.form-floating:not(:focus-within).is-valid,.input-group>.form-select:not(:focus).is-valid,.was-validated .input-group>.form-control:not(:focus):valid,.was-validated .input-group>.form-floating:not(:focus-within):valid,.was-validated .input-group>.form-select:not(:focus):valid{z-index:3}.invalid-feedback{display:none;width:100%;margin-top:.25rem;font-size:.875em;color:#e74c3c}.invalid-tooltip{position:absolute;top:100%;z-index:5;display:none;max-width:100%;padding:.25rem .5rem;margin-top:.1rem;font-size:.875rem;color:#fff;background-color:rgba(231,76,60,.9);border-radius:.375rem}.is-invalid~.invalid-feedback,.is-invalid~.invalid-tooltip,.was-validated :invalid~.invalid-feedback,.was-validated :invalid~.invalid-tooltip{display:block}.form-control.is-invalid,.was-validated .form-control:invalid{border-color:#e74c3c;padding-right:calc(1.5em + .75rem);background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23e74c3c'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23e74c3c' stroke='none'/%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right calc(.375em + .1875rem) center;background-size:calc(.75em + .375rem) calc(.75em + .375rem)}.form-control.is-invalid:focus,.was-validated .form-control:invalid:focus{border-color:#e74c3c;box-shadow:0 0 0 .25rem rgba(231,76,60,.25)}.was-validated textarea.form-control:invalid,textarea.form-control.is-invalid{padding-right:calc(1.5em + .75rem);background-position:top calc(.375em + .1875rem) right calc(.375em + .1875rem)}.form-select.is-invalid,.was-validated .form-select:invalid{border-color:#e74c3c}.form-select.is-invalid:not([multiple]):not([size]),.form-select.is-invalid:not([multiple])[size="1"],.was-validated .form-select:invalid:not([multiple]):not([size]),.was-validated .form-select:invalid:not([multiple])[size="1"]{padding-right:4.125rem;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23303030' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"),url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23e74c3c'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23e74c3c' stroke='none'/%3e%3c/svg%3e");background-position:right .75rem center,center right 2.25rem;background-size:16px 12px,calc(.75em + .375rem) calc(.75em + .375rem)}.form-select.is-invalid:focus,.was-validated .form-select:invalid:focus{border-color:#e74c3c;box-shadow:0 0 0 .25rem rgba(231,76,60,.25)}.form-control-color.is-invalid,.was-validated .form-control-color:invalid{width:calc(3rem + calc(1.5em + .75rem))}.form-check-input.is-invalid,.was-validated .form-check-input:invalid{border-color:#e74c3c}.form-check-input.is-invalid:checked,.was-validated .form-check-input:invalid:checked{background-color:#e74c3c}.form-check-input.is-invalid:focus,.was-validated .form-check-input:invalid:focus{box-shadow:0 0 0 .25rem rgba(231,76,60,.25)}.form-check-input.is-invalid~.form-check-label,.was-validated .form-check-input:invalid~.form-check-label{color:#e74c3c}.form-check-inline .form-check-input~.invalid-feedback{margin-left:.5em}.input-group>.form-control:not(:focus).is-invalid,.input-group>.form-floating:not(:focus-within).is-invalid,.input-group>.form-select:not(:focus).is-invalid,.was-validated .input-group>.form-control:not(:focus):invalid,.was-validated .input-group>.form-floating:not(:focus-within):invalid,.was-validated .input-group>.form-select:not(:focus):invalid{z-index:4}.btn{--bs-btn-padding-x:0.75rem;--bs-btn-padding-y:0.375rem;--bs-btn-font-family: ;--bs-btn-font-size:1rem;--bs-btn-font-weight:400;--bs-btn-line-height:1.5;--bs-btn-color:#fff;--bs-btn-bg:transparent;--bs-btn-border-width:1px;--bs-btn-border-color:transparent;--bs-btn-border-radius:0.375rem;--bs-btn-hover-border-color:transparent;--bs-btn-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.15),0 1px 1px rgba(0, 0, 0, 0.075);--bs-btn-disabled-opacity:0.65;--bs-btn-focus-box-shadow:0 0 0 0.25rem rgba(var(--bs-btn-focus-shadow-rgb), .5);display:inline-block;padding:var(--bs-btn-padding-y) var(--bs-btn-padding-x);font-family:var(--bs-btn-font-family);font-size:var(--bs-btn-font-size);font-weight:var(--bs-btn-font-weight);line-height:var(--bs-btn-line-height);color:var(--bs-btn-color);text-align:center;text-decoration:none;vertical-align:middle;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;border:var(--bs-btn-border-width) solid var(--bs-btn-border-color);border-radius:var(--bs-btn-border-radius);background-color:var(--bs-btn-bg);transition:color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out}@media (prefers-reduced-motion:reduce){.btn{transition:none}}.btn:hover{color:var(--bs-btn-hover-color);background-color:var(--bs-btn-hover-bg);border-color:var(--bs-btn-hover-border-color)}.btn-check+.btn:hover{color:var(--bs-btn-color);background-color:var(--bs-btn-bg);border-color:var(--bs-btn-border-color)}.btn:focus-visible{color:var(--bs-btn-hover-color);background-color:var(--bs-btn-hover-bg);border-color:var(--bs-btn-hover-border-color);outline:0;box-shadow:var(--bs-btn-focus-box-shadow)}.btn-check:focus-visible+.btn{border-color:var(--bs-btn-hover-border-color);outline:0;box-shadow:var(--bs-btn-focus-box-shadow)}.btn-check:checked+.btn,.btn.active,.btn.show,.btn:first-child:active,:not(.btn-check)+.btn:active{color:var(--bs-btn-active-color);background-color:var(--bs-btn-active-bg);border-color:var(--bs-btn-active-border-color)}.btn-check:checked+.btn:focus-visible,.btn.active:focus-visible,.btn.show:focus-visible,.btn:first-child:active:focus-visible,:not(.btn-check)+.btn:active:focus-visible{box-shadow:var(--bs-btn-focus-box-shadow)}.btn.disabled,.btn:disabled,fieldset:disabled .btn{color:var(--bs-btn-disabled-color);pointer-events:none;background-color:var(--bs-btn-disabled-bg);border-color:var(--bs-btn-disabled-border-color);opacity:var(--bs-btn-disabled-opacity)}.btn-primary{--bs-btn-color:#fff;--bs-btn-bg:#375a7f;--bs-btn-border-color:#375a7f;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#2f4d6c;--bs-btn-hover-border-color:#2c4866;--bs-btn-focus-shadow-rgb:85,115,146;--bs-btn-active-color:#fff;--bs-btn-active-bg:#2c4866;--bs-btn-active-border-color:#29445f;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#375a7f;--bs-btn-disabled-border-color:#375a7f}.btn-secondary{--bs-btn-color:#fff;--bs-btn-bg:#444;--bs-btn-border-color:#444;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#3a3a3a;--bs-btn-hover-border-color:#363636;--bs-btn-focus-shadow-rgb:96,96,96;--bs-btn-active-color:#fff;--bs-btn-active-bg:#363636;--bs-btn-active-border-color:#333333;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#444;--bs-btn-disabled-border-color:#444}.btn-success{--bs-btn-color:#fff;--bs-btn-bg:#00bc8c;--bs-btn-border-color:#00bc8c;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#00a077;--bs-btn-hover-border-color:#009670;--bs-btn-focus-shadow-rgb:38,198,157;--bs-btn-active-color:#fff;--bs-btn-active-bg:#009670;--bs-btn-active-border-color:#008d69;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#00bc8c;--bs-btn-disabled-border-color:#00bc8c}.btn-info{--bs-btn-color:#fff;--bs-btn-bg:#3498db;--bs-btn-border-color:#3498db;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#2c81ba;--bs-btn-hover-border-color:#2a7aaf;--bs-btn-focus-shadow-rgb:82,167,224;--bs-btn-active-color:#fff;--bs-btn-active-bg:#2a7aaf;--bs-btn-active-border-color:#2772a4;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#3498db;--bs-btn-disabled-border-color:#3498db}.btn-warning{--bs-btn-color:#fff;--bs-btn-bg:#f39c12;--bs-btn-border-color:#f39c12;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#cf850f;--bs-btn-hover-border-color:#c27d0e;--bs-btn-focus-shadow-rgb:245,171,54;--bs-btn-active-color:#fff;--bs-btn-active-bg:#c27d0e;--bs-btn-active-border-color:#b6750e;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#f39c12;--bs-btn-disabled-border-color:#f39c12}.btn-danger{--bs-btn-color:#fff;--bs-btn-bg:#e74c3c;--bs-btn-border-color:#e74c3c;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#c44133;--bs-btn-hover-border-color:#b93d30;--bs-btn-focus-shadow-rgb:235,103,89;--bs-btn-active-color:#fff;--bs-btn-active-bg:#b93d30;--bs-btn-active-border-color:#ad392d;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#e74c3c;--bs-btn-disabled-border-color:#e74c3c}.btn-light{--bs-btn-color:#fff;--bs-btn-bg:#adb5bd;--bs-btn-border-color:#adb5bd;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#939aa1;--bs-btn-hover-border-color:#8a9197;--bs-btn-focus-shadow-rgb:185,192,199;--bs-btn-active-color:#fff;--bs-btn-active-bg:#8a9197;--bs-btn-active-border-color:#82888e;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#adb5bd;--bs-btn-disabled-border-color:#adb5bd}.btn-dark{--bs-btn-color:#fff;--bs-btn-bg:#303030;--bs-btn-border-color:#303030;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#4f4f4f;--bs-btn-hover-border-color:#454545;--bs-btn-focus-shadow-rgb:79,79,79;--bs-btn-active-color:#fff;--bs-btn-active-bg:#595959;--bs-btn-active-border-color:#454545;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#fff;--bs-btn-disabled-bg:#303030;--bs-btn-disabled-border-color:#303030}.btn-outline-primary{--bs-btn-color:#375a7f;--bs-btn-border-color:#375a7f;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#375a7f;--bs-btn-hover-border-color:#375a7f;--bs-btn-focus-shadow-rgb:55,90,127;--bs-btn-active-color:#fff;--bs-btn-active-bg:#375a7f;--bs-btn-active-border-color:#375a7f;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#375a7f;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#375a7f;--bs-gradient:none}.btn-outline-secondary{--bs-btn-color:#444;--bs-btn-border-color:#444;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#444;--bs-btn-hover-border-color:#444;--bs-btn-focus-shadow-rgb:68,68,68;--bs-btn-active-color:#fff;--bs-btn-active-bg:#444;--bs-btn-active-border-color:#444;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#444;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#444;--bs-gradient:none}.btn-outline-success{--bs-btn-color:#00bc8c;--bs-btn-border-color:#00bc8c;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#00bc8c;--bs-btn-hover-border-color:#00bc8c;--bs-btn-focus-shadow-rgb:0,188,140;--bs-btn-active-color:#fff;--bs-btn-active-bg:#00bc8c;--bs-btn-active-border-color:#00bc8c;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#00bc8c;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#00bc8c;--bs-gradient:none}.btn-outline-info{--bs-btn-color:#3498db;--bs-btn-border-color:#3498db;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#3498db;--bs-btn-hover-border-color:#3498db;--bs-btn-focus-shadow-rgb:52,152,219;--bs-btn-active-color:#fff;--bs-btn-active-bg:#3498db;--bs-btn-active-border-color:#3498db;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#3498db;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#3498db;--bs-gradient:none}.btn-outline-warning{--bs-btn-color:#f39c12;--bs-btn-border-color:#f39c12;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#f39c12;--bs-btn-hover-border-color:#f39c12;--bs-btn-focus-shadow-rgb:243,156,18;--bs-btn-active-color:#fff;--bs-btn-active-bg:#f39c12;--bs-btn-active-border-color:#f39c12;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#f39c12;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#f39c12;--bs-gradient:none}.btn-outline-danger{--bs-btn-color:#e74c3c;--bs-btn-border-color:#e74c3c;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#e74c3c;--bs-btn-hover-border-color:#e74c3c;--bs-btn-focus-shadow-rgb:231,76,60;--bs-btn-active-color:#fff;--bs-btn-active-bg:#e74c3c;--bs-btn-active-border-color:#e74c3c;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#e74c3c;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#e74c3c;--bs-gradient:none}.btn-outline-light{--bs-btn-color:#adb5bd;--bs-btn-border-color:#adb5bd;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#adb5bd;--bs-btn-hover-border-color:#adb5bd;--bs-btn-focus-shadow-rgb:173,181,189;--bs-btn-active-color:#fff;--bs-btn-active-bg:#adb5bd;--bs-btn-active-border-color:#adb5bd;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#adb5bd;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#adb5bd;--bs-gradient:none}.btn-outline-dark{--bs-btn-color:#303030;--bs-btn-border-color:#303030;--bs-btn-hover-color:#fff;--bs-btn-hover-bg:#303030;--bs-btn-hover-border-color:#303030;--bs-btn-focus-shadow-rgb:48,48,48;--bs-btn-active-color:#fff;--bs-btn-active-bg:#303030;--bs-btn-active-border-color:#303030;--bs-btn-active-shadow:inset 0 3px 5px rgba(0, 0, 0, 0.125);--bs-btn-disabled-color:#303030;--bs-btn-disabled-bg:transparent;--bs-btn-disabled-border-color:#303030;--bs-gradient:none}.btn-link{--bs-btn-font-weight:400;--bs-btn-color:var(--bs-link-color);--bs-btn-bg:transparent;--bs-btn-border-color:transparent;--bs-btn-hover-color:var(--bs-link-hover-color);--bs-btn-hover-border-color:transparent;--bs-btn-active-color:var(--bs-link-hover-color);--bs-btn-active-border-color:transparent;--bs-btn-disabled-color:#888;--bs-btn-disabled-border-color:transparent;--bs-btn-box-shadow:none;--bs-btn-focus-shadow-rgb:85,115,146;text-decoration:underline}.btn-link:focus-visible{color:var(--bs-btn-color)}.btn-link:hover{color:var(--bs-btn-hover-color)}.btn-group-lg>.btn,.btn-lg{--bs-btn-padding-y:0.5rem;--bs-btn-padding-x:1rem;--bs-btn-font-size:1.25rem;--bs-btn-border-radius:0.5rem}.btn-group-sm>.btn,.btn-sm{--bs-btn-padding-y:0.25rem;--bs-btn-padding-x:0.5rem;--bs-btn-font-size:0.875rem;--bs-btn-border-radius:0.25rem}.fade{transition:opacity .15s linear}@media (prefers-reduced-motion:reduce){.fade{transition:none}}.fade:not(.show){opacity:0}.collapse:not(.show){display:none}.collapsing{height:0;overflow:hidden;transition:height .35s ease}@media (prefers-reduced-motion:reduce){.collapsing{transition:none}}.collapsing.collapse-horizontal{width:0;height:auto;transition:width .35s ease}@media (prefers-reduced-motion:reduce){.collapsing.collapse-horizontal{transition:none}}.dropdown,.dropdown-center,.dropend,.dropstart,.dropup,.dropup-center{position:relative}.dropdown-toggle{white-space:nowrap}.dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:"";border-top:.3em solid;border-right:.3em solid transparent;border-bottom:0;border-left:.3em solid transparent}.dropdown-toggle:empty::after{margin-left:0}.dropdown-menu{--bs-dropdown-zindex:1000;--bs-dropdown-min-width:10rem;--bs-dropdown-padding-x:0;--bs-dropdown-padding-y:0.5rem;--bs-dropdown-spacer:0.125rem;--bs-dropdown-font-size:1rem;--bs-dropdown-color:#fff;--bs-dropdown-bg:#222;--bs-dropdown-border-color:#444;--bs-dropdown-border-radius:0.375rem;--bs-dropdown-border-width:1px;--bs-dropdown-inner-border-radius:calc(0.375rem - 1px);--bs-dropdown-divider-bg:#444;--bs-dropdown-divider-margin-y:0.5rem;--bs-dropdown-box-shadow:0 0.5rem 1rem rgba(0, 0, 0, 0.15);--bs-dropdown-link-color:#fff;--bs-dropdown-link-hover-color:#fff;--bs-dropdown-link-hover-bg:#375a7f;--bs-dropdown-link-active-color:#fff;--bs-dropdown-link-active-bg:#375a7f;--bs-dropdown-link-disabled-color:#adb5bd;--bs-dropdown-item-padding-x:1rem;--bs-dropdown-item-padding-y:0.25rem;--bs-dropdown-header-color:#888;--bs-dropdown-header-padding-x:1rem;--bs-dropdown-header-padding-y:0.5rem;position:absolute;z-index:var(--bs-dropdown-zindex);display:none;min-width:var(--bs-dropdown-min-width);padding:var(--bs-dropdown-padding-y) var(--bs-dropdown-padding-x);margin:0;font-size:var(--bs-dropdown-font-size);color:var(--bs-dropdown-color);text-align:left;list-style:none;background-color:var(--bs-dropdown-bg);background-clip:padding-box;border:var(--bs-dropdown-border-width) solid var(--bs-dropdown-border-color);border-radius:var(--bs-dropdown-border-radius)}.dropdown-menu[data-bs-popper]{top:100%;left:0;margin-top:var(--bs-dropdown-spacer)}.dropdown-menu-start{--bs-position:start}.dropdown-menu-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-end{--bs-position:end}.dropdown-menu-end[data-bs-popper]{right:0;left:auto}@media (min-width:576px){.dropdown-menu-sm-start{--bs-position:start}.dropdown-menu-sm-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-sm-end{--bs-position:end}.dropdown-menu-sm-end[data-bs-popper]{right:0;left:auto}}@media (min-width:768px){.dropdown-menu-md-start{--bs-position:start}.dropdown-menu-md-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-md-end{--bs-position:end}.dropdown-menu-md-end[data-bs-popper]{right:0;left:auto}}@media (min-width:992px){.dropdown-menu-lg-start{--bs-position:start}.dropdown-menu-lg-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-lg-end{--bs-position:end}.dropdown-menu-lg-end[data-bs-popper]{right:0;left:auto}}@media (min-width:1200px){.dropdown-menu-xl-start{--bs-position:start}.dropdown-menu-xl-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-xl-end{--bs-position:end}.dropdown-menu-xl-end[data-bs-popper]{right:0;left:auto}}@media (min-width:1400px){.dropdown-menu-xxl-start{--bs-position:start}.dropdown-menu-xxl-start[data-bs-popper]{right:auto;left:0}.dropdown-menu-xxl-end{--bs-position:end}.dropdown-menu-xxl-end[data-bs-popper]{right:0;left:auto}}.dropup .dropdown-menu[data-bs-popper]{top:auto;bottom:100%;margin-top:0;margin-bottom:var(--bs-dropdown-spacer)}.dropup .dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:"";border-top:0;border-right:.3em solid transparent;border-bottom:.3em solid;border-left:.3em solid transparent}.dropup .dropdown-toggle:empty::after{margin-left:0}.dropend .dropdown-menu[data-bs-popper]{top:0;right:auto;left:100%;margin-top:0;margin-left:var(--bs-dropdown-spacer)}.dropend .dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:"";border-top:.3em solid transparent;border-right:0;border-bottom:.3em solid transparent;border-left:.3em solid}.dropend .dropdown-toggle:empty::after{margin-left:0}.dropend .dropdown-toggle::after{vertical-align:0}.dropstart .dropdown-menu[data-bs-popper]{top:0;right:100%;left:auto;margin-top:0;margin-right:var(--bs-dropdown-spacer)}.dropstart .dropdown-toggle::after{display:inline-block;margin-left:.255em;vertical-align:.255em;content:""}.dropstart .dropdown-toggle::after{display:none}.dropstart .dropdown-toggle::before{display:inline-block;margin-right:.255em;vertical-align:.255em;content:"";border-top:.3em solid transparent;border-right:.3em solid;border-bottom:.3em solid transparent}.dropstart .dropdown-toggle:empty::after{margin-left:0}.dropstart .dropdown-toggle::before{vertical-align:0}.dropdown-divider{height:0;margin:var(--bs-dropdown-divider-margin-y) 0;overflow:hidden;border-top:1px solid var(--bs-dropdown-divider-bg);opacity:1}.dropdown-item{display:block;width:100%;padding:var(--bs-dropdown-item-padding-y) var(--bs-dropdown-item-padding-x);clear:both;font-weight:400;color:var(--bs-dropdown-link-color);text-align:inherit;text-decoration:none;white-space:nowrap;background-color:transparent;border:0}.dropdown-item:focus,.dropdown-item:hover{color:var(--bs-dropdown-link-hover-color);background-color:var(--bs-dropdown-link-hover-bg)}.dropdown-item.active,.dropdown-item:active{color:var(--bs-dropdown-link-active-color);text-decoration:none;background-color:var(--bs-dropdown-link-active-bg)}.dropdown-item.disabled,.dropdown-item:disabled{color:var(--bs-dropdown-link-disabled-color);pointer-events:none;background-color:transparent}.dropdown-menu.show{display:block}.dropdown-header{display:block;padding:var(--bs-dropdown-header-padding-y) var(--bs-dropdown-header-padding-x);margin-bottom:0;font-size:.875rem;color:var(--bs-dropdown-header-color);white-space:nowrap}.dropdown-item-text{display:block;padding:var(--bs-dropdown-item-padding-y) var(--bs-dropdown-item-padding-x);color:var(--bs-dropdown-link-color)}.dropdown-menu-dark{--bs-dropdown-color:#dee2e6;--bs-dropdown-bg:#303030;--bs-dropdown-border-color:#444;--bs-dropdown-box-shadow: ;--bs-dropdown-link-color:#dee2e6;--bs-dropdown-link-hover-color:#fff;--bs-dropdown-divider-bg:#444;--bs-dropdown-link-hover-bg:rgba(255, 255, 255, 0.15);--bs-dropdown-link-active-color:#fff;--bs-dropdown-link-active-bg:#375a7f;--bs-dropdown-link-disabled-color:#adb5bd;--bs-dropdown-header-color:#adb5bd}.btn-group,.btn-group-vertical{position:relative;display:inline-flex;vertical-align:middle}.btn-group-vertical>.btn,.btn-group>.btn{position:relative;flex:1 1 auto}.btn-group-vertical>.btn-check:checked+.btn,.btn-group-vertical>.btn-check:focus+.btn,.btn-group-vertical>.btn.active,.btn-group-vertical>.btn:active,.btn-group-vertical>.btn:focus,.btn-group-vertical>.btn:hover,.btn-group>.btn-check:checked+.btn,.btn-group>.btn-check:focus+.btn,.btn-group>.btn.active,.btn-group>.btn:active,.btn-group>.btn:focus,.btn-group>.btn:hover{z-index:1}.btn-toolbar{display:flex;flex-wrap:wrap;justify-content:flex-start}.btn-toolbar .input-group{width:auto}.btn-group{border-radius:.375rem}.btn-group>.btn-group:not(:first-child),.btn-group>:not(.btn-check:first-child)+.btn{margin-left:-1px}.btn-group>.btn-group:not(:last-child)>.btn,.btn-group>.btn.dropdown-toggle-split:first-child,.btn-group>.btn:not(:last-child):not(.dropdown-toggle){border-top-right-radius:0;border-bottom-right-radius:0}.btn-group>.btn-group:not(:first-child)>.btn,.btn-group>.btn:nth-child(n+3),.btn-group>:not(.btn-check)+.btn{border-top-left-radius:0;border-bottom-left-radius:0}.dropdown-toggle-split{padding-right:.5625rem;padding-left:.5625rem}.dropdown-toggle-split::after,.dropend .dropdown-toggle-split::after,.dropup .dropdown-toggle-split::after{margin-left:0}.dropstart .dropdown-toggle-split::before{margin-right:0}.btn-group-sm>.btn+.dropdown-toggle-split,.btn-sm+.dropdown-toggle-split{padding-right:.375rem;padding-left:.375rem}.btn-group-lg>.btn+.dropdown-toggle-split,.btn-lg+.dropdown-toggle-split{padding-right:.75rem;padding-left:.75rem}.btn-group-vertical{flex-direction:column;align-items:flex-start;justify-content:center}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group{width:100%}.btn-group-vertical>.btn-group:not(:first-child),.btn-group-vertical>.btn:not(:first-child){margin-top:-1px}.btn-group-vertical>.btn-group:not(:last-child)>.btn,.btn-group-vertical>.btn:not(:last-child):not(.dropdown-toggle){border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn-group:not(:first-child)>.btn,.btn-group-vertical>.btn~.btn{border-top-left-radius:0;border-top-right-radius:0}.nav{--bs-nav-link-padding-x:2rem;--bs-nav-link-padding-y:0.5rem;--bs-nav-link-font-weight: ;--bs-nav-link-color:var(--bs-link-color);--bs-nav-link-hover-color:var(--bs-link-hover-color);--bs-nav-link-disabled-color:#adb5bd;display:flex;flex-wrap:wrap;padding-left:0;margin-bottom:0;list-style:none}.nav-link{display:block;padding:var(--bs-nav-link-padding-y) var(--bs-nav-link-padding-x);font-size:var(--bs-nav-link-font-size);font-weight:var(--bs-nav-link-font-weight);color:var(--bs-nav-link-color);text-decoration:none;transition:color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out}@media (prefers-reduced-motion:reduce){.nav-link{transition:none}}.nav-link:focus,.nav-link:hover{color:var(--bs-nav-link-hover-color)}.nav-link.disabled{color:var(--bs-nav-link-disabled-color);pointer-events:none;cursor:default}.nav-tabs{--bs-nav-tabs-border-width:1px;--bs-nav-tabs-border-color:#444;--bs-nav-tabs-border-radius:0.375rem;--bs-nav-tabs-link-hover-border-color:#444 #444 transparent;--bs-nav-tabs-link-active-color:#fff;--bs-nav-tabs-link-active-bg:#222;--bs-nav-tabs-link-active-border-color:#444 #444 transparent;border-bottom:var(--bs-nav-tabs-border-width) solid var(--bs-nav-tabs-border-color)}.nav-tabs .nav-link{margin-bottom:calc(-1 * var(--bs-nav-tabs-border-width));background:0 0;border:var(--bs-nav-tabs-border-width) solid transparent;border-top-left-radius:var(--bs-nav-tabs-border-radius);border-top-right-radius:var(--bs-nav-tabs-border-radius)}.nav-tabs .nav-link:focus,.nav-tabs .nav-link:hover{isolation:isolate;border-color:var(--bs-nav-tabs-link-hover-border-color)}.nav-tabs .nav-link.disabled,.nav-tabs .nav-link:disabled{color:var(--bs-nav-link-disabled-color);background-color:transparent;border-color:transparent}.nav-tabs .nav-item.show .nav-link,.nav-tabs .nav-link.active{color:var(--bs-nav-tabs-link-active-color);background-color:var(--bs-nav-tabs-link-active-bg);border-color:var(--bs-nav-tabs-link-active-border-color)}.nav-tabs .dropdown-menu{margin-top:calc(-1 * var(--bs-nav-tabs-border-width));border-top-left-radius:0;border-top-right-radius:0}.nav-pills{--bs-nav-pills-border-radius:0.375rem;--bs-nav-pills-link-active-color:#fff;--bs-nav-pills-link-active-bg:#375a7f}.nav-pills .nav-link{background:0 0;border:0;border-radius:var(--bs-nav-pills-border-radius)}.nav-pills .nav-link:disabled{color:var(--bs-nav-link-disabled-color);background-color:transparent;border-color:transparent}.nav-pills .nav-link.active,.nav-pills .show>.nav-link{color:var(--bs-nav-pills-link-active-color);background-color:var(--bs-nav-pills-link-active-bg)}.nav-fill .nav-item,.nav-fill>.nav-link{flex:1 1 auto;text-align:center}.nav-justified .nav-item,.nav-justified>.nav-link{flex-basis:0;flex-grow:1;text-align:center}.nav-fill .nav-item .nav-link,.nav-justified .nav-item .nav-link{width:100%}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.navbar{--bs-navbar-padding-x:0;--bs-navbar-padding-y:1rem;--bs-navbar-color:rgba(34, 34, 34, 0.7);--bs-navbar-hover-color:#222;--bs-navbar-disabled-color:rgba(0, 0, 0, 0.3);--bs-navbar-active-color:#222;--bs-navbar-brand-padding-y:0.3125rem;--bs-navbar-brand-margin-end:1rem;--bs-navbar-brand-font-size:1.25rem;--bs-navbar-brand-color:#222;--bs-navbar-brand-hover-color:#222;--bs-navbar-nav-link-padding-x:0.5rem;--bs-navbar-toggler-padding-y:0.25rem;--bs-navbar-toggler-padding-x:0.75rem;--bs-navbar-toggler-font-size:1.25rem;--bs-navbar-toggler-icon-bg:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2834, 34, 34, 0.7%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");--bs-navbar-toggler-border-color:rgba(34, 34, 34, 0.1);--bs-navbar-toggler-border-radius:0.375rem;--bs-navbar-toggler-focus-width:0.25rem;--bs-navbar-toggler-transition:box-shadow 0.15s ease-in-out;position:relative;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;padding:var(--bs-navbar-padding-y) var(--bs-navbar-padding-x)}.navbar>.container,.navbar>.container-fluid,.navbar>.container-lg,.navbar>.container-md,.navbar>.container-sm,.navbar>.container-xl,.navbar>.container-xxl{display:flex;flex-wrap:inherit;align-items:center;justify-content:space-between}.navbar-brand{padding-top:var(--bs-navbar-brand-padding-y);padding-bottom:var(--bs-navbar-brand-padding-y);margin-right:var(--bs-navbar-brand-margin-end);font-size:var(--bs-navbar-brand-font-size);color:var(--bs-navbar-brand-color);text-decoration:none;white-space:nowrap}.navbar-brand:focus,.navbar-brand:hover{color:var(--bs-navbar-brand-hover-color)}.navbar-nav{--bs-nav-link-padding-x:0;--bs-nav-link-padding-y:0.5rem;--bs-nav-link-font-weight: ;--bs-nav-link-color:var(--bs-navbar-color);--bs-nav-link-hover-color:var(--bs-navbar-hover-color);--bs-nav-link-disabled-color:var(--bs-navbar-disabled-color);display:flex;flex-direction:column;padding-left:0;margin-bottom:0;list-style:none}.navbar-nav .nav-link.active,.navbar-nav .show>.nav-link{color:var(--bs-navbar-active-color)}.navbar-nav .dropdown-menu{position:static}.navbar-text{padding-top:.5rem;padding-bottom:.5rem;color:var(--bs-navbar-color)}.navbar-text a,.navbar-text a:focus,.navbar-text a:hover{color:var(--bs-navbar-active-color)}.navbar-collapse{flex-basis:100%;flex-grow:1;align-items:center}.navbar-toggler{padding:var(--bs-navbar-toggler-padding-y) var(--bs-navbar-toggler-padding-x);font-size:var(--bs-navbar-toggler-font-size);line-height:1;color:var(--bs-navbar-color);background-color:transparent;border:var(--bs-border-width) solid var(--bs-navbar-toggler-border-color);border-radius:var(--bs-navbar-toggler-border-radius);transition:var(--bs-navbar-toggler-transition)}@media (prefers-reduced-motion:reduce){.navbar-toggler{transition:none}}.navbar-toggler:hover{text-decoration:none}.navbar-toggler:focus{text-decoration:none;outline:0;box-shadow:0 0 0 var(--bs-navbar-toggler-focus-width)}.navbar-toggler-icon{display:inline-block;width:1.5em;height:1.5em;vertical-align:middle;background-image:var(--bs-navbar-toggler-icon-bg);background-repeat:no-repeat;background-position:center;background-size:100%}.navbar-nav-scroll{max-height:var(--bs-scroll-height,75vh);overflow-y:auto}@media (min-width:576px){.navbar-expand-sm{flex-wrap:nowrap;justify-content:flex-start}.navbar-expand-sm .navbar-nav{flex-direction:row}.navbar-expand-sm .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-sm .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-sm .navbar-nav-scroll{overflow:visible}.navbar-expand-sm .navbar-collapse{display:flex!important;flex-basis:auto}.navbar-expand-sm .navbar-toggler{display:none}.navbar-expand-sm .offcanvas{position:static;z-index:auto;flex-grow:1;width:auto!important;height:auto!important;visibility:visible!important;background-color:transparent!important;border:0!important;transform:none!important;transition:none}.navbar-expand-sm .offcanvas .offcanvas-header{display:none}.navbar-expand-sm .offcanvas .offcanvas-body{display:flex;flex-grow:0;padding:0;overflow-y:visible}}@media (min-width:768px){.navbar-expand-md{flex-wrap:nowrap;justify-content:flex-start}.navbar-expand-md .navbar-nav{flex-direction:row}.navbar-expand-md .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-md .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-md .navbar-nav-scroll{overflow:visible}.navbar-expand-md .navbar-collapse{display:flex!important;flex-basis:auto}.navbar-expand-md .navbar-toggler{display:none}.navbar-expand-md .offcanvas{position:static;z-index:auto;flex-grow:1;width:auto!important;height:auto!important;visibility:visible!important;background-color:transparent!important;border:0!important;transform:none!important;transition:none}.navbar-expand-md .offcanvas .offcanvas-header{display:none}.navbar-expand-md .offcanvas .offcanvas-body{display:flex;flex-grow:0;padding:0;overflow-y:visible}}@media (min-width:992px){.navbar-expand-lg{flex-wrap:nowrap;justify-content:flex-start}.navbar-expand-lg .navbar-nav{flex-direction:row}.navbar-expand-lg .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-lg .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-lg .navbar-nav-scroll{overflow:visible}.navbar-expand-lg .navbar-collapse{display:flex!important;flex-basis:auto}.navbar-expand-lg .navbar-toggler{display:none}.navbar-expand-lg .offcanvas{position:static;z-index:auto;flex-grow:1;width:auto!important;height:auto!important;visibility:visible!important;background-color:transparent!important;border:0!important;transform:none!important;transition:none}.navbar-expand-lg .offcanvas .offcanvas-header{display:none}.navbar-expand-lg .offcanvas .offcanvas-body{display:flex;flex-grow:0;padding:0;overflow-y:visible}}@media (min-width:1200px){.navbar-expand-xl{flex-wrap:nowrap;justify-content:flex-start}.navbar-expand-xl .navbar-nav{flex-direction:row}.navbar-expand-xl .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-xl .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-xl .navbar-nav-scroll{overflow:visible}.navbar-expand-xl .navbar-collapse{display:flex!important;flex-basis:auto}.navbar-expand-xl .navbar-toggler{display:none}.navbar-expand-xl .offcanvas{position:static;z-index:auto;flex-grow:1;width:auto!important;height:auto!important;visibility:visible!important;background-color:transparent!important;border:0!important;transform:none!important;transition:none}.navbar-expand-xl .offcanvas .offcanvas-header{display:none}.navbar-expand-xl .offcanvas .offcanvas-body{display:flex;flex-grow:0;padding:0;overflow-y:visible}}@media (min-width:1400px){.navbar-expand-xxl{flex-wrap:nowrap;justify-content:flex-start}.navbar-expand-xxl .navbar-nav{flex-direction:row}.navbar-expand-xxl .navbar-nav .dropdown-menu{position:absolute}.navbar-expand-xxl .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand-xxl .navbar-nav-scroll{overflow:visible}.navbar-expand-xxl .navbar-collapse{display:flex!important;flex-basis:auto}.navbar-expand-xxl .navbar-toggler{display:none}.navbar-expand-xxl .offcanvas{position:static;z-index:auto;flex-grow:1;width:auto!important;height:auto!important;visibility:visible!important;background-color:transparent!important;border:0!important;transform:none!important;transition:none}.navbar-expand-xxl .offcanvas .offcanvas-header{display:none}.navbar-expand-xxl .offcanvas .offcanvas-body{display:flex;flex-grow:0;padding:0;overflow-y:visible}}.navbar-expand{flex-wrap:nowrap;justify-content:flex-start}.navbar-expand .navbar-nav{flex-direction:row}.navbar-expand .navbar-nav .dropdown-menu{position:absolute}.navbar-expand .navbar-nav .nav-link{padding-right:var(--bs-navbar-nav-link-padding-x);padding-left:var(--bs-navbar-nav-link-padding-x)}.navbar-expand .navbar-nav-scroll{overflow:visible}.navbar-expand .navbar-collapse{display:flex!important;flex-basis:auto}.navbar-expand .navbar-toggler{display:none}.navbar-expand .offcanvas{position:static;z-index:auto;flex-grow:1;width:auto!important;height:auto!important;visibility:visible!important;background-color:transparent!important;border:0!important;transform:none!important;transition:none}.navbar-expand .offcanvas .offcanvas-header{display:none}.navbar-expand .offcanvas .offcanvas-body{display:flex;flex-grow:0;padding:0;overflow-y:visible}.navbar-dark{--bs-navbar-color:rgba(255, 255, 255, 0.6);--bs-navbar-hover-color:#fff;--bs-navbar-disabled-color:rgba(255, 255, 255, 0.25);--bs-navbar-active-color:#fff;--bs-navbar-brand-color:#fff;--bs-navbar-brand-hover-color:#fff;--bs-navbar-toggler-border-color:rgba(255, 255, 255, 0.1);--bs-navbar-toggler-icon-bg:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.6%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e")}.card{--bs-card-spacer-y:1rem;--bs-card-spacer-x:1rem;--bs-card-title-spacer-y:0.5rem;--bs-card-border-width:1px;--bs-card-border-color:var(--bs-border-color-translucent);--bs-card-border-radius:0.375rem;--bs-card-box-shadow: ;--bs-card-inner-border-radius:calc(0.375rem - 1px);--bs-card-cap-padding-y:0.5rem;--bs-card-cap-padding-x:1rem;--bs-card-cap-bg:#444;--bs-card-cap-color: ;--bs-card-height: ;--bs-card-color: ;--bs-card-bg:#303030;--bs-card-img-overlay-padding:1rem;--bs-card-group-margin:0.75rem;position:relative;display:flex;flex-direction:column;min-width:0;height:var(--bs-card-height);word-wrap:break-word;background-color:var(--bs-card-bg);background-clip:border-box;border:var(--bs-card-border-width) solid var(--bs-card-border-color);border-radius:var(--bs-card-border-radius)}.card>hr{margin-right:0;margin-left:0}.card>.list-group{border-top:inherit;border-bottom:inherit}.card>.list-group:first-child{border-top-width:0;border-top-left-radius:var(--bs-card-inner-border-radius);border-top-right-radius:var(--bs-card-inner-border-radius)}.card>.list-group:last-child{border-bottom-width:0;border-bottom-right-radius:var(--bs-card-inner-border-radius);border-bottom-left-radius:var(--bs-card-inner-border-radius)}.card>.card-header+.list-group,.card>.list-group+.card-footer{border-top:0}.card-body{flex:1 1 auto;padding:var(--bs-card-spacer-y) var(--bs-card-spacer-x);color:var(--bs-card-color)}.card-title{margin-bottom:var(--bs-card-title-spacer-y)}.card-subtitle{margin-top:calc(-.5 * var(--bs-card-title-spacer-y));margin-bottom:0}.card-text:last-child{margin-bottom:0}.card-link+.card-link{margin-left:var(--bs-card-spacer-x)}.card-header{padding:var(--bs-card-cap-padding-y) var(--bs-card-cap-padding-x);margin-bottom:0;color:var(--bs-card-cap-color);background-color:var(--bs-card-cap-bg);border-bottom:var(--bs-card-border-width) solid var(--bs-card-border-color)}.card-header:first-child{border-radius:var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius) 0 0}.card-footer{padding:var(--bs-card-cap-padding-y) var(--bs-card-cap-padding-x);color:var(--bs-card-cap-color);background-color:var(--bs-card-cap-bg);border-top:var(--bs-card-border-width) solid var(--bs-card-border-color)}.card-footer:last-child{border-radius:0 0 var(--bs-card-inner-border-radius) var(--bs-card-inner-border-radius)}.card-header-tabs{margin-right:calc(-.5 * var(--bs-card-cap-padding-x));margin-bottom:calc(-1 * var(--bs-card-cap-padding-y));margin-left:calc(-.5 * var(--bs-card-cap-padding-x));border-bottom:0}.card-header-tabs .nav-link.active{background-color:var(--bs-card-bg);border-bottom-color:var(--bs-card-bg)}.card-header-pills{margin-right:calc(-.5 * var(--bs-card-cap-padding-x));margin-left:calc(-.5 * var(--bs-card-cap-padding-x))}.card-img-overlay{position:absolute;top:0;right:0;bottom:0;left:0;padding:var(--bs-card-img-overlay-padding);border-radius:var(--bs-card-inner-border-radius)}.card-img,.card-img-bottom,.card-img-top{width:100%}.card-img,.card-img-top{border-top-left-radius:var(--bs-card-inner-border-radius);border-top-right-radius:var(--bs-card-inner-border-radius)}.card-img,.card-img-bottom{border-bottom-right-radius:var(--bs-card-inner-border-radius);border-bottom-left-radius:var(--bs-card-inner-border-radius)}.card-group>.card{margin-bottom:var(--bs-card-group-margin)}@media (min-width:576px){.card-group{display:flex;flex-flow:row wrap}.card-group>.card{flex:1 0 0%;margin-bottom:0}.card-group>.card+.card{margin-left:0;border-left:0}.card-group>.card:not(:last-child){border-top-right-radius:0;border-bottom-right-radius:0}.card-group>.card:not(:last-child) .card-header,.card-group>.card:not(:last-child) .card-img-top{border-top-right-radius:0}.card-group>.card:not(:last-child) .card-footer,.card-group>.card:not(:last-child) .card-img-bottom{border-bottom-right-radius:0}.card-group>.card:not(:first-child){border-top-left-radius:0;border-bottom-left-radius:0}.card-group>.card:not(:first-child) .card-header,.card-group>.card:not(:first-child) .card-img-top{border-top-left-radius:0}.card-group>.card:not(:first-child) .card-footer,.card-group>.card:not(:first-child) .card-img-bottom{border-bottom-left-radius:0}}.accordion{--bs-accordion-color:#fff;--bs-accordion-bg:#222;--bs-accordion-transition:color 0.15s ease-in-out,background-color 0.15s ease-in-out,border-color 0.15s ease-in-out,box-shadow 0.15s ease-in-out,border-radius 0.15s ease;--bs-accordion-border-color:var(--bs-border-color);--bs-accordion-border-width:1px;--bs-accordion-border-radius:0.375rem;--bs-accordion-inner-border-radius:calc(0.375rem - 1px);--bs-accordion-btn-padding-x:1.25rem;--bs-accordion-btn-padding-y:1rem;--bs-accordion-btn-color:#fff;--bs-accordion-btn-bg:var(--bs-accordion-bg);--bs-accordion-btn-icon:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");--bs-accordion-btn-icon-width:1.25rem;--bs-accordion-btn-icon-transform:rotate(-180deg);--bs-accordion-btn-icon-transition:transform 0.2s ease-in-out;--bs-accordion-btn-active-icon:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23325172'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");--bs-accordion-btn-focus-border-color:#9badbf;--bs-accordion-btn-focus-box-shadow:0 0 0 0.25rem rgba(55, 90, 127, 0.25);--bs-accordion-body-padding-x:1.25rem;--bs-accordion-body-padding-y:1rem;--bs-accordion-active-color:#325172;--bs-accordion-active-bg:#ebeff2}.accordion-button{position:relative;display:flex;align-items:center;width:100%;padding:var(--bs-accordion-btn-padding-y) var(--bs-accordion-btn-padding-x);font-size:1rem;color:var(--bs-accordion-btn-color);text-align:left;background-color:var(--bs-accordion-btn-bg);border:0;border-radius:0;overflow-anchor:none;transition:var(--bs-accordion-transition)}@media (prefers-reduced-motion:reduce){.accordion-button{transition:none}}.accordion-button:not(.collapsed){color:var(--bs-accordion-active-color);background-color:var(--bs-accordion-active-bg);box-shadow:inset 0 calc(-1 * var(--bs-accordion-border-width)) 0 var(--bs-accordion-border-color)}.accordion-button:not(.collapsed)::after{background-image:var(--bs-accordion-btn-active-icon);transform:var(--bs-accordion-btn-icon-transform)}.accordion-button::after{flex-shrink:0;width:var(--bs-accordion-btn-icon-width);height:var(--bs-accordion-btn-icon-width);margin-left:auto;content:"";background-image:var(--bs-accordion-btn-icon);background-repeat:no-repeat;background-size:var(--bs-accordion-btn-icon-width);transition:var(--bs-accordion-btn-icon-transition)}@media (prefers-reduced-motion:reduce){.accordion-button::after{transition:none}}.accordion-button:hover{z-index:2}.accordion-button:focus{z-index:3;border-color:var(--bs-accordion-btn-focus-border-color);outline:0;box-shadow:var(--bs-accordion-btn-focus-box-shadow)}.accordion-header{margin-bottom:0}.accordion-item{color:var(--bs-accordion-color);background-color:var(--bs-accordion-bg);border:var(--bs-accordion-border-width) solid var(--bs-accordion-border-color)}.accordion-item:first-of-type{border-top-left-radius:var(--bs-accordion-border-radius);border-top-right-radius:var(--bs-accordion-border-radius)}.accordion-item:first-of-type .accordion-button{border-top-left-radius:var(--bs-accordion-inner-border-radius);border-top-right-radius:var(--bs-accordion-inner-border-radius)}.accordion-item:not(:first-of-type){border-top:0}.accordion-item:last-of-type{border-bottom-right-radius:var(--bs-accordion-border-radius);border-bottom-left-radius:var(--bs-accordion-border-radius)}.accordion-item:last-of-type .accordion-button.collapsed{border-bottom-right-radius:var(--bs-accordion-inner-border-radius);border-bottom-left-radius:var(--bs-accordion-inner-border-radius)}.accordion-item:last-of-type .accordion-collapse{border-bottom-right-radius:var(--bs-accordion-border-radius);border-bottom-left-radius:var(--bs-accordion-border-radius)}.accordion-body{padding:var(--bs-accordion-body-padding-y) var(--bs-accordion-body-padding-x)}.accordion-flush .accordion-collapse{border-width:0}.accordion-flush .accordion-item{border-right:0;border-left:0;border-radius:0}.accordion-flush .accordion-item:first-child{border-top:0}.accordion-flush .accordion-item:last-child{border-bottom:0}.accordion-flush .accordion-item .accordion-button,.accordion-flush .accordion-item .accordion-button.collapsed{border-radius:0}.breadcrumb{--bs-breadcrumb-padding-x:0.75rem;--bs-breadcrumb-padding-y:0.375rem;--bs-breadcrumb-margin-bottom:1rem;--bs-breadcrumb-bg:#444;--bs-breadcrumb-border-radius:0.25rem;--bs-breadcrumb-divider-color:#888;--bs-breadcrumb-item-padding-x:0.5rem;--bs-breadcrumb-item-active-color:#888;display:flex;flex-wrap:wrap;padding:var(--bs-breadcrumb-padding-y) var(--bs-breadcrumb-padding-x);margin-bottom:var(--bs-breadcrumb-margin-bottom);font-size:var(--bs-breadcrumb-font-size);list-style:none;background-color:var(--bs-breadcrumb-bg);border-radius:var(--bs-breadcrumb-border-radius)}.breadcrumb-item+.breadcrumb-item{padding-left:var(--bs-breadcrumb-item-padding-x)}.breadcrumb-item+.breadcrumb-item::before{float:left;padding-right:var(--bs-breadcrumb-item-padding-x);color:var(--bs-breadcrumb-divider-color);content:var(--bs-breadcrumb-divider, "/")}.breadcrumb-item.active{color:var(--bs-breadcrumb-item-active-color)}.pagination{--bs-pagination-padding-x:0.75rem;--bs-pagination-padding-y:0.375rem;--bs-pagination-font-size:1rem;--bs-pagination-color:#fff;--bs-pagination-bg:#00bc8c;--bs-pagination-border-width:0;--bs-pagination-border-color:transparent;--bs-pagination-border-radius:0.375rem;--bs-pagination-hover-color:#fff;--bs-pagination-hover-bg:#00efb2;--bs-pagination-hover-border-color:transparent;--bs-pagination-focus-color:var(--bs-link-hover-color);--bs-pagination-focus-bg:#ebebeb;--bs-pagination-focus-box-shadow:0 0 0 0.25rem rgba(55, 90, 127, 0.25);--bs-pagination-active-color:#fff;--bs-pagination-active-bg:#00efb2;--bs-pagination-active-border-color:transparent;--bs-pagination-disabled-color:#fff;--bs-pagination-disabled-bg:#007053;--bs-pagination-disabled-border-color:transparent;display:flex;padding-left:0;list-style:none}.page-link{position:relative;display:block;padding:var(--bs-pagination-padding-y) var(--bs-pagination-padding-x);font-size:var(--bs-pagination-font-size);color:var(--bs-pagination-color);text-decoration:none;background-color:var(--bs-pagination-bg);border:var(--bs-pagination-border-width) solid var(--bs-pagination-border-color);transition:color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out}@media (prefers-reduced-motion:reduce){.page-link{transition:none}}.page-link:hover{z-index:2;color:var(--bs-pagination-hover-color);background-color:var(--bs-pagination-hover-bg);border-color:var(--bs-pagination-hover-border-color)}.page-link:focus{z-index:3;color:var(--bs-pagination-focus-color);background-color:var(--bs-pagination-focus-bg);outline:0;box-shadow:var(--bs-pagination-focus-box-shadow)}.active>.page-link,.page-link.active{z-index:3;color:var(--bs-pagination-active-color);background-color:var(--bs-pagination-active-bg);border-color:var(--bs-pagination-active-border-color)}.disabled>.page-link,.page-link.disabled{color:var(--bs-pagination-disabled-color);pointer-events:none;background-color:var(--bs-pagination-disabled-bg);border-color:var(--bs-pagination-disabled-border-color)}.page-item:not(:first-child) .page-link{margin-left:0}.page-item:first-child .page-link{border-top-left-radius:var(--bs-pagination-border-radius);border-bottom-left-radius:var(--bs-pagination-border-radius)}.page-item:last-child .page-link{border-top-right-radius:var(--bs-pagination-border-radius);border-bottom-right-radius:var(--bs-pagination-border-radius)}.pagination-lg{--bs-pagination-padding-x:1.5rem;--bs-pagination-padding-y:0.75rem;--bs-pagination-font-size:1.25rem;--bs-pagination-border-radius:0.5rem}.pagination-sm{--bs-pagination-padding-x:0.5rem;--bs-pagination-padding-y:0.25rem;--bs-pagination-font-size:0.875rem;--bs-pagination-border-radius:0.25rem}.badge{--bs-badge-padding-x:0.65em;--bs-badge-padding-y:0.35em;--bs-badge-font-size:0.75em;--bs-badge-font-weight:700;--bs-badge-color:#fff;--bs-badge-border-radius:0.375rem;display:inline-block;padding:var(--bs-badge-padding-y) var(--bs-badge-padding-x);font-size:var(--bs-badge-font-size);font-weight:var(--bs-badge-font-weight);line-height:1;color:var(--bs-badge-color);text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:var(--bs-badge-border-radius)}.badge:empty{display:none}.btn .badge{position:relative;top:-1px}.alert{--bs-alert-bg:transparent;--bs-alert-padding-x:1rem;--bs-alert-padding-y:1rem;--bs-alert-margin-bottom:1rem;--bs-alert-color:inherit;--bs-alert-border-color:transparent;--bs-alert-border:1px solid var(--bs-alert-border-color);--bs-alert-border-radius:0.375rem;position:relative;padding:var(--bs-alert-padding-y) var(--bs-alert-padding-x);margin-bottom:var(--bs-alert-margin-bottom);color:var(--bs-alert-color);background-color:var(--bs-alert-bg);border:var(--bs-alert-border);border-radius:var(--bs-alert-border-radius)}.alert-heading{color:inherit}.alert-link{font-weight:700}.alert-dismissible{padding-right:3rem}.alert-dismissible .btn-close{position:absolute;top:0;right:0;z-index:2;padding:1.25rem 1rem}.alert-primary{--bs-alert-color:#21364c;--bs-alert-bg:#d7dee5;--bs-alert-border-color:#c3ced9}.alert-primary .alert-link{color:#1a2b3d}.alert-secondary{--bs-alert-color:#292929;--bs-alert-bg:#dadada;--bs-alert-border-color:#c7c7c7}.alert-secondary .alert-link{color:#212121}.alert-success{--bs-alert-color:#007154;--bs-alert-bg:#ccf2e8;--bs-alert-border-color:#b3ebdd}.alert-success .alert-link{color:#005a43}.alert-info{--bs-alert-color:#1f5b83;--bs-alert-bg:#d6eaf8;--bs-alert-border-color:#c2e0f4}.alert-info .alert-link{color:#194969}.alert-warning{--bs-alert-color:#925e0b;--bs-alert-bg:#fdebd0;--bs-alert-border-color:#fbe1b8}.alert-warning .alert-link{color:#754b09}.alert-danger{--bs-alert-color:#8b2e24;--bs-alert-bg:#fadbd8;--bs-alert-border-color:#f8c9c5}.alert-danger .alert-link{color:#6f251d}.alert-light{--bs-alert-color:#686d71;--bs-alert-bg:#eff0f2;--bs-alert-border-color:#e6e9eb}.alert-light .alert-link{color:#53575a}.alert-dark{--bs-alert-color:#1d1d1d;--bs-alert-bg:#d6d6d6;--bs-alert-border-color:#c1c1c1}.alert-dark .alert-link{color:#171717}@keyframes progress-bar-stripes{0%{background-position-x:1rem}}.progress{--bs-progress-height:1rem;--bs-progress-font-size:0.75rem;--bs-progress-bg:#444;--bs-progress-border-radius:0.375rem;--bs-progress-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.075);--bs-progress-bar-color:#fff;--bs-progress-bar-bg:#375a7f;--bs-progress-bar-transition:width 0.6s ease;display:flex;height:var(--bs-progress-height);overflow:hidden;font-size:var(--bs-progress-font-size);background-color:var(--bs-progress-bg);border-radius:var(--bs-progress-border-radius)}.progress-bar{display:flex;flex-direction:column;justify-content:center;overflow:hidden;color:var(--bs-progress-bar-color);text-align:center;white-space:nowrap;background-color:var(--bs-progress-bar-bg);transition:var(--bs-progress-bar-transition)}@media (prefers-reduced-motion:reduce){.progress-bar{transition:none}}.progress-bar-striped{background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-size:var(--bs-progress-height) var(--bs-progress-height)}.progress-bar-animated{animation:1s linear infinite progress-bar-stripes}@media (prefers-reduced-motion:reduce){.progress-bar-animated{animation:none}}.list-group{--bs-list-group-color:#fff;--bs-list-group-bg:#303030;--bs-list-group-border-color:#444;--bs-list-group-border-width:1px;--bs-list-group-border-radius:0.375rem;--bs-list-group-item-padding-x:1rem;--bs-list-group-item-padding-y:0.5rem;--bs-list-group-action-color:#444;--bs-list-group-action-hover-color:#fff;--bs-list-group-action-hover-bg:#444;--bs-list-group-action-active-color:#fff;--bs-list-group-action-active-bg:#222;--bs-list-group-disabled-color:#888;--bs-list-group-disabled-bg:#303030;--bs-list-group-active-color:#fff;--bs-list-group-active-bg:#375a7f;--bs-list-group-active-border-color:#375a7f;display:flex;flex-direction:column;padding-left:0;margin-bottom:0;border-radius:var(--bs-list-group-border-radius)}.list-group-numbered{list-style-type:none;counter-reset:section}.list-group-numbered>.list-group-item::before{content:counters(section, ".") ". ";counter-increment:section}.list-group-item-action{width:100%;color:var(--bs-list-group-action-color);text-align:inherit}.list-group-item-action:focus,.list-group-item-action:hover{z-index:1;color:var(--bs-list-group-action-hover-color);text-decoration:none;background-color:var(--bs-list-group-action-hover-bg)}.list-group-item-action:active{color:var(--bs-list-group-action-active-color);background-color:var(--bs-list-group-action-active-bg)}.list-group-item{position:relative;display:block;padding:var(--bs-list-group-item-padding-y) var(--bs-list-group-item-padding-x);color:var(--bs-list-group-color);text-decoration:none;background-color:var(--bs-list-group-bg);border:var(--bs-list-group-border-width) solid var(--bs-list-group-border-color)}.list-group-item:first-child{border-top-left-radius:inherit;border-top-right-radius:inherit}.list-group-item:last-child{border-bottom-right-radius:inherit;border-bottom-left-radius:inherit}.list-group-item.disabled,.list-group-item:disabled{color:var(--bs-list-group-disabled-color);pointer-events:none;background-color:var(--bs-list-group-disabled-bg)}.list-group-item.active{z-index:2;color:var(--bs-list-group-active-color);background-color:var(--bs-list-group-active-bg);border-color:var(--bs-list-group-active-border-color)}.list-group-item+.list-group-item{border-top-width:0}.list-group-item+.list-group-item.active{margin-top:calc(-1 * var(--bs-list-group-border-width));border-top-width:var(--bs-list-group-border-width)}.list-group-horizontal{flex-direction:row}.list-group-horizontal>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal>.list-group-item.active{margin-top:0}.list-group-horizontal>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}@media (min-width:576px){.list-group-horizontal-sm{flex-direction:row}.list-group-horizontal-sm>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-sm>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-sm>.list-group-item.active{margin-top:0}.list-group-horizontal-sm>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-sm>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width:768px){.list-group-horizontal-md{flex-direction:row}.list-group-horizontal-md>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-md>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-md>.list-group-item.active{margin-top:0}.list-group-horizontal-md>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-md>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width:992px){.list-group-horizontal-lg{flex-direction:row}.list-group-horizontal-lg>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-lg>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-lg>.list-group-item.active{margin-top:0}.list-group-horizontal-lg>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-lg>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width:1200px){.list-group-horizontal-xl{flex-direction:row}.list-group-horizontal-xl>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-xl>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-xl>.list-group-item.active{margin-top:0}.list-group-horizontal-xl>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-xl>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}@media (min-width:1400px){.list-group-horizontal-xxl{flex-direction:row}.list-group-horizontal-xxl>.list-group-item:first-child:not(:last-child){border-bottom-left-radius:var(--bs-list-group-border-radius);border-top-right-radius:0}.list-group-horizontal-xxl>.list-group-item:last-child:not(:first-child){border-top-right-radius:var(--bs-list-group-border-radius);border-bottom-left-radius:0}.list-group-horizontal-xxl>.list-group-item.active{margin-top:0}.list-group-horizontal-xxl>.list-group-item+.list-group-item{border-top-width:var(--bs-list-group-border-width);border-left-width:0}.list-group-horizontal-xxl>.list-group-item+.list-group-item.active{margin-left:calc(-1 * var(--bs-list-group-border-width));border-left-width:var(--bs-list-group-border-width)}}.list-group-flush{border-radius:0}.list-group-flush>.list-group-item{border-width:0 0 var(--bs-list-group-border-width)}.list-group-flush>.list-group-item:last-child{border-bottom-width:0}.list-group-item-primary{color:#21364c;background-color:#d7dee5}.list-group-item-primary.list-group-item-action:focus,.list-group-item-primary.list-group-item-action:hover{color:#21364c;background-color:#c2c8ce}.list-group-item-primary.list-group-item-action.active{color:#fff;background-color:#21364c;border-color:#21364c}.list-group-item-secondary{color:#292929;background-color:#dadada}.list-group-item-secondary.list-group-item-action:focus,.list-group-item-secondary.list-group-item-action:hover{color:#292929;background-color:#c4c4c4}.list-group-item-secondary.list-group-item-action.active{color:#fff;background-color:#292929;border-color:#292929}.list-group-item-success{color:#007154;background-color:#ccf2e8}.list-group-item-success.list-group-item-action:focus,.list-group-item-success.list-group-item-action:hover{color:#007154;background-color:#b8dad1}.list-group-item-success.list-group-item-action.active{color:#fff;background-color:#007154;border-color:#007154}.list-group-item-info{color:#1f5b83;background-color:#d6eaf8}.list-group-item-info.list-group-item-action:focus,.list-group-item-info.list-group-item-action:hover{color:#1f5b83;background-color:#c1d3df}.list-group-item-info.list-group-item-action.active{color:#fff;background-color:#1f5b83;border-color:#1f5b83}.list-group-item-warning{color:#925e0b;background-color:#fdebd0}.list-group-item-warning.list-group-item-action:focus,.list-group-item-warning.list-group-item-action:hover{color:#925e0b;background-color:#e4d4bb}.list-group-item-warning.list-group-item-action.active{color:#fff;background-color:#925e0b;border-color:#925e0b}.list-group-item-danger{color:#8b2e24;background-color:#fadbd8}.list-group-item-danger.list-group-item-action:focus,.list-group-item-danger.list-group-item-action:hover{color:#8b2e24;background-color:#e1c5c2}.list-group-item-danger.list-group-item-action.active{color:#fff;background-color:#8b2e24;border-color:#8b2e24}.list-group-item-light{color:#686d71;background-color:#eff0f2}.list-group-item-light.list-group-item-action:focus,.list-group-item-light.list-group-item-action:hover{color:#686d71;background-color:#d7d8da}.list-group-item-light.list-group-item-action.active{color:#fff;background-color:#686d71;border-color:#686d71}.list-group-item-dark{color:#1d1d1d;background-color:#d6d6d6}.list-group-item-dark.list-group-item-action:focus,.list-group-item-dark.list-group-item-action:hover{color:#1d1d1d;background-color:#c1c1c1}.list-group-item-dark.list-group-item-action.active{color:#fff;background-color:#1d1d1d;border-color:#1d1d1d}.btn-close{box-sizing:content-box;width:1em;height:1em;padding:.25em .25em;color:#fff;background:transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;border:0;border-radius:.375rem;opacity:.4}.btn-close:hover{color:#fff;text-decoration:none;opacity:1}.btn-close:focus{outline:0;box-shadow:0 0 0 .25rem rgba(55,90,127,.25);opacity:1}.btn-close.disabled,.btn-close:disabled{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:.25}.btn-close-white{filter:invert(1) grayscale(100%) brightness(200%)}.toast{--bs-toast-zindex:1090;--bs-toast-padding-x:0.75rem;--bs-toast-padding-y:0.5rem;--bs-toast-spacing:1.5rem;--bs-toast-max-width:350px;--bs-toast-font-size:0.875rem;--bs-toast-color: ;--bs-toast-bg:#444;--bs-toast-border-width:1px;--bs-toast-border-color:var(--bs-border-color-translucent);--bs-toast-border-radius:0.375rem;--bs-toast-box-shadow:0 0.5rem 1rem rgba(0, 0, 0, 0.15);--bs-toast-header-color:#888;--bs-toast-header-bg:#303030;--bs-toast-header-border-color:rgba(0, 0, 0, 0.05);width:var(--bs-toast-max-width);max-width:100%;font-size:var(--bs-toast-font-size);color:var(--bs-toast-color);pointer-events:auto;background-color:var(--bs-toast-bg);background-clip:padding-box;border:var(--bs-toast-border-width) solid var(--bs-toast-border-color);box-shadow:var(--bs-toast-box-shadow);border-radius:var(--bs-toast-border-radius)}.toast.showing{opacity:0}.toast:not(.show){display:none}.toast-container{--bs-toast-zindex:1090;position:absolute;z-index:var(--bs-toast-zindex);width:-webkit-max-content;width:-moz-max-content;width:max-content;max-width:100%;pointer-events:none}.toast-container>:not(:last-child){margin-bottom:var(--bs-toast-spacing)}.toast-header{display:flex;align-items:center;padding:var(--bs-toast-padding-y) var(--bs-toast-padding-x);color:var(--bs-toast-header-color);background-color:var(--bs-toast-header-bg);background-clip:padding-box;border-bottom:var(--bs-toast-border-width) solid var(--bs-toast-header-border-color);border-top-left-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width));border-top-right-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width))}.toast-header .btn-close{margin-right:calc(-.5 * var(--bs-toast-padding-x));margin-left:var(--bs-toast-padding-x)}.toast-body{padding:var(--bs-toast-padding-x);word-wrap:break-word}.modal{--bs-modal-zindex:1055;--bs-modal-width:500px;--bs-modal-padding:1rem;--bs-modal-margin:0.5rem;--bs-modal-color: ;--bs-modal-bg:#303030;--bs-modal-border-color:#444;--bs-modal-border-width:1px;--bs-modal-border-radius:0.5rem;--bs-modal-box-shadow:0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);--bs-modal-inner-border-radius:calc(0.5rem - 1px);--bs-modal-header-padding-x:1rem;--bs-modal-header-padding-y:1rem;--bs-modal-header-padding:1rem 1rem;--bs-modal-header-border-color:#444;--bs-modal-header-border-width:1px;--bs-modal-title-line-height:1.5;--bs-modal-footer-gap:0.5rem;--bs-modal-footer-bg: ;--bs-modal-footer-border-color:#444;--bs-modal-footer-border-width:1px;position:fixed;top:0;left:0;z-index:var(--bs-modal-zindex);display:none;width:100%;height:100%;overflow-x:hidden;overflow-y:auto;outline:0}.modal-dialog{position:relative;width:auto;margin:var(--bs-modal-margin);pointer-events:none}.modal.fade .modal-dialog{transition:transform .3s ease-out;transform:translate(0,-50px)}@media (prefers-reduced-motion:reduce){.modal.fade .modal-dialog{transition:none}}.modal.show .modal-dialog{transform:none}.modal.modal-static .modal-dialog{transform:scale(1.02)}.modal-dialog-scrollable{height:calc(100% - var(--bs-modal-margin) * 2)}.modal-dialog-scrollable .modal-content{max-height:100%;overflow:hidden}.modal-dialog-scrollable .modal-body{overflow-y:auto}.modal-dialog-centered{display:flex;align-items:center;min-height:calc(100% - var(--bs-modal-margin) * 2)}.modal-content{position:relative;display:flex;flex-direction:column;width:100%;color:var(--bs-modal-color);pointer-events:auto;background-color:var(--bs-modal-bg);background-clip:padding-box;border:var(--bs-modal-border-width) solid var(--bs-modal-border-color);border-radius:var(--bs-modal-border-radius);outline:0}.modal-backdrop{--bs-backdrop-zindex:1050;--bs-backdrop-bg:#000;--bs-backdrop-opacity:0.5;position:fixed;top:0;left:0;z-index:var(--bs-backdrop-zindex);width:100vw;height:100vh;background-color:var(--bs-backdrop-bg)}.modal-backdrop.fade{opacity:0}.modal-backdrop.show{opacity:var(--bs-backdrop-opacity)}.modal-header{display:flex;flex-shrink:0;align-items:center;justify-content:space-between;padding:var(--bs-modal-header-padding);border-bottom:var(--bs-modal-header-border-width) solid var(--bs-modal-header-border-color);border-top-left-radius:var(--bs-modal-inner-border-radius);border-top-right-radius:var(--bs-modal-inner-border-radius)}.modal-header .btn-close{padding:calc(var(--bs-modal-header-padding-y) * .5) calc(var(--bs-modal-header-padding-x) * .5);margin:calc(-.5 * var(--bs-modal-header-padding-y)) calc(-.5 * var(--bs-modal-header-padding-x)) calc(-.5 * var(--bs-modal-header-padding-y)) auto}.modal-title{margin-bottom:0;line-height:var(--bs-modal-title-line-height)}.modal-body{position:relative;flex:1 1 auto;padding:var(--bs-modal-padding)}.modal-footer{display:flex;flex-shrink:0;flex-wrap:wrap;align-items:center;justify-content:flex-end;padding:calc(var(--bs-modal-padding) - var(--bs-modal-footer-gap) * .5);background-color:var(--bs-modal-footer-bg);border-top:var(--bs-modal-footer-border-width) solid var(--bs-modal-footer-border-color);border-bottom-right-radius:var(--bs-modal-inner-border-radius);border-bottom-left-radius:var(--bs-modal-inner-border-radius)}.modal-footer>*{margin:calc(var(--bs-modal-footer-gap) * .5)}@media (min-width:576px){.modal{--bs-modal-margin:1.75rem;--bs-modal-box-shadow:0 0.5rem 1rem rgba(0, 0, 0, 0.15)}.modal-dialog{max-width:var(--bs-modal-width);margin-right:auto;margin-left:auto}.modal-sm{--bs-modal-width:300px}}@media (min-width:992px){.modal-lg,.modal-xl{--bs-modal-width:800px}}@media (min-width:1200px){.modal-xl{--bs-modal-width:1140px}}.modal-fullscreen{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen .modal-footer,.modal-fullscreen .modal-header{border-radius:0}.modal-fullscreen .modal-body{overflow-y:auto}@media (max-width:575.98px){.modal-fullscreen-sm-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-sm-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-sm-down .modal-footer,.modal-fullscreen-sm-down .modal-header{border-radius:0}.modal-fullscreen-sm-down .modal-body{overflow-y:auto}}@media (max-width:767.98px){.modal-fullscreen-md-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-md-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-md-down .modal-footer,.modal-fullscreen-md-down .modal-header{border-radius:0}.modal-fullscreen-md-down .modal-body{overflow-y:auto}}@media (max-width:991.98px){.modal-fullscreen-lg-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-lg-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-lg-down .modal-footer,.modal-fullscreen-lg-down .modal-header{border-radius:0}.modal-fullscreen-lg-down .modal-body{overflow-y:auto}}@media (max-width:1199.98px){.modal-fullscreen-xl-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-xl-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-xl-down .modal-footer,.modal-fullscreen-xl-down .modal-header{border-radius:0}.modal-fullscreen-xl-down .modal-body{overflow-y:auto}}@media (max-width:1399.98px){.modal-fullscreen-xxl-down{width:100vw;max-width:none;height:100%;margin:0}.modal-fullscreen-xxl-down .modal-content{height:100%;border:0;border-radius:0}.modal-fullscreen-xxl-down .modal-footer,.modal-fullscreen-xxl-down .modal-header{border-radius:0}.modal-fullscreen-xxl-down .modal-body{overflow-y:auto}}.tooltip{--bs-tooltip-zindex:1080;--bs-tooltip-max-width:200px;--bs-tooltip-padding-x:0.5rem;--bs-tooltip-padding-y:0.25rem;--bs-tooltip-margin: ;--bs-tooltip-font-size:0.875rem;--bs-tooltip-color:#fff;--bs-tooltip-bg:#000;--bs-tooltip-border-radius:0.375rem;--bs-tooltip-opacity:0.9;--bs-tooltip-arrow-width:0.8rem;--bs-tooltip-arrow-height:0.4rem;z-index:var(--bs-tooltip-zindex);display:block;padding:var(--bs-tooltip-arrow-height);margin:var(--bs-tooltip-margin);font-family:var(--bs-font-sans-serif);font-style:normal;font-weight:400;line-height:1.5;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;white-space:normal;word-spacing:normal;line-break:auto;font-size:var(--bs-tooltip-font-size);word-wrap:break-word;opacity:0}.tooltip.show{opacity:var(--bs-tooltip-opacity)}.tooltip .tooltip-arrow{display:block;width:var(--bs-tooltip-arrow-width);height:var(--bs-tooltip-arrow-height)}.tooltip .tooltip-arrow::before{position:absolute;content:"";border-color:transparent;border-style:solid}.bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow,.bs-tooltip-top .tooltip-arrow{bottom:0}.bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow::before,.bs-tooltip-top .tooltip-arrow::before{top:-1px;border-width:var(--bs-tooltip-arrow-height) calc(var(--bs-tooltip-arrow-width) * .5) 0;border-top-color:var(--bs-tooltip-bg)}.bs-tooltip-auto[data-popper-placement^=right] .tooltip-arrow,.bs-tooltip-end .tooltip-arrow{left:0;width:var(--bs-tooltip-arrow-height);height:var(--bs-tooltip-arrow-width)}.bs-tooltip-auto[data-popper-placement^=right] .tooltip-arrow::before,.bs-tooltip-end .tooltip-arrow::before{right:-1px;border-width:calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height) calc(var(--bs-tooltip-arrow-width) * .5) 0;border-right-color:var(--bs-tooltip-bg)}.bs-tooltip-auto[data-popper-placement^=bottom] .tooltip-arrow,.bs-tooltip-bottom .tooltip-arrow{top:0}.bs-tooltip-auto[data-popper-placement^=bottom] .tooltip-arrow::before,.bs-tooltip-bottom .tooltip-arrow::before{bottom:-1px;border-width:0 calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height);border-bottom-color:var(--bs-tooltip-bg)}.bs-tooltip-auto[data-popper-placement^=left] .tooltip-arrow,.bs-tooltip-start .tooltip-arrow{right:0;width:var(--bs-tooltip-arrow-height);height:var(--bs-tooltip-arrow-width)}.bs-tooltip-auto[data-popper-placement^=left] .tooltip-arrow::before,.bs-tooltip-start .tooltip-arrow::before{left:-1px;border-width:calc(var(--bs-tooltip-arrow-width) * .5) 0 calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height);border-left-color:var(--bs-tooltip-bg)}.tooltip-inner{max-width:var(--bs-tooltip-max-width);padding:var(--bs-tooltip-padding-y) var(--bs-tooltip-padding-x);color:var(--bs-tooltip-color);text-align:center;background-color:var(--bs-tooltip-bg);border-radius:var(--bs-tooltip-border-radius)}.popover{--bs-popover-zindex:1070;--bs-popover-max-width:276px;--bs-popover-font-size:0.875rem;--bs-popover-bg:#303030;--bs-popover-border-width:1px;--bs-popover-border-color:var(--bs-border-color-translucent);--bs-popover-border-radius:0.5rem;--bs-popover-inner-border-radius:calc(0.5rem - 1px);--bs-popover-box-shadow:0 0.5rem 1rem rgba(0, 0, 0, 0.15);--bs-popover-header-padding-x:1rem;--bs-popover-header-padding-y:0.5rem;--bs-popover-header-font-size:1rem;--bs-popover-header-color: ;--bs-popover-header-bg:#444;--bs-popover-body-padding-x:1rem;--bs-popover-body-padding-y:1rem;--bs-popover-body-color:#fff;--bs-popover-arrow-width:1rem;--bs-popover-arrow-height:0.5rem;--bs-popover-arrow-border:var(--bs-popover-border-color);z-index:var(--bs-popover-zindex);display:block;max-width:var(--bs-popover-max-width);font-family:var(--bs-font-sans-serif);font-style:normal;font-weight:400;line-height:1.5;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;white-space:normal;word-spacing:normal;line-break:auto;font-size:var(--bs-popover-font-size);word-wrap:break-word;background-color:var(--bs-popover-bg);background-clip:padding-box;border:var(--bs-popover-border-width) solid var(--bs-popover-border-color);border-radius:var(--bs-popover-border-radius)}.popover .popover-arrow{display:block;width:var(--bs-popover-arrow-width);height:var(--bs-popover-arrow-height)}.popover .popover-arrow::after,.popover .popover-arrow::before{position:absolute;display:block;content:"";border-color:transparent;border-style:solid;border-width:0}.bs-popover-auto[data-popper-placement^=top]>.popover-arrow,.bs-popover-top>.popover-arrow{bottom:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width))}.bs-popover-auto[data-popper-placement^=top]>.popover-arrow::after,.bs-popover-auto[data-popper-placement^=top]>.popover-arrow::before,.bs-popover-top>.popover-arrow::after,.bs-popover-top>.popover-arrow::before{border-width:var(--bs-popover-arrow-height) calc(var(--bs-popover-arrow-width) * .5) 0}.bs-popover-auto[data-popper-placement^=top]>.popover-arrow::before,.bs-popover-top>.popover-arrow::before{bottom:0;border-top-color:var(--bs-popover-arrow-border)}.bs-popover-auto[data-popper-placement^=top]>.popover-arrow::after,.bs-popover-top>.popover-arrow::after{bottom:var(--bs-popover-border-width);border-top-color:var(--bs-popover-bg)}.bs-popover-auto[data-popper-placement^=right]>.popover-arrow,.bs-popover-end>.popover-arrow{left:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width));width:var(--bs-popover-arrow-height);height:var(--bs-popover-arrow-width)}.bs-popover-auto[data-popper-placement^=right]>.popover-arrow::after,.bs-popover-auto[data-popper-placement^=right]>.popover-arrow::before,.bs-popover-end>.popover-arrow::after,.bs-popover-end>.popover-arrow::before{border-width:calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height) calc(var(--bs-popover-arrow-width) * .5) 0}.bs-popover-auto[data-popper-placement^=right]>.popover-arrow::before,.bs-popover-end>.popover-arrow::before{left:0;border-right-color:var(--bs-popover-arrow-border)}.bs-popover-auto[data-popper-placement^=right]>.popover-arrow::after,.bs-popover-end>.popover-arrow::after{left:var(--bs-popover-border-width);border-right-color:var(--bs-popover-bg)}.bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow,.bs-popover-bottom>.popover-arrow{top:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width))}.bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow::after,.bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow::before,.bs-popover-bottom>.popover-arrow::after,.bs-popover-bottom>.popover-arrow::before{border-width:0 calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height)}.bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow::before,.bs-popover-bottom>.popover-arrow::before{top:0;border-bottom-color:var(--bs-popover-arrow-border)}.bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow::after,.bs-popover-bottom>.popover-arrow::after{top:var(--bs-popover-border-width);border-bottom-color:var(--bs-popover-bg)}.bs-popover-auto[data-popper-placement^=bottom] .popover-header::before,.bs-popover-bottom .popover-header::before{position:absolute;top:0;left:50%;display:block;width:var(--bs-popover-arrow-width);margin-left:calc(-.5 * var(--bs-popover-arrow-width));content:"";border-bottom:var(--bs-popover-border-width) solid var(--bs-popover-header-bg)}.bs-popover-auto[data-popper-placement^=left]>.popover-arrow,.bs-popover-start>.popover-arrow{right:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width));width:var(--bs-popover-arrow-height);height:var(--bs-popover-arrow-width)}.bs-popover-auto[data-popper-placement^=left]>.popover-arrow::after,.bs-popover-auto[data-popper-placement^=left]>.popover-arrow::before,.bs-popover-start>.popover-arrow::after,.bs-popover-start>.popover-arrow::before{border-width:calc(var(--bs-popover-arrow-width) * .5) 0 calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height)}.bs-popover-auto[data-popper-placement^=left]>.popover-arrow::before,.bs-popover-start>.popover-arrow::before{right:0;border-left-color:var(--bs-popover-arrow-border)}.bs-popover-auto[data-popper-placement^=left]>.popover-arrow::after,.bs-popover-start>.popover-arrow::after{right:var(--bs-popover-border-width);border-left-color:var(--bs-popover-bg)}.popover-header{padding:var(--bs-popover-header-padding-y) var(--bs-popover-header-padding-x);margin-bottom:0;font-size:var(--bs-popover-header-font-size);color:var(--bs-popover-header-color);background-color:var(--bs-popover-header-bg);border-bottom:var(--bs-popover-border-width) solid var(--bs-popover-border-color);border-top-left-radius:var(--bs-popover-inner-border-radius);border-top-right-radius:var(--bs-popover-inner-border-radius)}.popover-header:empty{display:none}.popover-body{padding:var(--bs-popover-body-padding-y) var(--bs-popover-body-padding-x);color:var(--bs-popover-body-color)}.carousel{position:relative}.carousel.pointer-event{touch-action:pan-y}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner::after{display:block;clear:both;content:""}.carousel-item{position:relative;display:none;float:left;width:100%;margin-right:-100%;-webkit-backface-visibility:hidden;backface-visibility:hidden;transition:transform .6s ease-in-out}@media (prefers-reduced-motion:reduce){.carousel-item{transition:none}}.carousel-item-next,.carousel-item-prev,.carousel-item.active{display:block}.active.carousel-item-end,.carousel-item-next:not(.carousel-item-start){transform:translateX(100%)}.active.carousel-item-start,.carousel-item-prev:not(.carousel-item-end){transform:translateX(-100%)}.carousel-fade .carousel-item{opacity:0;transition-property:opacity;transform:none}.carousel-fade .carousel-item-next.carousel-item-start,.carousel-fade .carousel-item-prev.carousel-item-end,.carousel-fade .carousel-item.active{z-index:1;opacity:1}.carousel-fade .active.carousel-item-end,.carousel-fade .active.carousel-item-start{z-index:0;opacity:0;transition:opacity 0s .6s}@media (prefers-reduced-motion:reduce){.carousel-fade .active.carousel-item-end,.carousel-fade .active.carousel-item-start{transition:none}}.carousel-control-next,.carousel-control-prev{position:absolute;top:0;bottom:0;z-index:1;display:flex;align-items:center;justify-content:center;width:15%;padding:0;color:#fff;text-align:center;background:0 0;border:0;opacity:.5;transition:opacity .15s ease}@media (prefers-reduced-motion:reduce){.carousel-control-next,.carousel-control-prev{transition:none}}.carousel-control-next:focus,.carousel-control-next:hover,.carousel-control-prev:focus,.carousel-control-prev:hover{color:#fff;text-decoration:none;outline:0;opacity:.9}.carousel-control-prev{left:0}.carousel-control-next{right:0}.carousel-control-next-icon,.carousel-control-prev-icon{display:inline-block;width:2rem;height:2rem;background-repeat:no-repeat;background-position:50%;background-size:100% 100%}.carousel-control-prev-icon{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z'/%3e%3c/svg%3e")}.carousel-control-next-icon{background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e")}.carousel-indicators{position:absolute;right:0;bottom:0;left:0;z-index:2;display:flex;justify-content:center;padding:0;margin-right:15%;margin-bottom:1rem;margin-left:15%;list-style:none}.carousel-indicators [data-bs-target]{box-sizing:content-box;flex:0 1 auto;width:30px;height:3px;padding:0;margin-right:3px;margin-left:3px;text-indent:-999px;cursor:pointer;background-color:#fff;background-clip:padding-box;border:0;border-top:10px solid transparent;border-bottom:10px solid transparent;opacity:.5;transition:opacity .6s ease}@media (prefers-reduced-motion:reduce){.carousel-indicators [data-bs-target]{transition:none}}.carousel-indicators .active{opacity:1}.carousel-caption{position:absolute;right:15%;bottom:1.25rem;left:15%;padding-top:1.25rem;padding-bottom:1.25rem;color:#fff;text-align:center}.carousel-dark .carousel-control-next-icon,.carousel-dark .carousel-control-prev-icon{filter:invert(1) grayscale(100)}.carousel-dark .carousel-indicators [data-bs-target]{background-color:#000}.carousel-dark .carousel-caption{color:#000}.spinner-border,.spinner-grow{display:inline-block;width:var(--bs-spinner-width);height:var(--bs-spinner-height);vertical-align:var(--bs-spinner-vertical-align);border-radius:50%;animation:var(--bs-spinner-animation-speed) linear infinite var(--bs-spinner-animation-name)}@keyframes spinner-border{to{transform:rotate(360deg)}}.spinner-border{--bs-spinner-width:2rem;--bs-spinner-height:2rem;--bs-spinner-vertical-align:-0.125em;--bs-spinner-border-width:0.25em;--bs-spinner-animation-speed:0.75s;--bs-spinner-animation-name:spinner-border;border:var(--bs-spinner-border-width) solid currentcolor;border-right-color:transparent}.spinner-border-sm{--bs-spinner-width:1rem;--bs-spinner-height:1rem;--bs-spinner-border-width:0.2em}@keyframes spinner-grow{0%{transform:scale(0)}50%{opacity:1;transform:none}}.spinner-grow{--bs-spinner-width:2rem;--bs-spinner-height:2rem;--bs-spinner-vertical-align:-0.125em;--bs-spinner-animation-speed:0.75s;--bs-spinner-animation-name:spinner-grow;background-color:currentcolor;opacity:0}.spinner-grow-sm{--bs-spinner-width:1rem;--bs-spinner-height:1rem}@media (prefers-reduced-motion:reduce){.spinner-border,.spinner-grow{--bs-spinner-animation-speed:1.5s}}.offcanvas,.offcanvas-lg,.offcanvas-md,.offcanvas-sm,.offcanvas-xl,.offcanvas-xxl{--bs-offcanvas-zindex:1045;--bs-offcanvas-width:400px;--bs-offcanvas-height:30vh;--bs-offcanvas-padding-x:1rem;--bs-offcanvas-padding-y:1rem;--bs-offcanvas-color: ;--bs-offcanvas-bg:#303030;--bs-offcanvas-border-width:1px;--bs-offcanvas-border-color:#444;--bs-offcanvas-box-shadow:0 0.125rem 0.25rem rgba(0, 0, 0, 0.075)}@media (max-width:575.98px){.offcanvas-sm{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;transition:transform .3s ease-in-out}}@media (max-width:575.98px) and (prefers-reduced-motion:reduce){.offcanvas-sm{transition:none}}@media (max-width:575.98px){.offcanvas-sm.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}}@media (max-width:575.98px){.offcanvas-sm.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}}@media (max-width:575.98px){.offcanvas-sm.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}}@media (max-width:575.98px){.offcanvas-sm.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}}@media (max-width:575.98px){.offcanvas-sm.show:not(.hiding),.offcanvas-sm.showing{transform:none}}@media (max-width:575.98px){.offcanvas-sm.hiding,.offcanvas-sm.show,.offcanvas-sm.showing{visibility:visible}}@media (min-width:576px){.offcanvas-sm{--bs-offcanvas-height:auto;--bs-offcanvas-border-width:0;background-color:transparent!important}.offcanvas-sm .offcanvas-header{display:none}.offcanvas-sm .offcanvas-body{display:flex;flex-grow:0;padding:0;overflow-y:visible;background-color:transparent!important}}@media (max-width:767.98px){.offcanvas-md{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;transition:transform .3s ease-in-out}}@media (max-width:767.98px) and (prefers-reduced-motion:reduce){.offcanvas-md{transition:none}}@media (max-width:767.98px){.offcanvas-md.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}}@media (max-width:767.98px){.offcanvas-md.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}}@media (max-width:767.98px){.offcanvas-md.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}}@media (max-width:767.98px){.offcanvas-md.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}}@media (max-width:767.98px){.offcanvas-md.show:not(.hiding),.offcanvas-md.showing{transform:none}}@media (max-width:767.98px){.offcanvas-md.hiding,.offcanvas-md.show,.offcanvas-md.showing{visibility:visible}}@media (min-width:768px){.offcanvas-md{--bs-offcanvas-height:auto;--bs-offcanvas-border-width:0;background-color:transparent!important}.offcanvas-md .offcanvas-header{display:none}.offcanvas-md .offcanvas-body{display:flex;flex-grow:0;padding:0;overflow-y:visible;background-color:transparent!important}}@media (max-width:991.98px){.offcanvas-lg{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;transition:transform .3s ease-in-out}}@media (max-width:991.98px) and (prefers-reduced-motion:reduce){.offcanvas-lg{transition:none}}@media (max-width:991.98px){.offcanvas-lg.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}}@media (max-width:991.98px){.offcanvas-lg.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}}@media (max-width:991.98px){.offcanvas-lg.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}}@media (max-width:991.98px){.offcanvas-lg.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}}@media (max-width:991.98px){.offcanvas-lg.show:not(.hiding),.offcanvas-lg.showing{transform:none}}@media (max-width:991.98px){.offcanvas-lg.hiding,.offcanvas-lg.show,.offcanvas-lg.showing{visibility:visible}}@media (min-width:992px){.offcanvas-lg{--bs-offcanvas-height:auto;--bs-offcanvas-border-width:0;background-color:transparent!important}.offcanvas-lg .offcanvas-header{display:none}.offcanvas-lg .offcanvas-body{display:flex;flex-grow:0;padding:0;overflow-y:visible;background-color:transparent!important}}@media (max-width:1199.98px){.offcanvas-xl{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;transition:transform .3s ease-in-out}}@media (max-width:1199.98px) and (prefers-reduced-motion:reduce){.offcanvas-xl{transition:none}}@media (max-width:1199.98px){.offcanvas-xl.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}}@media (max-width:1199.98px){.offcanvas-xl.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}}@media (max-width:1199.98px){.offcanvas-xl.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}}@media (max-width:1199.98px){.offcanvas-xl.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}}@media (max-width:1199.98px){.offcanvas-xl.show:not(.hiding),.offcanvas-xl.showing{transform:none}}@media (max-width:1199.98px){.offcanvas-xl.hiding,.offcanvas-xl.show,.offcanvas-xl.showing{visibility:visible}}@media (min-width:1200px){.offcanvas-xl{--bs-offcanvas-height:auto;--bs-offcanvas-border-width:0;background-color:transparent!important}.offcanvas-xl .offcanvas-header{display:none}.offcanvas-xl .offcanvas-body{display:flex;flex-grow:0;padding:0;overflow-y:visible;background-color:transparent!important}}@media (max-width:1399.98px){.offcanvas-xxl{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;transition:transform .3s ease-in-out}}@media (max-width:1399.98px) and (prefers-reduced-motion:reduce){.offcanvas-xxl{transition:none}}@media (max-width:1399.98px){.offcanvas-xxl.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}}@media (max-width:1399.98px){.offcanvas-xxl.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}}@media (max-width:1399.98px){.offcanvas-xxl.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}}@media (max-width:1399.98px){.offcanvas-xxl.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}}@media (max-width:1399.98px){.offcanvas-xxl.show:not(.hiding),.offcanvas-xxl.showing{transform:none}}@media (max-width:1399.98px){.offcanvas-xxl.hiding,.offcanvas-xxl.show,.offcanvas-xxl.showing{visibility:visible}}@media (min-width:1400px){.offcanvas-xxl{--bs-offcanvas-height:auto;--bs-offcanvas-border-width:0;background-color:transparent!important}.offcanvas-xxl .offcanvas-header{display:none}.offcanvas-xxl .offcanvas-body{display:flex;flex-grow:0;padding:0;overflow-y:visible;background-color:transparent!important}}.offcanvas{position:fixed;bottom:0;z-index:var(--bs-offcanvas-zindex);display:flex;flex-direction:column;max-width:100%;color:var(--bs-offcanvas-color);visibility:hidden;background-color:var(--bs-offcanvas-bg);background-clip:padding-box;outline:0;transition:transform .3s ease-in-out}@media (prefers-reduced-motion:reduce){.offcanvas{transition:none}}.offcanvas.offcanvas-start{top:0;left:0;width:var(--bs-offcanvas-width);border-right:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(-100%)}.offcanvas.offcanvas-end{top:0;right:0;width:var(--bs-offcanvas-width);border-left:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateX(100%)}.offcanvas.offcanvas-top{top:0;right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-bottom:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(-100%)}.offcanvas.offcanvas-bottom{right:0;left:0;height:var(--bs-offcanvas-height);max-height:100%;border-top:var(--bs-offcanvas-border-width) solid var(--bs-offcanvas-border-color);transform:translateY(100%)}.offcanvas.show:not(.hiding),.offcanvas.showing{transform:none}.offcanvas.hiding,.offcanvas.show,.offcanvas.showing{visibility:visible}.offcanvas-backdrop{position:fixed;top:0;left:0;z-index:1040;width:100vw;height:100vh;background-color:#000}.offcanvas-backdrop.fade{opacity:0}.offcanvas-backdrop.show{opacity:.5}.offcanvas-header{display:flex;align-items:center;justify-content:space-between;padding:var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x)}.offcanvas-header .btn-close{padding:calc(var(--bs-offcanvas-padding-y) * .5) calc(var(--bs-offcanvas-padding-x) * .5);margin-top:calc(-.5 * var(--bs-offcanvas-padding-y));margin-right:calc(-.5 * var(--bs-offcanvas-padding-x));margin-bottom:calc(-.5 * var(--bs-offcanvas-padding-y))}.offcanvas-title{margin-bottom:0;line-height:1.5}.offcanvas-body{flex-grow:1;padding:var(--bs-offcanvas-padding-y) var(--bs-offcanvas-padding-x);overflow-y:auto}.placeholder{display:inline-block;min-height:1em;vertical-align:middle;cursor:wait;background-color:currentcolor;opacity:.5}.placeholder.btn::before{display:inline-block;content:""}.placeholder-xs{min-height:.6em}.placeholder-sm{min-height:.8em}.placeholder-lg{min-height:1.2em}.placeholder-glow .placeholder{animation:placeholder-glow 2s ease-in-out infinite}@keyframes placeholder-glow{50%{opacity:.2}}.placeholder-wave{-webkit-mask-image:linear-gradient(130deg,#000 55%,rgba(0,0,0,0.8) 75%,#000 95%);mask-image:linear-gradient(130deg,#000 55%,rgba(0,0,0,0.8) 75%,#000 95%);-webkit-mask-size:200% 100%;mask-size:200% 100%;animation:placeholder-wave 2s linear infinite}@keyframes placeholder-wave{100%{-webkit-mask-position:-200% 0%;mask-position:-200% 0%}}.clearfix::after{display:block;clear:both;content:""}.text-bg-primary{color:#fff!important;background-color:RGBA(55,90,127,var(--bs-bg-opacity,1))!important}.text-bg-secondary{color:#fff!important;background-color:RGBA(68,68,68,var(--bs-bg-opacity,1))!important}.text-bg-success{color:#fff!important;background-color:RGBA(0,188,140,var(--bs-bg-opacity,1))!important}.text-bg-info{color:#fff!important;background-color:RGBA(52,152,219,var(--bs-bg-opacity,1))!important}.text-bg-warning{color:#fff!important;background-color:RGBA(243,156,18,var(--bs-bg-opacity,1))!important}.text-bg-danger{color:#fff!important;background-color:RGBA(231,76,60,var(--bs-bg-opacity,1))!important}.text-bg-light{color:#fff!important;background-color:RGBA(173,181,189,var(--bs-bg-opacity,1))!important}.text-bg-dark{color:#fff!important;background-color:RGBA(48,48,48,var(--bs-bg-opacity,1))!important}.link-primary{color:#375a7f!important}.link-primary:focus,.link-primary:hover{color:#2c4866!important}.link-secondary{color:#444!important}.link-secondary:focus,.link-secondary:hover{color:#363636!important}.link-success{color:#00bc8c!important}.link-success:focus,.link-success:hover{color:#009670!important}.link-info{color:#3498db!important}.link-info:focus,.link-info:hover{color:#2a7aaf!important}.link-warning{color:#f39c12!important}.link-warning:focus,.link-warning:hover{color:#c27d0e!important}.link-danger{color:#e74c3c!important}.link-danger:focus,.link-danger:hover{color:#b93d30!important}.link-light{color:#adb5bd!important}.link-light:focus,.link-light:hover{color:#8a9197!important}.link-dark{color:#303030!important}.link-dark:focus,.link-dark:hover{color:#262626!important}.ratio{position:relative;width:100%}.ratio::before{display:block;padding-top:var(--bs-aspect-ratio);content:""}.ratio>*{position:absolute;top:0;left:0;width:100%;height:100%}.ratio-1x1{--bs-aspect-ratio:100%}.ratio-4x3{--bs-aspect-ratio:75%}.ratio-16x9{--bs-aspect-ratio:56.25%}.ratio-21x9{--bs-aspect-ratio:42.8571428571%}.fixed-top{position:fixed;top:0;right:0;left:0;z-index:1030}.fixed-bottom{position:fixed;right:0;bottom:0;left:0;z-index:1030}.sticky-top{position:-webkit-sticky;position:sticky;top:0;z-index:1020}.sticky-bottom{position:-webkit-sticky;position:sticky;bottom:0;z-index:1020}@media (min-width:576px){.sticky-sm-top{position:-webkit-sticky;position:sticky;top:0;z-index:1020}.sticky-sm-bottom{position:-webkit-sticky;position:sticky;bottom:0;z-index:1020}}@media (min-width:768px){.sticky-md-top{position:-webkit-sticky;position:sticky;top:0;z-index:1020}.sticky-md-bottom{position:-webkit-sticky;position:sticky;bottom:0;z-index:1020}}@media (min-width:992px){.sticky-lg-top{position:-webkit-sticky;position:sticky;top:0;z-index:1020}.sticky-lg-bottom{position:-webkit-sticky;position:sticky;bottom:0;z-index:1020}}@media (min-width:1200px){.sticky-xl-top{position:-webkit-sticky;position:sticky;top:0;z-index:1020}.sticky-xl-bottom{position:-webkit-sticky;position:sticky;bottom:0;z-index:1020}}@media (min-width:1400px){.sticky-xxl-top{position:-webkit-sticky;position:sticky;top:0;z-index:1020}.sticky-xxl-bottom{position:-webkit-sticky;position:sticky;bottom:0;z-index:1020}}.hstack{display:flex;flex-direction:row;align-items:center;align-self:stretch}.vstack{display:flex;flex:1 1 auto;flex-direction:column;align-self:stretch}.visually-hidden,.visually-hidden-focusable:not(:focus):not(:focus-within){position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}.stretched-link::after{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;content:""}.text-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vr{display:inline-block;align-self:stretch;width:1px;min-height:1em;background-color:currentcolor;opacity:.25}.align-baseline{vertical-align:baseline!important}.align-top{vertical-align:top!important}.align-middle{vertical-align:middle!important}.align-bottom{vertical-align:bottom!important}.align-text-bottom{vertical-align:text-bottom!important}.align-text-top{vertical-align:text-top!important}.float-start{float:left!important}.float-end{float:right!important}.float-none{float:none!important}.opacity-0{opacity:0!important}.opacity-25{opacity:.25!important}.opacity-50{opacity:.5!important}.opacity-75{opacity:.75!important}.opacity-100{opacity:1!important}.overflow-auto{overflow:auto!important}.overflow-hidden{overflow:hidden!important}.overflow-visible{overflow:visible!important}.overflow-scroll{overflow:scroll!important}.d-inline{display:inline!important}.d-inline-block{display:inline-block!important}.d-block{display:block!important}.d-grid{display:grid!important}.d-table{display:table!important}.d-table-row{display:table-row!important}.d-table-cell{display:table-cell!important}.d-flex{display:flex!important}.d-inline-flex{display:inline-flex!important}.d-none{display:none!important}.shadow{box-shadow:0 .5rem 1rem rgba(0,0,0,.15)!important}.shadow-sm{box-shadow:0 .125rem .25rem rgba(0,0,0,.075)!important}.shadow-lg{box-shadow:0 1rem 3rem rgba(0,0,0,.175)!important}.shadow-none{box-shadow:none!important}.position-static{position:static!important}.position-relative{position:relative!important}.position-absolute{position:absolute!important}.position-fixed{position:fixed!important}.position-sticky{position:-webkit-sticky!important;position:sticky!important}.top-0{top:0!important}.top-50{top:50%!important}.top-100{top:100%!important}.bottom-0{bottom:0!important}.bottom-50{bottom:50%!important}.bottom-100{bottom:100%!important}.start-0{left:0!important}.start-50{left:50%!important}.start-100{left:100%!important}.end-0{right:0!important}.end-50{right:50%!important}.end-100{right:100%!important}.translate-middle{transform:translate(-50%,-50%)!important}.translate-middle-x{transform:translateX(-50%)!important}.translate-middle-y{transform:translateY(-50%)!important}.border{border:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color)!important}.border-0{border:0!important}.border-top{border-top:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color)!important}.border-top-0{border-top:0!important}.border-end{border-right:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color)!important}.border-end-0{border-right:0!important}.border-bottom{border-bottom:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color)!important}.border-bottom-0{border-bottom:0!important}.border-start{border-left:var(--bs-border-width) var(--bs-border-style) var(--bs-border-color)!important}.border-start-0{border-left:0!important}.border-primary{--bs-border-opacity:1;border-color:rgba(var(--bs-primary-rgb),var(--bs-border-opacity))!important}.border-secondary{--bs-border-opacity:1;border-color:rgba(var(--bs-secondary-rgb),var(--bs-border-opacity))!important}.border-success{--bs-border-opacity:1;border-color:rgba(var(--bs-success-rgb),var(--bs-border-opacity))!important}.border-info{--bs-border-opacity:1;border-color:rgba(var(--bs-info-rgb),var(--bs-border-opacity))!important}.border-warning{--bs-border-opacity:1;border-color:rgba(var(--bs-warning-rgb),var(--bs-border-opacity))!important}.border-danger{--bs-border-opacity:1;border-color:rgba(var(--bs-danger-rgb),var(--bs-border-opacity))!important}.border-light{--bs-border-opacity:1;border-color:rgba(var(--bs-light-rgb),var(--bs-border-opacity))!important}.border-dark{--bs-border-opacity:1;border-color:rgba(var(--bs-dark-rgb),var(--bs-border-opacity))!important}.border-white{--bs-border-opacity:1;border-color:rgba(var(--bs-white-rgb),var(--bs-border-opacity))!important}.border-1{--bs-border-width:1px}.border-2{--bs-border-width:2px}.border-3{--bs-border-width:3px}.border-4{--bs-border-width:4px}.border-5{--bs-border-width:5px}.border-opacity-10{--bs-border-opacity:0.1}.border-opacity-25{--bs-border-opacity:0.25}.border-opacity-50{--bs-border-opacity:0.5}.border-opacity-75{--bs-border-opacity:0.75}.border-opacity-100{--bs-border-opacity:1}.w-25{width:25%!important}.w-50{width:50%!important}.w-75{width:75%!important}.w-100{width:100%!important}.w-auto{width:auto!important}.mw-100{max-width:100%!important}.vw-100{width:100vw!important}.min-vw-100{min-width:100vw!important}.h-25{height:25%!important}.h-50{height:50%!important}.h-75{height:75%!important}.h-100{height:100%!important}.h-auto{height:auto!important}.mh-100{max-height:100%!important}.vh-100{height:100vh!important}.min-vh-100{min-height:100vh!important}.flex-fill{flex:1 1 auto!important}.flex-row{flex-direction:row!important}.flex-column{flex-direction:column!important}.flex-row-reverse{flex-direction:row-reverse!important}.flex-column-reverse{flex-direction:column-reverse!important}.flex-grow-0{flex-grow:0!important}.flex-grow-1{flex-grow:1!important}.flex-shrink-0{flex-shrink:0!important}.flex-shrink-1{flex-shrink:1!important}.flex-wrap{flex-wrap:wrap!important}.flex-nowrap{flex-wrap:nowrap!important}.flex-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-start{justify-content:flex-start!important}.justify-content-end{justify-content:flex-end!important}.justify-content-center{justify-content:center!important}.justify-content-between{justify-content:space-between!important}.justify-content-around{justify-content:space-around!important}.justify-content-evenly{justify-content:space-evenly!important}.align-items-start{align-items:flex-start!important}.align-items-end{align-items:flex-end!important}.align-items-center{align-items:center!important}.align-items-baseline{align-items:baseline!important}.align-items-stretch{align-items:stretch!important}.align-content-start{align-content:flex-start!important}.align-content-end{align-content:flex-end!important}.align-content-center{align-content:center!important}.align-content-between{align-content:space-between!important}.align-content-around{align-content:space-around!important}.align-content-stretch{align-content:stretch!important}.align-self-auto{align-self:auto!important}.align-self-start{align-self:flex-start!important}.align-self-end{align-self:flex-end!important}.align-self-center{align-self:center!important}.align-self-baseline{align-self:baseline!important}.align-self-stretch{align-self:stretch!important}.order-first{order:-1!important}.order-0{order:0!important}.order-1{order:1!important}.order-2{order:2!important}.order-3{order:3!important}.order-4{order:4!important}.order-5{order:5!important}.order-last{order:6!important}.m-0{margin:0!important}.m-1{margin:.25rem!important}.m-2{margin:.5rem!important}.m-3{margin:1rem!important}.m-4{margin:1.5rem!important}.m-5{margin:3rem!important}.m-auto{margin:auto!important}.mx-0{margin-right:0!important;margin-left:0!important}.mx-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-3{margin-right:1rem!important;margin-left:1rem!important}.mx-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-5{margin-right:3rem!important;margin-left:3rem!important}.mx-auto{margin-right:auto!important;margin-left:auto!important}.my-0{margin-top:0!important;margin-bottom:0!important}.my-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-0{margin-top:0!important}.mt-1{margin-top:.25rem!important}.mt-2{margin-top:.5rem!important}.mt-3{margin-top:1rem!important}.mt-4{margin-top:1.5rem!important}.mt-5{margin-top:3rem!important}.mt-auto{margin-top:auto!important}.me-0{margin-right:0!important}.me-1{margin-right:.25rem!important}.me-2{margin-right:.5rem!important}.me-3{margin-right:1rem!important}.me-4{margin-right:1.5rem!important}.me-5{margin-right:3rem!important}.me-auto{margin-right:auto!important}.mb-0{margin-bottom:0!important}.mb-1{margin-bottom:.25rem!important}.mb-2{margin-bottom:.5rem!important}.mb-3{margin-bottom:1rem!important}.mb-4{margin-bottom:1.5rem!important}.mb-5{margin-bottom:3rem!important}.mb-auto{margin-bottom:auto!important}.ms-0{margin-left:0!important}.ms-1{margin-left:.25rem!important}.ms-2{margin-left:.5rem!important}.ms-3{margin-left:1rem!important}.ms-4{margin-left:1.5rem!important}.ms-5{margin-left:3rem!important}.ms-auto{margin-left:auto!important}.p-0{padding:0!important}.p-1{padding:.25rem!important}.p-2{padding:.5rem!important}.p-3{padding:1rem!important}.p-4{padding:1.5rem!important}.p-5{padding:3rem!important}.px-0{padding-right:0!important;padding-left:0!important}.px-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-3{padding-right:1rem!important;padding-left:1rem!important}.px-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-5{padding-right:3rem!important;padding-left:3rem!important}.py-0{padding-top:0!important;padding-bottom:0!important}.py-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-0{padding-top:0!important}.pt-1{padding-top:.25rem!important}.pt-2{padding-top:.5rem!important}.pt-3{padding-top:1rem!important}.pt-4{padding-top:1.5rem!important}.pt-5{padding-top:3rem!important}.pe-0{padding-right:0!important}.pe-1{padding-right:.25rem!important}.pe-2{padding-right:.5rem!important}.pe-3{padding-right:1rem!important}.pe-4{padding-right:1.5rem!important}.pe-5{padding-right:3rem!important}.pb-0{padding-bottom:0!important}.pb-1{padding-bottom:.25rem!important}.pb-2{padding-bottom:.5rem!important}.pb-3{padding-bottom:1rem!important}.pb-4{padding-bottom:1.5rem!important}.pb-5{padding-bottom:3rem!important}.ps-0{padding-left:0!important}.ps-1{padding-left:.25rem!important}.ps-2{padding-left:.5rem!important}.ps-3{padding-left:1rem!important}.ps-4{padding-left:1.5rem!important}.ps-5{padding-left:3rem!important}.gap-0{gap:0!important}.gap-1{gap:.25rem!important}.gap-2{gap:.5rem!important}.gap-3{gap:1rem!important}.gap-4{gap:1.5rem!important}.gap-5{gap:3rem!important}.font-monospace{font-family:var(--bs-font-monospace)!important}.fs-1{font-size:calc(1.425rem + 2.1vw)!important}.fs-2{font-size:calc(1.375rem + 1.5vw)!important}.fs-3{font-size:calc(1.325rem + .9vw)!important}.fs-4{font-size:calc(1.275rem + .3vw)!important}.fs-5{font-size:1.25rem!important}.fs-6{font-size:1rem!important}.fst-italic{font-style:italic!important}.fst-normal{font-style:normal!important}.fw-light{font-weight:300!important}.fw-lighter{font-weight:lighter!important}.fw-normal{font-weight:400!important}.fw-bold{font-weight:700!important}.fw-semibold{font-weight:600!important}.fw-bolder{font-weight:bolder!important}.lh-1{line-height:1!important}.lh-sm{line-height:1.25!important}.lh-base{line-height:1.5!important}.lh-lg{line-height:2!important}.text-start{text-align:left!important}.text-end{text-align:right!important}.text-center{text-align:center!important}.text-decoration-none{text-decoration:none!important}.text-decoration-underline{text-decoration:underline!important}.text-decoration-line-through{text-decoration:line-through!important}.text-lowercase{text-transform:lowercase!important}.text-uppercase{text-transform:uppercase!important}.text-capitalize{text-transform:capitalize!important}.text-wrap{white-space:normal!important}.text-nowrap{white-space:nowrap!important}.text-break{word-wrap:break-word!important;word-break:break-word!important}.text-primary{--bs-text-opacity:1;color:rgba(var(--bs-primary-rgb),var(--bs-text-opacity))!important}.text-secondary{--bs-text-opacity:1;color:rgba(var(--bs-secondary-rgb),var(--bs-text-opacity))!important}.text-success{--bs-text-opacity:1;color:rgba(var(--bs-success-rgb),var(--bs-text-opacity))!important}.text-info{--bs-text-opacity:1;color:rgba(var(--bs-info-rgb),var(--bs-text-opacity))!important}.text-warning{--bs-text-opacity:1;color:rgba(var(--bs-warning-rgb),var(--bs-text-opacity))!important}.text-danger{--bs-text-opacity:1;color:rgba(var(--bs-danger-rgb),var(--bs-text-opacity))!important}.text-light{--bs-text-opacity:1;color:rgba(var(--bs-light-rgb),var(--bs-text-opacity))!important}.text-dark{--bs-text-opacity:1;color:rgba(var(--bs-dark-rgb),var(--bs-text-opacity))!important}.text-black{--bs-text-opacity:1;color:rgba(var(--bs-black-rgb),var(--bs-text-opacity))!important}.text-white{--bs-text-opacity:1;color:rgba(var(--bs-white-rgb),var(--bs-text-opacity))!important}.text-body{--bs-text-opacity:1;color:rgba(var(--bs-body-color-rgb),var(--bs-text-opacity))!important}.text-muted{--bs-text-opacity:1;color:#888!important}.text-black-50{--bs-text-opacity:1;color:rgba(0,0,0,.5)!important}.text-white-50{--bs-text-opacity:1;color:rgba(255,255,255,.5)!important}.text-reset{--bs-text-opacity:1;color:inherit!important}.text-opacity-25{--bs-text-opacity:0.25}.text-opacity-50{--bs-text-opacity:0.5}.text-opacity-75{--bs-text-opacity:0.75}.text-opacity-100{--bs-text-opacity:1}.bg-primary{--bs-bg-opacity:1;background-color:rgba(var(--bs-primary-rgb),var(--bs-bg-opacity))!important}.bg-secondary{--bs-bg-opacity:1;background-color:rgba(var(--bs-secondary-rgb),var(--bs-bg-opacity))!important}.bg-success{--bs-bg-opacity:1;background-color:rgba(var(--bs-success-rgb),var(--bs-bg-opacity))!important}.bg-info{--bs-bg-opacity:1;background-color:rgba(var(--bs-info-rgb),var(--bs-bg-opacity))!important}.bg-warning{--bs-bg-opacity:1;background-color:rgba(var(--bs-warning-rgb),var(--bs-bg-opacity))!important}.bg-danger{--bs-bg-opacity:1;background-color:rgba(var(--bs-danger-rgb),var(--bs-bg-opacity))!important}.bg-light{--bs-bg-opacity:1;background-color:rgba(var(--bs-light-rgb),var(--bs-bg-opacity))!important}.bg-dark{--bs-bg-opacity:1;background-color:rgba(var(--bs-dark-rgb),var(--bs-bg-opacity))!important}.bg-black{--bs-bg-opacity:1;background-color:rgba(var(--bs-black-rgb),var(--bs-bg-opacity))!important}.bg-white{--bs-bg-opacity:1;background-color:rgba(var(--bs-white-rgb),var(--bs-bg-opacity))!important}.bg-body{--bs-bg-opacity:1;background-color:rgba(var(--bs-body-bg-rgb),var(--bs-bg-opacity))!important}.bg-transparent{--bs-bg-opacity:1;background-color:transparent!important}.bg-opacity-10{--bs-bg-opacity:0.1}.bg-opacity-25{--bs-bg-opacity:0.25}.bg-opacity-50{--bs-bg-opacity:0.5}.bg-opacity-75{--bs-bg-opacity:0.75}.bg-opacity-100{--bs-bg-opacity:1}.bg-gradient{background-image:var(--bs-gradient)!important}.user-select-all{-webkit-user-select:all!important;-moz-user-select:all!important;user-select:all!important}.user-select-auto{-webkit-user-select:auto!important;-moz-user-select:auto!important;user-select:auto!important}.user-select-none{-webkit-user-select:none!important;-moz-user-select:none!important;user-select:none!important}.pe-none{pointer-events:none!important}.pe-auto{pointer-events:auto!important}.rounded{border-radius:var(--bs-border-radius)!important}.rounded-0{border-radius:0!important}.rounded-1{border-radius:var(--bs-border-radius-sm)!important}.rounded-2{border-radius:var(--bs-border-radius)!important}.rounded-3{border-radius:var(--bs-border-radius-lg)!important}.rounded-4{border-radius:var(--bs-border-radius-xl)!important}.rounded-5{border-radius:var(--bs-border-radius-2xl)!important}.rounded-circle{border-radius:50%!important}.rounded-pill{border-radius:var(--bs-border-radius-pill)!important}.rounded-top{border-top-left-radius:var(--bs-border-radius)!important;border-top-right-radius:var(--bs-border-radius)!important}.rounded-end{border-top-right-radius:var(--bs-border-radius)!important;border-bottom-right-radius:var(--bs-border-radius)!important}.rounded-bottom{border-bottom-right-radius:var(--bs-border-radius)!important;border-bottom-left-radius:var(--bs-border-radius)!important}.rounded-start{border-bottom-left-radius:var(--bs-border-radius)!important;border-top-left-radius:var(--bs-border-radius)!important}.visible{visibility:visible!important}.invisible{visibility:hidden!important}@media (min-width:576px){.float-sm-start{float:left!important}.float-sm-end{float:right!important}.float-sm-none{float:none!important}.d-sm-inline{display:inline!important}.d-sm-inline-block{display:inline-block!important}.d-sm-block{display:block!important}.d-sm-grid{display:grid!important}.d-sm-table{display:table!important}.d-sm-table-row{display:table-row!important}.d-sm-table-cell{display:table-cell!important}.d-sm-flex{display:flex!important}.d-sm-inline-flex{display:inline-flex!important}.d-sm-none{display:none!important}.flex-sm-fill{flex:1 1 auto!important}.flex-sm-row{flex-direction:row!important}.flex-sm-column{flex-direction:column!important}.flex-sm-row-reverse{flex-direction:row-reverse!important}.flex-sm-column-reverse{flex-direction:column-reverse!important}.flex-sm-grow-0{flex-grow:0!important}.flex-sm-grow-1{flex-grow:1!important}.flex-sm-shrink-0{flex-shrink:0!important}.flex-sm-shrink-1{flex-shrink:1!important}.flex-sm-wrap{flex-wrap:wrap!important}.flex-sm-nowrap{flex-wrap:nowrap!important}.flex-sm-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-sm-start{justify-content:flex-start!important}.justify-content-sm-end{justify-content:flex-end!important}.justify-content-sm-center{justify-content:center!important}.justify-content-sm-between{justify-content:space-between!important}.justify-content-sm-around{justify-content:space-around!important}.justify-content-sm-evenly{justify-content:space-evenly!important}.align-items-sm-start{align-items:flex-start!important}.align-items-sm-end{align-items:flex-end!important}.align-items-sm-center{align-items:center!important}.align-items-sm-baseline{align-items:baseline!important}.align-items-sm-stretch{align-items:stretch!important}.align-content-sm-start{align-content:flex-start!important}.align-content-sm-end{align-content:flex-end!important}.align-content-sm-center{align-content:center!important}.align-content-sm-between{align-content:space-between!important}.align-content-sm-around{align-content:space-around!important}.align-content-sm-stretch{align-content:stretch!important}.align-self-sm-auto{align-self:auto!important}.align-self-sm-start{align-self:flex-start!important}.align-self-sm-end{align-self:flex-end!important}.align-self-sm-center{align-self:center!important}.align-self-sm-baseline{align-self:baseline!important}.align-self-sm-stretch{align-self:stretch!important}.order-sm-first{order:-1!important}.order-sm-0{order:0!important}.order-sm-1{order:1!important}.order-sm-2{order:2!important}.order-sm-3{order:3!important}.order-sm-4{order:4!important}.order-sm-5{order:5!important}.order-sm-last{order:6!important}.m-sm-0{margin:0!important}.m-sm-1{margin:.25rem!important}.m-sm-2{margin:.5rem!important}.m-sm-3{margin:1rem!important}.m-sm-4{margin:1.5rem!important}.m-sm-5{margin:3rem!important}.m-sm-auto{margin:auto!important}.mx-sm-0{margin-right:0!important;margin-left:0!important}.mx-sm-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-sm-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-sm-3{margin-right:1rem!important;margin-left:1rem!important}.mx-sm-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-sm-5{margin-right:3rem!important;margin-left:3rem!important}.mx-sm-auto{margin-right:auto!important;margin-left:auto!important}.my-sm-0{margin-top:0!important;margin-bottom:0!important}.my-sm-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-sm-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-sm-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-sm-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-sm-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-sm-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-sm-0{margin-top:0!important}.mt-sm-1{margin-top:.25rem!important}.mt-sm-2{margin-top:.5rem!important}.mt-sm-3{margin-top:1rem!important}.mt-sm-4{margin-top:1.5rem!important}.mt-sm-5{margin-top:3rem!important}.mt-sm-auto{margin-top:auto!important}.me-sm-0{margin-right:0!important}.me-sm-1{margin-right:.25rem!important}.me-sm-2{margin-right:.5rem!important}.me-sm-3{margin-right:1rem!important}.me-sm-4{margin-right:1.5rem!important}.me-sm-5{margin-right:3rem!important}.me-sm-auto{margin-right:auto!important}.mb-sm-0{margin-bottom:0!important}.mb-sm-1{margin-bottom:.25rem!important}.mb-sm-2{margin-bottom:.5rem!important}.mb-sm-3{margin-bottom:1rem!important}.mb-sm-4{margin-bottom:1.5rem!important}.mb-sm-5{margin-bottom:3rem!important}.mb-sm-auto{margin-bottom:auto!important}.ms-sm-0{margin-left:0!important}.ms-sm-1{margin-left:.25rem!important}.ms-sm-2{margin-left:.5rem!important}.ms-sm-3{margin-left:1rem!important}.ms-sm-4{margin-left:1.5rem!important}.ms-sm-5{margin-left:3rem!important}.ms-sm-auto{margin-left:auto!important}.p-sm-0{padding:0!important}.p-sm-1{padding:.25rem!important}.p-sm-2{padding:.5rem!important}.p-sm-3{padding:1rem!important}.p-sm-4{padding:1.5rem!important}.p-sm-5{padding:3rem!important}.px-sm-0{padding-right:0!important;padding-left:0!important}.px-sm-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-sm-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-sm-3{padding-right:1rem!important;padding-left:1rem!important}.px-sm-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-sm-5{padding-right:3rem!important;padding-left:3rem!important}.py-sm-0{padding-top:0!important;padding-bottom:0!important}.py-sm-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-sm-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-sm-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-sm-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-sm-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-sm-0{padding-top:0!important}.pt-sm-1{padding-top:.25rem!important}.pt-sm-2{padding-top:.5rem!important}.pt-sm-3{padding-top:1rem!important}.pt-sm-4{padding-top:1.5rem!important}.pt-sm-5{padding-top:3rem!important}.pe-sm-0{padding-right:0!important}.pe-sm-1{padding-right:.25rem!important}.pe-sm-2{padding-right:.5rem!important}.pe-sm-3{padding-right:1rem!important}.pe-sm-4{padding-right:1.5rem!important}.pe-sm-5{padding-right:3rem!important}.pb-sm-0{padding-bottom:0!important}.pb-sm-1{padding-bottom:.25rem!important}.pb-sm-2{padding-bottom:.5rem!important}.pb-sm-3{padding-bottom:1rem!important}.pb-sm-4{padding-bottom:1.5rem!important}.pb-sm-5{padding-bottom:3rem!important}.ps-sm-0{padding-left:0!important}.ps-sm-1{padding-left:.25rem!important}.ps-sm-2{padding-left:.5rem!important}.ps-sm-3{padding-left:1rem!important}.ps-sm-4{padding-left:1.5rem!important}.ps-sm-5{padding-left:3rem!important}.gap-sm-0{gap:0!important}.gap-sm-1{gap:.25rem!important}.gap-sm-2{gap:.5rem!important}.gap-sm-3{gap:1rem!important}.gap-sm-4{gap:1.5rem!important}.gap-sm-5{gap:3rem!important}.text-sm-start{text-align:left!important}.text-sm-end{text-align:right!important}.text-sm-center{text-align:center!important}}@media (min-width:768px){.float-md-start{float:left!important}.float-md-end{float:right!important}.float-md-none{float:none!important}.d-md-inline{display:inline!important}.d-md-inline-block{display:inline-block!important}.d-md-block{display:block!important}.d-md-grid{display:grid!important}.d-md-table{display:table!important}.d-md-table-row{display:table-row!important}.d-md-table-cell{display:table-cell!important}.d-md-flex{display:flex!important}.d-md-inline-flex{display:inline-flex!important}.d-md-none{display:none!important}.flex-md-fill{flex:1 1 auto!important}.flex-md-row{flex-direction:row!important}.flex-md-column{flex-direction:column!important}.flex-md-row-reverse{flex-direction:row-reverse!important}.flex-md-column-reverse{flex-direction:column-reverse!important}.flex-md-grow-0{flex-grow:0!important}.flex-md-grow-1{flex-grow:1!important}.flex-md-shrink-0{flex-shrink:0!important}.flex-md-shrink-1{flex-shrink:1!important}.flex-md-wrap{flex-wrap:wrap!important}.flex-md-nowrap{flex-wrap:nowrap!important}.flex-md-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-md-start{justify-content:flex-start!important}.justify-content-md-end{justify-content:flex-end!important}.justify-content-md-center{justify-content:center!important}.justify-content-md-between{justify-content:space-between!important}.justify-content-md-around{justify-content:space-around!important}.justify-content-md-evenly{justify-content:space-evenly!important}.align-items-md-start{align-items:flex-start!important}.align-items-md-end{align-items:flex-end!important}.align-items-md-center{align-items:center!important}.align-items-md-baseline{align-items:baseline!important}.align-items-md-stretch{align-items:stretch!important}.align-content-md-start{align-content:flex-start!important}.align-content-md-end{align-content:flex-end!important}.align-content-md-center{align-content:center!important}.align-content-md-between{align-content:space-between!important}.align-content-md-around{align-content:space-around!important}.align-content-md-stretch{align-content:stretch!important}.align-self-md-auto{align-self:auto!important}.align-self-md-start{align-self:flex-start!important}.align-self-md-end{align-self:flex-end!important}.align-self-md-center{align-self:center!important}.align-self-md-baseline{align-self:baseline!important}.align-self-md-stretch{align-self:stretch!important}.order-md-first{order:-1!important}.order-md-0{order:0!important}.order-md-1{order:1!important}.order-md-2{order:2!important}.order-md-3{order:3!important}.order-md-4{order:4!important}.order-md-5{order:5!important}.order-md-last{order:6!important}.m-md-0{margin:0!important}.m-md-1{margin:.25rem!important}.m-md-2{margin:.5rem!important}.m-md-3{margin:1rem!important}.m-md-4{margin:1.5rem!important}.m-md-5{margin:3rem!important}.m-md-auto{margin:auto!important}.mx-md-0{margin-right:0!important;margin-left:0!important}.mx-md-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-md-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-md-3{margin-right:1rem!important;margin-left:1rem!important}.mx-md-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-md-5{margin-right:3rem!important;margin-left:3rem!important}.mx-md-auto{margin-right:auto!important;margin-left:auto!important}.my-md-0{margin-top:0!important;margin-bottom:0!important}.my-md-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-md-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-md-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-md-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-md-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-md-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-md-0{margin-top:0!important}.mt-md-1{margin-top:.25rem!important}.mt-md-2{margin-top:.5rem!important}.mt-md-3{margin-top:1rem!important}.mt-md-4{margin-top:1.5rem!important}.mt-md-5{margin-top:3rem!important}.mt-md-auto{margin-top:auto!important}.me-md-0{margin-right:0!important}.me-md-1{margin-right:.25rem!important}.me-md-2{margin-right:.5rem!important}.me-md-3{margin-right:1rem!important}.me-md-4{margin-right:1.5rem!important}.me-md-5{margin-right:3rem!important}.me-md-auto{margin-right:auto!important}.mb-md-0{margin-bottom:0!important}.mb-md-1{margin-bottom:.25rem!important}.mb-md-2{margin-bottom:.5rem!important}.mb-md-3{margin-bottom:1rem!important}.mb-md-4{margin-bottom:1.5rem!important}.mb-md-5{margin-bottom:3rem!important}.mb-md-auto{margin-bottom:auto!important}.ms-md-0{margin-left:0!important}.ms-md-1{margin-left:.25rem!important}.ms-md-2{margin-left:.5rem!important}.ms-md-3{margin-left:1rem!important}.ms-md-4{margin-left:1.5rem!important}.ms-md-5{margin-left:3rem!important}.ms-md-auto{margin-left:auto!important}.p-md-0{padding:0!important}.p-md-1{padding:.25rem!important}.p-md-2{padding:.5rem!important}.p-md-3{padding:1rem!important}.p-md-4{padding:1.5rem!important}.p-md-5{padding:3rem!important}.px-md-0{padding-right:0!important;padding-left:0!important}.px-md-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-md-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-md-3{padding-right:1rem!important;padding-left:1rem!important}.px-md-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-md-5{padding-right:3rem!important;padding-left:3rem!important}.py-md-0{padding-top:0!important;padding-bottom:0!important}.py-md-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-md-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-md-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-md-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-md-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-md-0{padding-top:0!important}.pt-md-1{padding-top:.25rem!important}.pt-md-2{padding-top:.5rem!important}.pt-md-3{padding-top:1rem!important}.pt-md-4{padding-top:1.5rem!important}.pt-md-5{padding-top:3rem!important}.pe-md-0{padding-right:0!important}.pe-md-1{padding-right:.25rem!important}.pe-md-2{padding-right:.5rem!important}.pe-md-3{padding-right:1rem!important}.pe-md-4{padding-right:1.5rem!important}.pe-md-5{padding-right:3rem!important}.pb-md-0{padding-bottom:0!important}.pb-md-1{padding-bottom:.25rem!important}.pb-md-2{padding-bottom:.5rem!important}.pb-md-3{padding-bottom:1rem!important}.pb-md-4{padding-bottom:1.5rem!important}.pb-md-5{padding-bottom:3rem!important}.ps-md-0{padding-left:0!important}.ps-md-1{padding-left:.25rem!important}.ps-md-2{padding-left:.5rem!important}.ps-md-3{padding-left:1rem!important}.ps-md-4{padding-left:1.5rem!important}.ps-md-5{padding-left:3rem!important}.gap-md-0{gap:0!important}.gap-md-1{gap:.25rem!important}.gap-md-2{gap:.5rem!important}.gap-md-3{gap:1rem!important}.gap-md-4{gap:1.5rem!important}.gap-md-5{gap:3rem!important}.text-md-start{text-align:left!important}.text-md-end{text-align:right!important}.text-md-center{text-align:center!important}}@media (min-width:992px){.float-lg-start{float:left!important}.float-lg-end{float:right!important}.float-lg-none{float:none!important}.d-lg-inline{display:inline!important}.d-lg-inline-block{display:inline-block!important}.d-lg-block{display:block!important}.d-lg-grid{display:grid!important}.d-lg-table{display:table!important}.d-lg-table-row{display:table-row!important}.d-lg-table-cell{display:table-cell!important}.d-lg-flex{display:flex!important}.d-lg-inline-flex{display:inline-flex!important}.d-lg-none{display:none!important}.flex-lg-fill{flex:1 1 auto!important}.flex-lg-row{flex-direction:row!important}.flex-lg-column{flex-direction:column!important}.flex-lg-row-reverse{flex-direction:row-reverse!important}.flex-lg-column-reverse{flex-direction:column-reverse!important}.flex-lg-grow-0{flex-grow:0!important}.flex-lg-grow-1{flex-grow:1!important}.flex-lg-shrink-0{flex-shrink:0!important}.flex-lg-shrink-1{flex-shrink:1!important}.flex-lg-wrap{flex-wrap:wrap!important}.flex-lg-nowrap{flex-wrap:nowrap!important}.flex-lg-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-lg-start{justify-content:flex-start!important}.justify-content-lg-end{justify-content:flex-end!important}.justify-content-lg-center{justify-content:center!important}.justify-content-lg-between{justify-content:space-between!important}.justify-content-lg-around{justify-content:space-around!important}.justify-content-lg-evenly{justify-content:space-evenly!important}.align-items-lg-start{align-items:flex-start!important}.align-items-lg-end{align-items:flex-end!important}.align-items-lg-center{align-items:center!important}.align-items-lg-baseline{align-items:baseline!important}.align-items-lg-stretch{align-items:stretch!important}.align-content-lg-start{align-content:flex-start!important}.align-content-lg-end{align-content:flex-end!important}.align-content-lg-center{align-content:center!important}.align-content-lg-between{align-content:space-between!important}.align-content-lg-around{align-content:space-around!important}.align-content-lg-stretch{align-content:stretch!important}.align-self-lg-auto{align-self:auto!important}.align-self-lg-start{align-self:flex-start!important}.align-self-lg-end{align-self:flex-end!important}.align-self-lg-center{align-self:center!important}.align-self-lg-baseline{align-self:baseline!important}.align-self-lg-stretch{align-self:stretch!important}.order-lg-first{order:-1!important}.order-lg-0{order:0!important}.order-lg-1{order:1!important}.order-lg-2{order:2!important}.order-lg-3{order:3!important}.order-lg-4{order:4!important}.order-lg-5{order:5!important}.order-lg-last{order:6!important}.m-lg-0{margin:0!important}.m-lg-1{margin:.25rem!important}.m-lg-2{margin:.5rem!important}.m-lg-3{margin:1rem!important}.m-lg-4{margin:1.5rem!important}.m-lg-5{margin:3rem!important}.m-lg-auto{margin:auto!important}.mx-lg-0{margin-right:0!important;margin-left:0!important}.mx-lg-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-lg-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-lg-3{margin-right:1rem!important;margin-left:1rem!important}.mx-lg-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-lg-5{margin-right:3rem!important;margin-left:3rem!important}.mx-lg-auto{margin-right:auto!important;margin-left:auto!important}.my-lg-0{margin-top:0!important;margin-bottom:0!important}.my-lg-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-lg-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-lg-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-lg-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-lg-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-lg-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-lg-0{margin-top:0!important}.mt-lg-1{margin-top:.25rem!important}.mt-lg-2{margin-top:.5rem!important}.mt-lg-3{margin-top:1rem!important}.mt-lg-4{margin-top:1.5rem!important}.mt-lg-5{margin-top:3rem!important}.mt-lg-auto{margin-top:auto!important}.me-lg-0{margin-right:0!important}.me-lg-1{margin-right:.25rem!important}.me-lg-2{margin-right:.5rem!important}.me-lg-3{margin-right:1rem!important}.me-lg-4{margin-right:1.5rem!important}.me-lg-5{margin-right:3rem!important}.me-lg-auto{margin-right:auto!important}.mb-lg-0{margin-bottom:0!important}.mb-lg-1{margin-bottom:.25rem!important}.mb-lg-2{margin-bottom:.5rem!important}.mb-lg-3{margin-bottom:1rem!important}.mb-lg-4{margin-bottom:1.5rem!important}.mb-lg-5{margin-bottom:3rem!important}.mb-lg-auto{margin-bottom:auto!important}.ms-lg-0{margin-left:0!important}.ms-lg-1{margin-left:.25rem!important}.ms-lg-2{margin-left:.5rem!important}.ms-lg-3{margin-left:1rem!important}.ms-lg-4{margin-left:1.5rem!important}.ms-lg-5{margin-left:3rem!important}.ms-lg-auto{margin-left:auto!important}.p-lg-0{padding:0!important}.p-lg-1{padding:.25rem!important}.p-lg-2{padding:.5rem!important}.p-lg-3{padding:1rem!important}.p-lg-4{padding:1.5rem!important}.p-lg-5{padding:3rem!important}.px-lg-0{padding-right:0!important;padding-left:0!important}.px-lg-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-lg-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-lg-3{padding-right:1rem!important;padding-left:1rem!important}.px-lg-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-lg-5{padding-right:3rem!important;padding-left:3rem!important}.py-lg-0{padding-top:0!important;padding-bottom:0!important}.py-lg-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-lg-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-lg-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-lg-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-lg-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-lg-0{padding-top:0!important}.pt-lg-1{padding-top:.25rem!important}.pt-lg-2{padding-top:.5rem!important}.pt-lg-3{padding-top:1rem!important}.pt-lg-4{padding-top:1.5rem!important}.pt-lg-5{padding-top:3rem!important}.pe-lg-0{padding-right:0!important}.pe-lg-1{padding-right:.25rem!important}.pe-lg-2{padding-right:.5rem!important}.pe-lg-3{padding-right:1rem!important}.pe-lg-4{padding-right:1.5rem!important}.pe-lg-5{padding-right:3rem!important}.pb-lg-0{padding-bottom:0!important}.pb-lg-1{padding-bottom:.25rem!important}.pb-lg-2{padding-bottom:.5rem!important}.pb-lg-3{padding-bottom:1rem!important}.pb-lg-4{padding-bottom:1.5rem!important}.pb-lg-5{padding-bottom:3rem!important}.ps-lg-0{padding-left:0!important}.ps-lg-1{padding-left:.25rem!important}.ps-lg-2{padding-left:.5rem!important}.ps-lg-3{padding-left:1rem!important}.ps-lg-4{padding-left:1.5rem!important}.ps-lg-5{padding-left:3rem!important}.gap-lg-0{gap:0!important}.gap-lg-1{gap:.25rem!important}.gap-lg-2{gap:.5rem!important}.gap-lg-3{gap:1rem!important}.gap-lg-4{gap:1.5rem!important}.gap-lg-5{gap:3rem!important}.text-lg-start{text-align:left!important}.text-lg-end{text-align:right!important}.text-lg-center{text-align:center!important}}@media (min-width:1200px){.float-xl-start{float:left!important}.float-xl-end{float:right!important}.float-xl-none{float:none!important}.d-xl-inline{display:inline!important}.d-xl-inline-block{display:inline-block!important}.d-xl-block{display:block!important}.d-xl-grid{display:grid!important}.d-xl-table{display:table!important}.d-xl-table-row{display:table-row!important}.d-xl-table-cell{display:table-cell!important}.d-xl-flex{display:flex!important}.d-xl-inline-flex{display:inline-flex!important}.d-xl-none{display:none!important}.flex-xl-fill{flex:1 1 auto!important}.flex-xl-row{flex-direction:row!important}.flex-xl-column{flex-direction:column!important}.flex-xl-row-reverse{flex-direction:row-reverse!important}.flex-xl-column-reverse{flex-direction:column-reverse!important}.flex-xl-grow-0{flex-grow:0!important}.flex-xl-grow-1{flex-grow:1!important}.flex-xl-shrink-0{flex-shrink:0!important}.flex-xl-shrink-1{flex-shrink:1!important}.flex-xl-wrap{flex-wrap:wrap!important}.flex-xl-nowrap{flex-wrap:nowrap!important}.flex-xl-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-xl-start{justify-content:flex-start!important}.justify-content-xl-end{justify-content:flex-end!important}.justify-content-xl-center{justify-content:center!important}.justify-content-xl-between{justify-content:space-between!important}.justify-content-xl-around{justify-content:space-around!important}.justify-content-xl-evenly{justify-content:space-evenly!important}.align-items-xl-start{align-items:flex-start!important}.align-items-xl-end{align-items:flex-end!important}.align-items-xl-center{align-items:center!important}.align-items-xl-baseline{align-items:baseline!important}.align-items-xl-stretch{align-items:stretch!important}.align-content-xl-start{align-content:flex-start!important}.align-content-xl-end{align-content:flex-end!important}.align-content-xl-center{align-content:center!important}.align-content-xl-between{align-content:space-between!important}.align-content-xl-around{align-content:space-around!important}.align-content-xl-stretch{align-content:stretch!important}.align-self-xl-auto{align-self:auto!important}.align-self-xl-start{align-self:flex-start!important}.align-self-xl-end{align-self:flex-end!important}.align-self-xl-center{align-self:center!important}.align-self-xl-baseline{align-self:baseline!important}.align-self-xl-stretch{align-self:stretch!important}.order-xl-first{order:-1!important}.order-xl-0{order:0!important}.order-xl-1{order:1!important}.order-xl-2{order:2!important}.order-xl-3{order:3!important}.order-xl-4{order:4!important}.order-xl-5{order:5!important}.order-xl-last{order:6!important}.m-xl-0{margin:0!important}.m-xl-1{margin:.25rem!important}.m-xl-2{margin:.5rem!important}.m-xl-3{margin:1rem!important}.m-xl-4{margin:1.5rem!important}.m-xl-5{margin:3rem!important}.m-xl-auto{margin:auto!important}.mx-xl-0{margin-right:0!important;margin-left:0!important}.mx-xl-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-xl-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-xl-3{margin-right:1rem!important;margin-left:1rem!important}.mx-xl-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-xl-5{margin-right:3rem!important;margin-left:3rem!important}.mx-xl-auto{margin-right:auto!important;margin-left:auto!important}.my-xl-0{margin-top:0!important;margin-bottom:0!important}.my-xl-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-xl-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-xl-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-xl-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-xl-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-xl-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-xl-0{margin-top:0!important}.mt-xl-1{margin-top:.25rem!important}.mt-xl-2{margin-top:.5rem!important}.mt-xl-3{margin-top:1rem!important}.mt-xl-4{margin-top:1.5rem!important}.mt-xl-5{margin-top:3rem!important}.mt-xl-auto{margin-top:auto!important}.me-xl-0{margin-right:0!important}.me-xl-1{margin-right:.25rem!important}.me-xl-2{margin-right:.5rem!important}.me-xl-3{margin-right:1rem!important}.me-xl-4{margin-right:1.5rem!important}.me-xl-5{margin-right:3rem!important}.me-xl-auto{margin-right:auto!important}.mb-xl-0{margin-bottom:0!important}.mb-xl-1{margin-bottom:.25rem!important}.mb-xl-2{margin-bottom:.5rem!important}.mb-xl-3{margin-bottom:1rem!important}.mb-xl-4{margin-bottom:1.5rem!important}.mb-xl-5{margin-bottom:3rem!important}.mb-xl-auto{margin-bottom:auto!important}.ms-xl-0{margin-left:0!important}.ms-xl-1{margin-left:.25rem!important}.ms-xl-2{margin-left:.5rem!important}.ms-xl-3{margin-left:1rem!important}.ms-xl-4{margin-left:1.5rem!important}.ms-xl-5{margin-left:3rem!important}.ms-xl-auto{margin-left:auto!important}.p-xl-0{padding:0!important}.p-xl-1{padding:.25rem!important}.p-xl-2{padding:.5rem!important}.p-xl-3{padding:1rem!important}.p-xl-4{padding:1.5rem!important}.p-xl-5{padding:3rem!important}.px-xl-0{padding-right:0!important;padding-left:0!important}.px-xl-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-xl-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-xl-3{padding-right:1rem!important;padding-left:1rem!important}.px-xl-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-xl-5{padding-right:3rem!important;padding-left:3rem!important}.py-xl-0{padding-top:0!important;padding-bottom:0!important}.py-xl-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-xl-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-xl-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-xl-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-xl-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-xl-0{padding-top:0!important}.pt-xl-1{padding-top:.25rem!important}.pt-xl-2{padding-top:.5rem!important}.pt-xl-3{padding-top:1rem!important}.pt-xl-4{padding-top:1.5rem!important}.pt-xl-5{padding-top:3rem!important}.pe-xl-0{padding-right:0!important}.pe-xl-1{padding-right:.25rem!important}.pe-xl-2{padding-right:.5rem!important}.pe-xl-3{padding-right:1rem!important}.pe-xl-4{padding-right:1.5rem!important}.pe-xl-5{padding-right:3rem!important}.pb-xl-0{padding-bottom:0!important}.pb-xl-1{padding-bottom:.25rem!important}.pb-xl-2{padding-bottom:.5rem!important}.pb-xl-3{padding-bottom:1rem!important}.pb-xl-4{padding-bottom:1.5rem!important}.pb-xl-5{padding-bottom:3rem!important}.ps-xl-0{padding-left:0!important}.ps-xl-1{padding-left:.25rem!important}.ps-xl-2{padding-left:.5rem!important}.ps-xl-3{padding-left:1rem!important}.ps-xl-4{padding-left:1.5rem!important}.ps-xl-5{padding-left:3rem!important}.gap-xl-0{gap:0!important}.gap-xl-1{gap:.25rem!important}.gap-xl-2{gap:.5rem!important}.gap-xl-3{gap:1rem!important}.gap-xl-4{gap:1.5rem!important}.gap-xl-5{gap:3rem!important}.text-xl-start{text-align:left!important}.text-xl-end{text-align:right!important}.text-xl-center{text-align:center!important}}@media (min-width:1400px){.float-xxl-start{float:left!important}.float-xxl-end{float:right!important}.float-xxl-none{float:none!important}.d-xxl-inline{display:inline!important}.d-xxl-inline-block{display:inline-block!important}.d-xxl-block{display:block!important}.d-xxl-grid{display:grid!important}.d-xxl-table{display:table!important}.d-xxl-table-row{display:table-row!important}.d-xxl-table-cell{display:table-cell!important}.d-xxl-flex{display:flex!important}.d-xxl-inline-flex{display:inline-flex!important}.d-xxl-none{display:none!important}.flex-xxl-fill{flex:1 1 auto!important}.flex-xxl-row{flex-direction:row!important}.flex-xxl-column{flex-direction:column!important}.flex-xxl-row-reverse{flex-direction:row-reverse!important}.flex-xxl-column-reverse{flex-direction:column-reverse!important}.flex-xxl-grow-0{flex-grow:0!important}.flex-xxl-grow-1{flex-grow:1!important}.flex-xxl-shrink-0{flex-shrink:0!important}.flex-xxl-shrink-1{flex-shrink:1!important}.flex-xxl-wrap{flex-wrap:wrap!important}.flex-xxl-nowrap{flex-wrap:nowrap!important}.flex-xxl-wrap-reverse{flex-wrap:wrap-reverse!important}.justify-content-xxl-start{justify-content:flex-start!important}.justify-content-xxl-end{justify-content:flex-end!important}.justify-content-xxl-center{justify-content:center!important}.justify-content-xxl-between{justify-content:space-between!important}.justify-content-xxl-around{justify-content:space-around!important}.justify-content-xxl-evenly{justify-content:space-evenly!important}.align-items-xxl-start{align-items:flex-start!important}.align-items-xxl-end{align-items:flex-end!important}.align-items-xxl-center{align-items:center!important}.align-items-xxl-baseline{align-items:baseline!important}.align-items-xxl-stretch{align-items:stretch!important}.align-content-xxl-start{align-content:flex-start!important}.align-content-xxl-end{align-content:flex-end!important}.align-content-xxl-center{align-content:center!important}.align-content-xxl-between{align-content:space-between!important}.align-content-xxl-around{align-content:space-around!important}.align-content-xxl-stretch{align-content:stretch!important}.align-self-xxl-auto{align-self:auto!important}.align-self-xxl-start{align-self:flex-start!important}.align-self-xxl-end{align-self:flex-end!important}.align-self-xxl-center{align-self:center!important}.align-self-xxl-baseline{align-self:baseline!important}.align-self-xxl-stretch{align-self:stretch!important}.order-xxl-first{order:-1!important}.order-xxl-0{order:0!important}.order-xxl-1{order:1!important}.order-xxl-2{order:2!important}.order-xxl-3{order:3!important}.order-xxl-4{order:4!important}.order-xxl-5{order:5!important}.order-xxl-last{order:6!important}.m-xxl-0{margin:0!important}.m-xxl-1{margin:.25rem!important}.m-xxl-2{margin:.5rem!important}.m-xxl-3{margin:1rem!important}.m-xxl-4{margin:1.5rem!important}.m-xxl-5{margin:3rem!important}.m-xxl-auto{margin:auto!important}.mx-xxl-0{margin-right:0!important;margin-left:0!important}.mx-xxl-1{margin-right:.25rem!important;margin-left:.25rem!important}.mx-xxl-2{margin-right:.5rem!important;margin-left:.5rem!important}.mx-xxl-3{margin-right:1rem!important;margin-left:1rem!important}.mx-xxl-4{margin-right:1.5rem!important;margin-left:1.5rem!important}.mx-xxl-5{margin-right:3rem!important;margin-left:3rem!important}.mx-xxl-auto{margin-right:auto!important;margin-left:auto!important}.my-xxl-0{margin-top:0!important;margin-bottom:0!important}.my-xxl-1{margin-top:.25rem!important;margin-bottom:.25rem!important}.my-xxl-2{margin-top:.5rem!important;margin-bottom:.5rem!important}.my-xxl-3{margin-top:1rem!important;margin-bottom:1rem!important}.my-xxl-4{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.my-xxl-5{margin-top:3rem!important;margin-bottom:3rem!important}.my-xxl-auto{margin-top:auto!important;margin-bottom:auto!important}.mt-xxl-0{margin-top:0!important}.mt-xxl-1{margin-top:.25rem!important}.mt-xxl-2{margin-top:.5rem!important}.mt-xxl-3{margin-top:1rem!important}.mt-xxl-4{margin-top:1.5rem!important}.mt-xxl-5{margin-top:3rem!important}.mt-xxl-auto{margin-top:auto!important}.me-xxl-0{margin-right:0!important}.me-xxl-1{margin-right:.25rem!important}.me-xxl-2{margin-right:.5rem!important}.me-xxl-3{margin-right:1rem!important}.me-xxl-4{margin-right:1.5rem!important}.me-xxl-5{margin-right:3rem!important}.me-xxl-auto{margin-right:auto!important}.mb-xxl-0{margin-bottom:0!important}.mb-xxl-1{margin-bottom:.25rem!important}.mb-xxl-2{margin-bottom:.5rem!important}.mb-xxl-3{margin-bottom:1rem!important}.mb-xxl-4{margin-bottom:1.5rem!important}.mb-xxl-5{margin-bottom:3rem!important}.mb-xxl-auto{margin-bottom:auto!important}.ms-xxl-0{margin-left:0!important}.ms-xxl-1{margin-left:.25rem!important}.ms-xxl-2{margin-left:.5rem!important}.ms-xxl-3{margin-left:1rem!important}.ms-xxl-4{margin-left:1.5rem!important}.ms-xxl-5{margin-left:3rem!important}.ms-xxl-auto{margin-left:auto!important}.p-xxl-0{padding:0!important}.p-xxl-1{padding:.25rem!important}.p-xxl-2{padding:.5rem!important}.p-xxl-3{padding:1rem!important}.p-xxl-4{padding:1.5rem!important}.p-xxl-5{padding:3rem!important}.px-xxl-0{padding-right:0!important;padding-left:0!important}.px-xxl-1{padding-right:.25rem!important;padding-left:.25rem!important}.px-xxl-2{padding-right:.5rem!important;padding-left:.5rem!important}.px-xxl-3{padding-right:1rem!important;padding-left:1rem!important}.px-xxl-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.px-xxl-5{padding-right:3rem!important;padding-left:3rem!important}.py-xxl-0{padding-top:0!important;padding-bottom:0!important}.py-xxl-1{padding-top:.25rem!important;padding-bottom:.25rem!important}.py-xxl-2{padding-top:.5rem!important;padding-bottom:.5rem!important}.py-xxl-3{padding-top:1rem!important;padding-bottom:1rem!important}.py-xxl-4{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.py-xxl-5{padding-top:3rem!important;padding-bottom:3rem!important}.pt-xxl-0{padding-top:0!important}.pt-xxl-1{padding-top:.25rem!important}.pt-xxl-2{padding-top:.5rem!important}.pt-xxl-3{padding-top:1rem!important}.pt-xxl-4{padding-top:1.5rem!important}.pt-xxl-5{padding-top:3rem!important}.pe-xxl-0{padding-right:0!important}.pe-xxl-1{padding-right:.25rem!important}.pe-xxl-2{padding-right:.5rem!important}.pe-xxl-3{padding-right:1rem!important}.pe-xxl-4{padding-right:1.5rem!important}.pe-xxl-5{padding-right:3rem!important}.pb-xxl-0{padding-bottom:0!important}.pb-xxl-1{padding-bottom:.25rem!important}.pb-xxl-2{padding-bottom:.5rem!important}.pb-xxl-3{padding-bottom:1rem!important}.pb-xxl-4{padding-bottom:1.5rem!important}.pb-xxl-5{padding-bottom:3rem!important}.ps-xxl-0{padding-left:0!important}.ps-xxl-1{padding-left:.25rem!important}.ps-xxl-2{padding-left:.5rem!important}.ps-xxl-3{padding-left:1rem!important}.ps-xxl-4{padding-left:1.5rem!important}.ps-xxl-5{padding-left:3rem!important}.gap-xxl-0{gap:0!important}.gap-xxl-1{gap:.25rem!important}.gap-xxl-2{gap:.5rem!important}.gap-xxl-3{gap:1rem!important}.gap-xxl-4{gap:1.5rem!important}.gap-xxl-5{gap:3rem!important}.text-xxl-start{text-align:left!important}.text-xxl-end{text-align:right!important}.text-xxl-center{text-align:center!important}}@media (min-width:1200px){.fs-1{font-size:3rem!important}.fs-2{font-size:2.5rem!important}.fs-3{font-size:2rem!important}.fs-4{font-size:1.5rem!important}}@media print{.d-print-inline{display:inline!important}.d-print-inline-block{display:inline-block!important}.d-print-block{display:block!important}.d-print-grid{display:grid!important}.d-print-table{display:table!important}.d-print-table-row{display:table-row!important}.d-print-table-cell{display:table-cell!important}.d-print-flex{display:flex!important}.d-print-inline-flex{display:inline-flex!important}.d-print-none{display:none!important}}:root{color-scheme:dark}.blockquote-footer{color:#888}.input-group-addon{color:#fff}.form-floating>label{color:#444}.nav-pills .nav-item.open .nav-link,.nav-pills .nav-item.open .nav-link:focus,.nav-pills .nav-item.open .nav-link:hover,.nav-pills .nav-link,.nav-pills .nav-link.active,.nav-pills .nav-link.active:focus,.nav-pills .nav-link.active:hover,.nav-tabs .nav-item.open .nav-link,.nav-tabs .nav-item.open .nav-link:focus,.nav-tabs .nav-item.open .nav-link:hover,.nav-tabs .nav-link,.nav-tabs .nav-link.active,.nav-tabs .nav-link.active:focus,.nav-tabs .nav-link.active:hover{color:#fff}.breadcrumb a{color:#fff}.pagination a:hover{text-decoration:none}.alert{color:#fff;border:none}.alert .alert-link,.alert a{color:#fff;text-decoration:underline}.alert-primary{background-color:#375a7f}.alert-secondary{background-color:#444}.alert-success{background-color:#00bc8c}.alert-info{background-color:#3498db}.alert-warning{background-color:#f39c12}.alert-danger{background-color:#e74c3c}.alert-light{background-color:#adb5bd}.alert-dark{background-color:#303030} \ No newline at end of file diff --git a/modules/web-map/src/main/resources/css/kafkatorio.css b/modules/web-map/src/main/resources/css/kafkatorio.css new file mode 100644 index 0000000..00e0e43 --- /dev/null +++ b/modules/web-map/src/main/resources/css/kafkatorio.css @@ -0,0 +1,13 @@ +.leaflet-tile { + /* https://github.com/Leaflet/Leaflet/issues/3575 */ + /*width: 257px !important;*/ + /*height: 257px !important;*/ + /*box-shadow: 0 0 1px rgba(0, 0, 0, 0.05);*/ + + image-rendering: pixelated; +} + +.leaflet-container { + /* make the Leaflet map background transparent, so it matches the site theme */ + background-color: rgba(255, 0, 0, 0.0) !important; +} diff --git a/modules/web-map/src/main/resources/img/kafkatorio-logo.png b/modules/web-map/src/main/resources/img/kafkatorio-logo.png new file mode 100644 index 0000000..a37200e Binary files /dev/null and b/modules/web-map/src/main/resources/img/kafkatorio-logo.png differ diff --git a/modules/web-map/src/main/web/index.html b/modules/web-map/src/main/web/index.html new file mode 100644 index 0000000..dc31aa7 --- /dev/null +++ b/modules/web-map/src/main/web/index.html @@ -0,0 +1,16 @@ + + + + + + Kafkatorio Web Map + + + + + + + +

+ + diff --git a/modules/web-map/src/test/kotlin/test/dev/adamko/kafkatorio/webmap/AppSpec.kt b/modules/web-map/src/test/kotlin/test/dev/adamko/kafkatorio/webmap/AppSpec.kt new file mode 100644 index 0000000..cce7cab --- /dev/null +++ b/modules/web-map/src/test/kotlin/test/dev/adamko/kafkatorio/webmap/AppSpec.kt @@ -0,0 +1,15 @@ +package test.dev.adamko.kafkatorio.webmap + +import io.kvision.test.SimpleSpec +import kotlin.test.Test +import kotlin.test.assertTrue + +class AppSpec : SimpleSpec { + + @Test + fun render() { + run { + assertTrue(true, "Dummy test") + } + } +} diff --git a/modules/web-map/webpack.config.d/bootstrap.js b/modules/web-map/webpack.config.d/bootstrap.js new file mode 100644 index 0000000..c9ac06d --- /dev/null +++ b/modules/web-map/webpack.config.d/bootstrap.js @@ -0,0 +1,3 @@ +config.module.rules.push({test: /\.(woff|woff2)(\?v=\d+\.\d+\.\d+)?$/, type: 'asset'}); +config.module.rules.push({test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, type: 'asset'}); +config.module.rules.push({test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, type: 'asset/resource'}); diff --git a/modules/web-map/webpack.config.d/css.js b/modules/web-map/webpack.config.d/css.js new file mode 100644 index 0000000..3ed3ebc --- /dev/null +++ b/modules/web-map/webpack.config.d/css.js @@ -0,0 +1,2 @@ +config.module.rules.push({ test: /\.css$/, use: ["style-loader", { loader: "css-loader", options: {sourceMap: false} } ] }); + diff --git a/modules/web-map/webpack.config.d/file.js b/modules/web-map/webpack.config.d/file.js new file mode 100644 index 0000000..aa64925 --- /dev/null +++ b/modules/web-map/webpack.config.d/file.js @@ -0,0 +1,6 @@ +config.module.rules.push( + { + test: /\.(jpe?g|png|gif|svg)$/i, + type: 'asset/resource' + } +); diff --git a/modules/web-map/webpack.config.d/handlebars.js b/modules/web-map/webpack.config.d/handlebars.js new file mode 100644 index 0000000..d17c90e --- /dev/null +++ b/modules/web-map/webpack.config.d/handlebars.js @@ -0,0 +1,6 @@ +config.module.rules.push( + { + test: /\.hbs$/i, + loader: 'handlebars-loader' + } +); diff --git a/modules/web-map/webpack.config.d/jquery.js b/modules/web-map/webpack.config.d/jquery.js new file mode 100644 index 0000000..e6c6b21 --- /dev/null +++ b/modules/web-map/webpack.config.d/jquery.js @@ -0,0 +1,9 @@ +;(function() { + const webpack = require('webpack') + + config.plugins.push(new webpack.ProvidePlugin({ + $: "jquery", + jQuery: "jquery", + "window.jQuery": "jquery" + })); +})(); diff --git a/modules/web-map/webpack.config.d/moment.js b/modules/web-map/webpack.config.d/moment.js new file mode 100644 index 0000000..1dac35c --- /dev/null +++ b/modules/web-map/webpack.config.d/moment.js @@ -0,0 +1,15 @@ +;(function() { + const webpack = require('webpack') + try { + const moment = require("moment"); + config.plugins.push(new webpack.IgnorePlugin({ + resourceRegExp: /^\.\/locale$/, + contextRegExp: /moment$/, + })); + config.plugins.push(new webpack.ProvidePlugin({ + moment: "moment", + "window.moment": "moment" + })); + } catch (e) { + } +})(); diff --git a/modules/web-map/webpack.config.d/webpack.js b/modules/web-map/webpack.config.d/webpack.js new file mode 100644 index 0000000..8369c61 --- /dev/null +++ b/modules/web-map/webpack.config.d/webpack.js @@ -0,0 +1,18 @@ +config.resolve.modules.push("../../processedResources/js/main"); + +if (config.devServer) { + config.devServer.hot = true; + config.devtool = 'eval-cheap-source-map'; + config.devServer.host = "0.0.0.0" + // required for single-page app + config.devServer.historyApiFallback = true +} else { + config.devtool = undefined; +} + +// disable bundle size warning +config.performance = { + assetFilter: function (assetFilename) { + return !assetFilename.endsWith('.js'); + }, +}; diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..04b6e42 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,62 @@ +rootProject.name = "kafkatorio" + + +@Suppress("UnstableApiUsage") +pluginManagement { + includeBuild("./gradle-plugins/settings-plugins/") +} + + +includeBuild("./gradle-plugins/builder-plugins/") +includeBuild("./gradle-plugins/docker-compose/") +includeBuild("./gradle-plugins/factorio-gradle/") + + +plugins { + id("kafkatorio.conventions.settings.repositories") +} + + +include( + ":modules:events-library", + + ":modules:events-mod", + + ":modules:events-processor-core", +// ":modules:events-processor-entities", + ":modules:events-processors", +// ":modules:events-processor-tiles", + + +// ":modules:events-server", +// ":modules:events-server-core", + ":modules:events-server-web", + ":modules:events-server-syslog", + + ":modules:infra-factorio-client", + ":modules:infra-factorio-server", + + ":modules:infra-kafka-cluster", + ":modules:infra-kafka-pipe", + + ":modules:kt-rcon", + ":modules:web-map", + +// ":modules:factorio-mod-portal-client", + + ":modules:versions-platform", +) + + +//enableFeaturePreview(org.gradle.api.internal.FeaturePreviews.Feature.TYPESAFE_PROJECT_ACCESSORS.name) +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") +enableFeaturePreview("STABLE_CONFIGURATION_CACHE") + + +//apply(from = "./buildSrc/repositories.settings.gradle.kts") + + +@Suppress("UnstableApiUsage") // Central declaration of repositories is an incubating feature +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS) +}