mirror of https://github.com/sylv/micro.git
Compare commits
7 Commits
fc0071165f
...
eb15ce1ea6
Author | SHA1 | Date |
---|---|---|
Sylver | eb15ce1ea6 | |
Sylver | 853fc2f475 | |
Sylver | 4b7b7dac81 | |
Sylver | ee0c6ffa4a | |
Sylver | f849e80984 | |
Sylver | 9550b1190a | |
Sylver | bdcafc8347 |
|
@ -1,13 +1,10 @@
|
|||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true,
|
||||
"css.validate": false,
|
||||
"less.validate": false,
|
||||
"typescript.preferences.importModuleSpecifier": "relative",
|
||||
"npm.scriptExplorerExclude": ["^((?!watch|generate:watch).)*$"],
|
||||
"scss.validate": false,
|
||||
"eslint.workingDirectories": [
|
||||
{
|
||||
"pattern": "./{packages,apps}/*"
|
||||
"pattern": "./packages/*"
|
||||
}
|
||||
],
|
||||
"files.associations": {
|
||||
|
@ -28,8 +25,5 @@
|
|||
// const class = 'value'
|
||||
// const selectedClass = 'value'
|
||||
["const [a-zA-Z]+s = ['\"`]([^\"`'`]*)"]
|
||||
],
|
||||
"yaml.schemas": {
|
||||
"https://json.schemastore.org/github-workflow.json": "file:///home/ryan/projects/micro/.github/workflows/build.yaml"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
417
LICENSE
417
LICENSE
|
@ -1,190 +1,178 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 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.
|
||||
Copyright (C) 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 GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. 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.
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
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.
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
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.
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
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.
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
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.
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
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
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
"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
|
||||
"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
|
||||
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
|
||||
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
|
||||
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
|
||||
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,
|
||||
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
|
||||
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"
|
||||
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
|
||||
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.
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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 "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
|
||||
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
|
||||
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
|
||||
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
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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.
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
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
|
||||
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
|
||||
|
@ -192,9 +180,9 @@ 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.
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
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
|
||||
|
@ -202,12 +190,12 @@ 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,
|
||||
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.
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
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:
|
||||
|
||||
|
@ -232,19 +220,19 @@ terms of section 4, provided that you also meet all of these conditions:
|
|||
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
|
||||
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
|
||||
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.
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
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:
|
||||
|
@ -290,75 +278,75 @@ in one of these ways:
|
|||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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,
|
||||
"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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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,
|
||||
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.
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
"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
|
||||
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
|
||||
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
|
||||
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
|
||||
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:
|
||||
|
||||
|
@ -385,74 +373,74 @@ that material) supplement the terms of this License with terms:
|
|||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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.
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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.
|
||||
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
|
||||
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,
|
||||
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
|
||||
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.
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
@ -460,43 +448,43 @@ 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
|
||||
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.
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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,
|
||||
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,
|
||||
|
@ -504,13 +492,13 @@ 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
|
||||
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
|
||||
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
|
||||
|
@ -518,10 +506,10 @@ 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
|
||||
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
|
||||
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
|
||||
|
@ -533,73 +521,83 @@ 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
|
||||
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.
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
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
|
||||
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
|
||||
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.
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
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
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
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.
|
||||
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
|
||||
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
|
||||
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.
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
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
|
||||
|
@ -609,9 +607,9 @@ 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.
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
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
|
||||
|
@ -622,11 +620,11 @@ copy of the Program in return for a fee.
|
|||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
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 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.
|
||||
|
@ -635,40 +633,29 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||
Copyright (C) <year> <name of author>
|
||||
|
||||
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
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
You should have received a copy of the GNU Affero 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:
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
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,
|
||||
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
|
||||
For more information on this, and how to apply and follow the GNU AGPL, 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/licenses/why-not-lgpl.html>.
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"syncpack": "^12.3.0",
|
||||
"turbo": "1.11.3",
|
||||
"turbo": "1.12.3",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"packageManager": "pnpm@7.0.0"
|
||||
|
|
|
@ -5,5 +5,7 @@ module.exports = {
|
|||
},
|
||||
rules: {
|
||||
'unicorn/no-abusive-eslint-disable': 'off',
|
||||
'unicorn/filename-case': 'off',
|
||||
'import/no-default-export': 'off',
|
||||
},
|
||||
};
|
|
@ -26,24 +26,24 @@
|
|||
"@mikro-orm/migrations": "^5.9.7",
|
||||
"@mikro-orm/nestjs": "^5.2.3",
|
||||
"@mikro-orm/postgresql": "^5.9.7",
|
||||
"@nestjs/common": "^10.3.0",
|
||||
"@nestjs/core": "^10.3.0",
|
||||
"@nestjs/graphql": "^12.0.11",
|
||||
"@nestjs/common": "^10.3.2",
|
||||
"@nestjs/core": "^10.3.2",
|
||||
"@nestjs/graphql": "^12.1.1",
|
||||
"@nestjs/jwt": "^10.2.0",
|
||||
"@nestjs/mercurius": "^12.0.11",
|
||||
"@nestjs/mercurius": "^12.1.1",
|
||||
"@nestjs/passport": "^10.0.3",
|
||||
"@nestjs/platform-fastify": "^10.3.0",
|
||||
"@nestjs/schedule": "^4.0.0",
|
||||
"@nestjs/platform-fastify": "^10.3.2",
|
||||
"@nestjs/schedule": "^4.0.1",
|
||||
"@ryanke/venera": "^1.0.5",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.14.0",
|
||||
"fastify": "^4.25.2",
|
||||
"fastify": "^4.26.0",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"graphql": "^16.8.1",
|
||||
"mercurius": "^13.3.3",
|
||||
"mime-types": "^2.1.35",
|
||||
"nodemailer": "^6.9.8",
|
||||
"nodemailer": "^6.9.9",
|
||||
"otplib": "^12.0.1",
|
||||
"passport": "^0.7.0",
|
||||
"passport-jwt": "^4.0.1",
|
||||
|
@ -55,7 +55,7 @@
|
|||
"devDependencies": {
|
||||
"@atlasbot/configs": "^10.5.15",
|
||||
"@mikro-orm/cli": "^5.9.7",
|
||||
"@swc/core": "^1.3.102",
|
||||
"@swc/core": "^1.4.0",
|
||||
"@types/bcryptjs": "^2.4.6",
|
||||
"@types/bytes": "^3.1.4",
|
||||
"@types/dedent": "^0.7.2",
|
||||
|
@ -63,7 +63,7 @@
|
|||
"@types/luxon": "^3.4.0",
|
||||
"@types/mime-types": "^2.1.4",
|
||||
"@types/ms": "^0.7.34",
|
||||
"@types/node": "^20.10.6",
|
||||
"@types/node": "^20.11.17",
|
||||
"@types/nodemailer": "^6.4.14",
|
||||
"@types/passport-jwt": "^4.0.0",
|
||||
"@types/utf-8-validate": "^5.0.2",
|
||||
|
@ -72,21 +72,21 @@
|
|||
"content-range": "^2.0.2",
|
||||
"dedent": "^1.5.1",
|
||||
"escape-string-regexp": "^5.0.0",
|
||||
"file-type": "^18.7.0",
|
||||
"file-type": "^19.0.0",
|
||||
"handlebars": "^4.7.8",
|
||||
"istextorbinary": "^9.5.0",
|
||||
"luxon": "^3.4.4",
|
||||
"ms": "^3.0.0-canary.1",
|
||||
"nanoid": "^5.0.4",
|
||||
"nanoid": "^5.0.5",
|
||||
"normalize-url": "^8.0.0",
|
||||
"pretty-bytes": "^6.1.1",
|
||||
"reflect-metadata": "^0.2.1",
|
||||
"ts-node": "^10.9.2",
|
||||
"tsup": "^8.0.1",
|
||||
"tsup": "^8.0.2",
|
||||
"typescript": "^5.3.3",
|
||||
"vitest": "^1.1.3",
|
||||
"vitest": "^1.2.2",
|
||||
"zod": "^3.22.4",
|
||||
"zod-validation-error": "^2.1.0"
|
||||
"zod-validation-error": "^3.0.0"
|
||||
},
|
||||
"mikro-orm": {
|
||||
"useTsNode": true,
|
||||
|
|
|
@ -11,8 +11,8 @@ import { Transform } from 'stream';
|
|||
export class ExifTransformer extends Transform {
|
||||
private static readonly app1Marker = Buffer.from('ffe1', 'hex');
|
||||
private static readonly exifMarker = Buffer.from('457869660000', 'hex'); // Exif\0\0
|
||||
private static readonly xmpMarker = Buffer.from('http://ns.adobe.com/xap', 'utf-8');
|
||||
private static readonly flirMarker = Buffer.from('FLIR', 'utf-8');
|
||||
private static readonly xmpMarker = Buffer.from('http://ns.adobe.com/xap', 'utf8');
|
||||
private static readonly flirMarker = Buffer.from('FLIR', 'utf8');
|
||||
private static readonly maxMarkerLength = Math.max(
|
||||
ExifTransformer.exifMarker.length,
|
||||
ExifTransformer.xmpMarker.length,
|
||||
|
@ -48,7 +48,7 @@ export class ExifTransformer extends Transform {
|
|||
// no app1 in the current pendingChunk
|
||||
if (app1Start === -1) {
|
||||
// if last byte is ff, wait for more
|
||||
if (!atEnd && pendingChunk[pendingChunk.length - 1] === ExifTransformer.app1Marker[0]) {
|
||||
if (!atEnd && pendingChunk.at(-1) === ExifTransformer.app1Marker[0]) {
|
||||
if (chunk) this.pending.push(chunk);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ const enhanceHost = (host: z.infer<typeof schema>['hosts'][0]) => {
|
|||
};
|
||||
|
||||
export const config = result.data as Omit<z.infer<typeof schema>, 'hosts'>;
|
||||
export const hosts = result.data.hosts.map(enhanceHost);
|
||||
export const hosts = result.data.hosts.map((host) => enhanceHost(host));
|
||||
export const rootHost = hosts[0];
|
||||
|
||||
if (rootHost.isWildcard) {
|
||||
|
@ -92,9 +92,9 @@ if (disallowed.has(config.secret.toLowerCase())) {
|
|||
const token = randomBytes(24).toString('hex');
|
||||
throw new Error(
|
||||
dedent`
|
||||
${c.redBright.bold('Do not use the default secret.')}
|
||||
Please generate a random, secure secret or you risk anyone being able to impersonate you.
|
||||
If you're lazy, here is a random secret: ${c.underline(token)}
|
||||
${c.redBright.bold('Do not use the default secret.')}
|
||||
Please generate a random, secure secret or you risk anyone being able to impersonate you.
|
||||
If you're lazy, here is a random secret: ${c.underline(token)}
|
||||
`,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ export const expandMime = (input: string | string[]) => {
|
|||
if (!Array.isArray(input)) input = [input];
|
||||
const output: string[] = [];
|
||||
for (const mimeType of input) {
|
||||
const alias = MIME_MAP.get(mimeType.replace(WILDCARD_REGEX, ''));
|
||||
const alias = MIME_MAP.get(mimeType.replaceAll(WILDCARD_REGEX, ''));
|
||||
if (alias) {
|
||||
output.push(...alias);
|
||||
continue;
|
||||
|
|
|
@ -18,8 +18,7 @@ export function parseCursor(cursor: string) {
|
|||
|
||||
export function paginate<T>(items: T[], total: number, offset: number): Paginated<T> {
|
||||
const edges: Edge<T>[] = [];
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
const item = items[itemIndex];
|
||||
for (const [itemIndex, item] of items.entries()) {
|
||||
const cursor = createCursor(offset + itemIndex);
|
||||
edges.push({
|
||||
cursor: cursor,
|
||||
|
@ -31,7 +30,7 @@ export function paginate<T>(items: T[], total: number, offset: number): Paginate
|
|||
edges: edges,
|
||||
totalCount: total,
|
||||
pageInfo: {
|
||||
endCursor: edges[0] ? edges[edges.length - 1].cursor : undefined,
|
||||
endCursor: edges[0] ? edges.at(-1)!.cursor : undefined,
|
||||
startCursor: edges[0] ? edges[0].cursor : undefined,
|
||||
hasPreviousPage: offset > 0,
|
||||
hasNextPage: offset + items.length < total,
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* eslint-disable sonarjs/no-duplicate-string */
|
||||
import type { IdentifiedReference } from '@mikro-orm/core';
|
||||
import type { Ref } from '@mikro-orm/core';
|
||||
import { BeforeCreate, Entity, Property, type EventArgs } from '@mikro-orm/core';
|
||||
import { ObjectType } from '@nestjs/graphql';
|
||||
import type { FastifyRequest } from 'fastify';
|
||||
|
@ -14,7 +13,7 @@ export abstract class Resource {
|
|||
@Property({ nullable: true })
|
||||
hostname?: string;
|
||||
|
||||
abstract owner?: IdentifiedReference<User>;
|
||||
abstract owner?: Ref<User>;
|
||||
abstract getPaths(): ResourceLocations;
|
||||
|
||||
getUrls() {
|
||||
|
|
|
@ -11,64 +11,56 @@ import { migrate } from './migrate.js';
|
|||
import { AppModule } from './modules/app.module.js';
|
||||
import { HostGuard } from './modules/host/host.guard.js';
|
||||
|
||||
async function bootstrap() {
|
||||
await migrate();
|
||||
await migrate();
|
||||
|
||||
const logger = new Logger('bootstrap');
|
||||
const server = fastify({
|
||||
trustProxy: process.env.TRUST_PROXY === 'true',
|
||||
maxParamLength: 500,
|
||||
bodyLimit: config.uploadLimit,
|
||||
});
|
||||
|
||||
const adapter = new FastifyAdapter(server as any);
|
||||
const app = await NestFactory.create<NestFastifyApplication>(AppModule, adapter);
|
||||
app.useGlobalGuards(new HostGuard());
|
||||
app.useGlobalPipes(
|
||||
new ValidationPipe({
|
||||
whitelist: true,
|
||||
forbidNonWhitelisted: true,
|
||||
forbidUnknownValues: true,
|
||||
exceptionFactory(errors) {
|
||||
// without this, nestjs won't include validation errors in the graphql response,
|
||||
// just a blank bad request error, which is just a little confusing. thanks nestjs!
|
||||
const formattedErrors = errors.map((error) => {
|
||||
if (error.constraints) {
|
||||
const constraints = Object.values(error.constraints);
|
||||
if (constraints[0]) return constraints.join(', ');
|
||||
}
|
||||
|
||||
return error.toString();
|
||||
});
|
||||
|
||||
return new BadRequestException(formattedErrors.join('\n'));
|
||||
},
|
||||
transformOptions: {
|
||||
enableImplicitConversion: true,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
await app.register(fastifyCookie as any);
|
||||
await app.register(fastifyHelmet.default as any);
|
||||
await app.register(fastifyMultipart.default as any, {
|
||||
limits: {
|
||||
fieldNameSize: 100,
|
||||
fieldSize: 100,
|
||||
fields: 0,
|
||||
files: 1,
|
||||
headerPairs: 20,
|
||||
},
|
||||
});
|
||||
|
||||
await app.listen(8080, '0.0.0.0', (error, address) => {
|
||||
if (error) throw error;
|
||||
logger.log(`Listening at ${address}`);
|
||||
});
|
||||
}
|
||||
|
||||
// top-level await is not supported by ncc
|
||||
bootstrap().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
const logger = new Logger('bootstrap');
|
||||
const server = fastify({
|
||||
trustProxy: process.env.TRUST_PROXY === 'true',
|
||||
maxParamLength: 500,
|
||||
bodyLimit: config.uploadLimit,
|
||||
});
|
||||
|
||||
const adapter = new FastifyAdapter(server as any);
|
||||
const app = await NestFactory.create<NestFastifyApplication>(AppModule, adapter);
|
||||
app.useGlobalGuards(new HostGuard());
|
||||
app.useGlobalPipes(
|
||||
new ValidationPipe({
|
||||
whitelist: true,
|
||||
forbidNonWhitelisted: true,
|
||||
forbidUnknownValues: true,
|
||||
exceptionFactory(errors) {
|
||||
// without this, nestjs won't include validation errors in the graphql response,
|
||||
// just a blank bad request error, which is just a little confusing. thanks nestjs!
|
||||
const formattedErrors = errors.map((error) => {
|
||||
if (error.constraints) {
|
||||
const constraints = Object.values(error.constraints);
|
||||
if (constraints[0]) return constraints.join(', ');
|
||||
}
|
||||
|
||||
return error.toString();
|
||||
});
|
||||
|
||||
return new BadRequestException(formattedErrors.join('\n'));
|
||||
},
|
||||
transformOptions: {
|
||||
enableImplicitConversion: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
await app.register(fastifyCookie as any);
|
||||
await app.register(fastifyHelmet.default as any);
|
||||
await app.register(fastifyMultipart.default as any, {
|
||||
limits: {
|
||||
fieldNameSize: 100,
|
||||
fieldSize: 100,
|
||||
fields: 0,
|
||||
files: 1,
|
||||
headerPairs: 20,
|
||||
},
|
||||
});
|
||||
|
||||
await app.listen(8080, '0.0.0.0', (error, address) => {
|
||||
if (error) throw error;
|
||||
logger.log(`Listening at ${address}`);
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { Controller, Get, Req, UseGuards } from '@nestjs/common';
|
||||
import type { FastifyRequest } from 'fastify';
|
||||
import { config, hosts, rootHost } from '../config.js';
|
||||
import { UserId } from './auth/auth.decorators.js';
|
||||
import { OptionalJWTAuthGuard } from './auth/guards/optional-jwt.guard.js';
|
||||
import { UserService } from './user/user.service.js';
|
||||
import { type FastifyRequest } from 'fastify';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
|
@ -23,7 +23,7 @@ export class AppController {
|
|||
return {
|
||||
inquiries: config.inquiries,
|
||||
uploadLimit: config.uploadLimit,
|
||||
allowTypes: config.allowTypes ? [...config.allowTypes?.values()] : undefined,
|
||||
allowTypes: config.allowTypes ? [...config.allowTypes.values()] : undefined,
|
||||
email: !!config.email,
|
||||
rootHost: {
|
||||
url: rootHost.url,
|
||||
|
|
|
@ -25,7 +25,7 @@ export class AppResolver {
|
|||
return {
|
||||
inquiriesEmail: config.inquiries,
|
||||
uploadLimit: config.uploadLimit,
|
||||
allowTypes: config.allowTypes ? [...config.allowTypes?.values()] : [],
|
||||
allowTypes: config.allowTypes ? [...config.allowTypes.values()] : [],
|
||||
requireEmails: !!config.email,
|
||||
rootHost: this.filterHost(rootHost),
|
||||
currentHost: this.filterHost(currentHost),
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
Res,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { type FastifyReply, type FastifyRequest } from 'fastify';
|
||||
import { rootHost } from '../../config.js';
|
||||
import { UserId } from '../auth/auth.decorators.js';
|
||||
import { JWTAuthGuard } from '../auth/guards/jwt.guard.js';
|
||||
|
|
|
@ -72,8 +72,13 @@ export class File extends Resource {
|
|||
}
|
||||
|
||||
getDisplayName() {
|
||||
if (this.name) return this.name;
|
||||
const extension = this.getExtension();
|
||||
return this.name ? this.name : extension ? `${this.id}.${extension}` : this.id;
|
||||
if (extension) {
|
||||
return `${this.id}.${extension}`;
|
||||
}
|
||||
|
||||
return this.id;
|
||||
}
|
||||
|
||||
getPaths() {
|
||||
|
|
|
@ -118,8 +118,9 @@ export class FileService implements OnApplicationBootstrap {
|
|||
uploadStream = uploadStream.pipe(transformer).pipe(new PassThrough());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
default: {
|
||||
throw new Error(`Unknown or unsupported conversion ${fromGroup} to ${toGroup}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import { EntityRepository } from '@mikro-orm/postgresql';
|
||||
import { Controller, Get, Param, Request, Res } from '@nestjs/common';
|
||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { type FastifyReply, type FastifyRequest } from 'fastify';
|
||||
import { Link } from './link.entity.js';
|
||||
import { LinkService } from './link.service.js';
|
||||
|
||||
|
@ -9,7 +9,7 @@ import { LinkService } from './link.service.js';
|
|||
export class LinkController {
|
||||
constructor(
|
||||
@InjectRepository(Link) private readonly linkRepo: EntityRepository<Link>,
|
||||
private readonly linkService: LinkService
|
||||
private readonly linkService: LinkService,
|
||||
) {}
|
||||
|
||||
@Get('link/:id')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Controller, Get, Param, Req } from '@nestjs/common';
|
||||
import type { FastifyRequest } from 'fastify';
|
||||
import { type FastifyRequest } from 'fastify';
|
||||
import { PasteService } from './paste.service.js';
|
||||
|
||||
@Controller('paste')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Controller, Get, Param, Req, Res } from '@nestjs/common';
|
||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { type FastifyReply, type FastifyRequest } from 'fastify';
|
||||
import { ThumbnailService } from './thumbnail.service.js';
|
||||
|
||||
@Controller()
|
||||
|
@ -10,7 +10,7 @@ export class ThumbnailController {
|
|||
async getThumbnailContent(
|
||||
@Param('fileId') fileId: string,
|
||||
@Req() request: FastifyRequest,
|
||||
@Res() reply: FastifyReply
|
||||
@Res() reply: FastifyReply,
|
||||
) {
|
||||
return this.thumbnailService.sendThumbnail(fileId, request, reply);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable no-await-in-loop */
|
||||
import { EntityRepository } from '@mikro-orm/core';
|
||||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
|
||||
|
@ -23,7 +24,7 @@ export class ThumbnailService {
|
|||
private static readonly IMAGE_TYPES = new Set(
|
||||
Object.keys(sharp.format)
|
||||
.map((key) => mime.lookup(key))
|
||||
.filter((key) => key && key.startsWith('image'))
|
||||
.filter((key) => key && key.startsWith('image')),
|
||||
);
|
||||
|
||||
private static readonly VIDEO_TYPES = new Set([
|
||||
|
@ -42,7 +43,7 @@ export class ThumbnailService {
|
|||
@InjectRepository('Thumbnail') private readonly thumbnailRepo: EntityRepository<Thumbnail>,
|
||||
@InjectRepository('File') private readonly fileRepo: EntityRepository<File>,
|
||||
private readonly storageService: StorageService,
|
||||
private readonly fileService: FileService
|
||||
private readonly fileService: FileService,
|
||||
) {}
|
||||
|
||||
async getThumbnail(fileId: string) {
|
||||
|
@ -111,8 +112,7 @@ export class ThumbnailService {
|
|||
// and it is so whatever. maybe there is a way to do this faster, but this is already pretty fast.
|
||||
const positions = ['5%', '10%', '20%', '40%'];
|
||||
const size = `${ThumbnailService.THUMBNAIL_SIZE}x?`;
|
||||
for (let positionIndex = 0; positionIndex < positions.length; positionIndex++) {
|
||||
const percent = positions[positionIndex];
|
||||
for (const [positionIndex, percent] of positions.entries()) {
|
||||
const stream = ffmpeg(filePath).screenshot({
|
||||
count: 1,
|
||||
timemarks: [percent],
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Controller, Get, Param, Response } from '@nestjs/common';
|
||||
import type { FastifyReply } from 'fastify';
|
||||
import { type FastifyReply } from 'fastify';
|
||||
import { UserService } from './user.service.js';
|
||||
|
||||
@Controller()
|
||||
|
@ -10,7 +10,7 @@ export class UserController {
|
|||
async verifyUser(
|
||||
@Param('userId') userId: string,
|
||||
@Param('verifyId') verifyId: string,
|
||||
@Response() reply: FastifyReply
|
||||
@Response() reply: FastifyReply,
|
||||
) {
|
||||
await this.userService.verifyUser(userId, verifyId);
|
||||
return reply.redirect(302, '/login?verified=true');
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
||||
/* eslint-disable import/no-default-export */
|
||||
import { FlushMode } from '@mikro-orm/core';
|
||||
import type { MikroOrmModuleSyncOptions } from '@mikro-orm/nestjs';
|
||||
import { Logger, NotFoundException } from '@nestjs/common';
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable unicorn/no-keyword-prefix */
|
||||
import type { Type } from '@nestjs/common';
|
||||
import { Field, ObjectType } from '@nestjs/graphql';
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable unicorn/no-keyword-prefix */
|
||||
import type { Type } from '@nestjs/common';
|
||||
import { Field, Int, ObjectType } from '@nestjs/graphql';
|
||||
import { Edge } from './edge.type.js';
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"noUncheckedIndexedAccess": false,
|
||||
"strictPropertyInitialization": false,
|
||||
"strictPropertyInitialization": false, // doesn't play nice with mikroorm/graphql decorators
|
||||
"noImplicitOverride": false,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"lib": ["es2021", "dom"]
|
||||
}
|
||||
"lib": ["es2021", "dom"],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
module.exports = {
|
||||
extends: require.resolve('@atlasbot/configs/eslint/react'),
|
||||
parserOptions: {
|
||||
project: './tsconfig.json',
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-floating-promises': 'off',
|
||||
'jsx-a11y/no-autofocus': 'off',
|
||||
'jsx-a11y/media-has-caption': 'off',
|
||||
'unicorn/consistent-destructuring': 'off',
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'unicorn/filename-case': 'off',
|
||||
'import/no-default-export': 'off',
|
||||
'@typescript-eslint/consistent-type-imports': [
|
||||
'error',
|
||||
{
|
||||
prefer: 'type-imports',
|
||||
disallowTypeAnnotations: false,
|
||||
fixStyle: 'separate-type-imports',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
|
@ -1,11 +0,0 @@
|
|||
module.exports = {
|
||||
extends: require.resolve('@atlasbot/configs/eslint/next'),
|
||||
parserOptions: {
|
||||
project: './tsconfig.json',
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-floating-promises': 'off',
|
||||
'jsx-a11y/no-autofocus': 'off',
|
||||
'jsx-a11y/media-has-caption': 'off',
|
||||
},
|
||||
};
|
|
@ -1,4 +1,4 @@
|
|||
import { CodegenConfig } from '@graphql-codegen/cli';
|
||||
import type { CodegenConfig } from '@graphql-codegen/cli';
|
||||
|
||||
export default {
|
||||
overwrite: true,
|
||||
|
@ -17,9 +17,6 @@ export default {
|
|||
fragmentMasking: false,
|
||||
},
|
||||
},
|
||||
'src/@generated/introspection.json': {
|
||||
plugins: ['introspection'],
|
||||
},
|
||||
},
|
||||
hooks: {
|
||||
afterAllFileWrite: ['prettier --write'],
|
||||
|
|
|
@ -11,44 +11,38 @@
|
|||
},
|
||||
"scripts": {
|
||||
"build": "tsc --noEmit && rm -rf ./dist/* && vavite build && tsup && rm -rf ./dist/server",
|
||||
"generate": "graphql-codegen --config codegen.ts",
|
||||
"start": "node ./dist/index.js",
|
||||
"watch": "concurrently \"vavite serve\" \"pnpm generate --watch\""
|
||||
"watch": "vavite serve"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@0no-co/graphqlsp": "^1.3.0",
|
||||
"@apollo/client": "^3.8.9",
|
||||
"@atlasbot/configs": "^10.5.15",
|
||||
"@fastify/early-hints": "^1.0.1",
|
||||
"@fastify/http-proxy": "^9.3.0",
|
||||
"@graphql-codegen/cli": "^5.0.0",
|
||||
"@graphql-codegen/client-preset": "^4.1.0",
|
||||
"@graphql-codegen/introspection": "^4.0.0",
|
||||
"@fastify/http-proxy": "^9.4.0",
|
||||
"@graphql-codegen/cli": "^5.0.2",
|
||||
"@graphql-codegen/client-preset": "^4.2.2",
|
||||
"@graphql-typed-document-node/core": "^3.2.0",
|
||||
"@parcel/watcher": "^2.3.0",
|
||||
"@preact/preset-vite": "^2.8.1",
|
||||
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
||||
"@tailwindcss/typography": "^0.5.10",
|
||||
"@types/node": "^20.10.6",
|
||||
"@types/react": "^18.2.47",
|
||||
"@types/react-dom": "^18.2.18",
|
||||
"@urql/devtools": "^2.0.3",
|
||||
"@urql/exchange-graphcache": "^6.4.1",
|
||||
"@urql/preact": "^4.0.4",
|
||||
"autoprefixer": "^10.4.16",
|
||||
"clsx": "^2.1.0",
|
||||
"concurrently": "^8.2.2",
|
||||
"copy-to-clipboard": "^3.3.3",
|
||||
"dayjs": "^1.11.10",
|
||||
"fastify": "^4.25.2",
|
||||
"fastify": "^4.26.0",
|
||||
"formik": "^2.4.5",
|
||||
"generate-avatar": "1.4.10",
|
||||
"graphql": "^16.8.1",
|
||||
"http-status-codes": "^2.3.0",
|
||||
"mime": "^4.0.1",
|
||||
"nanoid": "^5.0.4",
|
||||
"nanoid": "^5.0.5",
|
||||
"path-to-regexp": "^6.2.1",
|
||||
"postcss": "^8.4.33",
|
||||
"preact": "^10.19.3",
|
||||
"postcss": "^8.4.35",
|
||||
"preact": "^10.19.4",
|
||||
"preact-render-to-string": "^6.3.1",
|
||||
"prettier": "^3.1.1",
|
||||
"prettier": "^3.2.5",
|
||||
"prism-react-renderer": "^2.3.1",
|
||||
"qrcode.react": "^3.1.0",
|
||||
"react": "npm:@preact/compat@^17.1.2",
|
||||
|
@ -56,14 +50,15 @@
|
|||
"react-helmet-async": "^2.0.4",
|
||||
"react-icons": "^5.0.1",
|
||||
"react-markdown": "^9.0.1",
|
||||
"readdirp": "^3.6.0",
|
||||
"remark-gfm": "^4.0.0",
|
||||
"tailwindcss": "^3.4.1",
|
||||
"tsup": "^8.0.1",
|
||||
"tsup": "^8.0.2",
|
||||
"typescript": "^5.3.3",
|
||||
"vavite": "^4.0.1",
|
||||
"vike": "^0.4.156",
|
||||
"vite": "^5.0.11",
|
||||
"vavite": "^4.0.3",
|
||||
"vike": "^0.4.161",
|
||||
"vite": "^5.1.1",
|
||||
"vite-plugin-eslint": "^1.8.1",
|
||||
"vite-plugin-graphql-codegen": "^3.3.6",
|
||||
"yup": "^1.3.3"
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,4 +1,5 @@
|
|||
import React, { FC, Fragment } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import React, { Fragment } from 'react';
|
||||
import { Header } from './components/header/header';
|
||||
import { Title } from './components/title';
|
||||
import './styles/globals.css';
|
||||
|
@ -9,6 +10,10 @@ interface AppProps {
|
|||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
declare module 'react' {
|
||||
export type SVGAttributes<T extends EventTarget> = import('preact').JSX.SVGAttributes<T>;
|
||||
}
|
||||
|
||||
export const App: FC<AppProps> = ({ children }) => (
|
||||
<Fragment>
|
||||
<Title>Home</Title>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable react/no-danger */
|
||||
import clsx from 'clsx';
|
||||
import * as avatar from 'generate-avatar';
|
||||
import type { FC } from 'react';
|
||||
|
@ -14,7 +13,7 @@ export const Avatar: FC<AvatarProps> = (props) => {
|
|||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const svg = useMemo(() => {
|
||||
const result = avatar.generateFromString(props.userId);
|
||||
return result.replace(/(width|height)="(\d+)"/g, '$1="100%"');
|
||||
return result.replaceAll(/(width|height)="(\d+)"/g, '$1="100%"');
|
||||
}, [props.userId]);
|
||||
|
||||
return <div className={classes} dangerouslySetInnerHTML={{ __html: svg }} ref={containerRef} />;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import clsx from 'clsx';
|
||||
import React, { forwardRef } from 'react';
|
||||
import { forwardRef } from 'react';
|
||||
import { FiArrowLeft } from 'react-icons/fi';
|
||||
|
||||
export interface BreadcrumbsProps {
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
/* eslint-disable react/button-has-type */
|
||||
import clsx from 'clsx';
|
||||
import type { FC, HTMLAttributes } from 'react';
|
||||
import React, { forwardRef } from 'react';
|
||||
import { forwardRef } from 'react';
|
||||
import { Spinner } from './spinner';
|
||||
|
||||
export interface ButtonProps extends Omit<HTMLAttributes<HTMLButtonElement | HTMLAnchorElement>, 'prefix' | 'style'> {
|
||||
type ButtonBaseProps = Omit<
|
||||
HTMLAttributes<HTMLButtonElement | HTMLAnchorElement>,
|
||||
'prefix' | 'style' | 'as' | 'loading'
|
||||
>;
|
||||
|
||||
export interface ButtonProps extends ButtonBaseProps {
|
||||
href?: string;
|
||||
disabled?: boolean;
|
||||
style?: ButtonStyle;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import clsx from 'clsx';
|
||||
import type { FC, HTMLAttributes } from 'react';
|
||||
import type { ComponentProps, FC } from 'react';
|
||||
|
||||
export const Card: FC<HTMLAttributes<HTMLDivElement>> = ({ className, children, ...rest }) => {
|
||||
export const Card: FC<ComponentProps<'div'>> = ({ className, children, ...rest }) => {
|
||||
const classes = clsx(className, 'p-4 bg-dark-200 rounded');
|
||||
return (
|
||||
<div className={classes} {...rest}>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import clsx from 'clsx';
|
||||
import type { FC, ReactNode } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
export interface ContainerProps {
|
||||
centerX?: boolean;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FC } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import { getErrorMessage } from '../helpers/get-error-message.helper';
|
||||
import { usePaths } from '../hooks/usePaths';
|
||||
import { Container } from './container';
|
||||
|
|
|
@ -12,8 +12,8 @@ import { Input } from '../input/input';
|
|||
import { Link } from '../link';
|
||||
import { useToasts } from '../toast';
|
||||
import { HeaderUser } from './header-user';
|
||||
import { graphql } from '../../@generated';
|
||||
import { useMutation } from '@apollo/client';
|
||||
import { graphql } from '../../@generated/gql';
|
||||
import { useMutation } from '@urql/preact';
|
||||
|
||||
const ResendVerificationEmail = graphql(`
|
||||
mutation ResendVerificationEmail($data: ResendVerificationEmailDto) {
|
||||
|
@ -40,7 +40,7 @@ export const Header = memo(() => {
|
|||
setShowEmailInput(false);
|
||||
});
|
||||
|
||||
const [resendMutation] = useMutation(ResendVerificationEmail);
|
||||
const [, resendMutation] = useMutation(ResendVerificationEmail);
|
||||
const [resendVerification, sendingVerification] = useAsync(async () => {
|
||||
if (resent || !user.data) return;
|
||||
if (!user.data.email && !email) {
|
||||
|
@ -51,9 +51,7 @@ export const Header = memo(() => {
|
|||
const payload = !user.data.email && email ? { email } : null;
|
||||
try {
|
||||
await resendMutation({
|
||||
variables: {
|
||||
data: payload,
|
||||
},
|
||||
data: payload,
|
||||
});
|
||||
|
||||
setShowEmailInput(false);
|
||||
|
@ -99,7 +97,7 @@ export const Header = memo(() => {
|
|||
<div className="mt-3 flex gap-2 items-center">
|
||||
<Input
|
||||
value={email}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
onChange={(event) => setEmail(event.currentTarget.value)}
|
||||
className="flex-grow"
|
||||
placeholder="Email"
|
||||
disabled={sendingVerification}
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import type { InputHTMLAttributes } from 'react';
|
||||
import type { ComponentProps } from 'react';
|
||||
import React from 'react';
|
||||
import type { InputChildProps } from './container';
|
||||
import { InputContainer } from './container';
|
||||
|
||||
export interface CheckboxProps extends InputChildProps<InputHTMLAttributes<HTMLInputElement>> {}
|
||||
type CheckboxBaseProps = InputChildProps<ComponentProps<'input'>>;
|
||||
|
||||
export interface CheckboxProps extends CheckboxBaseProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(({ className, ...delegated }, ref) => {
|
||||
return (
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import type { InputHTMLAttributes } from 'react';
|
||||
import type { ComponentProps } from 'react';
|
||||
import React from 'react';
|
||||
import type { InputChildProps } from './container';
|
||||
import { InputContainer } from './container';
|
||||
|
||||
export interface InputProps extends InputChildProps<InputHTMLAttributes<HTMLInputElement>> {
|
||||
export interface InputProps extends InputChildProps<ComponentProps<'input'>> {
|
||||
isError?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const Input = React.forwardRef<HTMLInputElement, InputProps>(({ className, isError, ...delegated }, ref) => {
|
||||
|
|
|
@ -19,12 +19,12 @@ export const OtpInput: FC<OtpInputProps> = ({ loading, invalid, onCode }) => {
|
|||
isError={invalid}
|
||||
placeholder="123456"
|
||||
onChange={(event) => {
|
||||
if (loading || !event.target.value) return;
|
||||
if (loading || !event.currentTarget.value) return;
|
||||
if (
|
||||
(event.target.value.length === TOTP_CODE_LENGTH && NUMBER_REGEX.test(event.target.value)) ||
|
||||
event.target.value.length === RECOVERY_CODE_LENGTH
|
||||
(event.currentTarget.value.length === TOTP_CODE_LENGTH && NUMBER_REGEX.test(event.currentTarget.value)) ||
|
||||
event.currentTarget.value.length === RECOVERY_CODE_LENGTH
|
||||
) {
|
||||
onCode(event.target.value);
|
||||
onCode(event.currentTarget.value);
|
||||
}
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import clsx from 'clsx';
|
||||
import type { SelectHTMLAttributes } from 'react';
|
||||
import type { ComponentProps } from 'react';
|
||||
import React from 'react';
|
||||
import { FiChevronDown } from 'react-icons/fi';
|
||||
import type { InputChildProps } from './container';
|
||||
import { InputContainer } from './container';
|
||||
import { FiChevronDown } from 'react-icons/fi';
|
||||
|
||||
export interface SelectProps extends InputChildProps<SelectHTMLAttributes<HTMLSelectElement>> {}
|
||||
export interface SelectProps extends InputChildProps<ComponentProps<'select'>> {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const Select = React.forwardRef<HTMLSelectElement, SelectProps>(({ className, children, ...delegated }, ref) => {
|
||||
return (
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useFormikContext } from 'formik';
|
||||
import type { FC } from 'react';
|
||||
import { Button, ButtonProps } from '../button';
|
||||
import type { ButtonProps } from '../button';
|
||||
import { Button } from '../button';
|
||||
|
||||
/**
|
||||
* Wraps a button and disables when the form is not ready to be submitted.
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import clsx from 'clsx';
|
||||
import type { TextareaHTMLAttributes } from 'react';
|
||||
import type { ComponentProps } from 'react';
|
||||
import React from 'react';
|
||||
import type { InputChildProps } from './container';
|
||||
import { InputContainer } from './container';
|
||||
|
||||
export interface TextAreaProps extends InputChildProps<TextareaHTMLAttributes<HTMLTextAreaElement>> {}
|
||||
type TextAreaBaseProps = InputChildProps<ComponentProps<'textarea'>>;
|
||||
|
||||
export interface TextAreaProps extends TextAreaBaseProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(({ className, ...delegated }, ref) => {
|
||||
return (
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { forwardRef, Fragment, type HTMLAttributes } from 'react';
|
||||
import type { ComponentProps} from 'react';
|
||||
import { forwardRef } from 'react';
|
||||
|
||||
export interface LinkProps extends HTMLAttributes<HTMLAnchorElement> {
|
||||
export interface LinkProps extends ComponentProps<'a'> {
|
||||
href: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import clsx from 'clsx';
|
||||
import { FC, Fragment, ReactNode, memo } from 'react';
|
||||
import type { FC, ReactNode } from 'react';
|
||||
import { Fragment, memo } from 'react';
|
||||
import { BASE_BUTTON_CLASSES } from './button';
|
||||
import { BASE_INPUT_CLASSES, BASE_INPUT_MAX_HEIGHT } from './input/container';
|
||||
|
||||
|
@ -48,7 +49,7 @@ export const SkeletonWrap = memo<{
|
|||
show: boolean;
|
||||
children: ReactNode;
|
||||
}>(({ show, children }) => {
|
||||
if (!show) return children;
|
||||
if (!show) return <Fragment>{children}</Fragment>;
|
||||
|
||||
return (
|
||||
<span className="relative">
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import clsx from 'clsx';
|
||||
import type { FC, HTMLAttributes } from 'react';
|
||||
import React from 'react';
|
||||
import type { ComponentProps, FC } from 'react';
|
||||
|
||||
export interface SpinnerProps extends HTMLAttributes<SVGElement> {
|
||||
type SpinnerBaseProps = Omit<ComponentProps<'svg'>, 'size'>;
|
||||
|
||||
export interface SpinnerProps extends SpinnerBaseProps {
|
||||
size?: 'small' | 'medium' | 'large';
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import clsx from 'clsx';
|
||||
import type { Language } from 'prism-react-renderer';
|
||||
import { Highlight } from 'prism-react-renderer';
|
||||
import type { HTMLProps } from 'react';
|
||||
import type { ComponentProps } from 'react';
|
||||
import { memo, useState } from 'react';
|
||||
import { theme } from './prism-theme';
|
||||
import { SyntaxHighlighterControls } from './syntax-highlighter-controls';
|
||||
|
||||
export interface SyntaxHighlighterProps extends HTMLProps<HTMLPreElement> {
|
||||
export interface SyntaxHighlighterProps extends ComponentProps<'pre'> {
|
||||
children: string;
|
||||
language: Language;
|
||||
className?: string;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import React from "react";
|
||||
import { ToastProps } from "./toast";
|
||||
import React from 'react';
|
||||
import type { ToastProps } from './toast';
|
||||
|
||||
export type ToastContextData = null | ((toast: ToastProps) => void);
|
||||
export const ToastContext = React.createContext<ToastContextData>(null);
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { nanoid } from 'nanoid';
|
||||
import type { FC, ReactNode } from 'react';
|
||||
import React, { Fragment, useCallback, useState } from 'react';
|
||||
import { useCallback, useState } from 'preact/hooks';
|
||||
import { Fragment } from 'preact';
|
||||
import { ToastContext } from './context';
|
||||
import type { ToastProps } from './toast';
|
||||
import { Toast, TRANSITION_DURATION } from './toast';
|
||||
import { TRANSITION_DURATION, Toast } from './toast';
|
||||
|
||||
// spread operators on arrays are to fix this
|
||||
// https://stackoverflow.com/questions/56266575/why-is-usestate-not-triggering-re-render
|
||||
|
@ -47,7 +48,7 @@ export const ToastProvider: FC<{ children: ReactNode }> = (props) => {
|
|||
|
||||
return (
|
||||
<ToastContext.Provider value={createToast}>
|
||||
{props.children}
|
||||
<Fragment>{props.children}</Fragment>
|
||||
<div className="fixed flex justify-end bottom-5 right-5 left-5">
|
||||
{toasts.map((toast) => (
|
||||
<Toast key={toast.id} removing={toast.removing} {...toast} />
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import clsx from 'clsx';
|
||||
import type { FC } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
export interface ToastProps {
|
||||
text: string;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import clsx from 'clsx';
|
||||
import type { HTMLAttributes } from 'react';
|
||||
import type { ComponentProps } from 'react';
|
||||
import { forwardRef } from 'react';
|
||||
import { Avatar } from './avatar';
|
||||
|
||||
export interface UserPillProps extends HTMLAttributes<HTMLDivElement> {
|
||||
export interface UserPillProps extends ComponentProps<'div'> {
|
||||
userId: string;
|
||||
username: string;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import clsx from 'clsx';
|
||||
import { type FC, type ReactNode } from 'react';
|
||||
import type { FC, ReactNode } from 'react';
|
||||
import { FiInfo } from 'react-icons/fi';
|
||||
|
||||
export const Warning: FC<{ children: ReactNode; className?: string }> = ({ children, className }) => {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import clsx from 'clsx';
|
||||
import { FC, Fragment, useState } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import { Fragment, useState } from 'react';
|
||||
import { FiDownload } from 'react-icons/fi';
|
||||
import { RegularUserFragment } from '../../@generated/graphql';
|
||||
import type { RegularUserFragment } from '../../@generated/graphql';
|
||||
import { Container } from '../../components/container';
|
||||
import { Section } from '../../components/section';
|
||||
import { Skeleton, SkeletonList, SkeletonWrap } from '../../components/skeleton';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { memo, useEffect, useMemo, useState } from 'react';
|
||||
import { FiFileMinus, FiTrash } from 'react-icons/fi';
|
||||
import { graphql } from '../../../@generated';
|
||||
import { FileCardFragment } from '../../../@generated/graphql';
|
||||
import { graphql } from '../../../@generated/gql';
|
||||
import type { FileCardFragment } from '../../../@generated/graphql';
|
||||
import { Link } from '../../../components/link';
|
||||
import { Skeleton } from '../../../components/skeleton';
|
||||
import { useConfig } from '../../../hooks/useConfig';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import clsx from 'clsx';
|
||||
import { memo } from 'react';
|
||||
import { graphql } from '../../../@generated';
|
||||
import { PasteCardFragment } from '../../../@generated/graphql';
|
||||
import { graphql } from '../../../@generated/gql';
|
||||
import type { PasteCardFragment } from '../../../@generated/graphql';
|
||||
import { Link } from '../../../components/link';
|
||||
import { Time } from '../../../components/time';
|
||||
import { useUser } from '../../../hooks/useUser';
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { useQuery } from '@urql/preact';
|
||||
import type { FC } from 'react';
|
||||
import { Fragment } from 'react';
|
||||
import { graphql } from '../../@generated';
|
||||
import { Fragment, useState } from 'react';
|
||||
import { graphql } from '../../@generated/gql';
|
||||
import { Breadcrumbs } from '../../components/breadcrumbs';
|
||||
import { Card } from '../../components/card';
|
||||
import { Error } from '../../components/error';
|
||||
import { SkeletonList } from '../../components/skeleton';
|
||||
import { Toggle } from '../../components/toggle';
|
||||
import { useQueryState } from '../../hooks/useQueryState';
|
||||
import { FileCard, FileCardSkeleton } from './cards/file-card';
|
||||
import { FileCard } from './cards/file-card';
|
||||
import { PasteCard } from './cards/paste-card';
|
||||
import { PageLoader } from '../../components/page-loader';
|
||||
|
||||
const GetFilesQuery = graphql(`
|
||||
query GetFiles($after: String) {
|
||||
|
@ -51,9 +51,23 @@ const GetPastesQuery = graphql(`
|
|||
|
||||
export const FileList: FC = () => {
|
||||
const [filter, setFilter] = useQueryState('filter', 'files');
|
||||
const files = useQuery(GetFilesQuery, { skip: filter !== 'files' });
|
||||
const pastes = useQuery(GetPastesQuery, { skip: filter !== 'pastes' });
|
||||
|
||||
const [filesAfter, setFilesAfter] = useState<string | null>(null);
|
||||
const [files] = useQuery({
|
||||
query: GetFilesQuery,
|
||||
pause: filter !== 'files',
|
||||
variables: { after: filesAfter },
|
||||
});
|
||||
|
||||
const [pastesAfter, setPastesAfter] = useState<string | null>(null);
|
||||
const [pastes] = useQuery({
|
||||
query: GetPastesQuery,
|
||||
pause: filter !== 'pastes',
|
||||
variables: { after: pastesAfter },
|
||||
});
|
||||
|
||||
const source = filter === 'files' ? files : pastes;
|
||||
const setAfter = filter === 'files' ? setFilesAfter : setPastesAfter;
|
||||
if (source.error) {
|
||||
return <Error error={source.error} />;
|
||||
}
|
||||
|
@ -87,11 +101,7 @@ export const FileList: FC = () => {
|
|||
</div>
|
||||
</div>
|
||||
<div className="pb-5">
|
||||
{!source.data && (
|
||||
<SkeletonList count={12} className="grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6">
|
||||
<FileCardSkeleton />
|
||||
</SkeletonList>
|
||||
)}
|
||||
{!source.data && <PageLoader />}
|
||||
{filter === 'files' && (
|
||||
<div className="grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6">
|
||||
{files.data?.user.files.edges.map(({ node }) => <FileCard key={node.id} file={node} />)}
|
||||
|
@ -102,7 +112,7 @@ export const FileList: FC = () => {
|
|||
{pastes.data?.user.pastes.edges.map(({ node }) => <PasteCard key={node.id} paste={node} />)}
|
||||
</div>
|
||||
)}
|
||||
{!source.loading && !hasContent && (
|
||||
{!source.fetching && !hasContent && (
|
||||
<Card className="text-gray-500">
|
||||
You haven't uploaded anything yet. Once you upload something, it will appear here.
|
||||
</Card>
|
||||
|
@ -113,11 +123,8 @@ export const FileList: FC = () => {
|
|||
className="w-full bg-dark-200 px-2 py-2 text-gray-500 hover:bg-dark-300 transition"
|
||||
type="button"
|
||||
onClick={() => {
|
||||
source.fetchMore({
|
||||
variables: {
|
||||
after: currentPageInfo.pageInfo.endCursor,
|
||||
},
|
||||
});
|
||||
if (!currentPageInfo.pageInfo.endCursor) return;
|
||||
setAfter(currentPageInfo.pageInfo.endCursor);
|
||||
}}
|
||||
>
|
||||
Load More
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { memo } from 'react';
|
||||
import { IconType } from 'react-icons/lib';
|
||||
import type { IconType } from 'react-icons/lib';
|
||||
|
||||
interface MissingPreviewProps {
|
||||
icon: IconType;
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Form, Formik } from 'formik';
|
|||
import type { FC } from 'react';
|
||||
import { Fragment, useCallback, useEffect, useState } from 'react';
|
||||
import * as Yup from 'yup';
|
||||
import { LoginMutationVariables } from '../@generated/graphql';
|
||||
import type { LoginMutationVariables } from '../@generated/graphql';
|
||||
import { Input } from '../components/input/input';
|
||||
import { OtpInput } from '../components/input/otp';
|
||||
import { Submit } from '../components/input/submit';
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { graphql } from '../@generated';
|
||||
import type { CombinedError } from '@urql/preact';
|
||||
import { useQuery } from '@urql/preact';
|
||||
import { graphql } from '../@generated/gql';
|
||||
|
||||
const ConfigQuery = graphql(`
|
||||
query Config {
|
||||
|
@ -24,9 +25,9 @@ const ConfigQuery = graphql(`
|
|||
`);
|
||||
|
||||
export const useConfig = () => {
|
||||
const config = useQuery(ConfigQuery);
|
||||
const [config] = useQuery({ query: ConfigQuery });
|
||||
return {
|
||||
...config,
|
||||
error: config.error as CombinedError | undefined,
|
||||
data: config.data?.config,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/* eslint-disable sonarjs/no-duplicate-string */
|
||||
import { useConfig } from './useConfig';
|
||||
|
||||
export const usePaths = () => {
|
||||
|
|
|
@ -8,8 +8,7 @@ export const useQueryState = <S>(key: string, initialState?: S, parser?: (input:
|
|||
// during SSR, we can grab query params from the page context
|
||||
const value = pageContext.urlParsed.search[key];
|
||||
if (value) {
|
||||
const result = parser ? parser(value) : (value as any);
|
||||
return result;
|
||||
return parser ? parser(value) : (value as any);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +17,7 @@ export const useQueryState = <S>(key: string, initialState?: S, parser?: (input:
|
|||
const search = new URLSearchParams(window.location.search);
|
||||
const value = search.get(key);
|
||||
if (value) {
|
||||
const result = parser ? parser(value) : (value as any);
|
||||
return result;
|
||||
return parser ? parser(value) : (value as any);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { TypedDocumentNode, useMutation, useQuery } from '@apollo/client';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { graphql } from '../@generated';
|
||||
import type { GetUserQuery, LoginMutationVariables, RegularUserFragment } from '../@generated/graphql';
|
||||
import type { CombinedError, TypedDocumentNode } from '@urql/preact';
|
||||
import { useMutation, useQuery } from '@urql/preact';
|
||||
import { graphql } from '../@generated/gql';
|
||||
import type { GetUserQuery, LoginMutationVariables } from '../@generated/graphql';
|
||||
import { navigate, reload } from '../helpers/routing';
|
||||
import { type RegularUserFragment } from '../@generated/graphql';
|
||||
import { useAsync } from './useAsync';
|
||||
|
||||
const RegularUserFragment = graphql(`
|
||||
|
@ -38,10 +40,10 @@ const LogoutMutation = graphql(`
|
|||
|
||||
export const useLoginUser = () => {
|
||||
const [otp, setOtp] = useState(false);
|
||||
const [loginMutation] = useMutation(LoginMutation);
|
||||
const [, loginMutation] = useMutation(LoginMutation);
|
||||
const [login] = useAsync(async (variables: LoginMutationVariables) => {
|
||||
try {
|
||||
await loginMutation({ variables });
|
||||
await loginMutation(variables);
|
||||
navigate('/dashboard');
|
||||
} catch (error: any) {
|
||||
if (error.message.toLowerCase().includes('otp')) {
|
||||
|
@ -59,7 +61,7 @@ export const useLoginUser = () => {
|
|||
};
|
||||
|
||||
export const useLogoutUser = () => {
|
||||
const [logoutMutation] = useMutation(LogoutMutation);
|
||||
const [, logoutMutation] = useMutation(LogoutMutation);
|
||||
const [logout] = useAsync(async () => {
|
||||
await logoutMutation({});
|
||||
reload();
|
||||
|
@ -69,27 +71,27 @@ export const useLogoutUser = () => {
|
|||
};
|
||||
|
||||
export const useUserRedirect = (
|
||||
query: { data: { user: RegularUserFragment } | null | undefined; loading: boolean; called: boolean },
|
||||
query: { data?: { user: RegularUserFragment } | null | undefined; fetching: boolean },
|
||||
redirect: boolean | undefined,
|
||||
) => {
|
||||
useEffect(() => {
|
||||
if (!query.data && !query.loading && query.called && redirect) {
|
||||
if (!query.data && !query.fetching && redirect) {
|
||||
navigate(`/login?to=${window.location.href}`);
|
||||
}
|
||||
}, [redirect, query.data, query.loading, query.called]);
|
||||
}, [redirect, query.data, query.fetching]);
|
||||
};
|
||||
|
||||
export const useUser = <T extends TypedDocumentNode<GetUserQuery, any>>(redirect?: boolean, query?: T) => {
|
||||
const { login, otpRequired } = useLoginUser();
|
||||
const { logout } = useLogoutUser();
|
||||
const { data, loading, called, error } = useQuery((query || UserQuery) as T);
|
||||
const [{ data, fetching, error }] = useQuery({ query: (query || UserQuery) as T });
|
||||
|
||||
useUserRedirect({ data, loading, called }, redirect);
|
||||
useUserRedirect({ data, fetching }, redirect);
|
||||
|
||||
return {
|
||||
data: data?.user as RegularUserFragment | null | undefined,
|
||||
loading: loading,
|
||||
error: error,
|
||||
fetching: fetching,
|
||||
error: error as CombinedError | undefined,
|
||||
otpRequired: otpRequired,
|
||||
login: login,
|
||||
logout: logout,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FC } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import { Container } from '../components/container';
|
||||
import { useConfig } from '../hooks/useConfig';
|
||||
import { Spinner } from '../components/spinner';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { FC } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import { Container } from '../../components/container';
|
||||
import { Title } from '../../components/title';
|
||||
import { FileList } from '../../containers/file-list/file-list';
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { useMutation, useQuery } from '@apollo/client';
|
||||
import { useMutation, useQuery } from '@urql/preact';
|
||||
import clsx from 'clsx';
|
||||
import { QRCodeSVG } from 'qrcode.react';
|
||||
import { FC, Fragment, useCallback, useMemo } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import { Fragment, useCallback, useMemo } from 'react';
|
||||
import { FiChevronLeft, FiChevronRight, FiCopy, FiDownload } from 'react-icons/fi';
|
||||
import { graphql } from '../../../@generated';
|
||||
import { graphql } from '../../../@generated/gql';
|
||||
import { Button, ButtonStyle } from '../../../components/button';
|
||||
import { Container } from '../../../components/container';
|
||||
import { Error } from '../../../components/error';
|
||||
|
@ -32,10 +33,10 @@ const ConfirmOTP = graphql(`
|
|||
`);
|
||||
|
||||
export const Page: FC = () => {
|
||||
const result = useQuery(GenerateOtp);
|
||||
const [result] = useQuery({ query: GenerateOtp });
|
||||
const createToast = useToasts();
|
||||
const [currentStep, setCurrentStep] = useQueryState('step', 0, Number);
|
||||
const [confirmOtp] = useMutation(ConfirmOTP);
|
||||
const [, confirmOtp] = useMutation(ConfirmOTP);
|
||||
|
||||
const copyable = useMemo(() => {
|
||||
if (!result.data) return;
|
||||
|
@ -64,7 +65,7 @@ export const Page: FC = () => {
|
|||
|
||||
const [confirm, confirming] = useAsync(async (otpCode: string) => {
|
||||
try {
|
||||
await confirmOtp({ variables: { otpCode } });
|
||||
await confirmOtp({ otpCode });
|
||||
createToast({ text: 'Successfully enabled 2FA!' });
|
||||
navigate('/dashboard', { overwriteLastHistoryEntry: true });
|
||||
} catch (error: any) {
|
||||
|
@ -77,7 +78,7 @@ export const Page: FC = () => {
|
|||
}
|
||||
});
|
||||
|
||||
if (result.loading) return <PageLoader />;
|
||||
if (result.fetching) return <PageLoader />;
|
||||
if (!result.data) return <Error error={result.error} />;
|
||||
|
||||
return (
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useMutation, useQuery } from '@apollo/client';
|
||||
import { FC, Fragment } from 'react';
|
||||
import { graphql } from '../../../@generated';
|
||||
import { GetUserDocument } from '../../../@generated/graphql';
|
||||
import type { FC } from 'react';
|
||||
import { Fragment } from 'react';
|
||||
import { useMutation, useQuery } from '@urql/preact';
|
||||
import { graphql } from '../../../@generated/gql';
|
||||
import { Breadcrumbs } from '../../../components/breadcrumbs';
|
||||
import { Button } from '../../../components/button';
|
||||
import { Container } from '../../../components/container';
|
||||
|
@ -39,22 +39,19 @@ const UserQueryWithToken = graphql(`
|
|||
`);
|
||||
|
||||
export const Page: FC = () => {
|
||||
const user = useQuery(UserQueryWithToken);
|
||||
const [user] = useQuery({ query: UserQueryWithToken });
|
||||
const { logout } = useLogoutUser();
|
||||
const [refreshMutation] = useMutation(RefreshToken);
|
||||
const [, refreshMutation] = useMutation(RefreshToken);
|
||||
const [refresh, refreshing] = useAsync(async () => {
|
||||
// eslint-disable-next-line no-alert
|
||||
const confirmation = confirm('Are you sure? This will invalidate all existing configs and sessions and will sign you out of the dashboard.') // prettier-ignore
|
||||
if (!confirmation) return;
|
||||
await refreshMutation();
|
||||
await refreshMutation({});
|
||||
await logout();
|
||||
});
|
||||
|
||||
useUserRedirect(user, true);
|
||||
|
||||
const [disableOTP, disableOTPMut] = useMutation(DisableOtp, {
|
||||
refetchQueries: [{ query: GetUserDocument }],
|
||||
});
|
||||
const [disableOTPMut, disableOTP] = useMutation(DisableOtp);
|
||||
|
||||
return (
|
||||
<Container>
|
||||
|
@ -94,7 +91,7 @@ export const Page: FC = () => {
|
|||
readOnly
|
||||
value={user.data.user.token}
|
||||
onFocus={(event) => {
|
||||
event.target.select();
|
||||
event.currentTarget.select();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
@ -125,11 +122,9 @@ export const Page: FC = () => {
|
|||
<div className="right flex items-center col-span-full md:col-span-1">
|
||||
{user.data && user.data.user.otpEnabled && (
|
||||
<OtpInput
|
||||
loading={disableOTPMut.loading}
|
||||
loading={disableOTPMut.fetching}
|
||||
onCode={(otpCode) => {
|
||||
disableOTP({
|
||||
variables: { otpCode },
|
||||
});
|
||||
disableOTP({ otpCode });
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { useMutation, useQuery } from '@apollo/client';
|
||||
import clsx from 'clsx';
|
||||
import copyToClipboard from 'copy-to-clipboard';
|
||||
import type { FC, ReactNode } from 'react';
|
||||
import { Fragment, useState } from 'react';
|
||||
import { FiDownload, FiShare, FiTrash } from 'react-icons/fi';
|
||||
import { graphql } from '../../../@generated';
|
||||
import { useMutation, useQuery } from '@urql/preact';
|
||||
import { graphql } from '../../../@generated/gql';
|
||||
import { Container } from '../../../components/container';
|
||||
import { Embed } from '../../../components/embed/embed';
|
||||
import { Error } from '../../../components/error';
|
||||
|
@ -16,7 +16,7 @@ import { downloadUrl } from '../../../helpers/download.helper';
|
|||
import { navigate } from '../../../helpers/routing';
|
||||
import { useAsync } from '../../../hooks/useAsync';
|
||||
import { useQueryState } from '../../../hooks/useQueryState';
|
||||
import { PageProps } from '../../../renderer/types';
|
||||
import type { PageProps } from '../../../renderer/types';
|
||||
|
||||
const GetFile = graphql(`
|
||||
query GetFile($fileId: ID!) {
|
||||
|
@ -72,14 +72,15 @@ export const Page: FC<PageProps> = ({ routeParams }) => {
|
|||
const [deleteKey] = useQueryState<string | undefined>('deleteKey');
|
||||
const [confirm, setConfirm] = useState(false);
|
||||
const createToast = useToasts();
|
||||
const file = useQuery(GetFile, {
|
||||
skip: !fileId,
|
||||
const [file] = useQuery({
|
||||
query: GetFile,
|
||||
pause: !fileId,
|
||||
variables: {
|
||||
fileId: fileId as string,
|
||||
},
|
||||
});
|
||||
|
||||
const [deleteMutation] = useMutation(DeleteFile);
|
||||
const [, deleteMutation] = useMutation(DeleteFile);
|
||||
const copyLink = () => {
|
||||
copyToClipboard(file.data?.file.urls.view ?? window.location.href);
|
||||
createToast({
|
||||
|
@ -100,10 +101,8 @@ export const Page: FC<PageProps> = ({ routeParams }) => {
|
|||
}
|
||||
|
||||
await deleteMutation({
|
||||
variables: {
|
||||
fileId: file.data.file.id,
|
||||
deleteKey: deleteKey,
|
||||
},
|
||||
fileId: file.data.file.id,
|
||||
deleteKey: deleteKey,
|
||||
});
|
||||
|
||||
createToast({ text: `Deleted "${file.data.file.displayName}"` });
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
import { PageContext, RouteSync } from 'vike/types';
|
||||
import { resolveRoute } from 'vike/routing';
|
||||
|
||||
const PATTERN = /^\/(file|f|v|i)\//;
|
||||
|
||||
export const route: RouteSync = (pageContext: PageContext) => {
|
||||
if (PATTERN.test(pageContext.urlPathname)) {
|
||||
const replaced = pageContext.urlPathname.replace(PATTERN, '/file/');
|
||||
return resolveRoute('/file/@fileId', replaced);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
import { useMutation, useQuery } from '@apollo/client';
|
||||
import { FC, useEffect } from 'react';
|
||||
import { graphql } from '../../../@generated';
|
||||
import type { FC } from 'react';
|
||||
import { useEffect } from 'react';
|
||||
import { graphql } from '../../../@generated/gql';
|
||||
import { Container } from '../../../components/container';
|
||||
import { Error } from '../../../components/error';
|
||||
import { PageLoader } from '../../../components/page-loader';
|
||||
|
@ -13,7 +13,8 @@ import { getErrorMessage } from '../../../helpers/get-error-message.helper';
|
|||
import { navigate, prefetch } from '../../../helpers/routing';
|
||||
import { useAsync } from '../../../hooks/useAsync';
|
||||
import { useConfig } from '../../../hooks/useConfig';
|
||||
import { PageProps } from '../../../renderer/types';
|
||||
import type { PageProps } from '../../../renderer/types';
|
||||
import { useQuery, useMutation } from '@urql/preact';
|
||||
|
||||
const GetInvite = graphql(`
|
||||
query GetInvite($inviteId: ID!) {
|
||||
|
@ -36,23 +37,21 @@ export const Page: FC<PageProps> = ({ routeParams }) => {
|
|||
const config = useConfig();
|
||||
const createToast = useToasts();
|
||||
const inviteToken = routeParams.inviteToken;
|
||||
const invite = useQuery(GetInvite, { skip: !inviteToken, variables: { inviteId: inviteToken! } });
|
||||
const [invite] = useQuery({ query: GetInvite, pause: !inviteToken, variables: { inviteId: inviteToken! } });
|
||||
const expiresAt = invite.data?.invite.expiresAt;
|
||||
|
||||
useEffect(() => {
|
||||
prefetch('/login');
|
||||
}, []);
|
||||
|
||||
const [createUserMutation] = useMutation(CreateUser);
|
||||
const [, createUserMutation] = useMutation(CreateUser);
|
||||
const [onSubmit] = useAsync(async (data: SignupData) => {
|
||||
try {
|
||||
if (!inviteToken) return;
|
||||
await createUserMutation({
|
||||
variables: {
|
||||
user: {
|
||||
...data,
|
||||
invite: inviteToken,
|
||||
},
|
||||
user: {
|
||||
...data,
|
||||
invite: inviteToken,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { FC, useEffect } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import { useEffect } from 'react';
|
||||
import { Title } from '../../components/title';
|
||||
import { LoginForm } from '../../containers/login-form';
|
||||
import { Container } from '../../components/container';
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { useMutation } from '@apollo/client';
|
||||
import { Form, Formik } from 'formik';
|
||||
import { FC } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import * as Yup from 'yup';
|
||||
import { graphql } from '../../@generated';
|
||||
import { graphql } from '../../@generated/gql';
|
||||
import type { CreatePasteDto } from '../../@generated/graphql';
|
||||
import { Button } from '../../components/button';
|
||||
import { Container } from '../../components/container';
|
||||
|
@ -15,6 +14,7 @@ import { Title } from '../../components/title';
|
|||
import { encryptContent } from '../../helpers/encrypt.helper';
|
||||
import { useConfig } from '../../hooks/useConfig';
|
||||
import { useUser } from '../../hooks/useUser';
|
||||
import { useMutation } from '@urql/preact';
|
||||
|
||||
const EXPIRY_OPTIONS = [
|
||||
{ name: '15 minutes', value: 15 },
|
||||
|
@ -98,7 +98,7 @@ const CreatePaste = graphql(`
|
|||
export const Page: FC = () => {
|
||||
const user = useUser();
|
||||
const config = useConfig();
|
||||
const [pasteMutation] = useMutation(CreatePaste);
|
||||
const [, pasteMutation] = useMutation(CreatePaste);
|
||||
if (user.error) {
|
||||
return <Error error={user.error} />;
|
||||
}
|
||||
|
@ -148,12 +148,9 @@ export const Page: FC = () => {
|
|||
}
|
||||
|
||||
const paste = await pasteMutation({
|
||||
variables: {
|
||||
input: body,
|
||||
},
|
||||
input: body,
|
||||
});
|
||||
|
||||
if (paste.errors && paste.errors[0]) throw paste.errors[0];
|
||||
const url = new URL(paste.data!.createPaste.urls.view);
|
||||
if (body.burn) url.searchParams.set('burn_unless', user.data.id);
|
||||
if (encryptionKey) url.hash = `key=${encryptionKey}`;
|
||||
|
@ -167,7 +164,7 @@ export const Page: FC = () => {
|
|||
id="content"
|
||||
autoComplete="off"
|
||||
autoCorrect="off"
|
||||
spellCheck="false"
|
||||
spellCheck={false}
|
||||
placeholder="Markdown, code or plain text"
|
||||
/>
|
||||
<div className="flex gap-2 justify-end flex-wrap">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { FiBookOpen, FiClock, FiTrash } from 'react-icons/fi';
|
||||
import { graphql } from '../../../@generated';
|
||||
import { graphql } from '../../../@generated/gql';
|
||||
import { Button } from '../../../components/button';
|
||||
import { Container } from '../../../components/container';
|
||||
import { Embed } from '../../../components/embed/embed';
|
||||
|
@ -13,7 +13,8 @@ import { decryptContent } from '../../../helpers/encrypt.helper';
|
|||
import { hashToObject } from '../../../helpers/hash-to-object';
|
||||
import { navigate } from '../../../helpers/routing';
|
||||
import { useUser } from '../../../hooks/useUser';
|
||||
import { PageProps } from '../../../renderer/types';
|
||||
import type { PageProps } from '../../../renderer/types';
|
||||
import { useQuery } from '@urql/preact';
|
||||
|
||||
const PasteQuery = graphql(`
|
||||
query GetPaste($pasteId: ID!) {
|
||||
|
@ -47,8 +48,9 @@ export const Page: FC<PageProps> = ({ routeParams }) => {
|
|||
const skipQuery =
|
||||
!pasteId || (!confirmedBurn && (burnUnless === undefined || (burnUnless ? burnUnless !== user.data?.id : false)));
|
||||
|
||||
const paste = useQuery(PasteQuery, {
|
||||
skip: skipQuery,
|
||||
const [paste] = useQuery({
|
||||
query: PasteQuery,
|
||||
pause: skipQuery,
|
||||
variables: {
|
||||
pasteId: pasteId!,
|
||||
},
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import { useMutation } from '@apollo/client';
|
||||
import { useMutation } from '@urql/preact';
|
||||
import { Form, Formik } from 'formik';
|
||||
import { FC, useState } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import { useState } from 'react';
|
||||
import * as Yup from 'yup';
|
||||
import { graphql } from '../../@generated';
|
||||
import { graphql } from '../../@generated/gql';
|
||||
import { Button } from '../../components/button';
|
||||
import { Container } from '../../components/container';
|
||||
import { Input } from '../../components/input/input';
|
||||
|
@ -30,7 +31,7 @@ const Shorten = graphql(`
|
|||
`);
|
||||
|
||||
export const Page: FC = () => {
|
||||
const [shortenMutation] = useMutation(Shorten);
|
||||
const [, shortenMutation] = useMutation(Shorten);
|
||||
const [result, setResult] = useState<string | null>(null);
|
||||
const config = useConfig();
|
||||
|
||||
|
@ -48,10 +49,8 @@ export const Page: FC = () => {
|
|||
validationSchema={schema}
|
||||
onSubmit={async (values) => {
|
||||
const result = await shortenMutation({
|
||||
variables: {
|
||||
link: values.url,
|
||||
host: values.host,
|
||||
},
|
||||
link: values.url,
|
||||
host: values.host,
|
||||
});
|
||||
|
||||
setResult(result.data!.createLink.urls.view);
|
||||
|
@ -84,7 +83,7 @@ export const Page: FC = () => {
|
|||
readOnly
|
||||
value={result}
|
||||
onFocus={(event) => {
|
||||
event.target.select();
|
||||
event.currentTarget.select();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { ChangeEventHandler, DragEventHandler, FC } from 'react';
|
||||
import type { ChangeEventHandler, FC, JSX } from 'react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { FiUpload } from 'react-icons/fi';
|
||||
import { Button } from '../../components/button';
|
||||
|
@ -35,7 +35,7 @@ export const Page: FC = () => {
|
|||
const config = useConfig();
|
||||
|
||||
const onDragEvent =
|
||||
(entering?: boolean): DragEventHandler =>
|
||||
(entering?: boolean): JSX.DragEventHandler<HTMLDivElement> =>
|
||||
(event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
@ -43,12 +43,11 @@ export const Page: FC = () => {
|
|||
else if (entering === false) setHover(false);
|
||||
};
|
||||
|
||||
const onDrop: DragEventHandler = (event) => {
|
||||
const onDrop: JSX.DragEventHandler<HTMLDivElement> = (event) => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
setHover(false);
|
||||
const transfer = event.dataTransfer;
|
||||
const file = transfer.files.item(0);
|
||||
const file = event.dataTransfer?.files.item(0);
|
||||
if (file) {
|
||||
setFile(file);
|
||||
}
|
||||
|
@ -71,7 +70,7 @@ export const Page: FC = () => {
|
|||
const onFileChange: ChangeEventHandler<HTMLInputElement> = (event) => {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
const file = event.target.files?.[0];
|
||||
const file = event.currentTarget.files?.[0];
|
||||
if (file) {
|
||||
setFile(file);
|
||||
}
|
||||
|
@ -140,7 +139,7 @@ export const Page: FC = () => {
|
|||
prefix="Host"
|
||||
className="shrink-0 w-40 mr-2"
|
||||
value={selectedHost}
|
||||
onChange={(event) => setSelectedHost(event.target.value)}
|
||||
onChange={(event) => setSelectedHost(event.currentTarget.value)}
|
||||
>
|
||||
{config.data.hosts.map((host) => (
|
||||
<option key={host.normalised} value={host.normalised} selected={host.normalised === selectedHost}>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Config } from 'vike/types';
|
||||
import type { Config } from 'vike/types';
|
||||
|
||||
export default {
|
||||
passToClient: ['state', 'routeParams'],
|
||||
|
|
|
@ -1,32 +1,42 @@
|
|||
import { ApolloClient, ApolloProvider, HttpLink, InMemoryCache } from '@apollo/client';
|
||||
import { hydrateRoot } from 'react-dom/client';
|
||||
import { OnRenderClientAsync } from 'vike/types';
|
||||
import { App } from '../app';
|
||||
import { typePolicies } from './policy';
|
||||
import { PageContextProvider } from './usePageContext';
|
||||
import { createClient, fetchExchange, ssrExchange } from '@urql/preact';
|
||||
import { Provider as UrqlProvider } from '@urql/preact';
|
||||
import { hydrate } from 'preact';
|
||||
import { HelmetProvider } from 'react-helmet-async';
|
||||
import type { OnRenderClientAsync } from 'vike/types';
|
||||
import { App } from '../app';
|
||||
import { PageContextProvider } from './usePageContext';
|
||||
import { cacheOptions } from './cache';
|
||||
import { cacheExchange } from '@urql/exchange-graphcache';
|
||||
|
||||
export const onRenderClient: OnRenderClientAsync = async (pageContext) => {
|
||||
const { Page } = pageContext;
|
||||
const client = new ApolloClient({
|
||||
link: new HttpLink({ uri: '/api/graphql' }),
|
||||
cache: new InMemoryCache({ typePolicies }),
|
||||
const ssr = ssrExchange({ isClient: true });
|
||||
const exchanges = [ssr, cacheExchange(cacheOptions), fetchExchange];
|
||||
|
||||
if (import.meta.env.MODE === 'development') {
|
||||
const { devtoolsExchange } = await import('@urql/devtools');
|
||||
exchanges.unshift(devtoolsExchange);
|
||||
}
|
||||
|
||||
const client = createClient({
|
||||
url: '/api/graphql',
|
||||
exchanges: exchanges,
|
||||
});
|
||||
|
||||
if (pageContext.state) {
|
||||
client.cache.restore(pageContext.state);
|
||||
ssr.restoreData(pageContext.state);
|
||||
}
|
||||
|
||||
hydrateRoot(
|
||||
document.getElementById('root')!,
|
||||
hydrate(
|
||||
<PageContextProvider pageContext={pageContext}>
|
||||
<ApolloProvider client={client}>
|
||||
<UrqlProvider value={client}>
|
||||
<HelmetProvider>
|
||||
<App>
|
||||
<Page routeParams={pageContext.routeParams || {}} />
|
||||
</App>
|
||||
</HelmetProvider>
|
||||
</ApolloProvider>
|
||||
</UrqlProvider>
|
||||
</PageContextProvider>,
|
||||
document.querySelector('#root')!,
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import { ApolloClient, ApolloProvider, HttpLink, InMemoryCache } from '@apollo/client';
|
||||
import { renderToStringWithData } from '@apollo/client/react/ssr';
|
||||
import { HelmetProvider, HelmetServerState } from 'react-helmet-async';
|
||||
import { cacheExchange } from '@urql/exchange-graphcache';
|
||||
import { Provider as UrqlProvider, createClient, fetchExchange, ssrExchange } from '@urql/preact';
|
||||
import type { HelmetServerState } from 'react-helmet-async';
|
||||
import { HelmetProvider } from 'react-helmet-async';
|
||||
import { dangerouslySkipEscape, escapeInject } from 'vike/server';
|
||||
import type { OnRenderHtmlAsync } from 'vike/types';
|
||||
import { App } from '../app';
|
||||
import { typePolicies } from './policy';
|
||||
import { PageProps } from './types';
|
||||
import { cacheOptions } from './cache';
|
||||
import { renderToStringWithData } from './prepass';
|
||||
import type { PageProps } from './types';
|
||||
import { PageContextProvider } from './usePageContext';
|
||||
|
||||
const GRAPHQL_URL = (import.meta.env.PUBLIC_ENV__FRONTEND_API_URL || import.meta.env.FRONTEND_API_URL) + '/graphql';
|
||||
|
@ -15,34 +17,34 @@ export const onRenderHtml: OnRenderHtmlAsync = async (pageContext): ReturnType<O
|
|||
const pageProps: PageProps = { routeParams: pageContext.routeParams };
|
||||
|
||||
const headers = pageContext.cookies ? { Cookie: pageContext.cookies } : undefined;
|
||||
const client = new ApolloClient({
|
||||
ssrMode: true,
|
||||
cache: new InMemoryCache({ typePolicies }),
|
||||
link: new HttpLink({
|
||||
uri: GRAPHQL_URL,
|
||||
credentials: 'same-origin',
|
||||
const ssr = ssrExchange({ isClient: false });
|
||||
const client = createClient({
|
||||
url: GRAPHQL_URL,
|
||||
exchanges: [ssr, cacheExchange(cacheOptions), fetchExchange],
|
||||
fetchOptions: {
|
||||
headers: headers,
|
||||
}),
|
||||
credentials: 'same-origin',
|
||||
},
|
||||
});
|
||||
|
||||
const helmetContext: { helmet?: HelmetServerState } = {};
|
||||
const tree = (
|
||||
<PageContextProvider pageContext={pageContext}>
|
||||
<ApolloProvider client={client}>
|
||||
<UrqlProvider value={client}>
|
||||
<HelmetProvider context={helmetContext}>
|
||||
<App>
|
||||
<Page {...pageProps} />
|
||||
</App>
|
||||
</HelmetProvider>
|
||||
</ApolloProvider>
|
||||
</UrqlProvider>
|
||||
</PageContextProvider>
|
||||
);
|
||||
|
||||
const pageHtml = await renderToStringWithData(tree);
|
||||
const pageHtml = await renderToStringWithData(client, tree);
|
||||
const helmet = helmetContext.helmet!;
|
||||
const documentHtml = escapeInject`<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<Helmet>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
${dangerouslySkipEscape(helmet.title.toString())}
|
||||
|
@ -59,7 +61,7 @@ export const onRenderHtml: OnRenderHtmlAsync = async (pageContext): ReturnType<O
|
|||
return {
|
||||
documentHtml: documentHtml,
|
||||
pageContext: {
|
||||
state: client.cache.extract(),
|
||||
state: ssr.extractData(),
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import type { CacheExchangeOpts } from '@urql/exchange-graphcache';
|
||||
import { relayPagination } from '@urql/exchange-graphcache/extras';
|
||||
|
||||
export const cacheOptions: Partial<CacheExchangeOpts> = {
|
||||
resolvers: {
|
||||
User: {
|
||||
files: relayPagination(),
|
||||
pastes: relayPagination(),
|
||||
},
|
||||
},
|
||||
keys: {
|
||||
User: () => null,
|
||||
Config: () => null,
|
||||
ConfigHost: () => null,
|
||||
FileMetadata: () => null,
|
||||
ResourceLocations: () => null,
|
||||
FilePage: () => null,
|
||||
PastePage: () => null,
|
||||
OTPEnabledDto: () => null,
|
||||
},
|
||||
updates: {
|
||||
Mutation: {
|
||||
disableOTP: (result, args, cache) => {
|
||||
cache.invalidate('Query', 'user');
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
|
@ -1,13 +0,0 @@
|
|||
import { TypePolicies } from '@apollo/client';
|
||||
import { relayStylePagination } from '@apollo/client/utilities';
|
||||
|
||||
export const typePolicies: TypePolicies = {
|
||||
Config: { keyFields: [] },
|
||||
User: {
|
||||
keyFields: [],
|
||||
fields: {
|
||||
files: relayStylePagination(),
|
||||
pastes: relayStylePagination(),
|
||||
},
|
||||
},
|
||||
};
|
|
@ -0,0 +1,37 @@
|
|||
import type { VNode } from 'preact';
|
||||
import renderToString from 'preact-render-to-string';
|
||||
import type { Client } from '@urql/preact';
|
||||
|
||||
const MAX_DEPTH = 3;
|
||||
const isPromiseLike = (value: unknown): value is Promise<unknown> => {
|
||||
if (value && typeof (value as Promise<unknown>).then === 'function') return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Enables urql suspense, then re-renders the tree until there are no suspense errors.
|
||||
*/
|
||||
export const renderToStringWithData = async (client: Client, tree: VNode, depth = 0): Promise<string> => {
|
||||
// todo: this should use preact-ssr-prepass, but that has issues with `useId()` and radix.
|
||||
// i have absolutely no clue what that issue is, i can't find anything online and it's too vague
|
||||
// to debug. whatever, apollo did it this way and it worked fine. so whatever. i didn't want performance anyway.
|
||||
try {
|
||||
client.suspense = true;
|
||||
const result = renderToString(tree);
|
||||
client.suspense = false;
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (isPromiseLike(error)) {
|
||||
if (depth > MAX_DEPTH) {
|
||||
throw new Error(
|
||||
`Exceeded max suspense depth. Try merge your queries so there are not ${MAX_DEPTH}+ on a single page.`,
|
||||
);
|
||||
}
|
||||
|
||||
await error;
|
||||
return renderToStringWithData(client, tree, depth++);
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
|
@ -1,12 +1,13 @@
|
|||
import { NormalizedCacheObject } from '@apollo/client';
|
||||
import { FC } from 'react';
|
||||
import type { FC } from 'react';
|
||||
import type { SSRData } from '@urql/preact';
|
||||
|
||||
// https://vike.dev/pageContext#typescript
|
||||
/* eslint-disable @typescript-eslint/no-namespace */
|
||||
declare global {
|
||||
namespace Vike {
|
||||
interface PageContext {
|
||||
Page: FC<PageProps>;
|
||||
state?: NormalizedCacheObject;
|
||||
state?: SSRData;
|
||||
pageHtml?: string;
|
||||
cookies?: string;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,5 @@ export function PageContextProvider({
|
|||
}
|
||||
|
||||
export function usePageContext() {
|
||||
const pageContext = useContext(Context);
|
||||
return pageContext;
|
||||
return useContext(Context);
|
||||
}
|
||||
|
|
|
@ -1,20 +1,14 @@
|
|||
import FastifyEarlyHints from '@fastify/early-hints';
|
||||
import FastifyProxy from '@fastify/http-proxy';
|
||||
import Fastify, { FastifyInstance } from 'fastify';
|
||||
import { createReadStream } from 'fs';
|
||||
import { IncomingMessage, ServerResponse } from 'http';
|
||||
import mime from 'mime';
|
||||
import { dirname, resolve } from 'path';
|
||||
import type { FastifyInstance } from 'fastify';
|
||||
import Fastify from 'fastify';
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import { compile, match } from 'path-to-regexp';
|
||||
import rrdir from 'readdirp';
|
||||
import { renderPage } from 'vike/server';
|
||||
import { PageContext } from 'vike/types';
|
||||
import { REWRITES } from './rewrites';
|
||||
import { fileURLToPath } from 'url';
|
||||
import url from 'url';
|
||||
import { renderPage } from 'vike/server';
|
||||
import type { PageContext } from 'vike/types';
|
||||
import { REWRITES } from './rewrites';
|
||||
|
||||
const fileDir = dirname(fileURLToPath(import.meta.url));
|
||||
const staticDir = process.env.STATIC_DIR?.replace('{{FILE_DIR}}', fileDir) || resolve('dist/client');
|
||||
const rewrites = REWRITES.map(({ source, destination }) => ({
|
||||
match: match(source),
|
||||
toPath: compile(destination),
|
||||
|
@ -88,40 +82,14 @@ async function startServer() {
|
|||
},
|
||||
});
|
||||
|
||||
const files = new Set<string>();
|
||||
const info = new Map<string, { type: string; size: number }>();
|
||||
for await (const file of rrdir(staticDir, { type: 'files', alwaysStat: true })) {
|
||||
const mimeType = mime.getType(file.fullPath) || 'application/octet-stream';
|
||||
|
||||
files.add(file.fullPath);
|
||||
info.set(file.fullPath, {
|
||||
type: mimeType,
|
||||
size: file.stats!.size,
|
||||
});
|
||||
}
|
||||
|
||||
instance.get('*', async (request, reply) => {
|
||||
// check if its for a file on disk, and send that instead
|
||||
const pathname = new URL(request.url, 'http://localhost').pathname;
|
||||
const file = resolve(staticDir, pathname.slice(1));
|
||||
if (files.has(file)) {
|
||||
const extraInfo = info.get(file);
|
||||
if (extraInfo) {
|
||||
reply.header('Content-Type', extraInfo.type);
|
||||
reply.header('Content-Length', extraInfo.size);
|
||||
}
|
||||
|
||||
const stream = createReadStream(file);
|
||||
return reply.send(stream);
|
||||
}
|
||||
|
||||
let cookies;
|
||||
if (request.headers.cookie && typeof request.headers.cookie === 'string') {
|
||||
cookies = request.headers.cookie;
|
||||
}
|
||||
|
||||
const pageContextInit = {
|
||||
urlOriginal: request.originalUrl,
|
||||
urlOriginal: request.url,
|
||||
cookies: cookies,
|
||||
} satisfies Partial<PageContext>;
|
||||
|
||||
|
@ -131,14 +99,14 @@ async function startServer() {
|
|||
}
|
||||
|
||||
const { httpResponse } = pageContext;
|
||||
if (!httpResponse) {
|
||||
reply.status(500).send('Internal Server Error');
|
||||
} else {
|
||||
if (httpResponse) {
|
||||
const { body, statusCode, headers, earlyHints } = httpResponse;
|
||||
reply.writeEarlyHints({ link: earlyHints.map((e) => e.earlyHintLink) });
|
||||
headers.forEach(([name, value]) => reply.header(name, value));
|
||||
for (const [name, value] of headers) reply.header(name, value);
|
||||
reply.status(statusCode);
|
||||
reply.send(body);
|
||||
} else {
|
||||
reply.status(500).send('Internal Server Error');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -147,6 +115,7 @@ async function startServer() {
|
|||
}
|
||||
|
||||
let fastify: FastifyInstance | undefined;
|
||||
// eslint-disable-next-line unicorn/prefer-top-level-await
|
||||
const fastifyHandlerPromise = startServer().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
{
|
||||
"extends": "@atlasbot/configs/tsconfig/esm.json",
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"module": "ES2022",
|
||||
"target": "ES2022",
|
||||
"moduleResolution": "Bundler",
|
||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||
"types": ["vite/client"],
|
||||
"jsx": "react-jsx",
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"composite": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "@0no-co/graphqlsp",
|
||||
"schema": "../api/src/schema.gql"
|
||||
}
|
||||
]
|
||||
}
|
||||
"noUncheckedIndexedAccess": false,
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact",
|
||||
"baseUrl": "./",
|
||||
"paths": {
|
||||
"react": ["./node_modules/preact/compat/"],
|
||||
"react-dom": ["./node_modules/preact/compat/"],
|
||||
// todo: https://github.com/gxmari007/vite-plugin-eslint/issues/74
|
||||
"vite-plugin-eslint": ["./node_modules/vite-plugin-eslint/dist/index.d.ts"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -2,11 +2,14 @@ import { preact } from '@preact/preset-vite';
|
|||
import { vavite } from 'vavite';
|
||||
import ssr from 'vike/plugin';
|
||||
import { defineConfig } from 'vite';
|
||||
import eslint from 'vite-plugin-eslint';
|
||||
import codegen from 'vite-plugin-graphql-codegen';
|
||||
|
||||
// todo: https://github.com/dotansimha/graphql-code-generator/issues/9774
|
||||
export default defineConfig({
|
||||
buildSteps: [
|
||||
{ name: 'client' },
|
||||
{
|
||||
name: 'client',
|
||||
},
|
||||
{
|
||||
name: 'server',
|
||||
config: {
|
||||
|
@ -14,17 +17,21 @@ export default defineConfig({
|
|||
},
|
||||
},
|
||||
],
|
||||
optimizeDeps: {
|
||||
include: ['preact', 'preact/devtools', 'preact/debug', 'preact/jsx-dev-runtime', 'preact/hooks'],
|
||||
define: {
|
||||
'process.env.NODE_ENV': '"production"',
|
||||
},
|
||||
ssr: {
|
||||
noExternal: ['react-helmet-async', 'prism-react-renderer', 'qrcode.react', 'formik'],
|
||||
},
|
||||
define: { 'process.env.NODE_ENV': '"production"' },
|
||||
ssr: { noExternal: ['@apollo/client', 'prism-react-renderer', 'qrcode.react', 'formik', 'react-helmet-async'] },
|
||||
plugins: [
|
||||
codegen(),
|
||||
eslint({ cache: true }),
|
||||
preact(),
|
||||
ssr({ disableAutoFullBuild: true }),
|
||||
vavite({
|
||||
handlerEntry: '/src/server/index.ts',
|
||||
serveClientAssetsInDev: true,
|
||||
clientAssetsDir: 'dist/client',
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
|
1841
pnpm-lock.yaml
1841
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
42
turbo.json
42
turbo.json
|
@ -1,26 +1,20 @@
|
|||
{
|
||||
"baseBranch": "origin/main",
|
||||
"pipeline": {
|
||||
"build": {
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
],
|
||||
"outputs": [
|
||||
"dist/**",
|
||||
".next/{server,cache,src,static}"
|
||||
]
|
||||
},
|
||||
"lint": {
|
||||
"outputs": []
|
||||
},
|
||||
"test": {
|
||||
"outputs": []
|
||||
},
|
||||
"clean": {
|
||||
"outputs": []
|
||||
},
|
||||
"watch": {
|
||||
"cache": false
|
||||
}
|
||||
"pipeline": {
|
||||
"build": {
|
||||
"dependsOn": ["^build"],
|
||||
"outputs": ["dist/**", ".next/{server,cache,src,static}"]
|
||||
},
|
||||
"lint": {
|
||||
"outputs": []
|
||||
},
|
||||
"test": {
|
||||
"outputs": []
|
||||
},
|
||||
"clean": {
|
||||
"outputs": []
|
||||
},
|
||||
"watch": {
|
||||
"cache": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue