Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
931d248e4c | ||
|
|
b9922b3bdc | ||
|
|
4a1ddd0f98 | ||
|
|
8cb42f07a2 | ||
|
|
8682de7d17 | ||
|
|
50872d8951 | ||
|
|
68458be71f | ||
|
|
65c776d1a2 | ||
|
|
105bdc8c75 | ||
|
|
619de5e1f8 | ||
|
|
106abd851a | ||
|
|
f50fc96416 | ||
|
|
1f23f54ee4 | ||
|
|
1c8aa9265c | ||
|
|
a706962e1e | ||
|
|
60313f5373 | ||
|
|
92418e7e4e | ||
|
|
5c413f4e8b | ||
|
|
2183dda2df | ||
|
|
2fa12e22d5 | ||
|
|
c3f1af6818 | ||
|
|
18aeeb200f | ||
|
|
b40fa704c6 | ||
|
|
55787fe3c5 | ||
|
|
43589410e3 | ||
|
|
9ac27f5fbd | ||
|
|
1faab39849 | ||
|
|
0ad0e362d6 | ||
|
|
7fbf3593fb | ||
|
|
8830b130ad | ||
|
|
aaecba5642 | ||
|
|
05c3dcd5b5 | ||
|
|
f678c0fa54 | ||
|
|
ef09b642d6 | ||
|
|
7852a77a7c | ||
|
|
582eb68139 | ||
|
|
d0ff245582 | ||
|
|
a109c7115e | ||
|
|
8a06d7cb93 | ||
|
|
60eb56da56 | ||
|
|
0877993b41 | ||
|
|
d404f5daab | ||
|
|
8e0ae3dd83 | ||
|
|
85d98a41c1 | ||
|
|
e1fe000608 | ||
|
|
e853268e52 | ||
|
|
4428cc7e8a | ||
|
|
1af139201d |
@@ -0,0 +1,3 @@
|
|||||||
|
# Drizzle
|
||||||
|
# Replace with your DB credentials!
|
||||||
|
DATABASE_URL="mysql://user:password@host:port/db-name"
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
test-results
|
||||||
node_modules
|
node_modules
|
||||||
|
|
||||||
# Output
|
# Output
|
||||||
|
|||||||
@@ -7,3 +7,4 @@ bun.lockb
|
|||||||
|
|
||||||
# Miscellaneous
|
# Miscellaneous
|
||||||
/static/
|
/static/
|
||||||
|
/drizzle/
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"useTabs": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "none",
|
||||||
|
"printWidth": 100,
|
||||||
|
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": "*.svelte",
|
||||||
|
"options": {
|
||||||
|
"parser": "svelte"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tailwindStylesheet": "./src/app.css"
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"recommendations": [
|
|
||||||
"svelte.svelte-vscode",
|
|
||||||
"esbenp.prettier-vscode",
|
|
||||||
"dbaeumer.vscode-eslint",
|
|
||||||
"bradlc.vscode-tailwindcss"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"files.associations": {
|
|
||||||
"*.css": "tailwindcss"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,232 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
olszewski.ink
|
||||||
|
Copyright (C) 2026 ChaosMaker
|
||||||
|
|
||||||
|
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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
olszewski.ink Copyright (C) 2026 ChaosMaker
|
||||||
|
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”.
|
||||||
|
|
||||||
|
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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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 <https://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
@@ -1,54 +1,62 @@
|
|||||||
# sv
|
Preview can be found here -> https://gornodox.dev
|
||||||
|
|
||||||
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
|
Hello everyone that decided to visit my repo.
|
||||||
|
Today i present to you a 'Work In Progress', state of the art (not really) portfolio website.
|
||||||
|
|
||||||
## Creating a project
|
The main idea was that the "bash terminal" would serve as the main interface that the user would interact with...
|
||||||
|
|
||||||
If you're seeing this, you've probably already done this step. Congrats!
|
But then I thought to myself,
|
||||||
|
>*Wouldn't it be cool if it would actually work like a terminal?`*
|
||||||
|
|
||||||
```sh
|
...and that's how we got here.
|
||||||
# create a new project
|
|
||||||
npx sv create my-app
|
|
||||||
```
|
|
||||||
|
|
||||||
To recreate this project with the same configuration:
|
>***Make note that not all features listed below may be implemented when you're seeing this.***
|
||||||
|
|
||||||
```sh
|
The whole environment is a simulation of a linux environment, from every data structure to the way everything behaves. Theres a file system representation that gets generated from a live folder structure by [this](https://github.com/ChaosMakerMLG/FileSystemParser) project.
|
||||||
# recreate this project
|
This gets parsed by my website into the object structure that the whole `Bash` algorithm can deal and interact with.
|
||||||
pnpm dlx sv@1.1.1 create --template minimal --types ts --add prettier eslint tailwindcss="plugins:none" --install pnpm gornodox.dev
|
|
||||||
```
|
|
||||||
|
|
||||||
## Adding features
|
There are users, permissions, ownership, links (hard and symbolic)
|
||||||
|
File system supports file contents - they get cached into a file with a name, and the node stored on heap just has the name to the correct file cache.
|
||||||
|
|
||||||
Add features to your project with `sv add`:
|
Every command is treated like a process that can be exited
|
||||||
|
aswell as files being executable
|
||||||
|
|
||||||
```sh
|
All of this is purely data-driven and modular, so if you where to take my code and just implement an IO system that would interact with my algorithm, then it would work out of the box, which is REALLYYY COOOL in my opinion.
|
||||||
npx sv add
|
|
||||||
```
|
|
||||||
|
|
||||||
For example, to add Tailwind CSS:
|
All the changes that the user makes will be stored on their browsers `localStorage` and read out on login
|
||||||
|
|
||||||
```sh
|
The website will still serve the purpose of being a portfolio but the actuall portfolio part will just be a process that is ran at initialization of the terminal, and it will display the info about me as a TUI ^w^
|
||||||
npx sv add tailwindcss
|
|
||||||
```
|
|
||||||
|
|
||||||
## Developing
|
It can of course be shutdown as mentioned above and thats how you get access to the shell ;)
|
||||||
|
|
||||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
## This project uses and implements:
|
||||||
|
|
||||||
```sh
|
- Tree traversal
|
||||||
npm run dev
|
- Binary search
|
||||||
|
- Quick sort
|
||||||
|
- And much mode weird stuff...
|
||||||
|
|
||||||
# or start the server and open the app in a new browser tab
|
## Commands:
|
||||||
npm run dev -- --open
|
- return
|
||||||
```
|
- ls
|
||||||
|
- echo
|
||||||
|
- touch
|
||||||
|
- mkdir
|
||||||
|
- pwd
|
||||||
|
- cd
|
||||||
|
- exit
|
||||||
|
- cp
|
||||||
|
- mv
|
||||||
|
- rm
|
||||||
|
- cat
|
||||||
|
- less
|
||||||
|
- chown
|
||||||
|
- chmod
|
||||||
|
- reboot
|
||||||
|
- help
|
||||||
|
- whoami
|
||||||
|
- sudo
|
||||||
|
- su
|
||||||
|
- clear
|
||||||
|
|
||||||
## Building
|
> More will probably added with time :)
|
||||||
|
|
||||||
To create a production version of your app:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm run build
|
|
||||||
```
|
|
||||||
|
|
||||||
You can preview the production build with `npm run preview`.
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { defineConfig } from 'drizzle-kit';
|
||||||
|
|
||||||
|
if (!process.env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
schema: './src/lib/server/db/schema.ts',
|
||||||
|
dialect: 'mysql',
|
||||||
|
dbCredentials: { url: process.env.DATABASE_URL },
|
||||||
|
verbose: true,
|
||||||
|
strict: true
|
||||||
|
});
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { expect, test } from '@playwright/test';
|
||||||
|
|
||||||
|
test('home page has expected h1', async ({ page }) => {
|
||||||
|
await page.goto('/');
|
||||||
|
await expect(page.locator('h1')).toBeVisible();
|
||||||
|
});
|
||||||
@@ -1,22 +1,26 @@
|
|||||||
import prettier from 'eslint-config-prettier';
|
import prettier from 'eslint-config-prettier';
|
||||||
import path from 'node:path';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import { includeIgnoreFile } from '@eslint/compat';
|
||||||
import js from '@eslint/js';
|
import js from '@eslint/js';
|
||||||
import svelte from 'eslint-plugin-svelte';
|
import svelte from 'eslint-plugin-svelte';
|
||||||
import { defineConfig, includeIgnoreFile } from 'eslint/config';
|
import { defineConfig } from 'eslint/config';
|
||||||
import globals from 'globals';
|
import globals from 'globals';
|
||||||
import ts from 'typescript-eslint';
|
import ts from 'typescript-eslint';
|
||||||
|
import svelteConfig from './svelte.config.js';
|
||||||
|
|
||||||
const gitignorePath = path.resolve(import.meta.dirname, '.gitignore');
|
const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
|
||||||
|
|
||||||
export default defineConfig(
|
export default defineConfig(
|
||||||
includeIgnoreFile(gitignorePath),
|
includeIgnoreFile(gitignorePath),
|
||||||
js.configs.recommended,
|
js.configs.recommended,
|
||||||
ts.configs.recommended,
|
...ts.configs.recommended,
|
||||||
svelte.configs.recommended,
|
...svelte.configs.recommended,
|
||||||
prettier,
|
prettier,
|
||||||
svelte.configs.prettier,
|
...svelte.configs.prettier,
|
||||||
{
|
{
|
||||||
languageOptions: { globals: { ...globals.browser, ...globals.node } },
|
languageOptions: {
|
||||||
|
globals: { ...globals.browser, ...globals.node }
|
||||||
|
},
|
||||||
rules: {
|
rules: {
|
||||||
// typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
|
// typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
|
||||||
// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
||||||
@@ -29,13 +33,9 @@ export default defineConfig(
|
|||||||
parserOptions: {
|
parserOptions: {
|
||||||
projectService: true,
|
projectService: true,
|
||||||
extraFileExtensions: ['.svelte'],
|
extraFileExtensions: ['.svelte'],
|
||||||
parser: ts.parser
|
parser: ts.parser,
|
||||||
|
svelteConfig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
// Override or add rule settings here, such as:
|
|
||||||
// 'svelte/button-has-type': 'error'
|
|
||||||
rules: {}
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "gornodox.dev",
|
"name": "svelte-portfolio",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.1",
|
"version": "0.0.69",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
@@ -10,38 +10,50 @@
|
|||||||
"prepare": "svelte-kit sync || echo ''",
|
"prepare": "svelte-kit sync || echo ''",
|
||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
|
"format": "prettier --write .",
|
||||||
"lint": "prettier --check . && eslint .",
|
"lint": "prettier --check . && eslint .",
|
||||||
"format": "prettier --write ."
|
"test:e2e": "playwright test",
|
||||||
|
"test": "npm run test:e2e && npm run test:unit -- --run",
|
||||||
|
"test:unit": "vitest",
|
||||||
|
"db:push": "drizzle-kit push",
|
||||||
|
"db:generate": "drizzle-kit generate",
|
||||||
|
"db:migrate": "drizzle-kit migrate",
|
||||||
|
"db:studio": "drizzle-kit studio"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^10.0.1",
|
"@eslint/compat": "^1.4.0",
|
||||||
"@sveltejs/adapter-node": "^6.0.2",
|
"@eslint/js": "^9.36.0",
|
||||||
"@sveltejs/kit": "^3.1.1",
|
"@playwright/test": "^1.55.1",
|
||||||
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|
"@sveltejs/adapter-auto": "^6.1.0",
|
||||||
"@tailwindcss/vite": "^4.3.3",
|
"@sveltejs/kit": "^2.43.2",
|
||||||
"@types/node": "^26.6.6",
|
"@sveltejs/vite-plugin-svelte": "^6.2.0",
|
||||||
"eslint": "^10.14.0",
|
"@tailwindcss/vite": "^4.1.16",
|
||||||
|
"@types/node": "^24",
|
||||||
|
"@vitest/browser": "^3.2.4",
|
||||||
|
"drizzle-kit": "^0.18.1",
|
||||||
|
"drizzle-orm": "^0.45.2",
|
||||||
|
"eslint": "^9.36.0",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-svelte": "^3.23.1",
|
"eslint-plugin-svelte": "^3.12.4",
|
||||||
"globals": "^17.13.0",
|
"globals": "^16.4.0",
|
||||||
"prettier": "^3.9.10",
|
"mysql2": "^3.16.3",
|
||||||
"prettier-plugin-svelte": "^4.1.1",
|
"playwright": "^1.55.1",
|
||||||
"prettier-plugin-tailwindcss": "^0.8.1",
|
"prettier": "^3.6.2",
|
||||||
"svelte": "^5.57.3",
|
"prettier-plugin-svelte": "^3.4.0",
|
||||||
"svelte-check": "^4.7.7",
|
"prettier-plugin-tailwindcss": "^0.6.14",
|
||||||
"tailwindcss": "^4.3.3",
|
"svelte": "^5.39.5",
|
||||||
"typescript": "^6.0.3",
|
"svelte-check": "^4.3.2",
|
||||||
"typescript-eslint": "^8.72.1",
|
"tailwindcss": "^4.1.16",
|
||||||
"vite": "^8.3.5"
|
"typescript": "^5.9.2",
|
||||||
},
|
"typescript-eslint": "^8.44.1",
|
||||||
"imports": {
|
"vite": "^7.1.7",
|
||||||
"#lib": "./src/lib/index.js",
|
"vitest": "^3.2.4",
|
||||||
"#lib/*": "./src/lib/*"
|
"vitest-browser-svelte": "^1.1.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lucide/svelte": "^1.66.0",
|
"@lucide/svelte": "^0.548.0",
|
||||||
"@wterm/dom": "^0.5.9",
|
"animejs": "^4.5.0",
|
||||||
"@wterm/svelte": "^0.5.9",
|
"gl-matrix": "^3.4.4",
|
||||||
"termos": "file:./src/lib/termos-0.1.1.tgz"
|
"zod": "^4.3.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { defineConfig } from '@playwright/test';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
webServer: {
|
||||||
|
command: 'npm run build && npm run preview',
|
||||||
|
port: 4173
|
||||||
|
},
|
||||||
|
testDir: 'e2e'
|
||||||
|
});
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
allowBuilds:
|
|
||||||
esbuild: true
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/** @type {import("prettier").Config} */
|
|
||||||
const config = {
|
|
||||||
useTabs: true,
|
|
||||||
singleQuote: true,
|
|
||||||
trailingComma: 'none',
|
|
||||||
printWidth: 100,
|
|
||||||
plugins: ['prettier-plugin-svelte', 'prettier-plugin-tailwindcss'],
|
|
||||||
overrides: [{ files: '*.svelte', options: { parser: 'svelte' } }],
|
|
||||||
tailwindStylesheet: './src/routes/layout.css'
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
||||||
@@ -1,47 +1,6 @@
|
|||||||
@import './style/global.css';
|
@import './style/global.css';
|
||||||
@import './style/themes.css';
|
|
||||||
@import 'tailwindcss';
|
@import 'tailwindcss';
|
||||||
|
|
||||||
.crt-vignette {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 898;
|
|
||||||
pointer-events: none;
|
|
||||||
background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.3) 100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* scanlines — your existing rule, unchanged */
|
|
||||||
.crt-scanlines {
|
|
||||||
display: block;
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
pointer-events: none;
|
|
||||||
z-index: 900;
|
|
||||||
background:
|
|
||||||
linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
|
|
||||||
linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
|
|
||||||
background-size:
|
|
||||||
100% 2px,
|
|
||||||
3px 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* grain — SVG fractal noise, tiled, topmost */
|
|
||||||
.crt-grain {
|
|
||||||
position: fixed;
|
|
||||||
inset: 0;
|
|
||||||
z-index: 902;
|
|
||||||
pointer-events: none;
|
|
||||||
opacity: 0.035;
|
|
||||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* single toggle — hides all three when data-crt="false" */
|
|
||||||
:root[data-crt='false'] #crt-vignette,
|
|
||||||
:root[data-crt='false'] #crt-scanlines,
|
|
||||||
:root[data-crt='false'] #crt-grain {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
@@ -82,11 +41,10 @@ h1 {
|
|||||||
padding: 2em;
|
padding: 2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* button:hover {
|
button:hover {
|
||||||
border-color: #646cff;
|
border-color: #646cff;
|
||||||
}
|
}
|
||||||
button:focus,
|
button:focus,
|
||||||
button:focus-visible {
|
button:focus-visible {
|
||||||
outline: 4px auto -webkit-focus-ring-color;
|
outline: 4px auto -webkit-focus-ring-color;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ declare global {
|
|||||||
// interface PageState {}
|
// interface PageState {}
|
||||||
// interface Platform {}
|
// interface Platform {}
|
||||||
}
|
}
|
||||||
|
namespace TermOS {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en" data-theme="gruvbox">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<script>
|
<script>
|
||||||
// Immediately apply saved or system theme – no flash
|
// Immediately apply saved or system theme – no flash
|
||||||
@@ -9,18 +9,15 @@
|
|||||||
const theme =
|
const theme =
|
||||||
saved === 'dark' || saved === 'light' ? saved : prefersDark ? 'dark' : 'light';
|
saved === 'dark' || saved === 'light' ? saved : prefersDark ? 'dark' : 'light';
|
||||||
document.documentElement.setAttribute('data-theme', theme);
|
document.documentElement.setAttribute('data-theme', theme);
|
||||||
|
// Optional: prevent transition on load
|
||||||
document.documentElement.style.setProperty('--initial-load', 'true');
|
document.documentElement.style.setProperty('--initial-load', 'true');
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="text-scale" content="scale" />
|
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
<body data-sveltekit-preload-data="hover">
|
<body data-sveltekit-preload-data="hover">
|
||||||
<div style="display: contents">%sveltekit.body%</div>
|
<div style="display: contents">%sveltekit.body%</div>
|
||||||
<!-- <div id="crt-vignette" class="crt-vignette" aria-hidden="true"></div> -->
|
|
||||||
<div id="crt-scanlines" class="crt-scanlines" aria-hidden="true"></div>
|
|
||||||
<div id="crt-grain" class="crt-grain" aria-hidden="true"></div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
|
||||||
|
describe('sum test', () => {
|
||||||
|
it('adds 1 + 2 to equal 3', () => {
|
||||||
|
expect(1 + 2).toBe(3);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
After Width: | Height: | Size: 158 B |
|
After Width: | Height: | Size: 158 B |
|
After Width: | Height: | Size: 158 B |
|
After Width: | Height: | Size: 205 B |
|
After Width: | Height: | Size: 597 B |
|
After Width: | Height: | Size: 560 B |
|
After Width: | Height: | Size: 615 B |
|
After Width: | Height: | Size: 597 B |
|
After Width: | Height: | Size: 628 B |
|
After Width: | Height: | Size: 585 B |
|
After Width: | Height: | Size: 604 B |
|
After Width: | Height: | Size: 601 B |
|
After Width: | Height: | Size: 632 B |
|
After Width: | Height: | Size: 612 B |
|
After Width: | Height: | Size: 467 B |
|
After Width: | Height: | Size: 471 B |
|
After Width: | Height: | Size: 471 B |
|
After Width: | Height: | Size: 476 B |
|
After Width: | Height: | Size: 468 B |
|
After Width: | Height: | Size: 459 B |
|
After Width: | Height: | Size: 472 B |
|
After Width: | Height: | Size: 628 B |
|
After Width: | Height: | Size: 649 B |
|
After Width: | Height: | Size: 638 B |
|
After Width: | Height: | Size: 656 B |
|
After Width: | Height: | Size: 648 B |
|
After Width: | Height: | Size: 640 B |
|
After Width: | Height: | Size: 629 B |
|
After Width: | Height: | Size: 628 B |
|
After Width: | Height: | Size: 639 B |
|
After Width: | Height: | Size: 657 B |
|
After Width: | Height: | Size: 645 B |
|
After Width: | Height: | Size: 654 B |
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
viewBox="0 0 512 512" xml:space="preserve">
|
||||||
|
<path style="fill:#464655;" d="M473.655,88.276H38.345C17.167,88.276,0,105.443,0,126.621v73.471h512v-73.471
|
||||||
|
C512,105.443,494.833,88.276,473.655,88.276z"/>
|
||||||
|
<path style="fill:#FFE15A;" d="M0,385.379c0,21.177,17.167,38.345,38.345,38.345h435.31c21.177,0,38.345-17.167,38.345-38.345
|
||||||
|
v-73.471H0V385.379z"/>
|
||||||
|
<rect y="200.09" style="fill:#FF4B55;" width="512" height="111.81"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 668 B |
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg width="800px" height="800px" viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--twemoji" preserveAspectRatio="xMidYMid meet"><path fill="#00247D" d="M0 9.059V13h5.628zM4.664 31H13v-5.837zM23 25.164V31h8.335zM0 23v3.941L5.63 23zM31.337 5H23v5.837zM36 26.942V23h-5.631zM36 13V9.059L30.371 13zM13 5H4.664L13 10.837z"></path><path fill="#CF1B2B" d="M25.14 23l9.712 6.801a3.977 3.977 0 0 0 .99-1.749L28.627 23H25.14zM13 23h-2.141l-9.711 6.8c.521.53 1.189.909 1.938 1.085L13 23.943V23zm10-10h2.141l9.711-6.8a3.988 3.988 0 0 0-1.937-1.085L23 12.057V13zm-12.141 0L1.148 6.2a3.994 3.994 0 0 0-.991 1.749L7.372 13h3.487z"></path><path fill="#EEE" d="M36 21H21v10h2v-5.836L31.335 31H32a3.99 3.99 0 0 0 2.852-1.199L25.14 23h3.487l7.215 5.052c.093-.337.158-.686.158-1.052v-.058L30.369 23H36v-2zM0 21v2h5.63L0 26.941V27c0 1.091.439 2.078 1.148 2.8l9.711-6.8H13v.943l-9.914 6.941c.294.07.598.116.914.116h.664L13 25.163V31h2V21H0zM36 9a3.983 3.983 0 0 0-1.148-2.8L25.141 13H23v-.943l9.915-6.942A4.001 4.001 0 0 0 32 5h-.663L23 10.837V5h-2v10h15v-2h-5.629L36 9.059V9zM13 5v5.837L4.664 5H4a3.985 3.985 0 0 0-2.852 1.2l9.711 6.8H7.372L.157 7.949A3.968 3.968 0 0 0 0 9v.059L5.628 13H0v2h15V5h-2z"></path><path fill="#CF1B2B" d="M21 15V5h-6v10H0v6h15v10h6V21h15v-6z"></path></svg>
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
viewBox="0 0 512 512" xml:space="preserve">
|
||||||
|
<path style="fill:#41479B;" d="M38.345,88.273C17.167,88.273,0,105.44,0,126.618v258.759c0,21.177,17.167,38.345,38.345,38.345
|
||||||
|
h132.322V88.273H38.345z"/>
|
||||||
|
<rect x="170.67" y="88.277" style="fill:#F5F5F5;" width="170.67" height="335.45"/>
|
||||||
|
<path style="fill:#FF4B55;" d="M473.655,88.273H341.333v335.448h132.322c21.177,0,38.345-17.167,38.345-38.345V126.618
|
||||||
|
C512,105.44,494.833,88.273,473.655,88.273z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 695 B |
@@ -0,0 +1 @@
|
|||||||
|
32aac83d-ce2b-4def-977c-dcdcb6f514ef
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg height="800px" width="800px" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
|
viewBox="0 0 512 512" xml:space="preserve">
|
||||||
|
<path style="fill:#F5F5F5;" d="M473.655,88.275H38.345C17.167,88.275,0,105.442,0,126.62V385.38
|
||||||
|
c0,21.177,17.167,38.345,38.345,38.345h435.31c21.177,0,38.345-17.167,38.345-38.345V126.62
|
||||||
|
C512,105.442,494.833,88.275,473.655,88.275z"/>
|
||||||
|
<circle style="fill:#FF4B55;" cx="256" cy="255.999" r="97.1"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 620 B |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 44 KiB |
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg width="800px" height="800px" viewBox="0 0 36 36" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--twemoji" preserveAspectRatio="xMidYMid meet"><path fill="#EEE" d="M32 5H4a4 4 0 0 0-4 4v9h36V9a4 4 0 0 0-4-4z"></path><path fill="#DC143C" d="M0 27a4 4 0 0 0 4 4h28a4 4 0 0 0 4-4v-9H0v9z"></path></svg>
|
||||||
|
After Width: | Height: | Size: 506 B |
@@ -1 +1,2 @@
|
|||||||
// place files you want to import through the `#lib` alias in this folder.
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { onMount, type SvelteComponent } from 'svelte';
|
|
||||||
|
|
||||||
let {
|
|
||||||
node,
|
|
||||||
callbacks
|
|
||||||
}: {
|
|
||||||
node: HTMLElement | SvelteComponent | Document;
|
|
||||||
callbacks: { title: string; fn: (e: MouseEvent) => void }[];
|
|
||||||
} = $props();
|
|
||||||
|
|
||||||
let contextMenu: HTMLElement;
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
node.oncontextmenu = showContextMenu;
|
|
||||||
node.onclick = hideContextMenu;
|
|
||||||
contextMenu.onclick = hideContextMenu;
|
|
||||||
});
|
|
||||||
|
|
||||||
function showContextMenu(e: PointerEvent) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
console.log('im called');
|
|
||||||
|
|
||||||
contextMenu.style.display = 'block';
|
|
||||||
contextMenu.style.top = e.pageY.toString() + 'px';
|
|
||||||
contextMenu.style.left = e.pageX.toString() + 'px';
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideContextMenu() {
|
|
||||||
contextMenu.style.display = 'none';
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div bind:this={contextMenu} class=" bg-surface-3 absolute z-200 hidden rounded-md p-2">
|
|
||||||
<ul>
|
|
||||||
{#each callbacks as item}
|
|
||||||
<li class=" border-b-px border-text-primary">
|
|
||||||
<button aria-label={item.title} onclick={(e) => item.fn(e)}>{item.title}</button>
|
|
||||||
</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { mwin_movable } from '#lib/mwinlib/mwin_controller.svelte.ts';
|
|
||||||
import type { MWinParams } from '#lib/mwinlib/mwin_util.ts';
|
|
||||||
|
|
||||||
let {
|
|
||||||
children,
|
|
||||||
wrapper,
|
|
||||||
mwinoptions,
|
|
||||||
handle = $bindable(),
|
|
||||||
class: className = '',
|
|
||||||
...props
|
|
||||||
}: {
|
|
||||||
wrapper?: HTMLElement | string;
|
|
||||||
children?: any;
|
|
||||||
mwinoptions: Partial<MWinParams>;
|
|
||||||
handle?: HTMLElement | string;
|
|
||||||
class?: string;
|
|
||||||
[x: string]: any;
|
|
||||||
} = $props();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div
|
|
||||||
{...props}
|
|
||||||
class=" transition-discrete will-change-auto {className}"
|
|
||||||
use:mwin_movable={{
|
|
||||||
wrapper,
|
|
||||||
handle,
|
|
||||||
...mwinoptions
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{@render children()}
|
|
||||||
</div>
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
let {
|
|
||||||
username = $bindable(),
|
|
||||||
theme = $bindable(),
|
|
||||||
windowCount = $bindable(),
|
|
||||||
windowTitle = $bindable(),
|
|
||||||
version,
|
|
||||||
hash,
|
|
||||||
add
|
|
||||||
}: {
|
|
||||||
username: string;
|
|
||||||
theme: string;
|
|
||||||
windowCount: number;
|
|
||||||
windowTitle: string;
|
|
||||||
version: string;
|
|
||||||
hash: string;
|
|
||||||
add: () => void;
|
|
||||||
} = $props();
|
|
||||||
|
|
||||||
let now = $state(new Date());
|
|
||||||
let init = new Date().getTime();
|
|
||||||
|
|
||||||
function formatUptime(ms: number): string {
|
|
||||||
const totalSec = Math.floor(ms / 1000);
|
|
||||||
const d = Math.floor(totalSec / 86400);
|
|
||||||
const h = Math.floor((totalSec % 86400) / 3600);
|
|
||||||
const m = Math.floor((totalSec % 3600) / 60);
|
|
||||||
const s = totalSec % 60;
|
|
||||||
const pad = (n: number) => String(n).padStart(2, '0');
|
|
||||||
return d > 0 ? `${d}d ${h}:${pad(m)}:${pad(s)}` : `${h}:${pad(m)}:${pad(s)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
const id = setInterval(() => (now = new Date()), 1000);
|
|
||||||
return () => clearInterval(id);
|
|
||||||
});
|
|
||||||
|
|
||||||
const weekday = $derived(now.toLocaleDateString('en-US', { weekday: 'short' }));
|
|
||||||
const time = $derived(
|
|
||||||
`${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`
|
|
||||||
);
|
|
||||||
const uptime = $derived(`up ${formatUptime(now.getTime() - init)}`);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#snippet sep(cls: string = '')}
|
|
||||||
<span
|
|
||||||
aria-hidden="true"
|
|
||||||
class="text-fg3 text-[9px] select-none {cls}"
|
|
||||||
style="font-family:ui-monospace,monospace">·</span
|
|
||||||
>
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
{#snippet shortcut(keys: string, label: string)}
|
|
||||||
<span class="text-bg4 inline-flex items-center gap-0.75 whitespace-nowrap">
|
|
||||||
<kbd
|
|
||||||
class="border-bg1 text-fg2 inline-flex h-3.25 min-w-3.25 items-center justify-center rounded-[3px] border bg-black/25 px-1 text-[8.5px] leading-none font-medium"
|
|
||||||
>{keys}</kbd
|
|
||||||
>
|
|
||||||
<span class="text-fg4">{label}</span>
|
|
||||||
</span>
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
<div
|
|
||||||
class="bg-bg-soft text-fg3 border-bg3 font-system grid w-full grid-cols-[auto_1fr_auto] gap-x-3 rounded-b-lg border-t text-[11px] shadow-[inset_0_1px_0_rgba(255,255,255,0.04),0_-2px_0_0_rgba(0,0,0,0.1),0_-6px_20px_-4px_rgba(0,0,0,0.5)]"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="col-span-full grid h-[22px] grid-cols-subgrid items-center px-[18px] shadow-[inset_0_-1px_0_var(--color-bg2)]"
|
|
||||||
>
|
|
||||||
<div class="flex items-center gap-1.5 justify-self-start">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
class="group hover:bg-bg1 -ml-1 flex h-[18px] items-center rounded px-1"
|
|
||||||
aria-haspopup="menu"
|
|
||||||
aria-expanded="false"
|
|
||||||
>
|
|
||||||
<span class="text-fg3 group-hover:text-fg2 text-[10.5px] font-medium whitespace-nowrap"
|
|
||||||
>{username}</span
|
|
||||||
>
|
|
||||||
</button>
|
|
||||||
{@render sep()}
|
|
||||||
<span class="text-bg4 px-[3.5px] font-mono text-[9.5px] whitespace-nowrap">{uptime}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
aria-label="New session"
|
|
||||||
onclick={() => add()}
|
|
||||||
class="text-fg3 hover:bg-bg1 hover:text-fg2 active:bg-bg2 focus-visible:ring-tyellow grid h-[18px] w-[18px] place-items-center justify-self-center rounded transition-colors focus:outline-none focus-visible:ring-1"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
viewBox="0 0 16 16"
|
|
||||||
class="h-[10px] w-[10px]"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
stroke-width="1.8"
|
|
||||||
stroke-linecap="round"
|
|
||||||
>
|
|
||||||
<path d="M8 3.5v9M3.5 8h9" />
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<time class="text-bg4 justify-self-end font-mono text-[9.5px] whitespace-nowrap">
|
|
||||||
<span class="text-fg3 pr-2 font-medium">{weekday}</span><span>{time}</span>
|
|
||||||
</time>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="col-span-full grid h-[22px] grid-cols-subgrid items-center rounded-b-lg px-[18px] font-mono text-[9.5px] whitespace-nowrap"
|
|
||||||
>
|
|
||||||
<div class="flex items-center gap-1.5 justify-self-start">
|
|
||||||
<span class="text-fg3">
|
|
||||||
<span class="text-bg4">[</span><span class="font-medium">{windowCount.toString()}</span
|
|
||||||
><span class="text-bg4">]</span>
|
|
||||||
</span>
|
|
||||||
{@render sep()}
|
|
||||||
<span class="text-fg3">{windowTitle}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span></span>
|
|
||||||
|
|
||||||
<span class="flex items-center gap-1.5 justify-self-end">
|
|
||||||
<span class="text-fg3">{version}</span>
|
|
||||||
{@render sep()}
|
|
||||||
<span class="text-bg4">{hash}</span>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- <div
|
|
||||||
class="bg-bg-soft text-fg3 border-bg3 grid w-full zoom-115 grid-cols-[auto_1fr_auto_auto_auto] gap-x-2 overflow-hidden rounded-b-lg border-t text-[11px]"
|
|
||||||
style="font-family:-apple-system,BlinkMacSystemFont,system-ui,sans-serif; box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 -2px 0 0 rgba(0,0,0,0.1), 0 -6px 20px -4px rgba(0,0,0,0.5), 0 -16px 40px -12px rgba(0,0,0,0.65);"
|
|
||||||
role="region"
|
|
||||||
aria-label="System status bar"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="col-span-full grid h-[22px] grid-cols-subgrid items-center px-4.5 shadow-[inset_0_-1px_0_var(--bg2)]"
|
|
||||||
>
|
|
||||||
<div class="flex items-center gap-2 justify-self-end">
|
|
||||||
<span aria-hidden="true" class="bg-tgreen h-1.25 w-1.25 shrink-0 rounded-full"></span>
|
|
||||||
<span class="text-fg3 text-[10.5px] font-medium whitespace-nowrap">{username}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex min-w-0 items-center gap-2">
|
|
||||||
{@render sep()}
|
|
||||||
<span
|
|
||||||
class="text-fg3 hover:text-fg2 cursor-pointer text-[9.5px] whitespace-nowrap"
|
|
||||||
style="font-family:ui-monospace,monospace"
|
|
||||||
title="switch theme">{theme}</span
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
aria-label="Settings"
|
|
||||||
class="text-bg4 flex h-5 w-5 shrink-0 items-center justify-center justify-self-end rounded border-0 bg-transparent p-0 text-[12px]"
|
|
||||||
>
|
|
||||||
<Cog color={'var(--fg1)'} size={8} />
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{@render sep('justify-self-center')}
|
|
||||||
|
|
||||||
<time
|
|
||||||
datetime={now.toISOString()}
|
|
||||||
class="text-bg4 justify-self-start text-[9.5px] whitespace-nowrap"
|
|
||||||
style="font-family:ui-monospace,monospace"
|
|
||||||
>
|
|
||||||
<span class="text-fg4 font-medium">{weekday}</span>
|
|
||||||
{time}
|
|
||||||
</time>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="col-span-full grid h-[22px] grid-cols-subgrid items-center rounded-b-lg px-4.5 text-[9.5px] whitespace-nowrap"
|
|
||||||
style="font-family:ui-monospace,monospace"
|
|
||||||
>
|
|
||||||
<span class="text-fg3 justify-self-end whitespace-nowrap"
|
|
||||||
><span class="font-medium">{windowCount}</span> window{windowCount === 1 ? '' : 's'}</span
|
|
||||||
>
|
|
||||||
|
|
||||||
<div class="flex min-w-0 items-center gap-2">
|
|
||||||
{@render sep()}
|
|
||||||
{@render shortcut('⌘N', 'new terminal')}
|
|
||||||
{@render sep()}
|
|
||||||
{@render shortcut('⌘,', 'settings')}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span class="inline-flex items-center gap-1.25 justify-self-end">
|
|
||||||
<span class="text-fg3">{version}</span>
|
|
||||||
{@render sep()}
|
|
||||||
<span class="text-bg4">{hash}</span>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
{@render sep('justify-self-center')}
|
|
||||||
|
|
||||||
<span class="text-bg4 justify-self-start">{uptime}</span>
|
|
||||||
</div>
|
|
||||||
</div> -->
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { type MWinAPI, type MWinParams } from '#lib/mwinlib/mwin_util.ts';
|
|
||||||
import { resolvePointerToHome, type Shell } from 'termos';
|
|
||||||
import Input from './Input.svelte';
|
|
||||||
import Movable from './Movable.svelte';
|
|
||||||
|
|
||||||
let {
|
|
||||||
id,
|
|
||||||
wrapper,
|
|
||||||
username = $bindable(),
|
|
||||||
hostname = $bindable(),
|
|
||||||
working_dir = $bindable(),
|
|
||||||
mwin = $bindable(),
|
|
||||||
shell = $bindable(),
|
|
||||||
|
|
||||||
close
|
|
||||||
}: {
|
|
||||||
id: number;
|
|
||||||
wrapper: HTMLElement | string;
|
|
||||||
username: string;
|
|
||||||
hostname: string;
|
|
||||||
working_dir: string;
|
|
||||||
mwin: MWinAPI | undefined;
|
|
||||||
shell: Shell | undefined;
|
|
||||||
close?: (id: number) => void;
|
|
||||||
} = $props();
|
|
||||||
|
|
||||||
//let isProcessActive = $state(false);
|
|
||||||
const d = new TextDecoder('utf-8');
|
|
||||||
|
|
||||||
let inputValue = $state('');
|
|
||||||
let inputComponent: any;
|
|
||||||
let outputWrapper: HTMLElement;
|
|
||||||
let scrollDiv: HTMLElement;
|
|
||||||
let stdout: string = '';
|
|
||||||
let count: [string, string, string][] = $state([]);
|
|
||||||
let pwd: string = working_dir;
|
|
||||||
|
|
||||||
const mwinoptions: Partial<MWinParams> = {
|
|
||||||
handle: '#terminal-bar',
|
|
||||||
resizable: { threshold: 10, minWidth: 300, minHeight: 200 },
|
|
||||||
baseZIndex: 300,
|
|
||||||
onAPI: (api: MWinAPI) => {
|
|
||||||
mwin = api;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
async function onsubmit(value: string) {
|
|
||||||
const input = value.trim();
|
|
||||||
await shell!.execute(input);
|
|
||||||
pwd = resolvePointerToHome(shell!.State, shell!.Session.cwd);
|
|
||||||
}
|
|
||||||
|
|
||||||
$effect(() => {
|
|
||||||
shell!.on('stdout', (payload) => {
|
|
||||||
const decoded = d.decode(payload.data);
|
|
||||||
stdout = stdout + decoded;
|
|
||||||
});
|
|
||||||
|
|
||||||
shell!.on('result', (payload) => {
|
|
||||||
if (payload.result.type === 'error') {
|
|
||||||
stdout = stdout + payload.result.error.message + '\n';
|
|
||||||
}
|
|
||||||
working_dir = resolvePointerToHome(shell!.State, shell!.Session.cwd);
|
|
||||||
count.push([inputValue, pwd, stdout]);
|
|
||||||
stdout = '';
|
|
||||||
inputValue = '';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#snippet Out(value: string, path: string, stdout: string)}
|
|
||||||
<span
|
|
||||||
><span class=" scroll-line text-tyellow">{username}</span><span>@</span><span class=" text-fg1"
|
|
||||||
>{hostname}</span
|
|
||||||
>
|
|
||||||
<span class="text-bg4">{path}</span><br /></span
|
|
||||||
>
|
|
||||||
<span class=" scroll-line mr-[1ch]">$</span><span>{value}</span>
|
|
||||||
<div class=" whitespace-pre-wrap">{stdout}</div>
|
|
||||||
{/snippet}
|
|
||||||
|
|
||||||
<Movable
|
|
||||||
{wrapper}
|
|
||||||
{mwinoptions}
|
|
||||||
class="shadow-subtle bg-bg-hard flex size-full h-128 w-210 flex-col rounded-lg"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
id="terminal-bar"
|
|
||||||
class=" bg-bg-soft grid grid-cols-[1fr_auto_1fr] rounded-t-md py-1 select-none"
|
|
||||||
>
|
|
||||||
<div class="dots-wrapper m-auto mx-3 flex size-max flex-row items-center justify-center gap-2">
|
|
||||||
<button
|
|
||||||
data-close-btn
|
|
||||||
class="bg-tl-red h-2.5 w-2.5 cursor-pointer rounded-full active:brightness-85"
|
|
||||||
type="button"
|
|
||||||
aria-label="Close terminal"
|
|
||||||
onclick={() => close?.(id)}
|
|
||||||
></button>
|
|
||||||
<button
|
|
||||||
class="bg-tl-yellow h-2.5 w-2.5 cursor-pointer rounded-full active:brightness-85"
|
|
||||||
type="button"
|
|
||||||
aria-label="Maximize terminal"
|
|
||||||
onclick={() => mwin?.maximize()}
|
|
||||||
></button>
|
|
||||||
<button
|
|
||||||
class="bg-tl-green h-2.5 w-2.5 cursor-pointer rounded-2xl active:brightness-85"
|
|
||||||
type="button"
|
|
||||||
aria-label="Minimize terminal"
|
|
||||||
></button>
|
|
||||||
</div>
|
|
||||||
<span class=" text-fg2 mx-auto text-sm font-medium">{username} — tsh</span>
|
|
||||||
<span></span>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
class="inner-content scroll-hidden text-fg4 font-ibm grow origin-top overflow-y-auto p-4 text-sm"
|
|
||||||
bind:this={scrollDiv}
|
|
||||||
id="cout"
|
|
||||||
onclick={() => inputComponent?.focusInput()}
|
|
||||||
onkeydown={() => inputComponent?.focusInput()}
|
|
||||||
role="textbox"
|
|
||||||
tabindex="-1"
|
|
||||||
>
|
|
||||||
<div bind:this={outputWrapper} class="">
|
|
||||||
{#each count as c}
|
|
||||||
{@render Out(c[0], c[1], c[2])}
|
|
||||||
<div class="mb-3"></div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
<span
|
|
||||||
><span class=" text-tyellow">{shell!.Session.user.username}</span><span>@</span><span
|
|
||||||
class=" text-fg1">{hostname}</span
|
|
||||||
>
|
|
||||||
<span class="text-bg4">{working_dir}</span><br /></span
|
|
||||||
>
|
|
||||||
<Input bind:value={inputValue} blinkDelay={500} {onsubmit} bind:this={inputComponent}
|
|
||||||
><span class="font-ibm mr-[1ch]">$</span></Input
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</Movable>
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
let state = $state(false);
|
|
||||||
|
|
||||||
export function focus() {
|
|
||||||
console.log('called');
|
|
||||||
state = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
let { children, onclick }: { children?: any; onclick?: ({}?: unknown) => unknown } = $props();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<button
|
|
||||||
onclick={() => {
|
|
||||||
onclick?.();
|
|
||||||
console.log('im called');
|
|
||||||
}}
|
|
||||||
class="
|
|
||||||
|
|
||||||
cursor-pointer rounded-full
|
|
||||||
transition-all duration-200 active:translate-y-0.5
|
|
||||||
active:brightness-90 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:brightness-100
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<div class="">
|
|
||||||
{@render children()}
|
|
||||||
</div>
|
|
||||||
</button>
|
|
||||||
@@ -9,14 +9,13 @@ import {
|
|||||||
type ResizeDirection
|
type ResizeDirection
|
||||||
} from './mwin_util';
|
} from './mwin_util';
|
||||||
|
|
||||||
export function mwin_movable(node: HTMLElement, options: Partial<MWinParams>) {
|
export function mwin_movable(node: HTMLElement, options: MWinParams) {
|
||||||
const controller = new MWinController(node, options);
|
const controller = new MWinController(node, options);
|
||||||
const api: MWinAPI = {
|
const api: MWinAPI = {
|
||||||
state: controller.state,
|
state: controller.state,
|
||||||
minimize: () => controller.minimize(),
|
minimize: () => controller.minimize(),
|
||||||
maximize: () => controller.maximize(),
|
maximize: () => controller.maximize(),
|
||||||
close: () => controller.close(),
|
close: () => controller.close()
|
||||||
focus: () => controller.focus()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
options.onAPI?.(api);
|
options.onAPI?.(api);
|
||||||
@@ -62,12 +61,12 @@ class MWinController {
|
|||||||
zIndex: 0
|
zIndex: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
constructor(node: HTMLElement, options: Partial<MWinParams>) {
|
constructor(node: HTMLElement, options: MWinParams) {
|
||||||
this.#node = node;
|
this.#node = node;
|
||||||
|
|
||||||
const wrapper = resolveElement(options.wrapper, node);
|
const wrapper = resolveElement(options.wrapper, node);
|
||||||
if (!wrapper) throw new Error('[Movable] - Wrapper element not found!');
|
if (!wrapper) throw new Error('[Movable] - Wrapper element not found!');
|
||||||
this.#wrapper = wrapper ?? document;
|
this.#wrapper = wrapper;
|
||||||
|
|
||||||
const wrapperStyle = getComputedStyle(this.#wrapper);
|
const wrapperStyle = getComputedStyle(this.#wrapper);
|
||||||
this.#wrapperBorderLeft = parseFloat(wrapperStyle.borderLeftWidth);
|
this.#wrapperBorderLeft = parseFloat(wrapperStyle.borderLeftWidth);
|
||||||
@@ -91,8 +90,7 @@ class MWinController {
|
|||||||
maxHeight: resizableOpts.maxHeight ?? Infinity,
|
maxHeight: resizableOpts.maxHeight ?? Infinity,
|
||||||
onClose: options.onClose,
|
onClose: options.onClose,
|
||||||
onMinimize: options.onMinimize,
|
onMinimize: options.onMinimize,
|
||||||
onMaximize: options.onMaximize,
|
onMaximize: options.onMaximize
|
||||||
onFocus: options.onFocus
|
|
||||||
};
|
};
|
||||||
this.#savedStyles = this.#node.style.cssText;
|
this.#savedStyles = this.#node.style.cssText;
|
||||||
this.#savedTransition = this.#node.style.transition;
|
this.#savedTransition = this.#node.style.transition;
|
||||||
@@ -155,7 +153,6 @@ class MWinController {
|
|||||||
const mgr = getWrapperManager(this.#wrapper);
|
const mgr = getWrapperManager(this.#wrapper);
|
||||||
mgr.zCounter++;
|
mgr.zCounter++;
|
||||||
|
|
||||||
this.#opts.onFocus?.();
|
|
||||||
this.state.zIndex = this.#opts.baseZIndex + mgr.zCounter;
|
this.state.zIndex = this.#opts.baseZIndex + mgr.zCounter;
|
||||||
this.#node.style.zIndex = String(this.state.zIndex);
|
this.#node.style.zIndex = String(this.state.zIndex);
|
||||||
}
|
}
|
||||||
@@ -543,10 +540,6 @@ class MWinController {
|
|||||||
this.#opts.onClose?.();
|
this.#opts.onClose?.();
|
||||||
}
|
}
|
||||||
|
|
||||||
focus(): void {
|
|
||||||
this.#bringToFront();
|
|
||||||
}
|
|
||||||
|
|
||||||
destroy(): void {
|
destroy(): void {
|
||||||
if (this.#rafID !== null) {
|
if (this.#rafID !== null) {
|
||||||
cancelAnimationFrame(this.#rafID);
|
cancelAnimationFrame(this.#rafID);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ export interface MWinParams {
|
|||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
onMinimize?: () => void;
|
onMinimize?: () => void;
|
||||||
onMaximize?: () => void;
|
onMaximize?: () => void;
|
||||||
onFocus?: () => void;
|
|
||||||
onAPI?: (api: MWinAPI) => void;
|
onAPI?: (api: MWinAPI) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +31,6 @@ export interface MWinNormalizedParams {
|
|||||||
onClose?: () => void;
|
onClose?: () => void;
|
||||||
onMinimize?: () => void;
|
onMinimize?: () => void;
|
||||||
onMaximize?: () => void;
|
onMaximize?: () => void;
|
||||||
onFocus?: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MWinResizeParams {
|
export interface MWinResizeParams {
|
||||||
@@ -60,7 +58,6 @@ export interface MWinAPI {
|
|||||||
minimize: () => void;
|
minimize: () => void;
|
||||||
maximize: () => void;
|
maximize: () => void;
|
||||||
close: () => void;
|
close: () => void;
|
||||||
focus: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class WrapperManager {
|
export class WrapperManager {
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { customType } from 'drizzle-orm/mysql-core';
|
||||||
|
|
||||||
|
export const mediumblob = customType<{
|
||||||
|
data: Buffer;
|
||||||
|
driverData: Buffer;
|
||||||
|
}>({
|
||||||
|
dataType() {
|
||||||
|
return 'MEDIUMBLOB';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const longblob = customType<{
|
||||||
|
data: Buffer;
|
||||||
|
driverData: Buffer;
|
||||||
|
}>({
|
||||||
|
dataType() {
|
||||||
|
return 'LONGBLOB';
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
//if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
|
||||||
|
|
||||||
|
//const client = mysql.createPool(env.DATABASE_URL);
|
||||||
|
|
||||||
|
//export const db = drizzle(client, { schema, mode: 'default', logger: true });
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import {
|
||||||
|
boolean,
|
||||||
|
char,
|
||||||
|
int,
|
||||||
|
longtext,
|
||||||
|
mysqlTable,
|
||||||
|
serial,
|
||||||
|
text,
|
||||||
|
timestamp,
|
||||||
|
tinyint,
|
||||||
|
varchar
|
||||||
|
} from 'drizzle-orm/mysql-core';
|
||||||
|
import { longblob, mediumblob } from './custom-types';
|
||||||
|
|
||||||
|
export const task = mysqlTable('task', {
|
||||||
|
id: serial('id').primaryKey(),
|
||||||
|
title: text('title').notNull(),
|
||||||
|
priority: int('priority').notNull().default(1)
|
||||||
|
});
|
||||||
|
|
||||||
|
export const config = mysqlTable('config', {
|
||||||
|
key: varchar('key', { length: 64 }).primaryKey(),
|
||||||
|
value: longtext('value').notNull()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const projects = mysqlTable('projects', {
|
||||||
|
id: tinyint('id').notNull().primaryKey().autoincrement(),
|
||||||
|
name: text('name').notNull(),
|
||||||
|
data: longtext('data', {}).notNull(),
|
||||||
|
enabled: tinyint('enabled').notNull()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const locales = mysqlTable('locales', {
|
||||||
|
code: char('code').notNull().unique(),
|
||||||
|
name: char('name').notNull(),
|
||||||
|
dictionary: longtext().notNull(),
|
||||||
|
flag: longtext('').notNull(),
|
||||||
|
enabled: tinyint('enabled').notNull()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const groups = mysqlTable('groups', {
|
||||||
|
gid: int('gid').primaryKey().autoincrement(),
|
||||||
|
name: varchar('name', { length: 32 }).notNull().unique()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const users = mysqlTable('users', {
|
||||||
|
uid: int('uid').primaryKey().autoincrement(),
|
||||||
|
username: varchar('username', { length: 32 }).notNull().unique(),
|
||||||
|
password: varchar('password', { length: 128 }).notNull(),
|
||||||
|
home: int('home').notNull(),
|
||||||
|
gid: int('gid')
|
||||||
|
.notNull()
|
||||||
|
.references(() => groups.gid),
|
||||||
|
accessible: boolean('accessible').notNull(),
|
||||||
|
face: mediumblob('face')
|
||||||
|
});
|
||||||
|
|
||||||
|
export const filesystem = mysqlTable(
|
||||||
|
'filesystem',
|
||||||
|
{
|
||||||
|
id: int('id').primaryKey().default(1),
|
||||||
|
data: longtext('data').notNull(),
|
||||||
|
checksum: varchar('checksum', { length: 32 }).notNull(),
|
||||||
|
updatedAt: timestamp('updated_at').defaultNow().onUpdateNow()
|
||||||
|
} /* ,
|
||||||
|
{
|
||||||
|
// Ensures only one row can exist
|
||||||
|
singleRow: check('single_row_check', `id = 1`)
|
||||||
|
} */
|
||||||
|
);
|
||||||
|
|
||||||
|
export const fileContents = mysqlTable('file_contents', {
|
||||||
|
guid: varchar('guid', { length: 36 }).primaryKey(),
|
||||||
|
data: longblob('data').notNull(),
|
||||||
|
mimeType: varchar('mime_type', { length: 127 }).default('text/plain'),
|
||||||
|
checksum: varchar('checksum', { length: 32 }).notNull()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const allowList = mysqlTable('allow_list', {
|
||||||
|
ip: int('ip').notNull()
|
||||||
|
});
|
||||||
|
|
||||||
|
export type Config = typeof config.$inferSelect;
|
||||||
@@ -0,0 +1,382 @@
|
|||||||
|
|
||||||
|
// this file is generated — do not edit it
|
||||||
|
|
||||||
|
|
||||||
|
/// <reference types="@sveltejs/kit" />
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This module provides access to environment variables that are injected _statically_ into your bundle at build time and are limited to _private_ access.
|
||||||
|
*
|
||||||
|
* | | Runtime | Build time |
|
||||||
|
* | ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
||||||
|
* | Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |
|
||||||
|
* | Public | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public) | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public) |
|
||||||
|
*
|
||||||
|
* Static environment variables are [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env` at build time and then statically injected into your bundle at build time, enabling optimisations like dead code elimination.
|
||||||
|
*
|
||||||
|
* **_Private_ access:**
|
||||||
|
*
|
||||||
|
* - This module cannot be imported into client-side code
|
||||||
|
* - This module only includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured)
|
||||||
|
*
|
||||||
|
* For example, given the following build time environment:
|
||||||
|
*
|
||||||
|
* ```env
|
||||||
|
* ENVIRONMENT=production
|
||||||
|
* PUBLIC_BASE_URL=http://site.com
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* With the default `publicPrefix` and `privatePrefix`:
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* import { ENVIRONMENT, PUBLIC_BASE_URL } from '$env/static/private';
|
||||||
|
*
|
||||||
|
* console.log(ENVIRONMENT); // => "production"
|
||||||
|
* console.log(PUBLIC_BASE_URL); // => throws error during build
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The above values will be the same _even if_ different values for `ENVIRONMENT` or `PUBLIC_BASE_URL` are set at runtime, as they are statically replaced in your code with their build time values.
|
||||||
|
*/
|
||||||
|
declare module '$env/static/private' {
|
||||||
|
export const APP2UNIT_SLICES: string;
|
||||||
|
export const CHROME_DESKTOP: string;
|
||||||
|
export const CLUTTER_BACKEND: string;
|
||||||
|
export const DBUS_SESSION_BUS_ADDRESS: string;
|
||||||
|
export const DEBUGINFOD_URLS: string;
|
||||||
|
export const DESKTOP_SESSION: string;
|
||||||
|
export const DISPLAY: string;
|
||||||
|
export const EDITOR: string;
|
||||||
|
export const ELECTRON_NO_ATTACH_CONSOLE: string;
|
||||||
|
export const ELECTRON_OZONE_PLATFORM_HINT: string;
|
||||||
|
export const FC_FONTATIONS: string;
|
||||||
|
export const GDK_BACKEND: string;
|
||||||
|
export const HL_INITIAL_WORKSPACE_TOKEN: string;
|
||||||
|
export const HOME: string;
|
||||||
|
export const HYPRLAND_CMD: string;
|
||||||
|
export const HYPRLAND_INSTANCE_SIGNATURE: string;
|
||||||
|
export const INVOCATION_ID: string;
|
||||||
|
export const JOURNAL_STREAM: string;
|
||||||
|
export const LANG: string;
|
||||||
|
export const LC_ADDRESS: string;
|
||||||
|
export const LC_IDENTIFICATION: string;
|
||||||
|
export const LC_MEASUREMENT: string;
|
||||||
|
export const LC_MONETARY: string;
|
||||||
|
export const LC_NAME: string;
|
||||||
|
export const LC_NUMERIC: string;
|
||||||
|
export const LC_PAPER: string;
|
||||||
|
export const LC_TELEPHONE: string;
|
||||||
|
export const LC_TIME: string;
|
||||||
|
export const LOGNAME: string;
|
||||||
|
export const MAIL: string;
|
||||||
|
export const MANAGERPID: string;
|
||||||
|
export const MANAGERPIDFDID: string;
|
||||||
|
export const MEMORY_PRESSURE_WATCH: string;
|
||||||
|
export const MEMORY_PRESSURE_WRITE: string;
|
||||||
|
export const MOTD_SHOWN: string;
|
||||||
|
export const MOZ_ENABLE_WAYLAND: string;
|
||||||
|
export const NOTIFY_SOCKET: string;
|
||||||
|
export const NO_AT_BRIDGE: string;
|
||||||
|
export const PATH: string;
|
||||||
|
export const PWD: string;
|
||||||
|
export const QS_ICON_THEME: string;
|
||||||
|
export const QT_AUTO_SCREEN_SCALE_FACTOR: string;
|
||||||
|
export const QT_QPA_PLATFORM: string;
|
||||||
|
export const QT_QPA_PLATFORMTHEME: string;
|
||||||
|
export const QT_WAYLAND_DISABLE_WINDOWDECORATION: string;
|
||||||
|
export const SDL_VIDEODRIVER: string;
|
||||||
|
export const SHELL: string;
|
||||||
|
export const SHLVL: string;
|
||||||
|
export const SYSTEMD_EXEC_PID: string;
|
||||||
|
export const USER: string;
|
||||||
|
export const UWSM_FINALIZE_VARNAMES: string;
|
||||||
|
export const UWSM_WAIT_VARNAMES: string;
|
||||||
|
export const VIRTUAL_ENV_DISABLE_PROMPT: string;
|
||||||
|
export const VSCODE_CLI: string;
|
||||||
|
export const VSCODE_CODE_CACHE_PATH: string;
|
||||||
|
export const VSCODE_CRASH_REPORTER_PROCESS_TYPE: string;
|
||||||
|
export const VSCODE_CWD: string;
|
||||||
|
export const VSCODE_ESM_ENTRYPOINT: string;
|
||||||
|
export const VSCODE_HANDLES_UNCAUGHT_ERRORS: string;
|
||||||
|
export const VSCODE_IPC_HOOK: string;
|
||||||
|
export const VSCODE_NLS_CONFIG: string;
|
||||||
|
export const VSCODE_PID: string;
|
||||||
|
export const VSSCRIPT_PATH: string;
|
||||||
|
export const WAYLAND_DISPLAY: string;
|
||||||
|
export const XCURSOR_SIZE: string;
|
||||||
|
export const XCURSOR_THEME: string;
|
||||||
|
export const XDG_BACKEND: string;
|
||||||
|
export const XDG_CACHE_HOME: string;
|
||||||
|
export const XDG_CONFIG_DIRS: string;
|
||||||
|
export const XDG_CONFIG_HOME: string;
|
||||||
|
export const XDG_CURRENT_DESKTOP: string;
|
||||||
|
export const XDG_DATA_DIRS: string;
|
||||||
|
export const XDG_DATA_HOME: string;
|
||||||
|
export const XDG_MENU_PREFIX: string;
|
||||||
|
export const XDG_RUNTIME_DIR: string;
|
||||||
|
export const XDG_SEAT: string;
|
||||||
|
export const XDG_SEAT_PATH: string;
|
||||||
|
export const XDG_SESSION_CLASS: string;
|
||||||
|
export const XDG_SESSION_DESKTOP: string;
|
||||||
|
export const XDG_SESSION_ID: string;
|
||||||
|
export const XDG_SESSION_PATH: string;
|
||||||
|
export const XDG_SESSION_TYPE: string;
|
||||||
|
export const XDG_STATE_HOME: string;
|
||||||
|
export const XDG_VTNR: string;
|
||||||
|
export const _: string;
|
||||||
|
export const _JAVA_AWT_WM_NONREPARENTING: string;
|
||||||
|
export const ELECTRON_RUN_AS_NODE: string;
|
||||||
|
export const VSCODE_L10N_BUNDLE_LOCATION: string;
|
||||||
|
export const VITEST_VSCODE_LOG: string;
|
||||||
|
export const VITEST_VSCODE: string;
|
||||||
|
export const TEST: string;
|
||||||
|
export const VITEST_WS_ADDRESS: string;
|
||||||
|
export const VITEST: string;
|
||||||
|
export const NODE_ENV: string;
|
||||||
|
export const FORCE_COLOR: string;
|
||||||
|
export const PROD: string;
|
||||||
|
export const DEV: string;
|
||||||
|
export const BASE_URL: string;
|
||||||
|
export const MODE: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This module provides access to environment variables that are injected _statically_ into your bundle at build time and are _publicly_ accessible.
|
||||||
|
*
|
||||||
|
* | | Runtime | Build time |
|
||||||
|
* | ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
||||||
|
* | Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |
|
||||||
|
* | Public | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public) | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public) |
|
||||||
|
*
|
||||||
|
* Static environment variables are [loaded by Vite](https://vitejs.dev/guide/env-and-mode.html#env-files) from `.env` files and `process.env` at build time and then statically injected into your bundle at build time, enabling optimisations like dead code elimination.
|
||||||
|
*
|
||||||
|
* **_Public_ access:**
|
||||||
|
*
|
||||||
|
* - This module _can_ be imported into client-side code
|
||||||
|
* - **Only** variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`) are included
|
||||||
|
*
|
||||||
|
* For example, given the following build time environment:
|
||||||
|
*
|
||||||
|
* ```env
|
||||||
|
* ENVIRONMENT=production
|
||||||
|
* PUBLIC_BASE_URL=http://site.com
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* With the default `publicPrefix` and `privatePrefix`:
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* import { ENVIRONMENT, PUBLIC_BASE_URL } from '$env/static/public';
|
||||||
|
*
|
||||||
|
* console.log(ENVIRONMENT); // => throws error during build
|
||||||
|
* console.log(PUBLIC_BASE_URL); // => "http://site.com"
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The above values will be the same _even if_ different values for `ENVIRONMENT` or `PUBLIC_BASE_URL` are set at runtime, as they are statically replaced in your code with their build time values.
|
||||||
|
*/
|
||||||
|
declare module '$env/static/public' {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This module provides access to environment variables set _dynamically_ at runtime and that are limited to _private_ access.
|
||||||
|
*
|
||||||
|
* | | Runtime | Build time |
|
||||||
|
* | ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
||||||
|
* | Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |
|
||||||
|
* | Public | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public) | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public) |
|
||||||
|
*
|
||||||
|
* Dynamic environment variables are defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node) (or running [`vite preview`](https://svelte.dev/docs/kit/cli)), this is equivalent to `process.env`.
|
||||||
|
*
|
||||||
|
* **_Private_ access:**
|
||||||
|
*
|
||||||
|
* - This module cannot be imported into client-side code
|
||||||
|
* - This module includes variables that _do not_ begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) _and do_ start with [`config.kit.env.privatePrefix`](https://svelte.dev/docs/kit/configuration#env) (if configured)
|
||||||
|
*
|
||||||
|
* > [!NOTE] In `dev`, `$env/dynamic` includes environment variables from `.env`. In `prod`, this behavior will depend on your adapter.
|
||||||
|
*
|
||||||
|
* > [!NOTE] To get correct types, environment variables referenced in your code should be declared (for example in an `.env` file), even if they don't have a value until the app is deployed:
|
||||||
|
* >
|
||||||
|
* > ```env
|
||||||
|
* > MY_FEATURE_FLAG=
|
||||||
|
* > ```
|
||||||
|
* >
|
||||||
|
* > You can override `.env` values from the command line like so:
|
||||||
|
* >
|
||||||
|
* > ```sh
|
||||||
|
* > MY_FEATURE_FLAG="enabled" npm run dev
|
||||||
|
* > ```
|
||||||
|
*
|
||||||
|
* For example, given the following runtime environment:
|
||||||
|
*
|
||||||
|
* ```env
|
||||||
|
* ENVIRONMENT=production
|
||||||
|
* PUBLIC_BASE_URL=http://site.com
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* With the default `publicPrefix` and `privatePrefix`:
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* import { env } from '$env/dynamic/private';
|
||||||
|
*
|
||||||
|
* console.log(env.ENVIRONMENT); // => "production"
|
||||||
|
* console.log(env.PUBLIC_BASE_URL); // => undefined
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
declare module '$env/dynamic/private' {
|
||||||
|
export const env: {
|
||||||
|
APP2UNIT_SLICES: string;
|
||||||
|
CHROME_DESKTOP: string;
|
||||||
|
CLUTTER_BACKEND: string;
|
||||||
|
DBUS_SESSION_BUS_ADDRESS: string;
|
||||||
|
DEBUGINFOD_URLS: string;
|
||||||
|
DESKTOP_SESSION: string;
|
||||||
|
DISPLAY: string;
|
||||||
|
EDITOR: string;
|
||||||
|
ELECTRON_NO_ATTACH_CONSOLE: string;
|
||||||
|
ELECTRON_OZONE_PLATFORM_HINT: string;
|
||||||
|
FC_FONTATIONS: string;
|
||||||
|
GDK_BACKEND: string;
|
||||||
|
HL_INITIAL_WORKSPACE_TOKEN: string;
|
||||||
|
HOME: string;
|
||||||
|
HYPRLAND_CMD: string;
|
||||||
|
HYPRLAND_INSTANCE_SIGNATURE: string;
|
||||||
|
INVOCATION_ID: string;
|
||||||
|
JOURNAL_STREAM: string;
|
||||||
|
LANG: string;
|
||||||
|
LC_ADDRESS: string;
|
||||||
|
LC_IDENTIFICATION: string;
|
||||||
|
LC_MEASUREMENT: string;
|
||||||
|
LC_MONETARY: string;
|
||||||
|
LC_NAME: string;
|
||||||
|
LC_NUMERIC: string;
|
||||||
|
LC_PAPER: string;
|
||||||
|
LC_TELEPHONE: string;
|
||||||
|
LC_TIME: string;
|
||||||
|
LOGNAME: string;
|
||||||
|
MAIL: string;
|
||||||
|
MANAGERPID: string;
|
||||||
|
MANAGERPIDFDID: string;
|
||||||
|
MEMORY_PRESSURE_WATCH: string;
|
||||||
|
MEMORY_PRESSURE_WRITE: string;
|
||||||
|
MOTD_SHOWN: string;
|
||||||
|
MOZ_ENABLE_WAYLAND: string;
|
||||||
|
NOTIFY_SOCKET: string;
|
||||||
|
NO_AT_BRIDGE: string;
|
||||||
|
PATH: string;
|
||||||
|
PWD: string;
|
||||||
|
QS_ICON_THEME: string;
|
||||||
|
QT_AUTO_SCREEN_SCALE_FACTOR: string;
|
||||||
|
QT_QPA_PLATFORM: string;
|
||||||
|
QT_QPA_PLATFORMTHEME: string;
|
||||||
|
QT_WAYLAND_DISABLE_WINDOWDECORATION: string;
|
||||||
|
SDL_VIDEODRIVER: string;
|
||||||
|
SHELL: string;
|
||||||
|
SHLVL: string;
|
||||||
|
SYSTEMD_EXEC_PID: string;
|
||||||
|
USER: string;
|
||||||
|
UWSM_FINALIZE_VARNAMES: string;
|
||||||
|
UWSM_WAIT_VARNAMES: string;
|
||||||
|
VIRTUAL_ENV_DISABLE_PROMPT: string;
|
||||||
|
VSCODE_CLI: string;
|
||||||
|
VSCODE_CODE_CACHE_PATH: string;
|
||||||
|
VSCODE_CRASH_REPORTER_PROCESS_TYPE: string;
|
||||||
|
VSCODE_CWD: string;
|
||||||
|
VSCODE_ESM_ENTRYPOINT: string;
|
||||||
|
VSCODE_HANDLES_UNCAUGHT_ERRORS: string;
|
||||||
|
VSCODE_IPC_HOOK: string;
|
||||||
|
VSCODE_NLS_CONFIG: string;
|
||||||
|
VSCODE_PID: string;
|
||||||
|
VSSCRIPT_PATH: string;
|
||||||
|
WAYLAND_DISPLAY: string;
|
||||||
|
XCURSOR_SIZE: string;
|
||||||
|
XCURSOR_THEME: string;
|
||||||
|
XDG_BACKEND: string;
|
||||||
|
XDG_CACHE_HOME: string;
|
||||||
|
XDG_CONFIG_DIRS: string;
|
||||||
|
XDG_CONFIG_HOME: string;
|
||||||
|
XDG_CURRENT_DESKTOP: string;
|
||||||
|
XDG_DATA_DIRS: string;
|
||||||
|
XDG_DATA_HOME: string;
|
||||||
|
XDG_MENU_PREFIX: string;
|
||||||
|
XDG_RUNTIME_DIR: string;
|
||||||
|
XDG_SEAT: string;
|
||||||
|
XDG_SEAT_PATH: string;
|
||||||
|
XDG_SESSION_CLASS: string;
|
||||||
|
XDG_SESSION_DESKTOP: string;
|
||||||
|
XDG_SESSION_ID: string;
|
||||||
|
XDG_SESSION_PATH: string;
|
||||||
|
XDG_SESSION_TYPE: string;
|
||||||
|
XDG_STATE_HOME: string;
|
||||||
|
XDG_VTNR: string;
|
||||||
|
_: string;
|
||||||
|
_JAVA_AWT_WM_NONREPARENTING: string;
|
||||||
|
ELECTRON_RUN_AS_NODE: string;
|
||||||
|
VSCODE_L10N_BUNDLE_LOCATION: string;
|
||||||
|
VITEST_VSCODE_LOG: string;
|
||||||
|
VITEST_VSCODE: string;
|
||||||
|
TEST: string;
|
||||||
|
VITEST_WS_ADDRESS: string;
|
||||||
|
VITEST: string;
|
||||||
|
NODE_ENV: string;
|
||||||
|
FORCE_COLOR: string;
|
||||||
|
PROD: string;
|
||||||
|
DEV: string;
|
||||||
|
BASE_URL: string;
|
||||||
|
MODE: string;
|
||||||
|
[key: `PUBLIC_${string}`]: undefined;
|
||||||
|
[key: `${string}`]: string | undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This module provides access to environment variables set _dynamically_ at runtime and that are _publicly_ accessible.
|
||||||
|
*
|
||||||
|
* | | Runtime | Build time |
|
||||||
|
* | ------- | -------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
||||||
|
* | Private | [`$env/dynamic/private`](https://svelte.dev/docs/kit/$env-dynamic-private) | [`$env/static/private`](https://svelte.dev/docs/kit/$env-static-private) |
|
||||||
|
* | Public | [`$env/dynamic/public`](https://svelte.dev/docs/kit/$env-dynamic-public) | [`$env/static/public`](https://svelte.dev/docs/kit/$env-static-public) |
|
||||||
|
*
|
||||||
|
* Dynamic environment variables are defined by the platform you're running on. For example if you're using [`adapter-node`](https://github.com/sveltejs/kit/tree/main/packages/adapter-node) (or running [`vite preview`](https://svelte.dev/docs/kit/cli)), this is equivalent to `process.env`.
|
||||||
|
*
|
||||||
|
* **_Public_ access:**
|
||||||
|
*
|
||||||
|
* - This module _can_ be imported into client-side code
|
||||||
|
* - **Only** variables that begin with [`config.kit.env.publicPrefix`](https://svelte.dev/docs/kit/configuration#env) (which defaults to `PUBLIC_`) are included
|
||||||
|
*
|
||||||
|
* > [!NOTE] In `dev`, `$env/dynamic` includes environment variables from `.env`. In `prod`, this behavior will depend on your adapter.
|
||||||
|
*
|
||||||
|
* > [!NOTE] To get correct types, environment variables referenced in your code should be declared (for example in an `.env` file), even if they don't have a value until the app is deployed:
|
||||||
|
* >
|
||||||
|
* > ```env
|
||||||
|
* > MY_FEATURE_FLAG=
|
||||||
|
* > ```
|
||||||
|
* >
|
||||||
|
* > You can override `.env` values from the command line like so:
|
||||||
|
* >
|
||||||
|
* > ```sh
|
||||||
|
* > MY_FEATURE_FLAG="enabled" npm run dev
|
||||||
|
* > ```
|
||||||
|
*
|
||||||
|
* For example, given the following runtime environment:
|
||||||
|
*
|
||||||
|
* ```env
|
||||||
|
* ENVIRONMENT=production
|
||||||
|
* PUBLIC_BASE_URL=http://example.com
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* With the default `publicPrefix` and `privatePrefix`:
|
||||||
|
*
|
||||||
|
* ```ts
|
||||||
|
* import { env } from '$env/dynamic/public';
|
||||||
|
* console.log(env.ENVIRONMENT); // => undefined, not public
|
||||||
|
* console.log(env.PUBLIC_BASE_URL); // => "http://example.com"
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
declare module '$env/dynamic/public' {
|
||||||
|
export const env: {
|
||||||
|
[key: `PUBLIC_${string}`]: string | undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
export { matchers } from './matchers.js';
|
||||||
|
|
||||||
|
export const nodes = [
|
||||||
|
() => import('./nodes/0'),
|
||||||
|
() => import('./nodes/1')
|
||||||
|
];
|
||||||
|
|
||||||
|
export const server_loads = [];
|
||||||
|
|
||||||
|
export const dictionary = {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
export const hooks = {
|
||||||
|
handleError: (({ error }) => { console.error(error) }),
|
||||||
|
|
||||||
|
reroute: (() => {}),
|
||||||
|
transport: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const decoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.decode]));
|
||||||
|
export const encoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.encode]));
|
||||||
|
|
||||||
|
export const hash = false;
|
||||||
|
|
||||||
|
export const decode = (type, value) => decoders[type](value);
|
||||||
|
|
||||||
|
export { default as root } from '../root.js';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export const matchers = {};
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { default as component } from "../../../../../../../node_modules/@sveltejs/kit/src/runtime/components/svelte-5/layout.svelte";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { default as component } from "../../../../../../../node_modules/@sveltejs/kit/src/runtime/components/svelte-5/error.svelte";
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"paths": {
|
||||||
|
"$app/types": [
|
||||||
|
"./types/index.d.ts"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rootDirs": [
|
||||||
|
"..",
|
||||||
|
"./types"
|
||||||
|
],
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"lib": [
|
||||||
|
"esnext",
|
||||||
|
"DOM",
|
||||||
|
"DOM.Iterable"
|
||||||
|
],
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"module": "esnext",
|
||||||
|
"noEmit": true,
|
||||||
|
"target": "esnext",
|
||||||
|
"types": [
|
||||||
|
"node"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"ambient.d.ts",
|
||||||
|
"non-ambient.d.ts",
|
||||||
|
"./types/**/$types.d.ts",
|
||||||
|
"../vite.config.js",
|
||||||
|
"../vite.config.ts",
|
||||||
|
"../src/**/*.js",
|
||||||
|
"../src/**/*.ts",
|
||||||
|
"../src/**/*.svelte",
|
||||||
|
"../test/**/*.js",
|
||||||
|
"../test/**/*.ts",
|
||||||
|
"../test/**/*.svelte",
|
||||||
|
"../tests/**/*.js",
|
||||||
|
"../tests/**/*.ts",
|
||||||
|
"../tests/**/*.svelte"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"../node_modules/**",
|
||||||
|
"../src/service-worker.js",
|
||||||
|
"../src/service-worker/**/*.js",
|
||||||
|
"../src/service-worker.ts",
|
||||||
|
"../src/service-worker/**/*.ts",
|
||||||
|
"../src/service-worker.d.ts",
|
||||||
|
"../src/service-worker/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,478 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import {
|
||||||
|
CharacterRenderer,
|
||||||
|
INTERACTION,
|
||||||
|
ImageCache,
|
||||||
|
KeyboardInput,
|
||||||
|
NeedsSimulator,
|
||||||
|
Physics,
|
||||||
|
PointerController,
|
||||||
|
SoundPlayer,
|
||||||
|
StateClock,
|
||||||
|
collectStateUrls,
|
||||||
|
loadSoundPacks,
|
||||||
|
resolveStateName,
|
||||||
|
type BubblePack,
|
||||||
|
type ChatterConfig,
|
||||||
|
type InteractionConfig,
|
||||||
|
type StatePack
|
||||||
|
} from './';
|
||||||
|
import { CHATTER } from './chatter';
|
||||||
|
import { NEEDS, type ChatterHooks, type NeedDef } from './needs';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
states: Record<string, StatePack>;
|
||||||
|
bubblePacks?: Record<string, BubblePack>;
|
||||||
|
needsConfig?: NeedDef[];
|
||||||
|
chatter?: ChatterConfig | null;
|
||||||
|
interactions?: InteractionConfig;
|
||||||
|
scale?: number;
|
||||||
|
maxSpeed?: number;
|
||||||
|
idleThreshold?: number;
|
||||||
|
runThreshold?: number;
|
||||||
|
acceleration?: number;
|
||||||
|
friction?: number;
|
||||||
|
startAt?: number;
|
||||||
|
floorHeight?: number;
|
||||||
|
floorColor?: string;
|
||||||
|
reflectionOpacity?: number;
|
||||||
|
reflectionFade?: number;
|
||||||
|
reflectionTint?: string;
|
||||||
|
wrapEdges?: boolean;
|
||||||
|
jumpVelocity?: number;
|
||||||
|
gravity?: number;
|
||||||
|
showShadow?: boolean;
|
||||||
|
bubbleAnchorX?: number;
|
||||||
|
bubbleAnchorY?: number;
|
||||||
|
muted?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
let {
|
||||||
|
states,
|
||||||
|
bubblePacks,
|
||||||
|
needsConfig = NEEDS,
|
||||||
|
chatter = CHATTER,
|
||||||
|
interactions = INTERACTION,
|
||||||
|
scale = 4,
|
||||||
|
maxSpeed = 280,
|
||||||
|
idleThreshold = 10,
|
||||||
|
runThreshold = 190,
|
||||||
|
acceleration = 1600,
|
||||||
|
friction = 2400,
|
||||||
|
startAt = 0.5,
|
||||||
|
floorHeight = 90,
|
||||||
|
floorColor = '#242830',
|
||||||
|
reflectionOpacity = 0.45,
|
||||||
|
reflectionFade = 0.9,
|
||||||
|
reflectionTint = 'rgba(120, 160, 200, 0.3)',
|
||||||
|
wrapEdges = true,
|
||||||
|
jumpVelocity = 620,
|
||||||
|
gravity = 2400,
|
||||||
|
showShadow = true,
|
||||||
|
bubbleAnchorX = 0,
|
||||||
|
bubbleAnchorY = 4,
|
||||||
|
muted = false
|
||||||
|
}: Props = $props();
|
||||||
|
|
||||||
|
/* ---------- DOM ---------- */
|
||||||
|
let canvas = $state<HTMLCanvasElement>();
|
||||||
|
let ctx: CanvasRenderingContext2D | null = null;
|
||||||
|
let dpr = 1;
|
||||||
|
let viewW = 0;
|
||||||
|
let viewH = 0;
|
||||||
|
|
||||||
|
/* ---------- Subsystems ---------- */
|
||||||
|
const cache = new ImageCache();
|
||||||
|
const physics = new Physics();
|
||||||
|
const clock = new StateClock();
|
||||||
|
const input = new KeyboardInput();
|
||||||
|
const needs = new NeedsSimulator();
|
||||||
|
const renderer = new CharacterRenderer();
|
||||||
|
const pointer = new PointerController(INTERACTION);
|
||||||
|
|
||||||
|
let soundPlayer: SoundPlayer | null = null;
|
||||||
|
let audioCtx: AudioContext | null = null;
|
||||||
|
|
||||||
|
let ready = false;
|
||||||
|
let placed = false;
|
||||||
|
let heldAnchorSet = false;
|
||||||
|
let loadError = $state<string | null>(null);
|
||||||
|
|
||||||
|
// Last drawn body size — used for pointer hit-testing on the next frame.
|
||||||
|
let lastBodyW = 0;
|
||||||
|
let lastBodyH = 0;
|
||||||
|
|
||||||
|
/* ---------- Asset loading ---------- */
|
||||||
|
const urlKey = $derived(
|
||||||
|
[
|
||||||
|
...collectStateUrls(states),
|
||||||
|
...Object.values(bubblePacks ?? {}).flatMap((p) => p.frames)
|
||||||
|
].join('\n')
|
||||||
|
);
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
const key = urlKey;
|
||||||
|
ready = false;
|
||||||
|
loadError = null;
|
||||||
|
if (!key) {
|
||||||
|
loadError = 'No state frames found. Check $lib/assets/character/states/.';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let cancelled = false;
|
||||||
|
|
||||||
|
cache
|
||||||
|
.load(key.split('\n'))
|
||||||
|
.then(() => {
|
||||||
|
if (cancelled) return;
|
||||||
|
rebound();
|
||||||
|
ready = true;
|
||||||
|
})
|
||||||
|
.catch((err: Error) => {
|
||||||
|
if (cancelled) return;
|
||||||
|
loadError = err.message;
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelled = true;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
/* ---------- Bounds ---------- */
|
||||||
|
function bounds() {
|
||||||
|
const { w } = cache.largestSize(collectStateUrls(states));
|
||||||
|
return { viewW, viewH, floorHeight, spriteW: w, scale };
|
||||||
|
}
|
||||||
|
|
||||||
|
function resize() {
|
||||||
|
if (!canvas || !ctx) return;
|
||||||
|
dpr = Math.min(window.devicePixelRatio || 1, 3);
|
||||||
|
const rect = canvas.getBoundingClientRect();
|
||||||
|
viewW = rect.width;
|
||||||
|
viewH = rect.height;
|
||||||
|
canvas.width = Math.max(1, Math.round(rect.width * dpr));
|
||||||
|
canvas.height = Math.max(1, Math.round(rect.height * dpr));
|
||||||
|
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||||
|
ctx.imageSmoothingEnabled = false;
|
||||||
|
if (!placed && viewW > 0) {
|
||||||
|
placed = true;
|
||||||
|
physics.place(viewW, startAt);
|
||||||
|
}
|
||||||
|
rebound();
|
||||||
|
}
|
||||||
|
|
||||||
|
function rebound() {
|
||||||
|
physics.rebound(
|
||||||
|
{ maxSpeed, acceleration, friction, jumpVelocity, gravity, wrapEdges },
|
||||||
|
bounds()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- Audio ---------- */
|
||||||
|
const GESTURES = ['pointerdown', 'keydown', 'touchstart'] as const;
|
||||||
|
|
||||||
|
function unlockAudio() {
|
||||||
|
if (audioCtx) return;
|
||||||
|
try {
|
||||||
|
const Ctor = window.AudioContext ?? (window as any).webkitAudioContext;
|
||||||
|
if (!Ctor) return;
|
||||||
|
audioCtx = new Ctor();
|
||||||
|
void audioCtx.resume();
|
||||||
|
void loadSoundPacks(audioCtx).then((packs) => {
|
||||||
|
if (!audioCtx) return;
|
||||||
|
soundPlayer = new SoundPlayer(audioCtx, packs);
|
||||||
|
soundPlayer.setMuted(muted);
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[character] audio unavailable', err);
|
||||||
|
}
|
||||||
|
for (const g of GESTURES) window.removeEventListener(g, unlockAudio);
|
||||||
|
}
|
||||||
|
|
||||||
|
function installAudioUnlocker() {
|
||||||
|
for (const g of GESTURES) window.addEventListener(g, unlockAudio, { passive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
soundPlayer?.setMuted(muted);
|
||||||
|
});
|
||||||
|
|
||||||
|
function playSound(name: string, volume: number) {
|
||||||
|
soundPlayer?.play(name, volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- State resolution ---------- */
|
||||||
|
function activeStateName(): string {
|
||||||
|
const needAction =
|
||||||
|
needs.active?.actionState && needs.active.elapsed >= needs.active.actionStart
|
||||||
|
? needs.active.actionState.name
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return resolveStateName(
|
||||||
|
{
|
||||||
|
interaction: pointer.state,
|
||||||
|
grounded: physics.grounded,
|
||||||
|
speed: Math.abs(physics.vx),
|
||||||
|
needAction
|
||||||
|
},
|
||||||
|
{ idleThreshold, runThreshold },
|
||||||
|
states
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function sideFor(pack: StatePack) {
|
||||||
|
return physics.facing === 'left' ? pack.left : pack.right;
|
||||||
|
}
|
||||||
|
|
||||||
|
function bodyFor(name: string): HTMLImageElement | null {
|
||||||
|
const pack = states[name];
|
||||||
|
if (!pack) return null;
|
||||||
|
const side = sideFor(pack);
|
||||||
|
if (!side.frames.length) return null;
|
||||||
|
const i = clock.frameIndex(pack, side);
|
||||||
|
return cache.get(side.frames[i]) ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- Bubble ---------- */
|
||||||
|
function currentBubble(): { img: HTMLImageElement; index: number } | null {
|
||||||
|
if (pointer.state === 'held' || pointer.state === 'petted') return null;
|
||||||
|
const a = needs.active;
|
||||||
|
if (!a?.bubblePack || !a.bubblePack.frames.length) return null;
|
||||||
|
if (a.elapsed >= a.bubbleDuration) return null;
|
||||||
|
const index = Math.min(
|
||||||
|
Math.floor(a.elapsed * a.bubblePack.fps),
|
||||||
|
a.bubblePack.frames.length - 1
|
||||||
|
);
|
||||||
|
const img = cache.get(a.bubblePack.frames[index]);
|
||||||
|
return img ? { img, index } : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function currentCharsShown(): number {
|
||||||
|
const a = needs.active;
|
||||||
|
if (!a?.text || !chatter) return Infinity;
|
||||||
|
const speed = chatter.typeSpeed ?? 0;
|
||||||
|
if (speed <= 0) return Infinity;
|
||||||
|
const pack = a.bubblePack;
|
||||||
|
const textStart = pack ? (chatter.textFrame ?? 0) / pack.fps : 0;
|
||||||
|
const typingElapsed = a.elapsed - textStart;
|
||||||
|
if (typingElapsed <= 0) return 0;
|
||||||
|
return Math.min(a.text.length, Math.floor(typingElapsed * speed));
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildChatterHooks(c: ChatterConfig): ChatterHooks {
|
||||||
|
return {
|
||||||
|
pack: c.pack,
|
||||||
|
interval: c.interval,
|
||||||
|
lines: c.lines,
|
||||||
|
typeSpeed: c.typeSpeed,
|
||||||
|
typeSound: c.typeSound,
|
||||||
|
typeSoundEvery: c.typeSoundEvery,
|
||||||
|
typeSoundVolume: c.typeSoundVolume,
|
||||||
|
bubbleDuration: (line: string, pack: BubblePack) => {
|
||||||
|
const animDur = pack.frames.length / pack.fps;
|
||||||
|
const textStart = (c.textFrame ?? 0) / pack.fps;
|
||||||
|
const speed = c.typeSpeed ?? 0;
|
||||||
|
const typing = speed > 0 ? line.length / speed : 0;
|
||||||
|
return Math.max(animDur, textStart + typing) + (c.holdLast ?? 1.6);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------- Loop ---------- */
|
||||||
|
let raf = 0;
|
||||||
|
let last = 0;
|
||||||
|
|
||||||
|
function loop(now: number) {
|
||||||
|
raf = requestAnimationFrame(loop);
|
||||||
|
const dt = last ? Math.min((now - last) / 1000, 1 / 20) : 0;
|
||||||
|
last = now;
|
||||||
|
if (!ready || !ctx) return;
|
||||||
|
|
||||||
|
const locked = needs.isLocked || pointer.state === 'held';
|
||||||
|
|
||||||
|
/* --- physics or held --- */
|
||||||
|
if (pointer.state === 'held') {
|
||||||
|
if (!heldAnchorSet) {
|
||||||
|
pointer.setGrabAnchor(physics.x, physics.y);
|
||||||
|
heldAnchorSet = true;
|
||||||
|
}
|
||||||
|
const anchor = pointer.getHeldPosition();
|
||||||
|
if (anchor) {
|
||||||
|
physics.x = anchor.x;
|
||||||
|
physics.y = Math.max(0, anchor.y);
|
||||||
|
physics.vx = 0;
|
||||||
|
physics.vy = 0;
|
||||||
|
physics.grounded = false;
|
||||||
|
physics.squash = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
heldAnchorSet = false;
|
||||||
|
physics.step(
|
||||||
|
dt,
|
||||||
|
{
|
||||||
|
direction: locked ? 0 : input.direction(),
|
||||||
|
jump: locked ? false : input.consumeJump()
|
||||||
|
},
|
||||||
|
{ maxSpeed, acceleration, friction, jumpVelocity, gravity, wrapEdges },
|
||||||
|
bounds()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- falling → landing --- */
|
||||||
|
if (pointer.state === 'falling' && physics.grounded) {
|
||||||
|
pointer.setState('landing');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- pointer bounds, then tick the pointer --- */
|
||||||
|
if (lastBodyW > 0) {
|
||||||
|
const gy = physics.groundY(bounds());
|
||||||
|
pointer.setBounds({
|
||||||
|
left: physics.x - lastBodyW / 2,
|
||||||
|
top: gy - physics.y - lastBodyH,
|
||||||
|
width: lastBodyW,
|
||||||
|
height: lastBodyH
|
||||||
|
});
|
||||||
|
}
|
||||||
|
pointer.update(dt);
|
||||||
|
|
||||||
|
/* --- resolve state and advance its clock --- */
|
||||||
|
const name = activeStateName();
|
||||||
|
const pack = states[name];
|
||||||
|
clock.update(dt, name, pack, Math.abs(physics.vx));
|
||||||
|
|
||||||
|
/* --- body image --- */
|
||||||
|
const body = bodyFor(name);
|
||||||
|
if (body) {
|
||||||
|
lastBodyW = body.naturalWidth * scale;
|
||||||
|
lastBodyH = body.naturalHeight * scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- needs --- */
|
||||||
|
needs.step(dt, name, {
|
||||||
|
defs: needsConfig,
|
||||||
|
bubblePacks: bubblePacks ?? {},
|
||||||
|
states,
|
||||||
|
chatter: chatter ? buildChatterHooks(chatter) : null,
|
||||||
|
onSound: playSound
|
||||||
|
});
|
||||||
|
|
||||||
|
/* --- draw --- */
|
||||||
|
if (!body || !pack) return;
|
||||||
|
const side = sideFor(pack);
|
||||||
|
|
||||||
|
renderer.draw({
|
||||||
|
ctx,
|
||||||
|
viewW,
|
||||||
|
viewH,
|
||||||
|
groundY: physics.groundY(bounds()),
|
||||||
|
dpr,
|
||||||
|
body,
|
||||||
|
mirrored: side.mirrored,
|
||||||
|
x: physics.x,
|
||||||
|
y: physics.y,
|
||||||
|
squash: physics.squash,
|
||||||
|
bubble: currentBubble(),
|
||||||
|
bubbleText: needs.active?.text ?? null,
|
||||||
|
charsShown: currentCharsShown(),
|
||||||
|
bubbleTextFrame: chatter?.textFrame ?? 0,
|
||||||
|
scale,
|
||||||
|
showShadow,
|
||||||
|
reflectionOpacity,
|
||||||
|
reflectionFade,
|
||||||
|
reflectionTint,
|
||||||
|
bubbleAnchorX,
|
||||||
|
bubbleAnchorY,
|
||||||
|
chatter
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
if (!canvas) return;
|
||||||
|
ctx = canvas.getContext('2d');
|
||||||
|
if (!ctx) return;
|
||||||
|
|
||||||
|
pointer.onGrab = () => {
|
||||||
|
needs.active = null;
|
||||||
|
needs.queue.length = 0;
|
||||||
|
heldAnchorSet = false;
|
||||||
|
if (interactions.pickupSound) playSound(interactions.pickupSound, 1);
|
||||||
|
};
|
||||||
|
pointer.onRelease = () => {
|
||||||
|
const v = pointer.getThrowVelocity();
|
||||||
|
physics.vx = v.vx;
|
||||||
|
physics.vy = v.vy;
|
||||||
|
// If the throw is upward, lift the cat out of the grounded state.
|
||||||
|
if (physics.vy > 0) physics.grounded = false;
|
||||||
|
if (interactions.dropSound) playSound(interactions.dropSound, 0.8);
|
||||||
|
};
|
||||||
|
pointer.onLanding = () => {
|
||||||
|
if (interactions.landingSound) playSound(interactions.landingSound, 0.8);
|
||||||
|
};
|
||||||
|
pointer.onPetSound = () => {
|
||||||
|
if (interactions.purrSound) playSound(interactions.purrSound, interactions.purrVolume ?? 0.4);
|
||||||
|
};
|
||||||
|
|
||||||
|
resize();
|
||||||
|
const ro = new ResizeObserver(resize);
|
||||||
|
ro.observe(canvas);
|
||||||
|
|
||||||
|
input.attach(window);
|
||||||
|
pointer.attach(window);
|
||||||
|
installAudioUnlocker();
|
||||||
|
raf = requestAnimationFrame(loop);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelAnimationFrame(raf);
|
||||||
|
ro.disconnect();
|
||||||
|
input.detach(window);
|
||||||
|
pointer.detach(window);
|
||||||
|
for (const g of GESTURES) window.removeEventListener(g, unlockAudio);
|
||||||
|
void audioCtx?.close();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:window />
|
||||||
|
|
||||||
|
<div class="layer">
|
||||||
|
<div class="floor" style:height="{floorHeight}px" style:background={floorColor}></div>
|
||||||
|
<canvas bind:this={canvas} aria-hidden="true"></canvas>
|
||||||
|
{#if loadError}
|
||||||
|
<p class="err">{loadError}</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.layer {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 50;
|
||||||
|
}
|
||||||
|
.floor {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.15));
|
||||||
|
background-blend-mode: overlay;
|
||||||
|
}
|
||||||
|
canvas {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
image-rendering: pixelated;
|
||||||
|
}
|
||||||
|
.err {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 1rem;
|
||||||
|
left: 1rem;
|
||||||
|
margin: 0;
|
||||||
|
font:
|
||||||
|
12px/1.4 ui-monospace,
|
||||||
|
monospace;
|
||||||
|
color: #ff6b6b;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
const files = import.meta.glob('$lib/assets/character/bubbles/**/*.png', {
|
||||||
|
eager: true,
|
||||||
|
query: '?url',
|
||||||
|
import: 'default'
|
||||||
|
}) as Record<string, string>;
|
||||||
|
|
||||||
|
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
|
||||||
|
const BUBBLE_RE = /\/bubbles\/([^/]+)\/[^/]+\.png$/i;
|
||||||
|
|
||||||
|
export interface BubblePack {
|
||||||
|
name: string;
|
||||||
|
frames: string[];
|
||||||
|
fps: number;
|
||||||
|
duration: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BubblePackOptions {
|
||||||
|
fps?: number;
|
||||||
|
duration?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadBubblePacks(opts: BubblePackOptions = {}): Record<string, BubblePack> {
|
||||||
|
const { fps = 8, duration = 2.5 } = opts;
|
||||||
|
const groups = new Map<string, Array<[string, string]>>();
|
||||||
|
|
||||||
|
for (const [path, url] of Object.entries(files)) {
|
||||||
|
const m = BUBBLE_RE.exec(path);
|
||||||
|
if (!m) continue;
|
||||||
|
const name = m[1].toLowerCase();
|
||||||
|
if (!groups.has(name)) groups.set(name, []);
|
||||||
|
groups.get(name)!.push([path, url]);
|
||||||
|
}
|
||||||
|
|
||||||
|
const out: Record<string, BubblePack> = {};
|
||||||
|
for (const [name, entries] of groups) {
|
||||||
|
const frames = entries.sort(([a], [b]) => collator.compare(a, b)).map(([, url]) => url);
|
||||||
|
out[name] = { name, frames, fps, duration };
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ImageCache {
|
||||||
|
private images = new Map<string, HTMLImageElement>();
|
||||||
|
|
||||||
|
async load(urls: string[]): Promise<void> {
|
||||||
|
const results = await Promise.all(
|
||||||
|
urls.map(
|
||||||
|
(url) =>
|
||||||
|
new Promise<[string, HTMLImageElement]>((resolve, reject) => {
|
||||||
|
const img = new Image();
|
||||||
|
img.onload = () => resolve([url, img]);
|
||||||
|
img.onerror = () => reject(new Error(`Could not load "${url}"`));
|
||||||
|
img.src = url;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
this.images = new Map(results);
|
||||||
|
}
|
||||||
|
|
||||||
|
get(url: string): HTMLImageElement | undefined {
|
||||||
|
return this.images.get(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
largestSize(urls: string[]): { w: number; h: number } {
|
||||||
|
let w = 0;
|
||||||
|
let h = 0;
|
||||||
|
for (const url of urls) {
|
||||||
|
const img = this.images.get(url);
|
||||||
|
if (!img) continue;
|
||||||
|
w = Math.max(w, img.naturalWidth);
|
||||||
|
h = Math.max(h, img.naturalHeight);
|
||||||
|
}
|
||||||
|
return { w, h };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
export interface ChatterConfig {
|
||||||
|
pack: string;
|
||||||
|
interval: [number, number];
|
||||||
|
lines: string[];
|
||||||
|
fontFamily?: string;
|
||||||
|
fontSize?: number;
|
||||||
|
color?: string;
|
||||||
|
align?: 'center' | 'left';
|
||||||
|
padding?: { top?: number; right?: number; bottom?: number; left?: number };
|
||||||
|
/** Distance from bubble top to the top of the first line, in sprite px. */
|
||||||
|
textTop?: number;
|
||||||
|
lineHeight?: number;
|
||||||
|
/** Bubble frame index at which text appears. */
|
||||||
|
textFrame?: number;
|
||||||
|
/** Typewriter speed in characters per second. */
|
||||||
|
typeSpeed?: number;
|
||||||
|
/** Sound pack for typing clicks. */
|
||||||
|
typeSound?: string;
|
||||||
|
typeSoundEvery?: number;
|
||||||
|
typeSoundVolume?: number;
|
||||||
|
/** Seconds the last frame holds after typing completes. */
|
||||||
|
holdLast?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CHATTER: ChatterConfig = {
|
||||||
|
pack: 'chatter',
|
||||||
|
interval: [12, 28],
|
||||||
|
lines: [
|
||||||
|
'mrrrp?',
|
||||||
|
'i could go for a nap',
|
||||||
|
'nice day for it',
|
||||||
|
'...',
|
||||||
|
'you again',
|
||||||
|
'meow',
|
||||||
|
'did you see that bird',
|
||||||
|
'my bowl is looking empty',
|
||||||
|
'i meant to do that',
|
||||||
|
'five more minutes'
|
||||||
|
],
|
||||||
|
fontFamily: "'Micro 5', sans-serif",
|
||||||
|
fontSize: 11,
|
||||||
|
color: '#1a1a1a',
|
||||||
|
align: 'center',
|
||||||
|
padding: { top: 8, right: 8, bottom: 8, left: 8 },
|
||||||
|
textTop: 8,
|
||||||
|
lineHeight: 1.2,
|
||||||
|
textFrame: 1,
|
||||||
|
typeSpeed: 24,
|
||||||
|
typeSound: 'type',
|
||||||
|
typeSoundEvery: 2,
|
||||||
|
typeSoundVolume: 0.3,
|
||||||
|
holdLast: 1.6
|
||||||
|
};
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
export type { Facing, PhysicsInput } from './types';
|
||||||
|
|
||||||
|
export { collectStateUrls, loadStates, resolveStateName, STATE_CONFIG, StateClock } from './states';
|
||||||
|
export type {
|
||||||
|
InteractionState,
|
||||||
|
ResolverConfig,
|
||||||
|
StateConfig,
|
||||||
|
StateConfigMap,
|
||||||
|
StateContext,
|
||||||
|
StatePack,
|
||||||
|
StateSide
|
||||||
|
} from './states';
|
||||||
|
|
||||||
|
export { ImageCache, loadBubblePacks } from './assets';
|
||||||
|
export type { BubblePack, BubblePackOptions } from './assets';
|
||||||
|
|
||||||
|
export { clamp, Physics } from './physics';
|
||||||
|
export type { PhysicsBounds, PhysicsConfig } from './physics';
|
||||||
|
|
||||||
|
export { KeyboardInput } from './input';
|
||||||
|
|
||||||
|
export { NEEDS, NeedsSimulator } from './needs';
|
||||||
|
export type {
|
||||||
|
ActiveEvent,
|
||||||
|
ChatterHooks,
|
||||||
|
FiredEvent,
|
||||||
|
NeedBand,
|
||||||
|
NeedDef,
|
||||||
|
NeedsConfig,
|
||||||
|
NeedSideEffect
|
||||||
|
} from './needs';
|
||||||
|
|
||||||
|
export { CHATTER } from './chatter';
|
||||||
|
export type { ChatterConfig } from './chatter';
|
||||||
|
|
||||||
|
export { CharacterRenderer } from './render';
|
||||||
|
export type { RenderInput } from './render';
|
||||||
|
|
||||||
|
export { loadSoundPacks, SoundPlayer } from './sounds';
|
||||||
|
export type { SoundPack } from './sounds';
|
||||||
|
|
||||||
|
export { INTERACTION, PointerController } from './interactions';
|
||||||
|
export type { InteractionConfig, PointerBounds } from './interactions';
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
const JUMP_KEYS = new Set([' ', 'w', 'arrowup']);
|
||||||
|
const MOVE_KEYS = new Set(['arrowleft', 'arrowright', 'a', 'd']);
|
||||||
|
|
||||||
|
export class KeyboardInput {
|
||||||
|
private held = new Set<string>();
|
||||||
|
private jumpQueued = false;
|
||||||
|
private listeners: Array<[string, EventListener]> = [];
|
||||||
|
|
||||||
|
attach(target: Window): void {
|
||||||
|
const down: EventListener = (e) => this.onKeyDown(e as KeyboardEvent);
|
||||||
|
const up: EventListener = (e) => this.onKeyUp(e as KeyboardEvent);
|
||||||
|
const blur: EventListener = () => this.clear();
|
||||||
|
|
||||||
|
target.addEventListener('keydown', down);
|
||||||
|
target.addEventListener('keyup', up);
|
||||||
|
target.addEventListener('blur', blur);
|
||||||
|
|
||||||
|
this.listeners = [
|
||||||
|
['keydown', down],
|
||||||
|
['keyup', up],
|
||||||
|
['blur', blur]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
detach(target: Window): void {
|
||||||
|
for (const [type, fn] of this.listeners) target.removeEventListener(type, fn);
|
||||||
|
this.listeners = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
direction(): -1 | 0 | 1 {
|
||||||
|
let d = 0;
|
||||||
|
if (this.held.has('arrowleft') || this.held.has('a')) d -= 1;
|
||||||
|
if (this.held.has('arrowright') || this.held.has('d')) d += 1;
|
||||||
|
return d as -1 | 0 | 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
consumeJump(): boolean {
|
||||||
|
const j = this.jumpQueued;
|
||||||
|
this.jumpQueued = false;
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
|
||||||
|
clear(): void {
|
||||||
|
this.held.clear();
|
||||||
|
this.jumpQueued = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private onKeyDown(e: KeyboardEvent): void {
|
||||||
|
const k = e.key.toLowerCase();
|
||||||
|
|
||||||
|
if (JUMP_KEYS.has(k)) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (!this.held.has(k)) this.jumpQueued = true;
|
||||||
|
this.held.add(k);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MOVE_KEYS.has(k)) {
|
||||||
|
e.preventDefault();
|
||||||
|
this.held.add(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private onKeyUp(e: KeyboardEvent): void {
|
||||||
|
this.held.delete(e.key.toLowerCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,266 @@
|
|||||||
|
import type { InteractionState } from './states';
|
||||||
|
|
||||||
|
export interface PointerBounds {
|
||||||
|
left: number;
|
||||||
|
top: number;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InteractionConfig {
|
||||||
|
enabled?: boolean;
|
||||||
|
landingDuration?: number;
|
||||||
|
petDelay?: number;
|
||||||
|
petLinger?: number;
|
||||||
|
petSoundInterval?: number;
|
||||||
|
pickupSound?: string;
|
||||||
|
dropSound?: string;
|
||||||
|
landingSound?: string;
|
||||||
|
purrSound?: string;
|
||||||
|
purrVolume?: number;
|
||||||
|
/** Hard cap on throw speed, px/s. Prevents a fast flick launching the cat off-screen. */
|
||||||
|
maxThrowVelocity?: number;
|
||||||
|
/** Cursor-velocity smoothing, 0–1. Higher = twitchier throws, lower = smoother. */
|
||||||
|
throwSmoothing?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const INTERACTION: InteractionConfig = {
|
||||||
|
enabled: true,
|
||||||
|
landingDuration: 0.5,
|
||||||
|
petDelay: 0.25,
|
||||||
|
petLinger: 0.3,
|
||||||
|
petSoundInterval: 0.9,
|
||||||
|
pickupSound: 'pickup',
|
||||||
|
dropSound: 'drop',
|
||||||
|
landingSound: 'landing',
|
||||||
|
purrSound: 'purr',
|
||||||
|
purrVolume: 0.35,
|
||||||
|
maxThrowVelocity: 1200,
|
||||||
|
throwSmoothing: 0.35
|
||||||
|
};
|
||||||
|
|
||||||
|
function clamp(v: number, lo: number, hi: number): number {
|
||||||
|
return Math.min(Math.max(v, lo), hi);
|
||||||
|
}
|
||||||
|
|
||||||
|
function lerp(a: number, b: number, t: number): number {
|
||||||
|
return a + (b - a) * t;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class PointerController {
|
||||||
|
cursorX = 0;
|
||||||
|
cursorY = 0;
|
||||||
|
state: InteractionState = 'free';
|
||||||
|
timeInState = 0;
|
||||||
|
|
||||||
|
onGrab?: () => void;
|
||||||
|
onRelease?: () => void;
|
||||||
|
onLanding?: () => void;
|
||||||
|
onPetStart?: () => void;
|
||||||
|
onPetSound?: () => void;
|
||||||
|
|
||||||
|
private cfg: Required<
|
||||||
|
Pick<
|
||||||
|
InteractionConfig,
|
||||||
|
| 'landingDuration'
|
||||||
|
| 'petDelay'
|
||||||
|
| 'petLinger'
|
||||||
|
| 'petSoundInterval'
|
||||||
|
| 'maxThrowVelocity'
|
||||||
|
| 'throwSmoothing'
|
||||||
|
>
|
||||||
|
> & { enabled: boolean };
|
||||||
|
|
||||||
|
private bounds: PointerBounds | null = null;
|
||||||
|
private grabAnchor: { x: number; y: number } | null = null;
|
||||||
|
private grabPointer = { x: 0, y: 0 };
|
||||||
|
private hoverTime = 0;
|
||||||
|
private lingerTime = 0;
|
||||||
|
private purrTimer = 0;
|
||||||
|
private listeners: Array<[string, EventListener]> = [];
|
||||||
|
|
||||||
|
// Cursor velocity tracking (screen coordinates, px/s).
|
||||||
|
private prevCursorX = 0;
|
||||||
|
private prevCursorY = 0;
|
||||||
|
private prevCursorSet = false;
|
||||||
|
private smoothVX = 0;
|
||||||
|
private smoothVY = 0;
|
||||||
|
|
||||||
|
constructor(cfg: InteractionConfig) {
|
||||||
|
this.cfg = {
|
||||||
|
enabled: cfg.enabled ?? true,
|
||||||
|
landingDuration: cfg.landingDuration ?? 0.5,
|
||||||
|
petDelay: cfg.petDelay ?? 0.25,
|
||||||
|
petLinger: cfg.petLinger ?? 0.3,
|
||||||
|
petSoundInterval: cfg.petSoundInterval ?? 0.9,
|
||||||
|
maxThrowVelocity: cfg.maxThrowVelocity ?? 1200,
|
||||||
|
throwSmoothing: clamp(cfg.throwSmoothing ?? 0.35, 0.05, 1)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
attach(target: Window): void {
|
||||||
|
if (!this.cfg.enabled) return;
|
||||||
|
|
||||||
|
const down: EventListener = (e) => this.onPointerDown(e as PointerEvent);
|
||||||
|
const up: EventListener = () => this.onPointerUp();
|
||||||
|
const move: EventListener = (e) => this.onPointerMove(e as PointerEvent);
|
||||||
|
const leave: EventListener = () => this.onPointerLeave();
|
||||||
|
|
||||||
|
const pairs: Array<[string, EventListener]> = [
|
||||||
|
['pointerdown', down],
|
||||||
|
['pointerup', up],
|
||||||
|
['pointermove', move],
|
||||||
|
['pointerleave', leave]
|
||||||
|
];
|
||||||
|
for (const [type, fn] of pairs) target.addEventListener(type, fn);
|
||||||
|
this.listeners = pairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
detach(target: Window): void {
|
||||||
|
for (const [type, fn] of this.listeners) target.removeEventListener(type, fn);
|
||||||
|
this.listeners = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
setBounds(b: PointerBounds): void {
|
||||||
|
this.bounds = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
setGrabAnchor(x: number, y: number): void {
|
||||||
|
this.grabAnchor = { x, y };
|
||||||
|
}
|
||||||
|
|
||||||
|
getHeldPosition(): { x: number; y: number } | null {
|
||||||
|
if (this.state !== 'held' || !this.grabAnchor) return null;
|
||||||
|
const dx = this.cursorX - this.grabPointer.x;
|
||||||
|
const dy = this.cursorY - this.grabPointer.y;
|
||||||
|
return { x: this.grabAnchor.x + dx, y: this.grabAnchor.y - dy };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cursor velocity at the moment of release, converted to internal coordinates.
|
||||||
|
* `x` matches screen x; `y` is flipped because internal y grows upward.
|
||||||
|
*/
|
||||||
|
getThrowVelocity(): { vx: number; vy: number } {
|
||||||
|
const cap = this.cfg.maxThrowVelocity;
|
||||||
|
return {
|
||||||
|
vx: clamp(this.smoothVX, -cap, cap),
|
||||||
|
vy: clamp(-this.smoothVY, -cap, cap)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(s: InteractionState): void {
|
||||||
|
if (this.state === s) return;
|
||||||
|
this.state = s;
|
||||||
|
this.timeInState = 0;
|
||||||
|
|
||||||
|
if (s === 'held') this.onGrab?.();
|
||||||
|
if (s === 'falling') this.onRelease?.();
|
||||||
|
if (s === 'landing') this.onLanding?.();
|
||||||
|
if (s === 'petted') {
|
||||||
|
this.purrTimer = 0;
|
||||||
|
this.onPetStart?.();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update(dt: number): void {
|
||||||
|
this.timeInState += dt;
|
||||||
|
|
||||||
|
// Cursor velocity tracking. Only meaningful while held; otherwise decay
|
||||||
|
// to zero so a stale flick doesn't linger between grabs.
|
||||||
|
if (this.state === 'held' && this.prevCursorSet && dt > 0) {
|
||||||
|
const rawVX = (this.cursorX - this.prevCursorX) / dt;
|
||||||
|
const rawVY = (this.cursorY - this.prevCursorY) / dt;
|
||||||
|
const a = this.cfg.throwSmoothing;
|
||||||
|
this.smoothVX = lerp(this.smoothVX, rawVX, a);
|
||||||
|
this.smoothVY = lerp(this.smoothVY, rawVY, a);
|
||||||
|
} else if (this.state !== 'held') {
|
||||||
|
this.smoothVX = 0;
|
||||||
|
this.smoothVY = 0;
|
||||||
|
}
|
||||||
|
this.prevCursorX = this.cursorX;
|
||||||
|
this.prevCursorY = this.cursorY;
|
||||||
|
this.prevCursorSet = true;
|
||||||
|
|
||||||
|
if (this.state === 'landing' && this.timeInState >= this.cfg.landingDuration) {
|
||||||
|
this.setState('free');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state === 'free') {
|
||||||
|
if (this.hoveringHead()) {
|
||||||
|
this.hoverTime += dt;
|
||||||
|
if (this.hoverTime >= this.cfg.petDelay) {
|
||||||
|
this.hoverTime = 0;
|
||||||
|
this.setState('petted');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.hoverTime = 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.hoverTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.state === 'petted') {
|
||||||
|
if (this.hoveringHead()) {
|
||||||
|
this.lingerTime = 0;
|
||||||
|
} else {
|
||||||
|
this.lingerTime += dt;
|
||||||
|
if (this.lingerTime >= this.cfg.petLinger) {
|
||||||
|
this.lingerTime = 0;
|
||||||
|
this.setState('free');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.purrTimer += dt;
|
||||||
|
if (this.purrTimer >= this.cfg.petSoundInterval) {
|
||||||
|
this.purrTimer = 0;
|
||||||
|
this.onPetSound?.();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private hoveringHead(): boolean {
|
||||||
|
const b = this.bounds;
|
||||||
|
if (!b) return false;
|
||||||
|
return (
|
||||||
|
this.cursorX >= b.left &&
|
||||||
|
this.cursorX <= b.left + b.width &&
|
||||||
|
this.cursorY >= b.top &&
|
||||||
|
this.cursorY <= b.top + b.height / 2
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private hoveringBody(): boolean {
|
||||||
|
const b = this.bounds;
|
||||||
|
if (!b) return false;
|
||||||
|
return (
|
||||||
|
this.cursorX >= b.left &&
|
||||||
|
this.cursorX <= b.left + b.width &&
|
||||||
|
this.cursorY >= b.top &&
|
||||||
|
this.cursorY <= b.top + b.height
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private onPointerDown(e: PointerEvent): void {
|
||||||
|
if (this.state !== 'free' && this.state !== 'petted') return;
|
||||||
|
this.cursorX = e.clientX;
|
||||||
|
this.cursorY = e.clientY;
|
||||||
|
if (!this.hoveringBody()) return;
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
this.grabPointer = { x: this.cursorX, y: this.cursorY };
|
||||||
|
this.setState('held');
|
||||||
|
}
|
||||||
|
|
||||||
|
private onPointerUp(): void {
|
||||||
|
if (this.state === 'held') this.setState('falling');
|
||||||
|
}
|
||||||
|
|
||||||
|
private onPointerMove(e: PointerEvent): void {
|
||||||
|
this.cursorX = e.clientX;
|
||||||
|
this.cursorY = e.clientY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private onPointerLeave(): void {
|
||||||
|
if (this.state === 'held') this.setState('falling');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,338 @@
|
|||||||
|
import type { BubblePack } from './assets';
|
||||||
|
import type { StatePack } from './states';
|
||||||
|
|
||||||
|
export interface NeedBand {
|
||||||
|
at: number;
|
||||||
|
bubble: string;
|
||||||
|
action?: string;
|
||||||
|
sound?: string;
|
||||||
|
soundVolume?: number;
|
||||||
|
bubbleDuration?: number;
|
||||||
|
/** Seconds after the bubble disappears that the action begins. */
|
||||||
|
actionDelay?: number;
|
||||||
|
satisfyDuration?: number;
|
||||||
|
priority?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NeedSideEffect {
|
||||||
|
need: string;
|
||||||
|
perSecond: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NeedDef {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
riseRate: number;
|
||||||
|
max: number;
|
||||||
|
/** Multipliers on `riseRate` keyed by state name (idle, walk, run, jump, ...). */
|
||||||
|
activityMultipliers: Record<string, number>;
|
||||||
|
curve?: number;
|
||||||
|
bands: NeedBand[];
|
||||||
|
resetBelow: number;
|
||||||
|
priority: number;
|
||||||
|
satisfyDuration: number;
|
||||||
|
satisfyTo: number;
|
||||||
|
satisfySideEffects?: NeedSideEffect[];
|
||||||
|
/** Default bubbleDuration for this need's bands. */
|
||||||
|
bubbleDuration?: number;
|
||||||
|
/** Default actionDelay for this need's bands. */
|
||||||
|
actionDelay?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const NEEDS: NeedDef[] = [
|
||||||
|
{
|
||||||
|
id: 'thirst',
|
||||||
|
label: 'Thirst',
|
||||||
|
riseRate: 0.9,
|
||||||
|
max: 100,
|
||||||
|
activityMultipliers: { idle: 1, walk: 1.3, run: 2.0, jump: 1.6 },
|
||||||
|
curve: 0.5,
|
||||||
|
bands: [
|
||||||
|
{
|
||||||
|
at: 85,
|
||||||
|
bubble: 'thirst_urgent',
|
||||||
|
action: 'drink',
|
||||||
|
sound: 'thirst_urgent',
|
||||||
|
soundVolume: 0.6,
|
||||||
|
bubbleDuration: 1.6,
|
||||||
|
actionDelay: 0.4,
|
||||||
|
satisfyDuration: 4
|
||||||
|
},
|
||||||
|
{ at: 50, bubble: 'thirst_mild', bubbleDuration: 2 }
|
||||||
|
],
|
||||||
|
resetBelow: 15,
|
||||||
|
priority: 2,
|
||||||
|
satisfyDuration: 3,
|
||||||
|
satisfyTo: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'boredom',
|
||||||
|
label: 'Boredom',
|
||||||
|
riseRate: 1.4,
|
||||||
|
max: 100,
|
||||||
|
activityMultipliers: { idle: 1.8, walk: 0.6, run: 0.3, jump: 0.5 },
|
||||||
|
curve: 0.3,
|
||||||
|
bands: [
|
||||||
|
{
|
||||||
|
at: 80,
|
||||||
|
bubble: 'bored_urgent',
|
||||||
|
action: 'play',
|
||||||
|
bubbleDuration: 1.6,
|
||||||
|
actionDelay: 0.4,
|
||||||
|
satisfyDuration: 5
|
||||||
|
},
|
||||||
|
{ at: 40, bubble: 'bored_mild', bubbleDuration: 2 }
|
||||||
|
],
|
||||||
|
resetBelow: 10,
|
||||||
|
priority: 1,
|
||||||
|
satisfyDuration: 4,
|
||||||
|
satisfyTo: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'sleepiness',
|
||||||
|
label: 'Sleepiness',
|
||||||
|
riseRate: 0.6,
|
||||||
|
max: 100,
|
||||||
|
activityMultipliers: { idle: 1, walk: 1.2, run: 1.5, jump: 1.3 },
|
||||||
|
curve: 0.4,
|
||||||
|
bands: [
|
||||||
|
{
|
||||||
|
at: 90,
|
||||||
|
bubble: 'sleepy_urgent',
|
||||||
|
action: 'sleep',
|
||||||
|
bubbleDuration: 1.6,
|
||||||
|
actionDelay: 0.4,
|
||||||
|
satisfyDuration: 8
|
||||||
|
},
|
||||||
|
{ at: 60, bubble: 'sleepy_mild', bubbleDuration: 2 }
|
||||||
|
],
|
||||||
|
resetBelow: 5,
|
||||||
|
priority: 3,
|
||||||
|
satisfyDuration: 6,
|
||||||
|
satisfyTo: 0,
|
||||||
|
satisfySideEffects: [{ need: 'thirst', perSecond: 0.4 }]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
export interface FiredEvent {
|
||||||
|
needId: string | null;
|
||||||
|
def: NeedDef | null;
|
||||||
|
band: NeedBand;
|
||||||
|
priority: number;
|
||||||
|
text?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ActiveEvent {
|
||||||
|
needId: string | null;
|
||||||
|
def: NeedDef | null;
|
||||||
|
bubblePack: BubblePack | null;
|
||||||
|
actionState: StatePack | null;
|
||||||
|
elapsed: number;
|
||||||
|
totalDuration: number;
|
||||||
|
satisfyTo: number;
|
||||||
|
text?: string;
|
||||||
|
soundPack?: string | null;
|
||||||
|
soundVolume?: number;
|
||||||
|
lastCharsShown: number;
|
||||||
|
bubbleDuration: number;
|
||||||
|
actionDelay: number;
|
||||||
|
satisfyDuration: number;
|
||||||
|
actionStart: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChatterHooks {
|
||||||
|
pack: string;
|
||||||
|
interval: [number, number];
|
||||||
|
lines: string[];
|
||||||
|
typeSpeed?: number;
|
||||||
|
typeSound?: string;
|
||||||
|
typeSoundEvery?: number;
|
||||||
|
typeSoundVolume?: number;
|
||||||
|
/** Total seconds the bubble stays up, computed by the caller. */
|
||||||
|
bubbleDuration: (line: string, pack: BubblePack) => number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NeedsConfig {
|
||||||
|
defs: NeedDef[];
|
||||||
|
bubblePacks: Record<string, BubblePack>;
|
||||||
|
states: Record<string, StatePack>;
|
||||||
|
chatter: ChatterHooks | null;
|
||||||
|
onSound: (name: string, volume: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MAX_QUEUE = 8;
|
||||||
|
|
||||||
|
export class NeedsSimulator {
|
||||||
|
values: Record<string, number> = {};
|
||||||
|
firedBands = new Set<string>();
|
||||||
|
queue: FiredEvent[] = [];
|
||||||
|
active: ActiveEvent | null = null;
|
||||||
|
chatterTimer = 0;
|
||||||
|
chatterTarget = -1;
|
||||||
|
private initialized = false;
|
||||||
|
|
||||||
|
get isLocked(): boolean {
|
||||||
|
return !!this.active?.actionState && this.active.elapsed >= this.active.actionStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
step(dt: number, activity: string, cfg: NeedsConfig): void {
|
||||||
|
if (!cfg.defs.length) return;
|
||||||
|
|
||||||
|
if (!this.initialized) {
|
||||||
|
for (const d of cfg.defs) this.values[d.id] = 0;
|
||||||
|
this.initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rise(dt, activity, cfg);
|
||||||
|
this.applySideEffects(dt, cfg);
|
||||||
|
this.checkBands(cfg);
|
||||||
|
this.maybeChatter(dt, cfg);
|
||||||
|
this.drainQueue(cfg);
|
||||||
|
this.advance(dt, cfg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private rise(dt: number, activity: string, cfg: NeedsConfig): void {
|
||||||
|
for (const def of cfg.defs) {
|
||||||
|
if (this.active?.needId === def.id) continue;
|
||||||
|
const v = this.values[def.id] ?? 0;
|
||||||
|
const mult = def.activityMultipliers[activity] ?? 1;
|
||||||
|
const curve = def.curve ? Math.pow(1 + v / def.max, def.curve) : 1;
|
||||||
|
this.values[def.id] = Math.min(def.max, v + def.riseRate * mult * curve * dt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private applySideEffects(dt: number, cfg: NeedsConfig): void {
|
||||||
|
const fx = this.active?.def?.satisfySideEffects;
|
||||||
|
if (!fx) return;
|
||||||
|
for (const e of fx) {
|
||||||
|
const other = cfg.defs.find((n) => n.id === e.need);
|
||||||
|
if (!other) continue;
|
||||||
|
const cur = this.values[other.id] ?? 0;
|
||||||
|
this.values[other.id] = Math.min(other.max, cur + e.perSecond * dt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private checkBands(cfg: NeedsConfig): void {
|
||||||
|
for (const def of cfg.defs) {
|
||||||
|
const v = this.values[def.id] ?? 0;
|
||||||
|
for (const band of def.bands) {
|
||||||
|
const key = `${def.id}:${band.at}`;
|
||||||
|
if (v >= band.at && !this.firedBands.has(key)) {
|
||||||
|
this.firedBands.add(key);
|
||||||
|
if (this.queue.length < MAX_QUEUE) {
|
||||||
|
this.queue.push({
|
||||||
|
needId: def.id,
|
||||||
|
def,
|
||||||
|
band,
|
||||||
|
priority: band.priority ?? def.priority
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (v < def.resetBelow && this.firedBands.has(key)) {
|
||||||
|
this.firedBands.delete(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private maybeChatter(dt: number, cfg: NeedsConfig): void {
|
||||||
|
const c = cfg.chatter;
|
||||||
|
if (!c || !c.lines.length) return;
|
||||||
|
const pack = cfg.bubblePacks[c.pack];
|
||||||
|
if (!pack) return;
|
||||||
|
|
||||||
|
if (this.chatterTarget < 0) this.chatterTarget = randBetween(...c.interval);
|
||||||
|
|
||||||
|
if (this.active || this.queue.length > 0) return;
|
||||||
|
|
||||||
|
this.chatterTimer += dt;
|
||||||
|
if (this.chatterTimer < this.chatterTarget) return;
|
||||||
|
|
||||||
|
this.chatterTimer = 0;
|
||||||
|
this.chatterTarget = randBetween(...c.interval);
|
||||||
|
|
||||||
|
const line = c.lines[Math.floor(Math.random() * c.lines.length)];
|
||||||
|
this.queue.push({
|
||||||
|
needId: null,
|
||||||
|
def: null,
|
||||||
|
band: {
|
||||||
|
at: 0,
|
||||||
|
bubble: c.pack,
|
||||||
|
bubbleDuration: c.bubbleDuration(line, pack)
|
||||||
|
},
|
||||||
|
priority: -1000,
|
||||||
|
text: line
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private drainQueue(cfg: NeedsConfig): void {
|
||||||
|
if (this.queue.length > 1) this.queue.sort((a, b) => b.priority - a.priority);
|
||||||
|
if (this.active || !this.queue.length) return;
|
||||||
|
|
||||||
|
const fired = this.queue.shift()!;
|
||||||
|
this.active = buildActiveEvent(fired, cfg);
|
||||||
|
|
||||||
|
if (this.active.soundPack) {
|
||||||
|
cfg.onSound(this.active.soundPack, this.active.soundVolume ?? 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private advance(dt: number, cfg: NeedsConfig): void {
|
||||||
|
const a = this.active;
|
||||||
|
if (!a) return;
|
||||||
|
|
||||||
|
a.elapsed += dt;
|
||||||
|
|
||||||
|
const c = cfg.chatter;
|
||||||
|
if (a.text && c?.typeSound && a.elapsed < a.bubbleDuration) {
|
||||||
|
const speed = c.typeSpeed ?? 0;
|
||||||
|
if (speed > 0) {
|
||||||
|
const charsShown = Math.min(a.text.length, Math.floor(a.elapsed * speed));
|
||||||
|
const every = Math.max(1, c.typeSoundEvery ?? 2);
|
||||||
|
const before = Math.floor(a.lastCharsShown / every);
|
||||||
|
const now = Math.floor(charsShown / every);
|
||||||
|
if (now > before) cfg.onSound(c.typeSound, c.typeSoundVolume ?? 0.3);
|
||||||
|
a.lastCharsShown = charsShown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a.elapsed >= a.totalDuration) {
|
||||||
|
if (a.needId && a.def) this.values[a.needId] = a.satisfyTo;
|
||||||
|
this.active = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildActiveEvent(fired: FiredEvent, cfg: NeedsConfig): ActiveEvent {
|
||||||
|
const bubblePack = fired.band.bubble ? (cfg.bubblePacks[fired.band.bubble] ?? null) : null;
|
||||||
|
const actionState = fired.band.action ? (cfg.states[fired.band.action] ?? null) : null;
|
||||||
|
|
||||||
|
const bubbleDuration =
|
||||||
|
fired.band.bubbleDuration ?? fired.def?.bubbleDuration ?? bubblePack?.duration ?? 2.5;
|
||||||
|
const satisfyDuration = fired.band.satisfyDuration ?? fired.def?.satisfyDuration ?? 0;
|
||||||
|
const actionDelay = actionState ? (fired.band.actionDelay ?? fired.def?.actionDelay ?? 0.4) : 0;
|
||||||
|
|
||||||
|
const actionStart = bubbleDuration + actionDelay;
|
||||||
|
const totalDuration = actionState ? actionStart + satisfyDuration : bubbleDuration;
|
||||||
|
|
||||||
|
return {
|
||||||
|
needId: fired.needId,
|
||||||
|
def: fired.def,
|
||||||
|
bubblePack,
|
||||||
|
actionState,
|
||||||
|
elapsed: 0,
|
||||||
|
totalDuration,
|
||||||
|
satisfyTo: fired.def?.satisfyTo ?? 0,
|
||||||
|
text: fired.text,
|
||||||
|
soundPack: fired.band.sound ?? null,
|
||||||
|
soundVolume: fired.band.soundVolume ?? 1,
|
||||||
|
lastCharsShown: 0,
|
||||||
|
bubbleDuration,
|
||||||
|
actionDelay,
|
||||||
|
satisfyDuration,
|
||||||
|
actionStart
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function randBetween(min: number, max: number): number {
|
||||||
|
return min + Math.random() * (max - min);
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import type { Facing, PhysicsInput } from './types';
|
||||||
|
|
||||||
|
export interface PhysicsConfig {
|
||||||
|
maxSpeed: number;
|
||||||
|
acceleration: number;
|
||||||
|
friction: number;
|
||||||
|
jumpVelocity: number;
|
||||||
|
gravity: number;
|
||||||
|
wrapEdges: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PhysicsBounds {
|
||||||
|
viewW: number;
|
||||||
|
viewH: number;
|
||||||
|
floorHeight: number;
|
||||||
|
spriteW: number;
|
||||||
|
scale: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function clamp(v: number, lo: number, hi: number): number {
|
||||||
|
return Math.min(Math.max(v, lo), hi);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Physics {
|
||||||
|
x = 0;
|
||||||
|
vx = 0;
|
||||||
|
y = 0;
|
||||||
|
vy = 0;
|
||||||
|
grounded = true;
|
||||||
|
squash = 0;
|
||||||
|
facing: Facing = 'right';
|
||||||
|
|
||||||
|
place(viewW: number, fraction: number): void {
|
||||||
|
this.x = viewW * fraction;
|
||||||
|
}
|
||||||
|
|
||||||
|
step(dt: number, input: PhysicsInput, cfg: PhysicsConfig, bounds: PhysicsBounds): void {
|
||||||
|
/* --- horizontal --- */
|
||||||
|
if (input.direction !== 0) {
|
||||||
|
this.vx = clamp(
|
||||||
|
this.vx + input.direction * cfg.acceleration * dt,
|
||||||
|
-cfg.maxSpeed,
|
||||||
|
cfg.maxSpeed
|
||||||
|
);
|
||||||
|
this.facing = input.direction > 0 ? 'right' : 'left';
|
||||||
|
} else if (this.vx !== 0) {
|
||||||
|
// Air drag is much lighter than ground friction, so a thrown cat
|
||||||
|
// carries its momentum instead of stopping in a body length.
|
||||||
|
const f = this.grounded ? cfg.friction : cfg.friction * 0.15;
|
||||||
|
const drop = f * dt;
|
||||||
|
this.vx = Math.abs(this.vx) <= drop ? 0 : this.vx - Math.sign(this.vx) * drop;
|
||||||
|
}
|
||||||
|
|
||||||
|
const target = this.x + this.vx * dt;
|
||||||
|
const bounded = this.boundX(target, cfg, bounds);
|
||||||
|
if (!cfg.wrapEdges && bounded !== target) this.vx = 0;
|
||||||
|
this.x = bounded;
|
||||||
|
|
||||||
|
/* --- vertical --- */
|
||||||
|
if (input.jump && this.grounded) {
|
||||||
|
this.vy = cfg.jumpVelocity;
|
||||||
|
this.grounded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.grounded) {
|
||||||
|
this.vy -= cfg.gravity * dt;
|
||||||
|
this.y += this.vy * dt;
|
||||||
|
if (this.y <= 0) {
|
||||||
|
const impact = -this.vy;
|
||||||
|
this.y = 0;
|
||||||
|
this.vy = 0;
|
||||||
|
this.grounded = true;
|
||||||
|
this.squash = clamp(impact / 900, 0, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.squash > 0) this.squash = Math.max(0, this.squash - dt * 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
rebound(cfg: PhysicsConfig, bounds: PhysicsBounds): void {
|
||||||
|
this.x = this.boundX(this.x, cfg, bounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
groundY(bounds: PhysicsBounds): number {
|
||||||
|
return bounds.viewH - bounds.floorHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boundX(value: number, cfg: PhysicsConfig, bounds: PhysicsBounds): number {
|
||||||
|
if (bounds.viewW <= 0) return value;
|
||||||
|
const half = (bounds.spriteW * bounds.scale) / 2;
|
||||||
|
|
||||||
|
if (cfg.wrapEdges) {
|
||||||
|
const wrapWidth = bounds.viewW + bounds.spriteW * bounds.scale;
|
||||||
|
return ((((value + half) % wrapWidth) + wrapWidth) % wrapWidth) - half;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lo = half;
|
||||||
|
const hi = bounds.viewW - half;
|
||||||
|
if (hi <= lo) return bounds.viewW / 2;
|
||||||
|
return clamp(value, lo, hi);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export namespace Physis {
|
||||||
|
export class Engine {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import Vector2 from '$lib/vector';
|
||||||
|
import Rigidbody2D from '../rigidbody/rigidbody2d';
|
||||||
|
|
||||||
|
export class AABB {
|
||||||
|
private size: Vector2 = new Vector2();
|
||||||
|
private halfSize: Vector2 = new Vector2();
|
||||||
|
private rigidbody: Rigidbody2D = new Rigidbody2D();
|
||||||
|
|
||||||
|
constructor(min?: Vector2, max?: Vector2) {
|
||||||
|
if (min !== undefined && max !== undefined) this.size = new Vector2(max).sub(min);
|
||||||
|
|
||||||
|
this.halfSize = new Vector2(this.size.mul(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
public get getMin(): Vector2 {
|
||||||
|
return new Vector2(this.rigidbody.Position).sub(this.halfSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get getMax(): Vector2 {
|
||||||
|
return new Vector2(this.rigidbody.Position).add(this.halfSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AABB;
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import Vector2 from '$lib/vector';
|
||||||
|
import Rigidbody2D from '../rigidbody/rigidbody2d';
|
||||||
|
|
||||||
|
export class Box2D {
|
||||||
|
private size: Vector2 = new Vector2();
|
||||||
|
private halfSize: Vector2 = new Vector2();
|
||||||
|
private rigidbody: Rigidbody2D = new Rigidbody2D();
|
||||||
|
|
||||||
|
constructor();
|
||||||
|
constructor(min?: Vector2, max?: Vector2) {
|
||||||
|
if (min !== undefined && max !== undefined) this.size = new Vector2(max).sub(min);
|
||||||
|
|
||||||
|
this.halfSize = new Vector2(this.size.mul(0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
public get getMin(): Vector2 {
|
||||||
|
return new Vector2(this.rigidbody.Position).sub(this.halfSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get getMax(): Vector2 {
|
||||||
|
return new Vector2(this.rigidbody.Position).add(this.halfSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get getVectices(): Vector2[] {
|
||||||
|
const min: Vector2 = this.getMin;
|
||||||
|
const max: Vector2 = this.getMax;
|
||||||
|
|
||||||
|
const vertices: Vector2[] = [
|
||||||
|
new Vector2(min.x, min.y),
|
||||||
|
new Vector2(min.x, max.y),
|
||||||
|
new Vector2(max.x, min.y),
|
||||||
|
new Vector2(max.x, max.y)
|
||||||
|
];
|
||||||
|
|
||||||
|
if (this.rigidbody.Rotation != 0.0) {
|
||||||
|
for (const vert of vertices) {
|
||||||
|
//TODO Rotate Vert around this.rigidbody.getPosition by this.rigidbody.getRotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return vertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get getRigidbody(): Rigidbody2D {
|
||||||
|
return this.rigidbody;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get getHalfSize(): Vector2 {
|
||||||
|
return this.halfSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Box2D;
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import type Vector2 from '$lib/vector';
|
||||||
|
import Rigidbody2D from '../rigidbody/rigidbody2d';
|
||||||
|
|
||||||
|
class Circle {
|
||||||
|
private radius: number = 1.0;
|
||||||
|
private rigidbody: Rigidbody2D = new Rigidbody2D();
|
||||||
|
|
||||||
|
public get Radius(): number {
|
||||||
|
return this.radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Center(): Vector2 {
|
||||||
|
return this.rigidbody.Position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Circle;
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import Vector2 from "$lib/vector";
|
||||||
|
|
||||||
|
class Collider2D {
|
||||||
|
protected offset: Vector2 = new Vector2();
|
||||||
|
|
||||||
|
//public abstract getInnertiaTensor(mass: number): number;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import type Vector2 from '$lib/vector';
|
||||||
|
|
||||||
|
class Ray2D {
|
||||||
|
private origin: Vector2;
|
||||||
|
private direction: Vector2;
|
||||||
|
|
||||||
|
constructor(origin: Vector2, direction: Vector2) {
|
||||||
|
this.origin = origin;
|
||||||
|
this.direction = direction;
|
||||||
|
this.direction.normalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Origin(): Vector2 {
|
||||||
|
return this.origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get Direction(): Vector2 {
|
||||||
|
return this.direction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Ray2D;
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import Vector2 from '$lib/vector';
|
||||||
|
|
||||||
|
class RaycastResult {
|
||||||
|
private point: Vector2 = new Vector2();
|
||||||
|
private normal: Vector2 = new Vector2();
|
||||||
|
private t: number = -1;
|
||||||
|
private hit: boolean = false;
|
||||||
|
|
||||||
|
public init(point: Vector2, normal: Vector2, t: number, hit: boolean) {
|
||||||
|
this.point.set(point.x, point.y);
|
||||||
|
this.normal.set(normal.x, normal.y);
|
||||||
|
this.t = t;
|
||||||
|
this.hit = hit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static reset(result: RaycastResult) {
|
||||||
|
if (result != null) {
|
||||||
|
result.point.set(Vector2.zero.x, Vector2.zero.y);
|
||||||
|
result.normal.set(Vector2.zero.x, Vector2.zero.y);
|
||||||
|
result.t = -1;
|
||||||
|
result.hit = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default RaycastResult;
|
||||||