mirror of
https://github.com/janishutz/MusicPlayer.git
synced 2026-09-10 14:25:24 +02:00
Compare commits
47
Commits
d7433e95a4
..
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c27be5f42c | ||
|
|
5e322f6c67 | ||
|
|
8d6d24a780 | ||
|
|
946ba84518 | ||
|
|
be2a9f3a3e | ||
|
|
d573ac90eb | ||
|
|
b11882c993 | ||
|
|
047a3a8b29 | ||
|
|
6d9853f2c1 | ||
|
|
054fda2fb9 | ||
|
|
867374fa47 | ||
|
|
a5910df441 | ||
|
|
cb5cdc483f | ||
|
|
18bdf82bcf | ||
|
|
68bbfa7896 | ||
|
|
8a83326d60 | ||
|
|
ab08a94d55 | ||
|
|
4d4ddfe255 | ||
|
|
c123673ca5 | ||
|
|
223478f7cc | ||
|
|
b77f0a6dcf | ||
|
|
778f54055d | ||
|
|
b903eb416f | ||
|
|
8a3dd7a583 | ||
|
|
aba98d3122 | ||
|
|
4339861ffd | ||
|
|
01526034ce | ||
|
|
faa271edd6 | ||
|
|
3a0f8210dd | ||
|
|
a2b93e9624 | ||
|
|
f3d9251eee | ||
|
|
72dada18eb | ||
|
|
5f6e034dac | ||
|
|
eead8b558a | ||
|
|
4753d998b3 | ||
|
|
9bf88e033e | ||
|
|
0e155831d7 | ||
|
|
1d492d5922 | ||
|
|
4d9064f5c2 | ||
|
|
5b223875bd | ||
|
|
ce35371c06 | ||
|
|
4c5e1a864b | ||
|
|
94906c3499 | ||
|
|
c38b8d3115 | ||
|
|
d03fbe5e66 | ||
|
|
494eef6cd2 | ||
|
|
cb0db033ea |
@@ -0,0 +1,2 @@
|
|||||||
|
web/eslint.config.mjs linguist-generated
|
||||||
|
backend/eslint.config.mjs linguist-generated
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
# ignore node_modules
|
# ignore node_modules
|
||||||
node_modules
|
node_modules
|
||||||
*.secret.json
|
*.secret.json
|
||||||
|
*.secret.json
|
||||||
apple_private_key.p8
|
apple_private_key.p8
|
||||||
musicplayerv2-server.zip
|
musicplayerv2-server.zip
|
||||||
dist
|
dist
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
yarn.lock
|
||||||
|
|||||||
@@ -1,619 +1,212 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
|
||||||
of this license document, but changing it is not allowed.
|
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Preamble
|
Preamble
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for
|
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.
|
||||||
software and other kinds of works.
|
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed
|
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.
|
||||||
to take away your freedom to share and change the works. By contrast,
|
|
||||||
the GNU General Public License is intended to guarantee your freedom to
|
|
||||||
share and change all versions of a program--to make sure it remains free
|
|
||||||
software for all its users. We, the Free Software Foundation, use the
|
|
||||||
GNU General Public License for most of our software; it applies also to
|
|
||||||
any other work released this way by its authors. You can apply it to
|
|
||||||
your programs, too.
|
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not
|
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.
|
||||||
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
|
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.
|
||||||
these rights or asking you to surrender the rights. Therefore, you have
|
|
||||||
certain responsibilities if you distribute copies of the software, or if
|
|
||||||
you modify it: responsibilities to respect the freedom of others.
|
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
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.
|
||||||
gratis or for a fee, you must pass on to the recipients the same
|
|
||||||
freedoms that you received. You must make sure that they, too, receive
|
|
||||||
or can get the source code. And you must show them these terms so they
|
|
||||||
know their rights.
|
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps:
|
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.
|
||||||
(1) assert copyright on the software, and (2) offer you this License
|
|
||||||
giving you legal permission to copy, distribute and/or modify it.
|
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains
|
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.
|
||||||
that there is no warranty for this free software. For both users' and
|
|
||||||
authors' sake, the GPL requires that modified versions be marked as
|
|
||||||
changed, so that their problems will not be attributed erroneously to
|
|
||||||
authors of previous versions.
|
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run
|
The precise terms and conditions for copying, distribution and modification follow.
|
||||||
modified versions of the software inside them, although the manufacturer
|
|
||||||
can do so. This is fundamentally incompatible with the aim of
|
|
||||||
protecting users' freedom to change the software. The systematic
|
|
||||||
pattern of such abuse occurs in the area of products for individuals to
|
|
||||||
use, which is precisely where it is most unacceptable. Therefore, we
|
|
||||||
have designed this version of the GPL to prohibit the practice for those
|
|
||||||
products. If such problems arise substantially in other domains, we
|
|
||||||
stand ready to extend this provision to those domains in future versions
|
|
||||||
of the GPL, as needed to protect the freedom of users.
|
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents.
|
|
||||||
States should not allow patents to restrict development and use of
|
|
||||||
software on general-purpose computers, but in those that do, we wish to
|
|
||||||
avoid the special danger that patents applied to a free program could
|
|
||||||
make it effectively proprietary. To prevent this, the GPL assures that
|
|
||||||
patents cannot be used to render the program non-free.
|
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and
|
|
||||||
modification follow.
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
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.
|
||||||
works, such as semiconductor masks.
|
|
||||||
|
|
||||||
"The Program" refers to any copyrightable work licensed under this
|
"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.
|
||||||
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 earlier work or a work "based on" the earlier work.
|
||||||
in a fashion requiring copyright permission, other than the making of an
|
|
||||||
exact copy. The resulting work is called a "modified version" of the
|
|
||||||
earlier work or a work "based on" the earlier work.
|
|
||||||
|
|
||||||
A "covered work" means either the unmodified Program or a work based
|
A "covered work" means either the unmodified Program or a work based on the Program.
|
||||||
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, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||||
permission, would make you directly or secondarily liable for
|
|
||||||
infringement under applicable copyright law, except executing it on a
|
|
||||||
computer or modifying a private copy. Propagation includes copying,
|
|
||||||
distribution (with or without modification), making available to the
|
|
||||||
public, and in some countries other activities as well.
|
|
||||||
|
|
||||||
To "convey" a work means any kind of propagation that enables other
|
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.
|
||||||
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 the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||||
to the extent that it includes a convenient and prominently visible
|
|
||||||
feature that (1) displays an appropriate copyright notice, and (2)
|
|
||||||
tells the user that there is no warranty for the work (except to the
|
|
||||||
extent that warranties are provided), that licensees may convey the
|
|
||||||
work under this License, and how to view a copy of this License. If
|
|
||||||
the interface presents a list of user commands or options, such as a
|
|
||||||
menu, a prominent item in the list meets this criterion.
|
|
||||||
|
|
||||||
1. Source Code.
|
1. Source Code.
|
||||||
|
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
|
||||||
|
|
||||||
The "source code" for a work means the preferred form of the work
|
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||||
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
|
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||||
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 "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those
|
||||||
than the work as a whole, that (a) is included in the normal form of
|
|
||||||
packaging a Major Component, but which is not part of that Major
|
|
||||||
Component, and (b) serves only to enable use of the work with that
|
|
||||||
Major Component, or to implement a Standard Interface for which an
|
|
||||||
implementation is available to the public in source code form. A
|
|
||||||
"Major Component", in this context, means a major essential component
|
|
||||||
(kernel, window system, and so on) of the specific operating system
|
|
||||||
(if any) on which the executable work runs, or a compiler used to
|
|
||||||
produce the work, or an object code interpreter used to run it.
|
|
||||||
|
|
||||||
The "Corresponding Source" for a work in object code form means all
|
|
||||||
the source code needed to generate, install, and (for an executable
|
|
||||||
work) run the object code and to modify the work, including scripts to
|
|
||||||
control those activities. However, it does not include the work's
|
|
||||||
System Libraries, or general-purpose tools or generally available free
|
|
||||||
programs which are used unmodified in performing those activities but
|
|
||||||
which are not part of the work. For example, Corresponding Source
|
|
||||||
includes interface definition files associated with source files for
|
|
||||||
the work, and the source code for shared libraries and dynamically
|
|
||||||
linked subprograms that the work is specifically designed to require,
|
|
||||||
such as by intimate data communication or control flow between those
|
|
||||||
subprograms and other parts of the work.
|
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.
|
||||||
can regenerate automatically from other parts of the Corresponding
|
|
||||||
Source.
|
The Corresponding Source for a work in source code form is that same work.
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that
|
2. Basic Permissions.
|
||||||
same work.
|
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
2. Basic Permissions.
|
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
All rights granted under this License are granted for the term of
|
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||||
copyright on the Program, and are irrevocable provided the stated
|
|
||||||
conditions are met. This License explicitly affirms your unlimited
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
permission to run the unmodified Program. The output from running a
|
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.
|
||||||
covered work is covered by this License only if the output, given its
|
|
||||||
content, constitutes a covered work. This License acknowledges your
|
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||||
rights of fair use or other equivalent, as provided by copyright law.
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
You may make, run and propagate covered works that you do not
|
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||||
convey, without conditions so long as your license otherwise remains
|
|
||||||
in force. You may convey covered works to others for the sole purpose
|
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.
|
||||||
of having them make modifications exclusively for you, or provide you
|
|
||||||
with facilities for running those works, provided that you comply with
|
5. Conveying Modified Source Versions.
|
||||||
the terms of this License in conveying all material for which you do
|
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:
|
||||||
not control copyright. Those thus making or running the covered works
|
|
||||||
for you must do so exclusively on your behalf, under your direction
|
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||||
and control, on terms that prohibit them from making any copies of
|
|
||||||
your copyrighted material outside their relationship with you.
|
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under
|
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||||
the conditions stated below. Sublicensing is not allowed; section 10
|
|
||||||
makes it unnecessary.
|
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||||
|
|
||||||
No covered work shall be deemed part of an effective technological
|
6. Conveying Non-Source Forms.
|
||||||
measure under any applicable law fulfilling obligations under article
|
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:
|
||||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
|
||||||
similar laws prohibiting or restricting circumvention of such
|
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||||
measures.
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||||
When you convey a covered work, you waive any legal power to forbid
|
|
||||||
circumvention of technological measures to the extent such circumvention
|
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||||
is effected by exercising rights under this License with respect to
|
|
||||||
the covered work, and you disclaim any intention to limit operation or
|
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||||
modification of the work as a means of enforcing, against the work's
|
|
||||||
users, your or third parties' legal rights to forbid circumvention of
|
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||||
technological measures.
|
|
||||||
|
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.
|
||||||
4. Conveying Verbatim Copies.
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||||
You may convey verbatim copies of the Program's source code as you
|
|
||||||
receive it, in any medium, provided that you conspicuously and
|
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||||
appropriately publish on each copy an appropriate copyright notice;
|
|
||||||
keep intact all notices stating that this License and any
|
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||||
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
|
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||||
recipients a copy of this License along with the Program.
|
|
||||||
|
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.
|
||||||
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.
|
7. Additional Terms.
|
||||||
|
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||||
5. Conveying Modified Source Versions.
|
|
||||||
|
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||||
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
|
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:
|
||||||
terms of section 4, provided that you also meet all of these conditions:
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||||
a) The work must carry prominent notices stating that you modified
|
|
||||||
it, and giving a relevant date.
|
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is
|
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||||
released under this License and any conditions added under section
|
|
||||||
7. This requirement modifies the requirement in section 4 to
|
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||||
"keep intact all notices".
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||||
c) You must license the entire work, as a whole, under this
|
|
||||||
License to anyone who comes into possession of a copy. This
|
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||||
License will therefore apply, along with any applicable section 7
|
|
||||||
additional terms, to the whole of the work, and all its parts,
|
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||||
regardless of how they are packaged. This License gives no
|
|
||||||
permission to license the work in any other way, but it does not
|
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.
|
||||||
invalidate such permission if you have separately received it.
|
|
||||||
|
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.
|
||||||
d) If the work has interactive user interfaces, each must display
|
|
||||||
Appropriate Legal Notices; however, if the Program has interactive
|
8. Termination.
|
||||||
interfaces that do not display Appropriate Legal Notices, your
|
|
||||||
work need not make them do so.
|
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).
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent
|
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.
|
||||||
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,
|
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.
|
||||||
in or on a volume of a storage or distribution medium, is called an
|
|
||||||
"aggregate" if the compilation and its resulting copyright are not
|
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||||
used to limit the access or legal rights of the compilation's users
|
|
||||||
beyond what the individual works permit. Inclusion of a covered work
|
9. Acceptance Not Required for Having Copies.
|
||||||
in an aggregate does not cause this License to apply to the other
|
|
||||||
parts of the aggregate.
|
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
You may convey a covered work in object code form under the terms
|
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||||
of sections 4 and 5, provided that you also convey the
|
|
||||||
machine-readable Corresponding Source under the terms of this License,
|
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||||
in one of these ways:
|
|
||||||
|
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.
|
||||||
a) Convey the object code in, or embodied in, a physical product
|
|
||||||
(including a physical distribution medium), accompanied by the
|
11. Patents.
|
||||||
Corresponding Source fixed on a durable physical medium
|
|
||||||
customarily used for software interchange.
|
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".
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product
|
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||||
(including a physical distribution medium), accompanied by a
|
|
||||||
written offer, valid for at least three years and valid for as
|
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.
|
||||||
long as you offer spare parts or customer support for that product
|
|
||||||
model, to give anyone who possesses the object code either (1) a
|
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||||
copy of the Corresponding Source for all the software in the
|
|
||||||
product that is covered by this License, on a durable physical
|
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent
|
||||||
medium customarily used for software interchange, for a price no
|
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.
|
||||||
more than your reasonable cost of physically performing this
|
|
||||||
conveying of source, or (2) access to copy the
|
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||||
Corresponding Source from a network server at no charge.
|
|
||||||
|
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||||
c) Convey individual copies of the object code with a copy of the
|
|
||||||
written offer to provide the Corresponding Source. This
|
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.
|
||||||
alternative is allowed only occasionally and noncommercially, and
|
|
||||||
only if you received the object code with such an offer, in accord
|
12. No Surrender of Others' Freedom.
|
||||||
with subsection 6b.
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may
|
||||||
d) Convey the object code by offering access from a designated
|
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.
|
||||||
place (gratis or for a charge), and offer equivalent access to the
|
|
||||||
Corresponding Source in the same way through the same place at no
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
further charge. You need not require recipients to copy the
|
|
||||||
Corresponding Source along with the object code. If the place to
|
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.
|
||||||
copy the object code is a network server, the Corresponding Source
|
|
||||||
may be on a different server (operated by you or a third party)
|
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
|
||||||
that supports equivalent copying facilities, provided you maintain
|
|
||||||
clear directions next to the object code saying where to find the
|
14. Revised Versions of this License.
|
||||||
Corresponding Source. Regardless of what server hosts the
|
|
||||||
Corresponding Source, you remain obligated to ensure that it is
|
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.
|
||||||
available for as long as needed to satisfy these requirements.
|
|
||||||
|
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||||
e) Convey the object code using peer-to-peer transmission, provided
|
|
||||||
you inform other peers where the object code and Corresponding
|
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.
|
||||||
Source of the work are being offered to the general public at no
|
|
||||||
charge under subsection 6d.
|
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.
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded
|
15. Disclaimer of Warranty.
|
||||||
from the Corresponding Source as a System Library, need not be
|
|
||||||
included in conveying the object code work.
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
A "User Product" is either (1) a "consumer product", which means any
|
16. Limitation of Liability.
|
||||||
tangible personal property which is normally used for personal, family,
|
|
||||||
or household purposes, or (2) anything designed or sold for incorporation
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
into a dwelling. In determining whether a product is a consumer product,
|
|
||||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
17. Interpretation of Sections 15 and 16.
|
||||||
product received by a particular user, "normally used" refers to a
|
|
||||||
typical or common use of that class of product, regardless of the status
|
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||||
of the particular user or of the way in which the particular user
|
|
||||||
actually uses, or expects or is expected to use, the product. A product
|
|
||||||
is a consumer product regardless of whether the product has substantial
|
|
||||||
commercial, industrial or non-consumer uses, unless such uses represent
|
|
||||||
the only significant mode of use of the product.
|
|
||||||
|
|
||||||
"Installation Information" for a User Product means any methods,
|
|
||||||
procedures, authorization keys, or other information required to install
|
|
||||||
and execute modified versions of a covered work in that User Product from
|
|
||||||
a modified version of its Corresponding Source. The information must
|
|
||||||
suffice to ensure that the continued functioning of the modified object
|
|
||||||
code is in no case prevented or interfered with solely because
|
|
||||||
modification has been made.
|
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or
|
|
||||||
specifically for use in, a User Product, and the conveying occurs as
|
|
||||||
part of a transaction in which the right of possession and use of the
|
|
||||||
User Product is transferred to the recipient in perpetuity or for a
|
|
||||||
fixed term (regardless of how the transaction is characterized), the
|
|
||||||
Corresponding Source conveyed under this section must be accompanied
|
|
||||||
by the Installation Information. But this requirement does not apply
|
|
||||||
if neither you nor any third party retains the ability to install
|
|
||||||
modified object code on the User Product (for example, the work has
|
|
||||||
been installed in ROM).
|
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a
|
|
||||||
requirement to continue to provide support service, warranty, or updates
|
|
||||||
for a work that has been modified or installed by the recipient, or for
|
|
||||||
the User Product in which it has been modified or installed. Access to a
|
|
||||||
network may be denied when the modification itself materially and
|
|
||||||
adversely affects the operation of the network or violates the rules and
|
|
||||||
protocols for communication across the network.
|
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided,
|
|
||||||
in accord with this section must be in a format that is publicly
|
|
||||||
documented (and with an implementation available to the public in
|
|
||||||
source code form), and must require no special password or key for
|
|
||||||
unpacking, reading or copying.
|
|
||||||
|
|
||||||
7. Additional Terms.
|
|
||||||
|
|
||||||
"Additional permissions" are terms that supplement the terms of this
|
|
||||||
License by making exceptions from one or more of its conditions.
|
|
||||||
Additional permissions that are applicable to the entire Program shall
|
|
||||||
be treated as though they were included in this License, to the extent
|
|
||||||
that they are valid under applicable law. If additional permissions
|
|
||||||
apply only to part of the Program, that part may be used separately
|
|
||||||
under those permissions, but the entire Program remains governed by
|
|
||||||
this License without regard to the additional permissions.
|
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option
|
|
||||||
remove any additional permissions from that copy, or from any part of
|
|
||||||
it. (Additional permissions may be written to require their own
|
|
||||||
removal in certain cases when you modify the work.) You may place
|
|
||||||
additional permissions on material, added by you to a covered work,
|
|
||||||
for which you have or can give appropriate copyright permission.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you
|
|
||||||
add to a covered work, you may (if authorized by the copyright holders of
|
|
||||||
that material) supplement the terms of this License with terms:
|
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the
|
|
||||||
terms of sections 15 and 16 of this License; or
|
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or
|
|
||||||
author attributions in that material or in the Appropriate Legal
|
|
||||||
Notices displayed by works containing it; or
|
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or
|
|
||||||
requiring that modified versions of such material be marked in
|
|
||||||
reasonable ways as different from the original version; or
|
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or
|
|
||||||
authors of the material; or
|
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some
|
|
||||||
trade names, trademarks, or service marks; or
|
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that
|
|
||||||
material by anyone who conveys the material (or modified versions of
|
|
||||||
it) with contractual assumptions of liability to the recipient, for
|
|
||||||
any liability that these contractual assumptions directly impose on
|
|
||||||
those licensors and authors.
|
|
||||||
|
|
||||||
All other non-permissive additional terms are considered "further
|
|
||||||
restrictions" within the meaning of section 10. If the Program as you
|
|
||||||
received it, or any part of it, contains a notice stating that it is
|
|
||||||
governed by this License along with a term that is a further
|
|
||||||
restriction, you may remove that term. If a license document contains
|
|
||||||
a further restriction but permits relicensing or conveying under this
|
|
||||||
License, you may add to a covered work material governed by the terms
|
|
||||||
of that license document, provided that the further restriction does
|
|
||||||
not survive such relicensing or conveying.
|
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you
|
|
||||||
must place, in the relevant source files, a statement of the
|
|
||||||
additional terms that apply to those files, or a notice indicating
|
|
||||||
where to find the applicable terms.
|
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the
|
|
||||||
form of a separately written license, or stated as exceptions;
|
|
||||||
the above requirements apply either way.
|
|
||||||
|
|
||||||
8. Termination.
|
|
||||||
|
|
||||||
You may not propagate or modify a covered work except as expressly
|
|
||||||
provided under this License. Any attempt otherwise to propagate or
|
|
||||||
modify it is void, and will automatically terminate your rights under
|
|
||||||
this License (including any patent licenses granted under the third
|
|
||||||
paragraph of section 11).
|
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your
|
|
||||||
license from a particular copyright holder is reinstated (a)
|
|
||||||
provisionally, unless and until the copyright holder explicitly and
|
|
||||||
finally terminates your license, and (b) permanently, if the copyright
|
|
||||||
holder fails to notify you of the violation by some reasonable means
|
|
||||||
prior to 60 days after the cessation.
|
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is
|
|
||||||
reinstated permanently if the copyright holder notifies you of the
|
|
||||||
violation by some reasonable means, this is the first time you have
|
|
||||||
received notice of violation of this License (for any work) from that
|
|
||||||
copyright holder, and you cure the violation prior to 30 days after
|
|
||||||
your receipt of the notice.
|
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the
|
|
||||||
licenses of parties who have received copies or rights from you under
|
|
||||||
this License. If your rights have been terminated and not permanently
|
|
||||||
reinstated, you do not qualify to receive new licenses for the same
|
|
||||||
material under section 10.
|
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
|
||||||
|
|
||||||
You are not required to accept this License in order to receive or
|
|
||||||
run a copy of the Program. Ancillary propagation of a covered work
|
|
||||||
occurring solely as a consequence of using peer-to-peer transmission
|
|
||||||
to receive a copy likewise does not require acceptance. However,
|
|
||||||
nothing other than this License grants you permission to propagate or
|
|
||||||
modify any covered work. These actions infringe copyright if you do
|
|
||||||
not accept this License. Therefore, by modifying or propagating a
|
|
||||||
covered work, you indicate your acceptance of this License to do so.
|
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
|
||||||
|
|
||||||
Each time you convey a covered work, the recipient automatically
|
|
||||||
receives a license from the original licensors, to run, modify and
|
|
||||||
propagate that work, subject to this License. You are not responsible
|
|
||||||
for enforcing compliance by third parties with this License.
|
|
||||||
|
|
||||||
An "entity transaction" is a transaction transferring control of an
|
|
||||||
organization, or substantially all assets of one, or subdividing an
|
|
||||||
organization, or merging organizations. If propagation of a covered
|
|
||||||
work results from an entity transaction, each party to that
|
|
||||||
transaction who receives a copy of the work also receives whatever
|
|
||||||
licenses to the work the party's predecessor in interest had or could
|
|
||||||
give under the previous paragraph, plus a right to possession of the
|
|
||||||
Corresponding Source of the work from the predecessor in interest, if
|
|
||||||
the predecessor has it or can get it with reasonable efforts.
|
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the
|
|
||||||
rights granted or affirmed under this License. For example, you may
|
|
||||||
not impose a license fee, royalty, or other charge for exercise of
|
|
||||||
rights granted under this License, and you may not initiate litigation
|
|
||||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
|
||||||
any patent claim is infringed by making, using, selling, offering for
|
|
||||||
sale, or importing the Program or any portion of it.
|
|
||||||
|
|
||||||
11. Patents.
|
|
||||||
|
|
||||||
A "contributor" is a copyright holder who authorizes use under this
|
|
||||||
License of the Program or a work on which the Program is based. The
|
|
||||||
work thus licensed is called the contributor's "contributor version".
|
|
||||||
|
|
||||||
A contributor's "essential patent claims" are all patent claims
|
|
||||||
owned or controlled by the contributor, whether already acquired or
|
|
||||||
hereafter acquired, that would be infringed by some manner, permitted
|
|
||||||
by this License, of making, using, or selling its contributor version,
|
|
||||||
but do not include claims that would be infringed only as a
|
|
||||||
consequence of further modification of the contributor version. For
|
|
||||||
purposes of this definition, "control" includes the right to grant
|
|
||||||
patent sublicenses in a manner consistent with the requirements of
|
|
||||||
this License.
|
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
|
||||||
patent license under the contributor's essential patent claims, to
|
|
||||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
|
||||||
propagate the contents of its contributor version.
|
|
||||||
|
|
||||||
In the following three paragraphs, a "patent license" is any express
|
|
||||||
agreement or commitment, however denominated, not to enforce a patent
|
|
||||||
(such as an express permission to practice a patent or covenant not to
|
|
||||||
sue for patent infringement). To "grant" such a patent license to a
|
|
||||||
party means to make such an agreement or commitment not to enforce a
|
|
||||||
patent against the party.
|
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license,
|
|
||||||
and the Corresponding Source of the work is not available for anyone
|
|
||||||
to copy, free of charge and under the terms of this License, through a
|
|
||||||
publicly available network server or other readily accessible means,
|
|
||||||
then you must either (1) cause the Corresponding Source to be so
|
|
||||||
available, or (2) arrange to deprive yourself of the benefit of the
|
|
||||||
patent license for this particular work, or (3) arrange, in a manner
|
|
||||||
consistent with the requirements of this License, to extend the patent
|
|
||||||
license to downstream recipients. "Knowingly relying" means you have
|
|
||||||
actual knowledge that, but for the patent license, your conveying the
|
|
||||||
covered work in a country, or your recipient's use of the covered work
|
|
||||||
in a country, would infringe one or more identifiable patents in that
|
|
||||||
country that you have reason to believe are valid.
|
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or
|
|
||||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
|
||||||
covered work, and grant a patent license to some of the parties
|
|
||||||
receiving the covered work authorizing them to use, propagate, modify
|
|
||||||
or convey a specific copy of the covered work, then the patent license
|
|
||||||
you grant is automatically extended to all recipients of the covered
|
|
||||||
work and works based on it.
|
|
||||||
|
|
||||||
A patent license is "discriminatory" if it does not include within
|
|
||||||
the scope of its coverage, prohibits the exercise of, or is
|
|
||||||
conditioned on the non-exercise of one or more of the rights that are
|
|
||||||
specifically granted under this License. You may not convey a covered
|
|
||||||
work if you are a party to an arrangement with a third party that is
|
|
||||||
in the business of distributing software, under which you make payment
|
|
||||||
to the third party based on the extent of your activity of conveying
|
|
||||||
the work, and under which the third party grants, to any of the
|
|
||||||
parties who would receive the covered work from you, a discriminatory
|
|
||||||
patent license (a) in connection with copies of the covered work
|
|
||||||
conveyed by you (or copies made from those copies), or (b) primarily
|
|
||||||
for and in connection with specific products or compilations that
|
|
||||||
contain the covered work, unless you entered into that arrangement,
|
|
||||||
or that patent license was granted, prior to 28 March 2007.
|
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting
|
|
||||||
any implied license or other defenses to infringement that may
|
|
||||||
otherwise be available to you under applicable patent law.
|
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
|
||||||
|
|
||||||
If conditions are imposed on you (whether by court order, agreement or
|
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
|
||||||
excuse you from the conditions of this License. If you cannot convey a
|
|
||||||
covered work so as to satisfy simultaneously your obligations under this
|
|
||||||
License and any other pertinent obligations, then as a consequence you may
|
|
||||||
not convey it at all. For example, if you agree to terms that obligate you
|
|
||||||
to collect a royalty for further conveying from those to whom you convey
|
|
||||||
the Program, the only way you could satisfy both those terms and this
|
|
||||||
License would be to refrain entirely from conveying the Program.
|
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, you have
|
|
||||||
permission to link or combine any covered work with a work licensed
|
|
||||||
under version 3 of the GNU Affero General Public License into a single
|
|
||||||
combined work, and to convey the resulting work. The terms of this
|
|
||||||
License will continue to apply to the part which is the covered work,
|
|
||||||
but the special requirements of the GNU Affero General Public License,
|
|
||||||
section 13, concerning interaction through a network will apply to the
|
|
||||||
combination as such.
|
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
|
||||||
|
|
||||||
The Free Software Foundation may publish revised and/or new versions of
|
|
||||||
the GNU General Public License from time to time. Such new versions will
|
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
|
||||||
address new problems or concerns.
|
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the
|
|
||||||
Program specifies that a certain numbered version of the GNU General
|
|
||||||
Public License "or any later version" applies to it, you have the
|
|
||||||
option of following the terms and conditions either of that numbered
|
|
||||||
version or of any later version published by the Free Software
|
|
||||||
Foundation. If the Program does not specify a version number of the
|
|
||||||
GNU General Public License, you may choose any version ever published
|
|
||||||
by the Free Software Foundation.
|
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future
|
|
||||||
versions of the GNU General Public License can be used, that proxy's
|
|
||||||
public statement of acceptance of a version permanently authorizes you
|
|
||||||
to choose that version for the Program.
|
|
||||||
|
|
||||||
Later license versions may give you additional or different
|
|
||||||
permissions. However, no additional obligations are imposed on any
|
|
||||||
author or copyright holder as a result of your choosing to follow a
|
|
||||||
later version.
|
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
|
||||||
|
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
|
||||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
|
||||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
|
||||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
|
||||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
|
||||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
||||||
|
|
||||||
16. Limitation of Liability.
|
|
||||||
|
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
|
||||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
|
||||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
|
||||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
|
||||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
|
||||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
|
||||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
|
||||||
SUCH DAMAGES.
|
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
|
||||||
|
|
||||||
If the disclaimer of warranty and limitation of liability provided
|
|
||||||
above cannot be given local legal effect according to their terms,
|
|
||||||
reviewing courts shall apply local law that most closely approximates
|
|
||||||
an absolute waiver of all civil liability in connection with the
|
|
||||||
Program, unless a warranty or assumption of liability accompanies a
|
|
||||||
copy of the Program in return for a fee.
|
|
||||||
|
|||||||
@@ -4,23 +4,31 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="badges" align="center">
|
<div id="badges" align="center">
|
||||||
<img alt="Project License" src="https://img.shields.io/github/license/simplePCBuilding/MusicPlayerV2.svg">
|
<img alt="Project License" src="https://img.shields.io/github/license/janishutz/MusicPlayer.svg">
|
||||||
<img alt="GitHub Repo size" src="https://img.shields.io/github/repo-size/simplePCBuilding/MusicPlayerV2.svg">
|
<img alt="GitHub Repo size" src="https://img.shields.io/github/repo-size/janishutz/MusicPlayer.svg">
|
||||||
<img alt="GitHub Repo issues" src="https://img.shields.io/github/issues-pr-raw/simplePCBuilding/MusicPlayerV2">
|
<img alt="GitHub Repo issues" src="https://img.shields.io/github/issues-pr-raw/janishutz/MusicPlayer">
|
||||||
<img alt="Top Languages" src="https://img.shields.io/github/languages/top/simplePCBuilding/MusicPlayerV2">
|
<img alt="Top Languages" src="https://img.shields.io/github/languages/top/janishutz/MusicPlayer">
|
||||||
<img alt="GitHub Repo filecount" src="https://img.shields.io/github/directory-file-count/simplePCBuilding/MusicPlayerV2.svg">
|
<img alt="GitHub Repo filecount" src="https://img.shields.io/github/directory-file-count/janishutz/MusicPlayer.svg">
|
||||||
<br>
|
<br>
|
||||||
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/simplePCBuilding/MusicPlayerV2">
|
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/janishutz/MusicPlayer">
|
||||||
<img alt="GitHub watchers" src="https://img.shields.io/github/watchers/simplePCBuilding/MusicPlayerV2">
|
<img alt="GitHub watchers" src="https://img.shields.io/github/watchers/janishutz/MusicPlayer">
|
||||||
<img alt="GitHub forks" src="https://img.shields.io/github/forks/simplePCBuilding/MusicPlayerV2">
|
<img alt="GitHub forks" src="https://img.shields.io/github/forks/janishutz/MusicPlayer">
|
||||||
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/simplePCBuilding/MusicPlayerV2">
|
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/janishutz/MusicPlayer">
|
||||||
<br>
|
<br>
|
||||||
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/simplePCBuilding/MusicPlayerV2/total?label=Downloads (total)">
|
<img alt="GitHub all releases" src="https://img.shields.io/github/downloads/janishutz/MusicPlayer/total?label=Downloads (total)">
|
||||||
<img alt="GitHub release (latest by date)" src="https://img.shields.io/github/downloads/simplePCBuilding/MusicPlayerV2/latest/total?label=Downloads (latest)">
|
<img alt="GitHub release (latest by date)" src="https://img.shields.io/github/downloads/janishutz/MusicPlayer/latest/total?label=Downloads (latest)">
|
||||||
<img alt="Latest release" src="https://img.shields.io/github/release/simplePCBuilding/MusicPlayerV2.svg">
|
<img alt="Latest release" src="https://img.shields.io/github/release/janishutz/MusicPlayer.svg">
|
||||||
<img alt="App Version" src="https://img.shields.io/github/package-json/v/simplePCBuilding/MusicPlayerV2.svg?label=Development Version">
|
<img alt="App Version" src="https://img.shields.io/github/package-json/v/janishutz/MusicPlayer.svg?label=Development Version">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
# Development Branch
|
||||||
|
This branch is for the upcoming version 4 of Music Player and is in early stages of development
|
||||||
|
|
||||||
|
It uses my manually created [types for MusicKitJS](https://github.com/janishutz/musickit-v3-types)
|
||||||
|
|
||||||
|
|
||||||
|
# MusicPlayer
|
||||||
|
|
||||||
A music player, specifically created for displaying song information on multiple different displays that are connected to the same network, just from the browser.
|
A music player, specifically created for displaying song information on multiple different displays that are connected to the same network, just from the browser.
|
||||||
|
|
||||||
The [hosted version](https://music.janishutz.com) of this MusicPlayer, which is fully set up for you is subscription-based and can be paid for on my [store](https://store.janishutz.com/product/com.janishutz).
|
The [hosted version](https://music.janishutz.com) of this MusicPlayer, which is fully set up for you is subscription-based and can be paid for on my [store](https://store.janishutz.com/product/com.janishutz).
|
||||||
@@ -30,9 +38,20 @@ The [hosted version](https://music.janishutz.com) of this MusicPlayer, which is
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
**NOTICE:** This section has not been updated for the new version of MusicPlayer yet
|
||||||
- Browser based App that runs on all OS (Linux, MacOS, Windows, iOS, Android, iPadOS, ...)
|
- Browser based App that runs on all OS (Linux, MacOS, Windows, iOS, Android, iPadOS, ...)
|
||||||
- Fully featured Music Player
|
- Fully featured Music Player
|
||||||
- Show all song information over the Internet on any amount of client displays
|
- Show all song information over the Internet on any amount of client displays
|
||||||
- Client displays show the playback position and all information from song metadata fetched from the Apple Music API
|
- Client displays show the playback position and all information from song metadata fetched from the Apple Music API
|
||||||
- Play most common music files
|
- Play most common music files
|
||||||
- No setup required when using the hosted version at [music.janishutz.com](https://music.janishutz.com)
|
- No setup required when using the hosted version at [music.janishutz.com](https://music.janishutz.com)
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
MusicPlayer Copyright (C) 2026 janishutz
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
FROM node:25-alpine3.21 AS build
|
||||||
|
|
||||||
|
WORKDIR /usr/src/build
|
||||||
|
COPY . /usr/src/build
|
||||||
|
|
||||||
|
RUN npm i
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
|
||||||
|
# Prod build with fewer deps
|
||||||
|
FROM node:25-alpine3.21 AS prod
|
||||||
|
|
||||||
|
WORKDIR /usr/src/musicplayer
|
||||||
|
COPY --from=build /usr/src/build/dist /usr/src/musicplayer/dist
|
||||||
|
COPY ./index.js /usr/src/musicplayer/index.js
|
||||||
|
|
||||||
|
RUN npm i --omit=dev
|
||||||
|
|
||||||
|
CMD [ "node", "index.js" ]
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema",
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"mode": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"foss",
|
||||||
|
"hosted"
|
||||||
|
],
|
||||||
|
"default": "foss",
|
||||||
|
"description": "Mode to use for the login. If set to hosted, sdk configuration needs to be complete"
|
||||||
|
},
|
||||||
|
"clientMode": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"sse",
|
||||||
|
"poll"
|
||||||
|
],
|
||||||
|
"default": "poll",
|
||||||
|
"description": "Default information retrieval mode for the basic remote displays. Polling is slightly cheaper at the cost of responsiveness"
|
||||||
|
},
|
||||||
|
"webUrl": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The URL to the frontend. Just the host, in form https://music.janishutz.com"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"mode",
|
||||||
|
"clientMode",
|
||||||
|
"webUrl"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../config.schema.json",
|
||||||
|
"mode": "hosted",
|
||||||
|
"clientMode": "sse",
|
||||||
|
"webUrl": "http://localhost:8081"
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"playlists":[{"name":"Hello World","songs":[{"duration":236,"name":"CAN'T STOP THE FEELING! (Original Song From DreamWorks Animation's \"TROLLS\")","additional-info":"Test 3","artist":"Justin Timberlake","artwork":"https://is1-ssl.mzstatic.com/image/thumb/Music124/v4/52/d0/02/52d002d7-1f7f-8d91-4791-ed04c460ec93/886445894653.jpg/2000x2000bb.jpg","identifier":"blob:http://localhost:8081/fdb6fccd-30cb-458c-a9f6-c424d2f53c43","source":"local","additional-identifier":"16_Can't_Stop_The_Feeling-Justin_Timberlake.mp3__4407330"},{"duration":258,"name":"Muévelo","additional-info":"Test","artist":"Rey Ruiz","artwork":"https://is1-ssl.mzstatic.com/image/thumb/Music122/v4/58/15/0d/58150db1-0e74-dd19-f7eb-3f15e8a04b56/197187182459.jpg/2000x2000bb.jpg","identifier":"blob:http://localhost:8081/18dcea36-839d-4714-b7fc-6800f26e07b9","source":"local","additional-identifier":"18_Muevlo-Rey_Ruiz.mp3__4831574"}]}],"userid":"server-stubs","version":"1"}
|
||||||
Generated
+71
-29
@@ -1,15 +1,15 @@
|
|||||||
import vue from 'eslint-plugin-vue';
|
|
||||||
import eslint from '@eslint/js';
|
import eslint from '@eslint/js';
|
||||||
import globals from 'globals';
|
import globals from 'globals';
|
||||||
import typescript from '@typescript-eslint/eslint-plugin';
|
|
||||||
import stylistic from '@stylistic/eslint-plugin';
|
import stylistic from '@stylistic/eslint-plugin';
|
||||||
import tseslint from 'typescript-eslint';
|
import tseslint from 'typescript-eslint';
|
||||||
|
import typescript from '@typescript-eslint/eslint-plugin';
|
||||||
|
import vue from 'eslint-plugin-vue';
|
||||||
|
|
||||||
const style = {
|
const style = {
|
||||||
'plugins': {
|
'plugins': {
|
||||||
'@stylistic': stylistic,
|
'@stylistic': stylistic,
|
||||||
'@stylistic/js': stylistic,
|
'@stylistic/js': stylistic,
|
||||||
'@stylistic/ts': stylistic,
|
'@stylistic/ts': stylistic
|
||||||
},
|
},
|
||||||
'files': [
|
'files': [
|
||||||
'**/*.ts',
|
'**/*.ts',
|
||||||
@@ -20,11 +20,26 @@ const style = {
|
|||||||
'**/*.jsx'
|
'**/*.jsx'
|
||||||
],
|
],
|
||||||
'rules': {
|
'rules': {
|
||||||
|
'sort-imports': [
|
||||||
|
'warn',
|
||||||
|
{
|
||||||
|
'ignoreCase': false,
|
||||||
|
'ignoreDeclarationSort': false,
|
||||||
|
'ignoreMemberSort': false,
|
||||||
|
'memberSyntaxSortOrder': [
|
||||||
|
'none',
|
||||||
|
'all',
|
||||||
|
'multiple',
|
||||||
|
'single'
|
||||||
|
],
|
||||||
|
'allowSeparatedGroups': false
|
||||||
|
}
|
||||||
|
],
|
||||||
// Formatting
|
// Formatting
|
||||||
'@stylistic/array-bracket-newline': [
|
'@stylistic/array-bracket-newline': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
'multiline': true,
|
'multiline': false,
|
||||||
'minItems': 2
|
'minItems': 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -35,7 +50,8 @@ const style = {
|
|||||||
'@stylistic/array-element-newline': [
|
'@stylistic/array-element-newline': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
'multiline': true,
|
'consistent': false,
|
||||||
|
'multiline': false,
|
||||||
'minItems': 2
|
'minItems': 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -56,7 +72,14 @@ const style = {
|
|||||||
],
|
],
|
||||||
'@stylistic/brace-style': [
|
'@stylistic/brace-style': [
|
||||||
'error',
|
'error',
|
||||||
'1tbs'
|
'1tbs',
|
||||||
|
{
|
||||||
|
'allowSingleLine': false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/comma-dangle': [
|
||||||
|
'error',
|
||||||
|
'never'
|
||||||
],
|
],
|
||||||
'@stylistic/comma-spacing': [
|
'@stylistic/comma-spacing': [
|
||||||
'error',
|
'error',
|
||||||
@@ -73,9 +96,9 @@ const style = {
|
|||||||
'error',
|
'error',
|
||||||
'property'
|
'property'
|
||||||
],
|
],
|
||||||
'@stylistic/eol-last': [
|
'@stylistic/function-call-argument-newline': [
|
||||||
'error',
|
'error',
|
||||||
'always'
|
'consistent'
|
||||||
],
|
],
|
||||||
'@stylistic/function-call-spacing': [
|
'@stylistic/function-call-spacing': [
|
||||||
'error',
|
'error',
|
||||||
@@ -83,11 +106,7 @@ const style = {
|
|||||||
],
|
],
|
||||||
'@stylistic/function-paren-newline': [
|
'@stylistic/function-paren-newline': [
|
||||||
'error',
|
'error',
|
||||||
'multiline'
|
'multiline-arguments'
|
||||||
],
|
|
||||||
'@stylistic/function-call-argument-newline': [
|
|
||||||
'error',
|
|
||||||
'consistent'
|
|
||||||
],
|
],
|
||||||
'@stylistic/implicit-arrow-linebreak': [
|
'@stylistic/implicit-arrow-linebreak': [
|
||||||
'error',
|
'error',
|
||||||
@@ -97,6 +116,10 @@ const style = {
|
|||||||
'error',
|
'error',
|
||||||
4
|
4
|
||||||
],
|
],
|
||||||
|
'@stylistic/indent-binary-ops': [
|
||||||
|
'error',
|
||||||
|
4
|
||||||
|
],
|
||||||
'@stylistic/key-spacing': [
|
'@stylistic/key-spacing': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
@@ -118,18 +141,31 @@ const style = {
|
|||||||
'@stylistic/max-len': [
|
'@stylistic/max-len': [
|
||||||
'warn',
|
'warn',
|
||||||
{
|
{
|
||||||
'code': 90,
|
'code': 140,
|
||||||
'comments': 100,
|
'comments': 160,
|
||||||
'ignoreComments': false,
|
'ignoreComments': false,
|
||||||
'ignoreUrls': true,
|
'ignoreUrls': true,
|
||||||
'ignoreStrings': false
|
'ignoreStrings': true,
|
||||||
|
'ignoreTemplateLiterals': true,
|
||||||
|
'ignoreRegExpLiterals': true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
'@stylistic/max-statements-per-line': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'max': 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/multiline-ternary': [
|
||||||
|
'error',
|
||||||
|
'always-multiline'
|
||||||
|
],
|
||||||
'@stylistic/new-parens': [
|
'@stylistic/new-parens': [
|
||||||
'error',
|
'error',
|
||||||
'always'
|
'always'
|
||||||
],
|
],
|
||||||
'@stylistic/newline-per-chained-call': [ 'error' ],
|
'@stylistic/newline-per-chained-call': 'error',
|
||||||
|
'@stylistic/no-confusing-arrow': 'error',
|
||||||
'@stylistic/no-extra-parens': [
|
'@stylistic/no-extra-parens': [
|
||||||
'error',
|
'error',
|
||||||
'all',
|
'all',
|
||||||
@@ -167,17 +203,17 @@ const style = {
|
|||||||
'always'
|
'always'
|
||||||
],
|
],
|
||||||
'@stylistic/object-property-newline': 'error',
|
'@stylistic/object-property-newline': 'error',
|
||||||
|
'@stylistic/one-var-declaration-per-line': 'error',
|
||||||
'@stylistic/operator-linebreak': [
|
'@stylistic/operator-linebreak': [
|
||||||
'error',
|
'error',
|
||||||
'before'
|
'before'
|
||||||
],
|
],
|
||||||
'@stylistic/one-var-declaration-per-line': 'error',
|
|
||||||
'@stylistic/padded-blocks': [
|
'@stylistic/padded-blocks': [
|
||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
'blocks': 'never',
|
'blocks': 'never',
|
||||||
'classes': 'always',
|
'classes': 'always',
|
||||||
'switches': 'never',
|
'switches': 'never'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -561,7 +597,7 @@ const style = {
|
|||||||
'blankLine': 'always',
|
'blankLine': 'always',
|
||||||
'prev': 'class',
|
'prev': 'class',
|
||||||
'next': '*'
|
'next': '*'
|
||||||
},
|
}
|
||||||
],
|
],
|
||||||
'@stylistic/quote-props': [
|
'@stylistic/quote-props': [
|
||||||
'error',
|
'error',
|
||||||
@@ -613,17 +649,23 @@ const style = {
|
|||||||
'error',
|
'error',
|
||||||
'always'
|
'always'
|
||||||
],
|
],
|
||||||
|
'@stylistic/switch-colon-spacing': 'error',
|
||||||
'@stylistic/template-curly-spacing': [
|
'@stylistic/template-curly-spacing': [
|
||||||
'error',
|
'error',
|
||||||
'always'
|
'always'
|
||||||
],
|
],
|
||||||
'@stylistic/switch-colon-spacing': 'error',
|
'@stylistic/template-tag-spacing': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/type-generic-spacing': 'error',
|
||||||
|
'@stylistic/type-named-tuple-spacing': 'error',
|
||||||
'@stylistic/wrap-iife': [
|
'@stylistic/wrap-iife': [
|
||||||
'error',
|
'error',
|
||||||
'inside'
|
'inside'
|
||||||
],
|
],
|
||||||
'@stylistic/wrap-regex': 'error',
|
'@stylistic/wrap-regex': 'error',
|
||||||
'@stylistic/ts/type-annotation-spacing': 'error',
|
'@stylistic/ts/type-annotation-spacing': 'error'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -642,15 +684,15 @@ export default tseslint.config(
|
|||||||
'ecmaVersion': 'latest',
|
'ecmaVersion': 'latest',
|
||||||
'globals': globals.browser,
|
'globals': globals.browser,
|
||||||
'parserOptions': {
|
'parserOptions': {
|
||||||
'parser': tseslint.parser,
|
'parser': tseslint.parser
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
'plugins': {
|
'plugins': {
|
||||||
'vue': vue,
|
'vue': vue,
|
||||||
'@stylistic': stylistic,
|
'@stylistic': stylistic,
|
||||||
'@stylistic/js': stylistic,
|
'@stylistic/js': stylistic,
|
||||||
'@stylistic/ts': stylistic,
|
'@stylistic/ts': stylistic,
|
||||||
'@typescript-eslint': typescript,
|
'@typescript-eslint': typescript
|
||||||
},
|
},
|
||||||
'extends': [
|
'extends': [
|
||||||
eslint.configs.recommended,
|
eslint.configs.recommended,
|
||||||
@@ -694,9 +736,9 @@ export default tseslint.config(
|
|||||||
'error',
|
'error',
|
||||||
{
|
{
|
||||||
'singleline': 3,
|
'singleline': 3,
|
||||||
'multiline': 1,
|
'multiline': 1
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"@janishutz/login-sdk-server": "^1.4.0",
|
||||||
|
"@janishutz/login-sdk-server-stubs": "^1.4.0",
|
||||||
|
"@janishutz/store-sdk": "^1.2.1",
|
||||||
|
"body-parser": "^2.3.0",
|
||||||
|
"cors": "^2.8.6",
|
||||||
|
"express": "^5.2.1",
|
||||||
|
"express-session": "^1.19.0",
|
||||||
|
"jsonwebtoken": "^9.0.3",
|
||||||
|
"typescript": "^6.0.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^10.0.1",
|
||||||
|
"@stylistic/eslint-plugin": "^5.10.0",
|
||||||
|
"@types/body-parser": "^1.19.6",
|
||||||
|
"@types/cors": "^2.8.19",
|
||||||
|
"@types/express": "^5.0.6",
|
||||||
|
"@types/express-session": "^1.19.0",
|
||||||
|
"@types/jsonwebtoken": "^9.0.10",
|
||||||
|
"@types/node": "^26.2.0",
|
||||||
|
"eslint": "^10.9.0",
|
||||||
|
"eslint-plugin-vue": "^10.10.0",
|
||||||
|
"globals": "^17.11.0",
|
||||||
|
"typescript-eslint": "^8.67.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
import {
|
||||||
|
getLoginSdk,
|
||||||
|
getStoreSdk
|
||||||
|
} from './sdk';
|
||||||
|
import {
|
||||||
|
Config
|
||||||
|
} from './dtype/config';
|
||||||
|
import devtoken from './routes/devtoken';
|
||||||
|
import express from 'express';
|
||||||
|
import fs from 'fs';
|
||||||
|
import logger from './logger';
|
||||||
|
import path from 'path';
|
||||||
|
import room from './routes/room';
|
||||||
|
import user from './routes/user';
|
||||||
|
|
||||||
|
const run = () => {
|
||||||
|
// FIXME: Use DB instead of memory optionally
|
||||||
|
const config = JSON.parse( fs.readFileSync( path.join(
|
||||||
|
__dirname,
|
||||||
|
'/../config/config.json'
|
||||||
|
) ).toString() ) as Config;
|
||||||
|
const foss = config.mode !== 'hosted';
|
||||||
|
const sdkConfig = JSON.parse( fs.readFileSync( path.join(
|
||||||
|
__dirname,
|
||||||
|
`/../config/sdk.config.${ foss ? 'testing' : 'secret' }.json`
|
||||||
|
) ).toString() );
|
||||||
|
const sdk = getLoginSdk( foss );
|
||||||
|
const storeSdk = getStoreSdk( foss );
|
||||||
|
const app = express();
|
||||||
|
|
||||||
|
logger.info( 'Starting in', foss ? 'FOSS' : 'hosted', 'mode' );
|
||||||
|
|
||||||
|
app.use( logger.routeLogging() );
|
||||||
|
|
||||||
|
// Load id.janishutz.com SDK and allow signing in
|
||||||
|
sdk.setUp(
|
||||||
|
{
|
||||||
|
'prod': false,
|
||||||
|
'service': {
|
||||||
|
'serviceID': sdkConfig[ 'name' ],
|
||||||
|
'serviceToken': sdkConfig[ 'token' ]
|
||||||
|
},
|
||||||
|
'user-agent': sdkConfig[ 'ua' ],
|
||||||
|
'sessionType': 'memory',
|
||||||
|
'frontendURL': config.webUrl,
|
||||||
|
'corsWhitelist': [ config.webUrl ],
|
||||||
|
'recheckTimeout': 300 * 1000,
|
||||||
|
'advancedVerification': 'sdk',
|
||||||
|
'defaultRedirectURL': '/app'
|
||||||
|
},
|
||||||
|
app,
|
||||||
|
async () => {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
async ( uid: string ) => {
|
||||||
|
fs.writeFileSync( path.join( __dirname, '/data/', uid ), '{}' );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
async () => {
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
async () => {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Load store sdk
|
||||||
|
const storeConfig = JSON.parse( fs.readFileSync( path.join(
|
||||||
|
__dirname,
|
||||||
|
`/../config/store-sdk.config.${ foss ? 'testing' : 'secret' }.json`
|
||||||
|
) ).toString() );
|
||||||
|
|
||||||
|
storeSdk.configure( storeConfig );
|
||||||
|
|
||||||
|
app.get( '/', ( _request: express.Request, response: express.Response ) => {
|
||||||
|
response.redirect( config.webUrl ?? 'https://music.janishutz.com' );
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
// Load extra routes
|
||||||
|
devtoken.routes( app, foss );
|
||||||
|
room.routes( app, foss, config );
|
||||||
|
user.routes( app, foss );
|
||||||
|
|
||||||
|
|
||||||
|
app.use( ( _request: express.Request, response: express.Response ) => {
|
||||||
|
response.sendStatus( 404 );
|
||||||
|
} );
|
||||||
|
|
||||||
|
const PORT = process.env.PORT || 8080;
|
||||||
|
|
||||||
|
app.listen( PORT );
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
run
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import {
|
||||||
|
CorsOptions
|
||||||
|
} from 'cors';
|
||||||
|
import cors from 'cors';
|
||||||
|
|
||||||
|
let corsWhitelist: string[] = [];
|
||||||
|
|
||||||
|
const configure = ( whitelist: string[] ) => {
|
||||||
|
corsWhitelist = whitelist;
|
||||||
|
};
|
||||||
|
|
||||||
|
const middleware = ( rest: boolean = false ) => {
|
||||||
|
return cors( genCorsOpts( rest ) );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the options for the CORS library
|
||||||
|
* @param rest - [OPTIONAL] Whether to allow REST requests or not
|
||||||
|
* @returns CORS options object that can be used for the cors library
|
||||||
|
*/
|
||||||
|
const genCorsOpts = ( rest: boolean = false ): CorsOptions => {
|
||||||
|
const corsOpts: CorsOptions = {
|
||||||
|
'credentials': true,
|
||||||
|
'optionsSuccessStatus': 200,
|
||||||
|
'origin': ( origin, cb ) => {
|
||||||
|
const status = blockREST( origin! );
|
||||||
|
|
||||||
|
cb( null, status );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if ( rest ) {
|
||||||
|
corsOpts[ 'origin' ] = ( origin, cb ) => {
|
||||||
|
const status = allowREST( origin! );
|
||||||
|
|
||||||
|
cb( null, status );
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return corsOpts;
|
||||||
|
};
|
||||||
|
|
||||||
|
const blockREST = ( origin: string ): boolean => {
|
||||||
|
return corsWhitelist.includes( origin );
|
||||||
|
};
|
||||||
|
|
||||||
|
const allowREST = ( origin: string ): boolean => {
|
||||||
|
return blockREST( origin ) || !origin;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
genCorsOpts,
|
||||||
|
configure,
|
||||||
|
middleware
|
||||||
|
};
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
export interface Config {
|
||||||
|
'mode': 'foss' | 'hosted';
|
||||||
|
'clientMode': 'sse' | 'poll';
|
||||||
|
'webUrl': string;
|
||||||
|
}
|
||||||
Vendored
+55
@@ -0,0 +1,55 @@
|
|||||||
|
export interface UserPlaylistFile {
|
||||||
|
'version': '1',
|
||||||
|
'userid': string,
|
||||||
|
'playlists': Playlist[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Playlist {
|
||||||
|
'name': string;
|
||||||
|
'songs': PlaylistSongs;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PlaylistSongs = Song[];
|
||||||
|
|
||||||
|
export interface Song {
|
||||||
|
/**
|
||||||
|
* Where the song can be found
|
||||||
|
*/
|
||||||
|
'source': 'local' | 'applemusic';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifier for the song so it can be found again (such as Apple Music ID or URL for playback)
|
||||||
|
*/
|
||||||
|
'identifier': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any additional identifiers (such as filename, etc) to associate.
|
||||||
|
* Even if this is not used, set this value if local files are needed
|
||||||
|
*/
|
||||||
|
'additional-identifier'?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Additional info, such as dance type to be displayed on remote screens
|
||||||
|
*/
|
||||||
|
'additional-info': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The artist of the song
|
||||||
|
*/
|
||||||
|
'artist': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the song
|
||||||
|
*/
|
||||||
|
'name': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The cover image as a URL
|
||||||
|
*/
|
||||||
|
'artwork': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Song duration
|
||||||
|
*/
|
||||||
|
'duration': number;
|
||||||
|
}
|
||||||
+24
-15
@@ -1,29 +1,37 @@
|
|||||||
|
import express from 'express';
|
||||||
import {
|
import {
|
||||||
writeFile
|
writeFile
|
||||||
} from 'node:fs';
|
} from 'node:fs';
|
||||||
|
|
||||||
const log = ( ...msg: string[] ) => {
|
const log = ( ...msg: unknown[] ) => {
|
||||||
output( 'log', log.caller.toString(), ...msg );
|
output( 'log', 'UNKNOWN', ...msg );
|
||||||
};
|
};
|
||||||
|
|
||||||
const info = ( ...msg: string[] ) => {
|
const info = ( ...msg: unknown[] ) => {
|
||||||
output( 'info', log.caller.toString(), ...msg );
|
output( 'info', 'UNKNOWN', ...msg );
|
||||||
};
|
};
|
||||||
|
|
||||||
const debug = ( ...msg: string[] ) => {
|
const debug = ( ...msg: unknown[] ) => {
|
||||||
output( 'debug', log.caller.toString(), ...msg );
|
output( 'debug', 'UNKNOWN', ...msg );
|
||||||
};
|
};
|
||||||
|
|
||||||
const warn = ( ...msg: string[] ) => {
|
const warn = ( ...msg: unknown[] ) => {
|
||||||
output( 'warn', log.caller.toString(), ...msg );
|
output( 'warn', 'UNKNOWN', ...msg );
|
||||||
};
|
};
|
||||||
|
|
||||||
const error = ( ...msg: string[] ) => {
|
const error = ( ...msg: unknown[] ) => {
|
||||||
output( 'error', log.caller.toString(), ...msg );
|
output( 'error', 'UNKNOWN', ...msg );
|
||||||
};
|
};
|
||||||
|
|
||||||
const fatal = ( ...msg: string[] ) => {
|
const fatal = ( ...msg: unknown[] ) => {
|
||||||
output( 'fatal', log.caller.toString(), ...msg );
|
output( 'fatal', 'UNKNOWN', ...msg );
|
||||||
|
};
|
||||||
|
|
||||||
|
const routeLogging = () => {
|
||||||
|
return ( request: express.Request, _response: express.Response, next: express.NextFunction ) => {
|
||||||
|
output( 'info', 'ROUTER', request.originalUrl, 'from', request.headers['user-agent'] ?? 'No UA' );
|
||||||
|
next();
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -44,14 +52,14 @@ const configure = ( location: 'stderr' | 'file', minLevel: LogLevel, file?: stri
|
|||||||
throw new Error( 'File parameter required when location is "file"' );
|
throw new Error( 'File parameter required when location is "file"' );
|
||||||
}
|
}
|
||||||
|
|
||||||
loc = location === 'stderr' ? 'stderr' : file;
|
loc = location === 'stderr' ? 'stderr' : ( file ?? 'musicplayer.log' );
|
||||||
lev = levels.indexOf( minLevel );
|
lev = levels.indexOf( minLevel );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const logfile: string[] = [];
|
const logfile: string[] = [];
|
||||||
|
|
||||||
const output = ( level: LogLevel, caller: string, ...message: string[] ) => {
|
const output = ( level: LogLevel, caller: string, ...message: unknown[] ) => {
|
||||||
if ( levels.indexOf( level ) < lev ) {
|
if ( levels.indexOf( level ) < lev ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -100,5 +108,6 @@ export default {
|
|||||||
warn,
|
warn,
|
||||||
error,
|
error,
|
||||||
fatal,
|
fatal,
|
||||||
configure
|
configure,
|
||||||
|
routeLogging
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,186 @@
|
|||||||
|
import {
|
||||||
|
Client,
|
||||||
|
Room,
|
||||||
|
RoomStore
|
||||||
|
} from './room';
|
||||||
|
import {
|
||||||
|
PlaylistSongs
|
||||||
|
} from '../../dtype/file';
|
||||||
|
import {
|
||||||
|
Response
|
||||||
|
} from 'express';
|
||||||
|
|
||||||
|
const rooms: RoomStore = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The room to get
|
||||||
|
* @param room - The name of the room to get
|
||||||
|
* @returns The room, or undefined if it is not present
|
||||||
|
*/
|
||||||
|
const get = ( room: string ): Room | undefined => {
|
||||||
|
return rooms[room];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name - The name of the room to create
|
||||||
|
* @param uid - The ID of the user
|
||||||
|
*/
|
||||||
|
const create = ( name: string, uid: string ) => {
|
||||||
|
if ( rooms[ name ] ) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
rooms[ name ] = {
|
||||||
|
'clients': [],
|
||||||
|
'trackingClients': [],
|
||||||
|
'owner': uid,
|
||||||
|
'playlist': {
|
||||||
|
'playlist': [],
|
||||||
|
'lastUpdate': new Date().getTime()
|
||||||
|
},
|
||||||
|
'state': {
|
||||||
|
'index': 0,
|
||||||
|
'lastUpdate': new Date().getTime(),
|
||||||
|
'playing': false,
|
||||||
|
'start': new Date().getTime(),
|
||||||
|
'offset': 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a listening client to a room
|
||||||
|
* @param roomName - The room ID this client should belong to
|
||||||
|
* @param id - The ID of the client
|
||||||
|
* @param kind - The type of client that is to be removed
|
||||||
|
* @param response - The express response object
|
||||||
|
* @returns true if successful, false otherwise
|
||||||
|
*/
|
||||||
|
const addClient = ( roomName: string, id: string, kind: 'client' | 'trackingClient', response: Response ) => {
|
||||||
|
if ( !rooms[roomName] ) return false;
|
||||||
|
|
||||||
|
const room = rooms[roomName][kind + 's' as 'clients' | 'trackingClients'] as Client[];
|
||||||
|
|
||||||
|
room.push( {
|
||||||
|
'response': response,
|
||||||
|
'id': id
|
||||||
|
} );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a listening client by its ID
|
||||||
|
* @param roomName - The room ID this client belongs to
|
||||||
|
* @param id - The ID of the client
|
||||||
|
* @param kind - The type of client that is to be removed
|
||||||
|
* @returns true if successful, false otherwise
|
||||||
|
*/
|
||||||
|
const removeClient = ( roomName: string, id: string, kind: 'client' | 'trackingClient' ) => {
|
||||||
|
if ( !rooms[roomName] ) return false;
|
||||||
|
|
||||||
|
const room = rooms[roomName][kind + 's' as 'clients' | 'trackingClients'] as Client[];
|
||||||
|
const idx = room.findIndex( client => client.id === id );
|
||||||
|
|
||||||
|
if ( idx < 0 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
room.splice( idx, 1 );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close the room and disconnect all clients
|
||||||
|
* @param name - The name of the room
|
||||||
|
* @param uid - The name of the owner of the room
|
||||||
|
*/
|
||||||
|
const close = ( name: string, uid: string ) => {
|
||||||
|
if ( !rooms[name] || rooms[name].owner !== uid ) return false;
|
||||||
|
|
||||||
|
rooms[name].clients.forEach( client => client.response.send( 'data: closed\n\n' ) );
|
||||||
|
delete rooms[name];
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the state of the specified room
|
||||||
|
* @param room - The room to update the state for
|
||||||
|
* @param uid - The UserID of the user that created the room (i.e. the owner)
|
||||||
|
* @param playing - Set to true if the player is playing currently
|
||||||
|
* @param index - The current playback index
|
||||||
|
* @param start - The timestamp where playback of the current song started
|
||||||
|
* @param offset - The playback offset from the start in seconds
|
||||||
|
* @returns true if update succeeded
|
||||||
|
*/
|
||||||
|
const updateState = ( room: string, uid: string, playing: boolean, index: number, start: number, offset: number ) => {
|
||||||
|
if ( !rooms[room] || rooms[room].owner !== uid ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
rooms[room].state = {
|
||||||
|
'playing': playing,
|
||||||
|
'index': index,
|
||||||
|
'lastUpdate': new Date().getTime(),
|
||||||
|
'start': start,
|
||||||
|
'offset': offset
|
||||||
|
};
|
||||||
|
|
||||||
|
return sendUpdate( room, 'state' );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the playlist of the specified room
|
||||||
|
* @param room - The room to update the state for
|
||||||
|
* @param uid - The UserID of the user that created the room (i.e. the owner)
|
||||||
|
* @param playlist - The playlist that is currently playing
|
||||||
|
* @returns true if update succeeded
|
||||||
|
*/
|
||||||
|
const updatePlaylist = ( room: string, uid: string, playlist: PlaylistSongs ) => {
|
||||||
|
if ( !rooms[room] || rooms[room].owner !== uid ) return false;
|
||||||
|
|
||||||
|
rooms[room].playlist = {
|
||||||
|
'playlist': playlist,
|
||||||
|
'lastUpdate': new Date().getTime()
|
||||||
|
};
|
||||||
|
|
||||||
|
return sendUpdate( room, 'playlist' );
|
||||||
|
};
|
||||||
|
|
||||||
|
const sendUpdate = ( room: string, kind: 'state' | 'playlist' ) => {
|
||||||
|
const roomObject = rooms[room];
|
||||||
|
|
||||||
|
if ( !roomObject ) return false;
|
||||||
|
|
||||||
|
roomObject.clients.forEach( client => client.response.write( `data: json:${ JSON.stringify( {
|
||||||
|
'type': kind,
|
||||||
|
'data': roomObject[kind]
|
||||||
|
} ) }\n\n` ) );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an update from the trackking system to all admin clients
|
||||||
|
* @param room - The room to send it to
|
||||||
|
* @param update - The update to send
|
||||||
|
*/
|
||||||
|
const sendTrackingUpdate = ( room: string, update: string ) => {
|
||||||
|
if ( !rooms[room] ) return false;
|
||||||
|
|
||||||
|
rooms[room].trackingClients.forEach( client => client.response.write( `data: ${ update }\n\n` ) );
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
get,
|
||||||
|
create,
|
||||||
|
close,
|
||||||
|
updateState,
|
||||||
|
updatePlaylist,
|
||||||
|
sendTrackingUpdate,
|
||||||
|
addClient,
|
||||||
|
removeClient
|
||||||
|
};
|
||||||
Vendored
+33
@@ -0,0 +1,33 @@
|
|||||||
|
import {
|
||||||
|
PlaylistSongs
|
||||||
|
} from '../../dtype/file';
|
||||||
|
import {
|
||||||
|
Response
|
||||||
|
} from 'express';
|
||||||
|
|
||||||
|
export interface Client {
|
||||||
|
'id': string;
|
||||||
|
'response': Response;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Room {
|
||||||
|
'playlist': {
|
||||||
|
'lastUpdate': number;
|
||||||
|
'playlist': PlaylistSongs;
|
||||||
|
}
|
||||||
|
'state': {
|
||||||
|
'index': number;
|
||||||
|
'start': number;
|
||||||
|
'playing': boolean;
|
||||||
|
'lastUpdate': number;
|
||||||
|
'offset': number;
|
||||||
|
};
|
||||||
|
'owner': string;
|
||||||
|
'clients': Client[];
|
||||||
|
'trackingClients': Client[];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RoomStore {
|
||||||
|
[id: string]: Room
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import {
|
||||||
|
Config
|
||||||
|
} from '../../dtype/config';
|
||||||
|
import express from 'express';
|
||||||
|
import {
|
||||||
|
generateToken
|
||||||
|
} from '../../token';
|
||||||
|
import rooms from '.';
|
||||||
|
|
||||||
|
export const sseMiddleware = ( kind: 'client' | 'trackingClient', config?: Config ) => {
|
||||||
|
return ( request: express.Request, response: express.Response ) => {
|
||||||
|
if ( typeof request.params.id !== 'string' )
|
||||||
|
return response.sendStatus( 400 );
|
||||||
|
|
||||||
|
const room = rooms.get( request.params.id );
|
||||||
|
|
||||||
|
if ( !room ) return response.sendStatus( 404 );
|
||||||
|
|
||||||
|
response.writeHead( 200, {
|
||||||
|
'Content-Type': 'text/event-stream',
|
||||||
|
'Cache-Control': 'no-cache',
|
||||||
|
'Connection': 'keep-alive'
|
||||||
|
} );
|
||||||
|
response.status( 200 );
|
||||||
|
response.flushHeaders();
|
||||||
|
|
||||||
|
if ( kind === 'trackingClient' || config?.clientMode === 'poll' )
|
||||||
|
response.write( 'data: use-poll\n\n' );
|
||||||
|
else
|
||||||
|
response.write( 'data: connected\n\n' );
|
||||||
|
|
||||||
|
const token = generateToken( 20 );
|
||||||
|
|
||||||
|
rooms.addClient( request.params.id, token, kind, response );
|
||||||
|
|
||||||
|
request.on( 'close', () => {
|
||||||
|
rooms.removeClient( request.params.id as string, token, kind );
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import {
|
||||||
|
readFile,
|
||||||
|
stat,
|
||||||
|
writeFile
|
||||||
|
} from 'node:fs';
|
||||||
|
import {
|
||||||
|
UserPlaylistFile
|
||||||
|
} from '../../dtype/file';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
|
export const getUserFile = async ( uid: string ): Promise<UserPlaylistFile> => {
|
||||||
|
return new Promise( ( resolve, reject ) => {
|
||||||
|
readFile( getUserFilePath( uid ), ( err, data ) => {
|
||||||
|
if ( err ) return reject( err );
|
||||||
|
|
||||||
|
resolve( JSON.parse( String( data ) ) as UserPlaylistFile );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
const createUserFile = async ( uid: string ): Promise<void> => {
|
||||||
|
writeUserFile( uid, {
|
||||||
|
'playlists': [],
|
||||||
|
'userid': uid,
|
||||||
|
'version': '1'
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getUserFilePath = ( uid: string ): string => {
|
||||||
|
return path.join( __dirname, '/../../../data/', uid + '.json' );
|
||||||
|
};
|
||||||
|
|
||||||
|
export const testUserFileExists = async ( uid: string ): Promise<boolean> => {
|
||||||
|
return new Promise( resolve => {
|
||||||
|
stat( getUserFilePath( uid ), err => {
|
||||||
|
if ( err ) return resolve( false );
|
||||||
|
|
||||||
|
resolve( true );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
export const writeUserFile = async ( uid: string, file: UserPlaylistFile ) => {
|
||||||
|
writeFile( getUserFilePath( uid ), JSON.stringify( file ), err => {
|
||||||
|
if ( err ) return Promise.reject( err );
|
||||||
|
else Promise.resolve();
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
getUserFilePath,
|
||||||
|
getUserFile,
|
||||||
|
writeUserFile,
|
||||||
|
testUserFileExists,
|
||||||
|
createUserFile
|
||||||
|
};
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import {
|
||||||
|
getLoginSdk,
|
||||||
|
getStoreSdk
|
||||||
|
} from '../../sdk';
|
||||||
|
import express from 'express';
|
||||||
|
|
||||||
|
const cache: {
|
||||||
|
[key: string]: boolean
|
||||||
|
} = {};
|
||||||
|
|
||||||
|
export const getOwnershipManager = ( foss: boolean ) => {
|
||||||
|
const storeSdk = getStoreSdk( foss );
|
||||||
|
const sdk = getLoginSdk( foss );
|
||||||
|
|
||||||
|
const getOwned = async ( request: express.Request ) => {
|
||||||
|
const uid = sdk.getUID( request )!;
|
||||||
|
|
||||||
|
if ( cache[ uid ] ) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
const now = new Date().getTime();
|
||||||
|
|
||||||
|
if ( ( await storeSdk.getSubscriptions( uid ) ).findIndex(
|
||||||
|
sub => ( sub.id === 'com.janishutz.MusicPlayer.subscription' || sub.id === 'com.janishutz.MusicPlayer.subscription-month' ) && sub.expires - now > 0
|
||||||
|
) > -1 ) {
|
||||||
|
cache[ uid ] = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const middleware = () => {
|
||||||
|
return async ( request: express.Request, response: express.Response, next: express.NextFunction ) => {
|
||||||
|
if ( !await getOwned( request ) ) response.sendStatus( 402 );
|
||||||
|
else next();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
getOwned,
|
||||||
|
middleware
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import corsManager from '../corsManager';
|
||||||
|
import express from 'express';
|
||||||
|
import fs from 'fs';
|
||||||
|
import {
|
||||||
|
getLoginSdk
|
||||||
|
} from '../sdk';
|
||||||
|
import {
|
||||||
|
getOwnershipManager
|
||||||
|
} from '../manager/users/ownership';
|
||||||
|
import jwt from 'jsonwebtoken';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
const routes = ( app: express.Application, foss: boolean ) => {
|
||||||
|
const sdk = getLoginSdk( foss );
|
||||||
|
const privateKey = fs.readFileSync( path.join(
|
||||||
|
__dirname,
|
||||||
|
'/../config/apple_private_key.p8'
|
||||||
|
) ).toString();
|
||||||
|
const musicApiConfig = JSON.parse( fs.readFileSync( path.join(
|
||||||
|
__dirname,
|
||||||
|
'/../config/apple-music-api.config.secret.json'
|
||||||
|
) ).toString() );
|
||||||
|
const ownership = getOwnershipManager( foss );
|
||||||
|
|
||||||
|
app.get(
|
||||||
|
'/dev-token',
|
||||||
|
corsManager.middleware( false ),
|
||||||
|
sdk.loginCheck(),
|
||||||
|
ownership.middleware(),
|
||||||
|
( _request: express.Request, response: express.Response ) => {
|
||||||
|
// sign dev token
|
||||||
|
const now = new Date().getTime();
|
||||||
|
const tomorrow = now + ( 24 * 3600 * 1000 );
|
||||||
|
const jwtToken = jwt.sign( {
|
||||||
|
'iss': musicApiConfig.teamID,
|
||||||
|
'iat': Math.floor( now / 1000 ),
|
||||||
|
'exp': Math.floor( tomorrow / 1000 )
|
||||||
|
}, privateKey, {
|
||||||
|
'algorithm': 'ES256',
|
||||||
|
'keyid': musicApiConfig.keyID
|
||||||
|
} );
|
||||||
|
|
||||||
|
response.send( jwtToken );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
routes
|
||||||
|
};
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import {
|
||||||
|
Config
|
||||||
|
} from '../../dtype/config';
|
||||||
|
import express from 'express';
|
||||||
|
import {
|
||||||
|
getLoginSdk
|
||||||
|
} from '../../sdk';
|
||||||
|
import {
|
||||||
|
getOwnershipManager
|
||||||
|
} from '../../manager/users/ownership';
|
||||||
|
import rooms from '../../manager/rooms';
|
||||||
|
import tracking from './tracking';
|
||||||
|
import update from './update';
|
||||||
|
|
||||||
|
const routes = ( app: express.Application, foss: boolean, config: Config ) => {
|
||||||
|
const sdk = getLoginSdk( foss );
|
||||||
|
const ownership = getOwnershipManager( foss );
|
||||||
|
|
||||||
|
tracking.routes( app, foss );
|
||||||
|
update.routes( app, foss, config );
|
||||||
|
|
||||||
|
app.get(
|
||||||
|
'/room/create',
|
||||||
|
sdk.loginCheck(),
|
||||||
|
ownership.middleware(),
|
||||||
|
( request: express.Request, response: express.Response ) => {
|
||||||
|
if ( !request.query.room || !( /^[a-zA-Z0-9-]{3,20}/ ).test( String( request.query.room ) ) ) return response.sendStatus( 400 );
|
||||||
|
|
||||||
|
if ( rooms.create( String( request.query.room ), sdk.getUID( request )! ) )
|
||||||
|
response.sendStatus( 200 );
|
||||||
|
else
|
||||||
|
response.sendStatus( 409 );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
app.get(
|
||||||
|
'/room/:id/close',
|
||||||
|
sdk.loginCheck(),
|
||||||
|
( request: express.Request, response: express.Response ) => {
|
||||||
|
if ( typeof request.params.room !== 'string' ) return response.sendStatus( 400 );
|
||||||
|
|
||||||
|
if ( rooms.close( String( request.query.room ), sdk.getUID( request )! ) )
|
||||||
|
response.sendStatus( 200 );
|
||||||
|
else
|
||||||
|
response.sendStatus( 500 );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
routes
|
||||||
|
};
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import corsManager from '../../corsManager';
|
||||||
|
import express from 'express';
|
||||||
|
import {
|
||||||
|
getLoginSdk
|
||||||
|
} from '../../sdk';
|
||||||
|
import rooms from '../../manager/rooms';
|
||||||
|
import {
|
||||||
|
sseMiddleware
|
||||||
|
} from '../../manager/rooms/sse';
|
||||||
|
|
||||||
|
const tackingUpdate = ( message: string ) => {
|
||||||
|
return ( request: express.Request, response: express.Response ) => {
|
||||||
|
if ( typeof request.params.id === 'string' ) {
|
||||||
|
if ( rooms.sendTrackingUpdate( request.params.id, message ) )
|
||||||
|
response.sendStatus( 200 );
|
||||||
|
else
|
||||||
|
response.sendStatus( 500 );
|
||||||
|
} else
|
||||||
|
response.sendStatus( 400 );
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const routes = ( app: express.Application, foss: boolean ) => {
|
||||||
|
const sdk = getLoginSdk( foss );
|
||||||
|
|
||||||
|
app.get(
|
||||||
|
'/room/:id/tracking/exit',
|
||||||
|
corsManager.middleware( false ),
|
||||||
|
tackingUpdate( 'exit' )
|
||||||
|
);
|
||||||
|
|
||||||
|
app.get(
|
||||||
|
'/room/:id/tracking/ping',
|
||||||
|
corsManager.middleware( false ),
|
||||||
|
tackingUpdate( 'ping' )
|
||||||
|
);
|
||||||
|
|
||||||
|
app.get(
|
||||||
|
'/room/:id/admin',
|
||||||
|
corsManager.middleware( false ),
|
||||||
|
sdk.loginCheck(),
|
||||||
|
sseMiddleware( 'trackingClient' )
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
routes
|
||||||
|
};
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
import {
|
||||||
|
Config
|
||||||
|
} from '../../dtype/config';
|
||||||
|
import bodyParser from 'body-parser';
|
||||||
|
import corsManager from '../../corsManager';
|
||||||
|
import express from 'express';
|
||||||
|
import {
|
||||||
|
getLoginSdk
|
||||||
|
} from '../../sdk';
|
||||||
|
import logger from '../../logger';
|
||||||
|
import rooms from '../../manager/rooms';
|
||||||
|
import {
|
||||||
|
sseMiddleware
|
||||||
|
} from '../../manager/rooms/sse';
|
||||||
|
|
||||||
|
const routes = ( app: express.Application, foss: boolean, config: Config ) => {
|
||||||
|
const sdk = getLoginSdk( foss );
|
||||||
|
|
||||||
|
app.get( '/room/:id/connect', corsManager.middleware( false ), sseMiddleware( 'client', config ) );
|
||||||
|
|
||||||
|
app.get( '/room/:id/poll', corsManager.middleware( false ), ( request: express.Request, response: express.Response ) => {
|
||||||
|
if ( typeof request.params.id !== 'string' )
|
||||||
|
return response.sendStatus( 400 );
|
||||||
|
|
||||||
|
const room = rooms.get( request.params.id );
|
||||||
|
|
||||||
|
if ( !room ) response.sendStatus( 404 );
|
||||||
|
|
||||||
|
const lastRequest = parseInt( String( request.query.last ) ) ?? 0;
|
||||||
|
|
||||||
|
response.send(
|
||||||
|
JSON.stringify( {
|
||||||
|
'state': room?.state,
|
||||||
|
'playlist': ( lastRequest < room!.playlist!.lastUpdate || isNaN( lastRequest ) ) ? room!.playlist.playlist : undefined
|
||||||
|
} )
|
||||||
|
);
|
||||||
|
} );
|
||||||
|
|
||||||
|
app.options( '/room/:id/update/playlist', corsManager.middleware( false ) );
|
||||||
|
app.post(
|
||||||
|
'/room/:id/update/playlist',
|
||||||
|
corsManager.middleware( false ),
|
||||||
|
sdk.loginCheck(),
|
||||||
|
bodyParser.json(),
|
||||||
|
( request: express.Request, response: express.Response ) => {
|
||||||
|
if ( typeof request.params.id !== 'string' )
|
||||||
|
return response.sendStatus( 400 );
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ( rooms.updatePlaylist(
|
||||||
|
request.params.id,
|
||||||
|
sdk.getUID( request )!,
|
||||||
|
request.body.playlist ?? []
|
||||||
|
) )
|
||||||
|
response.sendStatus( 200 );
|
||||||
|
else
|
||||||
|
response.sendStatus( 400 );
|
||||||
|
} catch ( err ) {
|
||||||
|
logger.error( 'Failed sending updated playlists with error', err );
|
||||||
|
response.sendStatus( 500 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
app.options( '/room/:id/update/state', corsManager.middleware( false ) );
|
||||||
|
app.post(
|
||||||
|
'/room/:id/update/state',
|
||||||
|
corsManager.middleware( false ),
|
||||||
|
sdk.loginCheck(),
|
||||||
|
bodyParser.json(),
|
||||||
|
( request: express.Request, response: express.Response ) => {
|
||||||
|
if ( typeof request.params.id !== 'string' ) {
|
||||||
|
return response.sendStatus( 400 );
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ( rooms.updateState(
|
||||||
|
request.params.id,
|
||||||
|
sdk.getUID( request )!,
|
||||||
|
request.body.playing ?? false,
|
||||||
|
request.body.index ?? -1,
|
||||||
|
request.body.start ?? new Date().getTime(),
|
||||||
|
request.body.offset ?? 0
|
||||||
|
) )
|
||||||
|
response.sendStatus( 200 );
|
||||||
|
else
|
||||||
|
response.sendStatus( 400 );
|
||||||
|
} catch ( err ) {
|
||||||
|
logger.error( 'Failed sending updated state with error', err );
|
||||||
|
response.sendStatus( 500 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
routes
|
||||||
|
};
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import {
|
||||||
|
Playlist,
|
||||||
|
UserPlaylistFile
|
||||||
|
} from '../../dtype/file';
|
||||||
|
import {
|
||||||
|
getUserFile,
|
||||||
|
writeUserFile
|
||||||
|
} from '../../manager/users';
|
||||||
|
import bodyParser from 'body-parser';
|
||||||
|
import express from 'express';
|
||||||
|
import {
|
||||||
|
getLoginSdk
|
||||||
|
} from '../../sdk';
|
||||||
|
import {
|
||||||
|
getOwnershipManager
|
||||||
|
} from '../../manager/users/ownership';
|
||||||
|
import logger from '../../logger';
|
||||||
|
|
||||||
|
const routes = ( app: express.Application, foss: boolean ) => {
|
||||||
|
const sdk = getLoginSdk( foss );
|
||||||
|
const ownership = getOwnershipManager( foss );
|
||||||
|
|
||||||
|
app.get( '/user/owned', sdk.loginCheck(), async ( request: express.Request, response: express.Response ) => {
|
||||||
|
if ( await ownership.getOwned( request ) )
|
||||||
|
response.send( true );
|
||||||
|
else
|
||||||
|
response.send( true );
|
||||||
|
} );
|
||||||
|
|
||||||
|
app.get(
|
||||||
|
'/user/playlists',
|
||||||
|
sdk.loginCheck(),
|
||||||
|
async ( request: express.Request, response: express.Response ) => {
|
||||||
|
try {
|
||||||
|
const playlists = await getUserFile( sdk.getUID( request )! );
|
||||||
|
|
||||||
|
response.send( JSON.stringify( playlists.playlists ) );
|
||||||
|
} catch ( e ) {
|
||||||
|
logger.error( 'Failed retrieving user file with error', e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
app.post(
|
||||||
|
'/user/playlists',
|
||||||
|
sdk.loginCheck(),
|
||||||
|
ownership.middleware(),
|
||||||
|
bodyParser.json(),
|
||||||
|
async ( request: express.Request, response: express.Response ) => {
|
||||||
|
try {
|
||||||
|
const contents: UserPlaylistFile = {
|
||||||
|
'playlists': request.body as Playlist[],
|
||||||
|
'userid': sdk.getUID( request )!,
|
||||||
|
'version': '1'
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
await writeUserFile( contents.userid, contents );
|
||||||
|
response.sendStatus( 200 );
|
||||||
|
} catch ( e ) {
|
||||||
|
logger.error( 'Failed updating user playlists', e );
|
||||||
|
response.sendStatus( 500 );
|
||||||
|
}
|
||||||
|
} catch ( e ) {
|
||||||
|
logger.error( 'Failed retrieving user file with error', e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
routes
|
||||||
|
};
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import loginSdk from '@janishutz/login-sdk-server';
|
||||||
|
import loginSdkStub from '@janishutz/login-sdk-server-stubs';
|
||||||
|
import storeSdk from '@janishutz/store-sdk';
|
||||||
|
import storeSdkStub from './store-sdk-stub';
|
||||||
|
|
||||||
|
export const getLoginSdk = ( foss: boolean ) => {
|
||||||
|
if ( foss ) return loginSdkStub;
|
||||||
|
else return loginSdk;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getStoreSdk = ( foss: boolean ) => {
|
||||||
|
if ( foss ) return storeSdkStub;
|
||||||
|
else return storeSdk;
|
||||||
|
};
|
||||||
@@ -1,15 +1,30 @@
|
|||||||
|
interface StoreSDKConfig {
|
||||||
|
'backendURL': string;
|
||||||
|
'signingSecret': string;
|
||||||
|
'name': string;
|
||||||
|
'loglevel': 'debug' | 'info' | 'log' | 'warn' | 'error' | 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SubscriptionData {
|
||||||
|
'id': string;
|
||||||
|
'status': string;
|
||||||
|
'expires': number;
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
const getSubscriptions = ( _uid: string ) => {
|
const getSubscriptions = async ( _uid: string ): Promise<SubscriptionData[]> => {
|
||||||
return [
|
return [ {
|
||||||
{
|
'id': 'com.janishutz.MusicPlayer.subscription',
|
||||||
'id': 'com.janishutz.MusicPlayer.subscription',
|
'expires': new Date().getTime() + 200000,
|
||||||
'expires': new Date().getTime() + 200000,
|
'status': 'active'
|
||||||
'status': true
|
} ];
|
||||||
}
|
};
|
||||||
];
|
|
||||||
|
const configure = ( config: StoreSDKConfig ) => {
|
||||||
|
console.log( config );
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getSubscriptions,
|
getSubscriptions,
|
||||||
|
configure
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import crypto from 'node:crypto';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a token for e.g. login, etc
|
||||||
|
* @param length - The number of characters of the token
|
||||||
|
* @returns The generated token
|
||||||
|
*/
|
||||||
|
export const generateToken = ( length: number ): string => {
|
||||||
|
let token = '';
|
||||||
|
|
||||||
|
const min = 45;
|
||||||
|
const max = 122;
|
||||||
|
|
||||||
|
for ( let i = 0; i < length; i++ ) {
|
||||||
|
const buf = new Uint8Array( 1 );
|
||||||
|
|
||||||
|
crypto.getRandomValues( buf );
|
||||||
|
let randomNumber = Math.floor( ( buf[ 0 ] / 256 * ( max - min ) ) + min );
|
||||||
|
|
||||||
|
while (
|
||||||
|
( 58 < randomNumber && randomNumber < 63 )
|
||||||
|
|| ( 90 < randomNumber && randomNumber < 95 )
|
||||||
|
|| ( 95 < randomNumber && randomNumber < 97 )
|
||||||
|
) {
|
||||||
|
const buf = new Uint8Array( 1 );
|
||||||
|
|
||||||
|
crypto.getRandomValues( buf );
|
||||||
|
randomNumber = Math.floor( ( buf[ 0 ] / 256 * ( max - min ) ) + min );
|
||||||
|
}
|
||||||
|
|
||||||
|
token += String.fromCharCode( randomNumber );
|
||||||
|
}
|
||||||
|
|
||||||
|
return token;
|
||||||
|
};
|
||||||
+17
-12
@@ -1,13 +1,18 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"allowJs": true,
|
"rootDir": "./src",
|
||||||
"target": "ES6",
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
"target": "ES6",
|
||||||
"allowSyntheticDefaultImports": true,
|
"skipLibCheck": true,
|
||||||
"types": ["node"],
|
"allowSyntheticDefaultImports": true,
|
||||||
"module": "NodeNext",
|
"types": [
|
||||||
"moduleResolution": "NodeNext"
|
"node"
|
||||||
},
|
],
|
||||||
"include": [ "./src/**/*" ],
|
"module": "NodeNext",
|
||||||
}
|
"moduleResolution": "NodeNext"
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"./src/**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
FROM node:25-alpine3.21 AS build
|
||||||
|
|
||||||
|
# Frontend Build stage
|
||||||
|
WORKDIR /usr/src/build
|
||||||
|
|
||||||
|
COPY . /usr/src/build
|
||||||
|
|
||||||
|
RUN npm i
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Build final image
|
||||||
|
FROM nginx AS prod
|
||||||
|
COPY --from=build /usr/src/build/dist /usr/share/nginx/html
|
||||||
|
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||||
|
EXPOSE 3000
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# MusicPlayer Webapp
|
||||||
|
More notes to come
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
Generated
+744
@@ -0,0 +1,744 @@
|
|||||||
|
import eslint from '@eslint/js';
|
||||||
|
import globals from 'globals';
|
||||||
|
import stylistic from '@stylistic/eslint-plugin';
|
||||||
|
import tseslint from 'typescript-eslint';
|
||||||
|
import typescript from '@typescript-eslint/eslint-plugin';
|
||||||
|
import vue from 'eslint-plugin-vue';
|
||||||
|
|
||||||
|
const style = {
|
||||||
|
'plugins': {
|
||||||
|
'@stylistic': stylistic,
|
||||||
|
'@stylistic/js': stylistic,
|
||||||
|
'@stylistic/ts': stylistic
|
||||||
|
},
|
||||||
|
'files': [
|
||||||
|
'**/*.ts',
|
||||||
|
'**/*.js',
|
||||||
|
'**/*.mjs',
|
||||||
|
'**/*.cjs',
|
||||||
|
'**/*.tsx',
|
||||||
|
'**/*.jsx'
|
||||||
|
],
|
||||||
|
'rules': {
|
||||||
|
'sort-imports': [
|
||||||
|
'warn',
|
||||||
|
{
|
||||||
|
'ignoreCase': false,
|
||||||
|
'ignoreDeclarationSort': false,
|
||||||
|
'ignoreMemberSort': false,
|
||||||
|
'memberSyntaxSortOrder': [
|
||||||
|
'none',
|
||||||
|
'all',
|
||||||
|
'multiple',
|
||||||
|
'single'
|
||||||
|
],
|
||||||
|
'allowSeparatedGroups': false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
// Formatting
|
||||||
|
'@stylistic/array-bracket-newline': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'multiline': false,
|
||||||
|
'minItems': 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/array-bracket-spacing': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/array-element-newline': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'consistent': false,
|
||||||
|
'multiline': false,
|
||||||
|
'minItems': 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/arrow-parens': [
|
||||||
|
'error',
|
||||||
|
'as-needed'
|
||||||
|
],
|
||||||
|
'@stylistic/arrow-spacing': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'before': true,
|
||||||
|
'after': true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/block-spacing': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/brace-style': [
|
||||||
|
'error',
|
||||||
|
'1tbs',
|
||||||
|
{
|
||||||
|
'allowSingleLine': false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/comma-dangle': [
|
||||||
|
'error',
|
||||||
|
'never'
|
||||||
|
],
|
||||||
|
'@stylistic/comma-spacing': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'before': false,
|
||||||
|
'after': true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/comma-style': [
|
||||||
|
'error',
|
||||||
|
'last'
|
||||||
|
],
|
||||||
|
'@stylistic/dot-location': [
|
||||||
|
'error',
|
||||||
|
'property'
|
||||||
|
],
|
||||||
|
'@stylistic/function-call-argument-newline': [
|
||||||
|
'error',
|
||||||
|
'consistent'
|
||||||
|
],
|
||||||
|
'@stylistic/function-call-spacing': [
|
||||||
|
'error',
|
||||||
|
'never'
|
||||||
|
],
|
||||||
|
'@stylistic/function-paren-newline': [
|
||||||
|
'error',
|
||||||
|
'multiline-arguments'
|
||||||
|
],
|
||||||
|
'@stylistic/implicit-arrow-linebreak': [
|
||||||
|
'error',
|
||||||
|
'beside'
|
||||||
|
],
|
||||||
|
'@stylistic/indent': [
|
||||||
|
'error',
|
||||||
|
4
|
||||||
|
],
|
||||||
|
'@stylistic/indent-binary-ops': [
|
||||||
|
'error',
|
||||||
|
4
|
||||||
|
],
|
||||||
|
'@stylistic/key-spacing': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'beforeColon': false,
|
||||||
|
'afterColon': true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/keyword-spacing': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'before': true,
|
||||||
|
'after': true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/lines-between-class-members': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/max-len': [
|
||||||
|
'warn',
|
||||||
|
{
|
||||||
|
'code': 140,
|
||||||
|
'comments': 160,
|
||||||
|
'ignoreComments': false,
|
||||||
|
'ignoreUrls': true,
|
||||||
|
'ignoreStrings': true,
|
||||||
|
'ignoreTemplateLiterals': true,
|
||||||
|
'ignoreRegExpLiterals': true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/max-statements-per-line': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'max': 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/multiline-ternary': [
|
||||||
|
'error',
|
||||||
|
'always-multiline'
|
||||||
|
],
|
||||||
|
'@stylistic/new-parens': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/newline-per-chained-call': 'error',
|
||||||
|
'@stylistic/no-confusing-arrow': 'error',
|
||||||
|
'@stylistic/no-extra-parens': [
|
||||||
|
'error',
|
||||||
|
'all',
|
||||||
|
{
|
||||||
|
'nestedBinaryExpressions': false,
|
||||||
|
'ternaryOperandBinaryExpressions': false,
|
||||||
|
'ignoreJSX': 'multi-line',
|
||||||
|
'nestedConditionalExpressions': false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/no-extra-semi': 'error',
|
||||||
|
'@stylistic/no-floating-decimal': 'error',
|
||||||
|
'@stylistic/no-mixed-operators': 'error',
|
||||||
|
'@stylistic/no-mixed-spaces-and-tabs': 'error',
|
||||||
|
'@stylistic/no-multi-spaces': 'error',
|
||||||
|
'@stylistic/no-multiple-empty-lines': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'max': 3,
|
||||||
|
'maxEOF': 2
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/no-tabs': 'error',
|
||||||
|
'@stylistic/no-trailing-spaces': 'error',
|
||||||
|
'@stylistic/no-whitespace-before-property': 'error',
|
||||||
|
'@stylistic/object-curly-newline': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'multiline': true,
|
||||||
|
'minProperties': 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/object-curly-spacing': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/object-property-newline': 'error',
|
||||||
|
'@stylistic/one-var-declaration-per-line': 'error',
|
||||||
|
'@stylistic/operator-linebreak': [
|
||||||
|
'error',
|
||||||
|
'before'
|
||||||
|
],
|
||||||
|
'@stylistic/padded-blocks': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'blocks': 'never',
|
||||||
|
'classes': 'always',
|
||||||
|
'switches': 'never'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
// Padding lines. The most in-depth part of this config
|
||||||
|
'@stylistic/padding-line-between-statements': [
|
||||||
|
'error',
|
||||||
|
// Variables, Constants
|
||||||
|
{
|
||||||
|
'blankLine': 'never',
|
||||||
|
'prev': 'var',
|
||||||
|
'next': 'var'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'never',
|
||||||
|
'prev': 'let',
|
||||||
|
'next': 'let'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'never',
|
||||||
|
'prev': 'const',
|
||||||
|
'next': 'const'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'var',
|
||||||
|
'next': [
|
||||||
|
'block',
|
||||||
|
'block-like',
|
||||||
|
'break',
|
||||||
|
'cjs-export',
|
||||||
|
'cjs-import',
|
||||||
|
'class',
|
||||||
|
'const',
|
||||||
|
'continue',
|
||||||
|
'debugger',
|
||||||
|
'directive',
|
||||||
|
'do',
|
||||||
|
'empty',
|
||||||
|
'export',
|
||||||
|
'expression',
|
||||||
|
'for',
|
||||||
|
'function',
|
||||||
|
'if',
|
||||||
|
'iife',
|
||||||
|
'import',
|
||||||
|
'let',
|
||||||
|
'return',
|
||||||
|
'switch',
|
||||||
|
'throw',
|
||||||
|
'try',
|
||||||
|
'var',
|
||||||
|
'with'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'let',
|
||||||
|
'next': [
|
||||||
|
'block',
|
||||||
|
'block-like',
|
||||||
|
'break',
|
||||||
|
'cjs-export',
|
||||||
|
'cjs-import',
|
||||||
|
'class',
|
||||||
|
'const',
|
||||||
|
'continue',
|
||||||
|
'debugger',
|
||||||
|
'directive',
|
||||||
|
'do',
|
||||||
|
'empty',
|
||||||
|
'export',
|
||||||
|
'expression',
|
||||||
|
'for',
|
||||||
|
'function',
|
||||||
|
'if',
|
||||||
|
'iife',
|
||||||
|
'import',
|
||||||
|
'return',
|
||||||
|
'switch',
|
||||||
|
'throw',
|
||||||
|
'try',
|
||||||
|
'var',
|
||||||
|
'while',
|
||||||
|
'with'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'const',
|
||||||
|
'next': [
|
||||||
|
'block',
|
||||||
|
'block-like',
|
||||||
|
'break',
|
||||||
|
'cjs-export',
|
||||||
|
'cjs-import',
|
||||||
|
'class',
|
||||||
|
'continue',
|
||||||
|
'debugger',
|
||||||
|
'directive',
|
||||||
|
'do',
|
||||||
|
'empty',
|
||||||
|
'export',
|
||||||
|
'expression',
|
||||||
|
'for',
|
||||||
|
'function',
|
||||||
|
'if',
|
||||||
|
'iife',
|
||||||
|
'import',
|
||||||
|
'let',
|
||||||
|
'return',
|
||||||
|
'switch',
|
||||||
|
'throw',
|
||||||
|
'try',
|
||||||
|
'var',
|
||||||
|
'while',
|
||||||
|
'with'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
// Import
|
||||||
|
{
|
||||||
|
'blankLine': 'never',
|
||||||
|
'prev': 'import',
|
||||||
|
'next': 'import'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'never',
|
||||||
|
'prev': 'cjs-import',
|
||||||
|
'next': 'cjs-import'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': [
|
||||||
|
'block',
|
||||||
|
'block-like',
|
||||||
|
'break',
|
||||||
|
'cjs-export',
|
||||||
|
'class',
|
||||||
|
'const',
|
||||||
|
'continue',
|
||||||
|
'debugger',
|
||||||
|
'directive',
|
||||||
|
'do',
|
||||||
|
'empty',
|
||||||
|
'export',
|
||||||
|
'expression',
|
||||||
|
'for',
|
||||||
|
'function',
|
||||||
|
'if',
|
||||||
|
'iife',
|
||||||
|
'let',
|
||||||
|
'return',
|
||||||
|
'switch',
|
||||||
|
'throw',
|
||||||
|
'try',
|
||||||
|
'var',
|
||||||
|
'while',
|
||||||
|
'with'
|
||||||
|
],
|
||||||
|
'next': 'cjs-import'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'cjs-import',
|
||||||
|
'next': [
|
||||||
|
'block',
|
||||||
|
'block-like',
|
||||||
|
'break',
|
||||||
|
'cjs-export',
|
||||||
|
'class',
|
||||||
|
'const',
|
||||||
|
'continue',
|
||||||
|
'debugger',
|
||||||
|
'directive',
|
||||||
|
'do',
|
||||||
|
'empty',
|
||||||
|
'export',
|
||||||
|
'expression',
|
||||||
|
'for',
|
||||||
|
'function',
|
||||||
|
'if',
|
||||||
|
'iife',
|
||||||
|
'let',
|
||||||
|
'return',
|
||||||
|
'switch',
|
||||||
|
'throw',
|
||||||
|
'try',
|
||||||
|
'var',
|
||||||
|
'while',
|
||||||
|
'with'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': [
|
||||||
|
'block',
|
||||||
|
'block-like',
|
||||||
|
'break',
|
||||||
|
'cjs-export',
|
||||||
|
'class',
|
||||||
|
'const',
|
||||||
|
'continue',
|
||||||
|
'debugger',
|
||||||
|
'directive',
|
||||||
|
'do',
|
||||||
|
'empty',
|
||||||
|
'export',
|
||||||
|
'expression',
|
||||||
|
'for',
|
||||||
|
'function',
|
||||||
|
'if',
|
||||||
|
'iife',
|
||||||
|
'let',
|
||||||
|
'return',
|
||||||
|
'switch',
|
||||||
|
'throw',
|
||||||
|
'try',
|
||||||
|
'var',
|
||||||
|
'while',
|
||||||
|
'with'
|
||||||
|
],
|
||||||
|
'next': 'import'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'import',
|
||||||
|
'next': [
|
||||||
|
'block',
|
||||||
|
'block-like',
|
||||||
|
'break',
|
||||||
|
'cjs-export',
|
||||||
|
'class',
|
||||||
|
'const',
|
||||||
|
'continue',
|
||||||
|
'debugger',
|
||||||
|
'directive',
|
||||||
|
'do',
|
||||||
|
'empty',
|
||||||
|
'export',
|
||||||
|
'expression',
|
||||||
|
'for',
|
||||||
|
'function',
|
||||||
|
'if',
|
||||||
|
'iife',
|
||||||
|
'let',
|
||||||
|
'return',
|
||||||
|
'switch',
|
||||||
|
'throw',
|
||||||
|
'try',
|
||||||
|
'var',
|
||||||
|
'while',
|
||||||
|
'with'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
// If
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'if'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'if',
|
||||||
|
'next': '*'
|
||||||
|
},
|
||||||
|
// For
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'for'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'for',
|
||||||
|
'next': '*'
|
||||||
|
},
|
||||||
|
// While
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'while'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'while',
|
||||||
|
'next': '*'
|
||||||
|
},
|
||||||
|
// Functions
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'function'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'function',
|
||||||
|
'next': '*'
|
||||||
|
},
|
||||||
|
// Block Statements
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'block-like'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'block-like',
|
||||||
|
'next': '*'
|
||||||
|
},
|
||||||
|
// Switch
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'switch'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'switch',
|
||||||
|
'next': '*'
|
||||||
|
},
|
||||||
|
// Try-Catch
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'try'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'try',
|
||||||
|
'next': '*'
|
||||||
|
},
|
||||||
|
// Throw
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'throw'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'throw',
|
||||||
|
'next': '*'
|
||||||
|
},
|
||||||
|
// Return
|
||||||
|
{
|
||||||
|
'blankLine': 'never',
|
||||||
|
'prev': 'return',
|
||||||
|
'next': '*'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'return'
|
||||||
|
},
|
||||||
|
// Export
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'export'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'export',
|
||||||
|
'next': '*'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'cjs-export'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'cjs-export',
|
||||||
|
'next': '*'
|
||||||
|
},
|
||||||
|
// Classes
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': '*',
|
||||||
|
'next': 'class'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'blankLine': 'always',
|
||||||
|
'prev': 'class',
|
||||||
|
'next': '*'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/quote-props': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/quotes': [
|
||||||
|
'error',
|
||||||
|
'single'
|
||||||
|
],
|
||||||
|
'@stylistic/rest-spread-spacing': [
|
||||||
|
'error',
|
||||||
|
'never'
|
||||||
|
],
|
||||||
|
'@stylistic/semi': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/semi-spacing': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'before': false,
|
||||||
|
'after': true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/semi-style': [
|
||||||
|
'error',
|
||||||
|
'last'
|
||||||
|
],
|
||||||
|
'@stylistic/space-before-blocks': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/space-before-function-paren': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/space-in-parens': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/space-infix-ops': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'int32Hint': false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@stylistic/space-unary-ops': 'error',
|
||||||
|
'@stylistic/spaced-comment': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/switch-colon-spacing': 'error',
|
||||||
|
'@stylistic/template-curly-spacing': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/template-tag-spacing': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@stylistic/type-generic-spacing': 'error',
|
||||||
|
'@stylistic/type-named-tuple-spacing': 'error',
|
||||||
|
'@stylistic/wrap-iife': [
|
||||||
|
'error',
|
||||||
|
'inside'
|
||||||
|
],
|
||||||
|
'@stylistic/wrap-regex': 'error',
|
||||||
|
'@stylistic/ts/type-annotation-spacing': 'error'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @type {import('eslint').Linter.Config} */
|
||||||
|
export default tseslint.config(
|
||||||
|
// Base JavaScript rules
|
||||||
|
eslint.configs.recommended,
|
||||||
|
tseslint.configs.recommended,
|
||||||
|
style,
|
||||||
|
|
||||||
|
// Vue support (including TS and JSX inside SFCs)
|
||||||
|
{
|
||||||
|
'files': [ '**/*.vue' ],
|
||||||
|
'languageOptions': {
|
||||||
|
'sourceType': 'module',
|
||||||
|
'ecmaVersion': 'latest',
|
||||||
|
'globals': globals.browser,
|
||||||
|
'parserOptions': {
|
||||||
|
'parser': tseslint.parser
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'plugins': {
|
||||||
|
'vue': vue,
|
||||||
|
'@stylistic': stylistic,
|
||||||
|
'@stylistic/js': stylistic,
|
||||||
|
'@stylistic/ts': stylistic,
|
||||||
|
'@typescript-eslint': typescript
|
||||||
|
},
|
||||||
|
'extends': [
|
||||||
|
eslint.configs.recommended,
|
||||||
|
...vue.configs['flat/recommended']
|
||||||
|
],
|
||||||
|
'rules': {
|
||||||
|
...typescript.configs.recommended.rules,
|
||||||
|
...style.rules,
|
||||||
|
|
||||||
|
// Vue specific rules
|
||||||
|
'@stylistic/indent': 'off',
|
||||||
|
'vue/html-indent': [
|
||||||
|
'error',
|
||||||
|
4
|
||||||
|
],
|
||||||
|
'vue/html-comment-indent': [
|
||||||
|
'error',
|
||||||
|
4
|
||||||
|
],
|
||||||
|
'vue/script-indent': [
|
||||||
|
'error',
|
||||||
|
4,
|
||||||
|
{
|
||||||
|
'baseIndent': 1,
|
||||||
|
'switchCase': 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'vue/html-self-closing': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'html': {
|
||||||
|
'void': 'never',
|
||||||
|
'normal': 'never',
|
||||||
|
'component': 'always'
|
||||||
|
},
|
||||||
|
'svg': 'always',
|
||||||
|
'math': 'never'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'vue/max-attributes-per-line': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'singleline': 3,
|
||||||
|
'multiline': 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link rel="icon" href="/favicon.ico">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>MusicPlayer</title>
|
||||||
|
<script src="https://js-cdn.music.apple.com/musickit/v3/musickit.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<noscript>This application requires JavaScript to work!</noscript>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"name": "vue-project",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "run-p type-check \"build-only {@}\" --",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"build-only": "vite build",
|
||||||
|
"type-check": "vue-tsc --build"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@fortawesome/fontawesome-free": "^7.3.1",
|
||||||
|
"@fortawesome/fontawesome-svg-core": "^7.3.1",
|
||||||
|
"@fortawesome/free-regular-svg-icons": "^7.3.1",
|
||||||
|
"@globalhive/vuejs-tour": "^3.0.1",
|
||||||
|
"@janishutz/login-sdk-browser": "^1.1.0",
|
||||||
|
"@kyvg/vue3-notification": "^3.4.2",
|
||||||
|
"music-metadata": "^11.15.0",
|
||||||
|
"nprogress": "^0.2.0",
|
||||||
|
"pinia": "^4.0.2",
|
||||||
|
"vue": "^3.5.40",
|
||||||
|
"vue-router": "^5.2.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^10.0.1",
|
||||||
|
"@stylistic/eslint-plugin": "^5.10.0",
|
||||||
|
"@tsconfig/node24": "^24.0.4",
|
||||||
|
"@types/node": "^24.13.3",
|
||||||
|
"@vitejs/plugin-vue": "^6.0.8",
|
||||||
|
"@vue/tsconfig": "^0.9.1",
|
||||||
|
"eslint": "^10.9.1",
|
||||||
|
"eslint-plugin-vue": "^10.10.0",
|
||||||
|
"globals": "^17.12.0",
|
||||||
|
"musickitjs-v3-types": "^1.2.1",
|
||||||
|
"npm-run-all2": "^9.0.2",
|
||||||
|
"sass-embedded": "^1.103.1",
|
||||||
|
"typescript": "~6.0.0",
|
||||||
|
"typescript-eslint": "^8.69.0",
|
||||||
|
"vite": "^8.1.5",
|
||||||
|
"vite-plugin-vue-devtools": "^8.1.5",
|
||||||
|
"vue-tsc": "^3.3.7"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^22.18.0 || >=24.12.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,193 @@
|
|||||||
|
{
|
||||||
|
"ages": {
|
||||||
|
"below": "Orange",
|
||||||
|
"16-18": "Yellow",
|
||||||
|
"18+": "Turquoise"
|
||||||
|
},
|
||||||
|
"offering": {
|
||||||
|
"big-bar": {
|
||||||
|
"offering": {
|
||||||
|
"softdrinks": {
|
||||||
|
"name": "Softdrinks",
|
||||||
|
"price": 400,
|
||||||
|
"id": "softdrinks"
|
||||||
|
},
|
||||||
|
"energy": {
|
||||||
|
"name": "Energy",
|
||||||
|
"price": 400,
|
||||||
|
"id": "energy"
|
||||||
|
},
|
||||||
|
"mate": {
|
||||||
|
"name": "Mate",
|
||||||
|
"price": 500,
|
||||||
|
"id": "mate",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"sparkly-water": {
|
||||||
|
"name": "Mineralwasser mit",
|
||||||
|
"price": 300,
|
||||||
|
"id": "sparkly-water",
|
||||||
|
"showLine": true
|
||||||
|
},
|
||||||
|
"rose": {
|
||||||
|
"name": "Rosé",
|
||||||
|
"price": 1500,
|
||||||
|
"id": "rose",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"red": {
|
||||||
|
"name": "Rotwein",
|
||||||
|
"price": 2000,
|
||||||
|
"id": "red",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"wine-glasses": {
|
||||||
|
"name": "Weingläser",
|
||||||
|
"price": 0,
|
||||||
|
"id": "wine-glasses",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"appenzeller": {
|
||||||
|
"name": "Appenzeller Vollmond",
|
||||||
|
"price": 500,
|
||||||
|
"id": "appenzeller",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"feldschloesschen": {
|
||||||
|
"name": "Feldschlösschen",
|
||||||
|
"price": 500,
|
||||||
|
"id": "feldschloesschen",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"sommersby": {
|
||||||
|
"name": "Sommersby",
|
||||||
|
"price": 500,
|
||||||
|
"id": "sommersby",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"jever-fun": {
|
||||||
|
"name": "Jever Fun",
|
||||||
|
"price": 400,
|
||||||
|
"id": "jever-fun",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"trojka-ice": {
|
||||||
|
"name": "Trojka Ice",
|
||||||
|
"price": 600,
|
||||||
|
"id": "trojka-ice",
|
||||||
|
"depot": 200,
|
||||||
|
"showLine": true
|
||||||
|
},
|
||||||
|
"vodka-red-energy": {
|
||||||
|
"name": "Vodka Rot Energy",
|
||||||
|
"price": 800,
|
||||||
|
"id": "vodka-red-energy"
|
||||||
|
},
|
||||||
|
"vodka-green-citro": {
|
||||||
|
"name": "Vodka Grün Citro",
|
||||||
|
"price": 800,
|
||||||
|
"id": "vodka-green-citro"
|
||||||
|
},
|
||||||
|
"vodka-white-energy": {
|
||||||
|
"name": "Vodka White Energy",
|
||||||
|
"price": 900,
|
||||||
|
"id": "vodka-white-energy"
|
||||||
|
},
|
||||||
|
"gin-tonic": {
|
||||||
|
"name": "Gin Tonic",
|
||||||
|
"price": 900,
|
||||||
|
"id": "gin-tonic"
|
||||||
|
},
|
||||||
|
"rum-cola": {
|
||||||
|
"name": "Rum Cola",
|
||||||
|
"price": 900,
|
||||||
|
"id": "rum-cola"
|
||||||
|
},
|
||||||
|
"whiskey-cola": {
|
||||||
|
"name": "Whiskey Cola",
|
||||||
|
"price": 900,
|
||||||
|
"id": "whiskey-cola"
|
||||||
|
},
|
||||||
|
"mate-mit-schuss": {
|
||||||
|
"name": "Mate mit Schuss",
|
||||||
|
"price": 1200,
|
||||||
|
"id": "mate-mit-schuss",
|
||||||
|
"depot": 200,
|
||||||
|
"showLine": true
|
||||||
|
},
|
||||||
|
"poseidon": {
|
||||||
|
"name": "Poseidon",
|
||||||
|
"price": 900,
|
||||||
|
"id": "poseidon"
|
||||||
|
},
|
||||||
|
"arielle": {
|
||||||
|
"name": "Arielle",
|
||||||
|
"price": 900,
|
||||||
|
"id": "arielle"
|
||||||
|
},
|
||||||
|
"pearl-driver": {
|
||||||
|
"name": "Pearl Driver",
|
||||||
|
"price": 400,
|
||||||
|
"id": "pearl-driver"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "Poseidon's Quelle",
|
||||||
|
"id": "big-bar"
|
||||||
|
},
|
||||||
|
"small-bar": {
|
||||||
|
"offering": {
|
||||||
|
"softdrinks": {
|
||||||
|
"name": "Softdrinks (Alle)",
|
||||||
|
"price": 300,
|
||||||
|
"id": "softdrinks",
|
||||||
|
"showLine": true
|
||||||
|
},
|
||||||
|
"appenzeller": {
|
||||||
|
"name": "Appenzeller Vollmond",
|
||||||
|
"price": 500,
|
||||||
|
"id": "appenzeller",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"feldschloesschen": {
|
||||||
|
"name": "Feldschlösschen",
|
||||||
|
"price": 500,
|
||||||
|
"id": "feldschloesschen",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"sommersby": {
|
||||||
|
"name": "Sommersby",
|
||||||
|
"price": 500,
|
||||||
|
"id": "sommersby",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"jever-fun": {
|
||||||
|
"name": "Jever Fun",
|
||||||
|
"price": 400,
|
||||||
|
"id": "jever-fun",
|
||||||
|
"depot": 200,
|
||||||
|
"showLine": true
|
||||||
|
},
|
||||||
|
"rose": {
|
||||||
|
"name": "Rosé",
|
||||||
|
"price": 1500,
|
||||||
|
"id": "rose",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"red": {
|
||||||
|
"name": "Rotwein",
|
||||||
|
"price": 2000,
|
||||||
|
"id": "red",
|
||||||
|
"depot": 200
|
||||||
|
},
|
||||||
|
"wine-glasses": {
|
||||||
|
"name": "Weingläser",
|
||||||
|
"price": 0,
|
||||||
|
"id": "wine-glasses",
|
||||||
|
"depot": 200
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"name": "Seepferdchenbar",
|
||||||
|
"id": "small-bar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
+231
@@ -0,0 +1,231 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
Notifications
|
||||||
|
} from '@kyvg/vue3-notification';
|
||||||
|
import {
|
||||||
|
RouterView
|
||||||
|
} from 'vue-router';
|
||||||
|
import {
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
const theme = ref( 'dark' );
|
||||||
|
|
||||||
|
const changeTheme = () => {
|
||||||
|
if ( theme.value === 'moon' ) {
|
||||||
|
document.documentElement.classList.remove( 'dark' );
|
||||||
|
document.documentElement.classList.add( 'light' );
|
||||||
|
localStorage.setItem( 'theme', 'light' );
|
||||||
|
theme.value = 'sun';
|
||||||
|
} else if ( theme.value === 'sun' ) {
|
||||||
|
document.documentElement.classList.remove( 'light' );
|
||||||
|
document.documentElement.classList.add( 'dark' );
|
||||||
|
localStorage.setItem( 'theme', 'dark' );
|
||||||
|
theme.value = 'moon';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
theme.value = localStorage.getItem( 'theme' ) ?? '';
|
||||||
|
|
||||||
|
if ( window.matchMedia( '(prefers-color-scheme: dark)' ).matches || theme.value === 'dark' ) {
|
||||||
|
document.documentElement.classList.add( 'dark' );
|
||||||
|
theme.value = 'moon';
|
||||||
|
} else {
|
||||||
|
document.documentElement.classList.add( 'light' );
|
||||||
|
theme.value = 'sun';
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<notifications
|
||||||
|
position="top center"
|
||||||
|
:duration="5000"
|
||||||
|
class="notifications"
|
||||||
|
style="top: 20px;"
|
||||||
|
width="400px"
|
||||||
|
:max="3"
|
||||||
|
/>
|
||||||
|
<button id="themeSelector" title="Toggle between light and dark mode" @click="changeTheme();">
|
||||||
|
<i :class="['fa-solid', 'fa-' + theme]"></i>
|
||||||
|
</button>
|
||||||
|
<router-view id="main-view" v-slot="{ Component, route }">
|
||||||
|
<transition :name="route.meta.transition ? String( route.meta.transition ) : 'fade'" mode="out-in">
|
||||||
|
<component :is="Component" />
|
||||||
|
</transition>
|
||||||
|
</router-view>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
body {
|
||||||
|
background-color: var( --background-color );
|
||||||
|
}
|
||||||
|
|
||||||
|
.notifications {
|
||||||
|
.vue-notification {
|
||||||
|
padding: 20px;
|
||||||
|
.notification-title {
|
||||||
|
font-size: 1rem;
|
||||||
|
}
|
||||||
|
.notification-text {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:root, :root.light {
|
||||||
|
--primary-color: #0a1520;
|
||||||
|
--secondary-color: white;
|
||||||
|
--background-color: rgb(221, 221, 221);
|
||||||
|
--nav-background: white;
|
||||||
|
--accent-color: #00457a;
|
||||||
|
--popup-color: rgb(224, 224, 224);
|
||||||
|
--overlay-color: rgba(0, 0, 0, 0.7);
|
||||||
|
--PI: 3.14159265358979;
|
||||||
|
--gray-color: rgb(53, 53, 53);
|
||||||
|
--footer-background: rgb(233, 233, 233);
|
||||||
|
--accent-background: rgb(195, 235, 243);
|
||||||
|
--loading-color: rgb(167, 167, 167);
|
||||||
|
--slider-color: rgb(119, 132, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
:root.dark {
|
||||||
|
--primary-color: white;
|
||||||
|
--secondary-color: black;
|
||||||
|
--background-color: rgb(32, 32, 32);
|
||||||
|
--nav-background: rgb(54, 54, 54);
|
||||||
|
--popup-color: rgb(58, 58, 58);
|
||||||
|
--accent-color: #007ddd;
|
||||||
|
--overlay-color: rgba(104, 104, 104, 0.575);
|
||||||
|
--gray-color: rgb(207, 207, 207);
|
||||||
|
--footer-background: rgb(53, 53, 53);
|
||||||
|
--accent-background: rgb(24, 12, 58);
|
||||||
|
--loading-color: rgb(65, 65, 65);
|
||||||
|
--slider-color: rgb(119, 132, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media ( prefers-color-scheme: dark ) {
|
||||||
|
:root {
|
||||||
|
--primary-color: white;
|
||||||
|
--secondary-color: black;
|
||||||
|
--background-color: rgb(32, 32, 32);
|
||||||
|
--nav-background: rgb(54, 54, 54);
|
||||||
|
--popup-color: rgb(58, 58, 58);
|
||||||
|
--accent-color: #007ddd;
|
||||||
|
--overlay-color: rgba(104, 104, 104, 0.575);
|
||||||
|
--gray-color: rgb(207, 207, 207);
|
||||||
|
--footer-background: rgb(53, 53, 53);
|
||||||
|
--accent-background: rgb(24, 12, 58);
|
||||||
|
--loading-color: rgb(65, 65, 65);
|
||||||
|
--slider-color: rgb(119, 132, 255);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
::selection {
|
||||||
|
background-color: #7c8cec;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 17px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#app {
|
||||||
|
transition: 0.5s;
|
||||||
|
background-color: var( --background-color );
|
||||||
|
font-family: 'Plus Jakarta Sans', sans-serif;
|
||||||
|
/* font-family: Avenir, Helvetica, Arial, sans-serif; */
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
text-align: center;
|
||||||
|
color: var( --primary-color );
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex-grow: 1;
|
||||||
|
width: 100vw;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#main-view {
|
||||||
|
min-height: 60vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scale-enter-active,
|
||||||
|
.scale-leave-active {
|
||||||
|
transition: all 0.5s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scale-enter-from,
|
||||||
|
.scale-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale(0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fade-enter-active,
|
||||||
|
.fade-leave-active {
|
||||||
|
transition: opacity 0.4s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fade-enter-from,
|
||||||
|
.fade-leave-to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-outlined {
|
||||||
|
font-variation-settings:
|
||||||
|
'FILL' 0,
|
||||||
|
'wght' 400,
|
||||||
|
'GRAD' 0,
|
||||||
|
'opsz' 48
|
||||||
|
}
|
||||||
|
|
||||||
|
.clr-open {
|
||||||
|
border: black solid 1px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#themeSelector {
|
||||||
|
position: fixed;
|
||||||
|
top: 10px;
|
||||||
|
left: 10px;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: var( --primary-color );
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.fancy-button {
|
||||||
|
text-decoration: none;
|
||||||
|
color: white;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 20px;
|
||||||
|
border: none;
|
||||||
|
background: linear-gradient( 45deg, rgb(0, 33, 139), rgb(151, 0, 0) );
|
||||||
|
font-size: larger;
|
||||||
|
transition: all 0.5s;
|
||||||
|
background-size: 150%;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancy-button:hover {
|
||||||
|
border-radius: 5px;
|
||||||
|
background-position: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancy-button-inactive {
|
||||||
|
background: linear-gradient( 45deg, rgba(0, 33, 139, 0.6), rgba(151, 0, 0, 0.6) );
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fancy-button-inactive:hover {
|
||||||
|
border-radius: 20px;
|
||||||
|
background-position: 0px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
<script setup lang="ts" generic="T">
|
||||||
|
import {
|
||||||
|
computed,
|
||||||
|
ref,
|
||||||
|
useTemplateRef
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
const array = defineModel<T[]>( {
|
||||||
|
'required': true
|
||||||
|
} );
|
||||||
|
|
||||||
|
defineSlots<{
|
||||||
|
default( props: {
|
||||||
|
'item': T,
|
||||||
|
'index': number
|
||||||
|
} ): void
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
( e: 'dropped' ): void
|
||||||
|
}>();
|
||||||
|
const scrollContainer = useTemplateRef( 'scroll-container' );
|
||||||
|
const movingIdx = ref( -1 );
|
||||||
|
const movingCurrentIdx = ref( -1 );
|
||||||
|
const movableSize = ref( -1 );
|
||||||
|
const offset = ref( -1 );
|
||||||
|
|
||||||
|
let mover = -1;
|
||||||
|
let moveSpeed = 0;
|
||||||
|
|
||||||
|
const start = ( ev: MouseEvent, idx: number ) => {
|
||||||
|
if ( array.value.length < 2 ) return;
|
||||||
|
|
||||||
|
movableSize.value = document.getElementById( 'movable-' + idx )!.scrollHeight;
|
||||||
|
offset.value = ev.y - ( movableSize.value / 2 );
|
||||||
|
movingIdx.value = idx;
|
||||||
|
movingCurrentIdx.value = idx;
|
||||||
|
};
|
||||||
|
|
||||||
|
const move = ( ev: MouseEvent ) => {
|
||||||
|
if ( movingIdx.value < 0 ) return;
|
||||||
|
|
||||||
|
offset.value = ev.y - ( movableSize.value / 2 );
|
||||||
|
const relToContainer = ev.y - scrollContainer.value!.offsetTop;
|
||||||
|
const height = scrollContainer.value!.offsetHeight;
|
||||||
|
|
||||||
|
// Scrolling up and down
|
||||||
|
if ( relToContainer < 50 ) {
|
||||||
|
if ( relToContainer < 0 )
|
||||||
|
moveSpeed = -20;
|
||||||
|
else
|
||||||
|
moveSpeed = -Math.ceil( Math.max( 1, Math.min( 5 / relToContainer, 10 ) ) );
|
||||||
|
|
||||||
|
startTracker();
|
||||||
|
} else if ( relToContainer > height - 50 ) {
|
||||||
|
if ( height - relToContainer < 0 )
|
||||||
|
moveSpeed = 20;
|
||||||
|
else
|
||||||
|
moveSpeed = Math.ceil( Math.max( 1, Math.min( 5 / ( height - relToContainer ), 10 ) ) );
|
||||||
|
|
||||||
|
startTracker();
|
||||||
|
} else {
|
||||||
|
if ( mover >= 0 ) {
|
||||||
|
try {
|
||||||
|
clearInterval( mover );
|
||||||
|
mover = -1;
|
||||||
|
} catch { /* empty */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine current index to insert
|
||||||
|
const percentage = ( relToContainer + scrollContainer.value!.scrollTop ) / scrollContainer.value!.scrollHeight;
|
||||||
|
const newIdx = Math.min( Math.max( Math.round( percentage * array.value.length ), 0 ), array.value.length - 1 );
|
||||||
|
|
||||||
|
if ( newIdx !== movingIdx.value )
|
||||||
|
movingCurrentIdx.value = newIdx;
|
||||||
|
else
|
||||||
|
movingCurrentIdx.value = movingIdx.value;
|
||||||
|
};
|
||||||
|
|
||||||
|
const startTracker = () => {
|
||||||
|
if ( mover < 0 ) {
|
||||||
|
mover = setInterval( () => {
|
||||||
|
scrollContainer.value!.scrollTop += moveSpeed;
|
||||||
|
}, 100 );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const end = () => {
|
||||||
|
offset.value = -1;
|
||||||
|
|
||||||
|
try {
|
||||||
|
clearInterval( mover );
|
||||||
|
mover = -1;
|
||||||
|
} catch { /* empty */ }
|
||||||
|
|
||||||
|
const before = array.value.slice( 0, movingIdx.value );
|
||||||
|
const after = array.value.slice( movingIdx.value + 1 );
|
||||||
|
const el = array.value[ movingIdx.value ]!;
|
||||||
|
const arr = before.concat( after );
|
||||||
|
|
||||||
|
arr.splice( movingCurrentIdx.value, 0, el );
|
||||||
|
array.value = arr;
|
||||||
|
movingIdx.value = -1;
|
||||||
|
movingCurrentIdx.value = -1;
|
||||||
|
|
||||||
|
emit( 'dropped' );
|
||||||
|
};
|
||||||
|
|
||||||
|
const style = computed( () => {
|
||||||
|
return ( index: number ) => {
|
||||||
|
if ( movingIdx.value === array.value.length - 1 && movingIdx.value === index + 1
|
||||||
|
&& movingCurrentIdx.value === movingIdx.value )
|
||||||
|
return `margin-bottom: ${ movableSize.value }px;`;
|
||||||
|
|
||||||
|
if ( movingIdx.value >= 0 ) {
|
||||||
|
if ( movingIdx.value === index ) {
|
||||||
|
// Current item is moved
|
||||||
|
return `top: ${ offset.value }px;`;
|
||||||
|
} else {
|
||||||
|
// Current item is not moved
|
||||||
|
if ( movingCurrentIdx.value === array.value.length - 1 && index === movingCurrentIdx.value ) {
|
||||||
|
// Create gap below
|
||||||
|
return `margin-bottom: ${ movableSize.value }px;`;
|
||||||
|
} else if ( movingCurrentIdx.value === index
|
||||||
|
|| ( movingCurrentIdx.value === index - 1 && movingIdx.value == index - 1 ) ) {
|
||||||
|
// Create a gap above
|
||||||
|
return `margin-top: ${ movableSize.value }px;`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
} );
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div ref="scroll-container" class="sortable-list">
|
||||||
|
<div
|
||||||
|
v-if="movingIdx >= 0"
|
||||||
|
class="grip-target"
|
||||||
|
@mousemove="move"
|
||||||
|
@mouseleave="end"
|
||||||
|
@mouseup="end"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-for="(item, index) in array"
|
||||||
|
:id="'movable-' + index"
|
||||||
|
:key="index"
|
||||||
|
:class="[ 'movable', movingIdx === index ? 'moving' : undefined ]"
|
||||||
|
:style="style(index)"
|
||||||
|
>
|
||||||
|
<slot :item="item" :index="index"></slot>
|
||||||
|
<i class="fa-solid fa-grip-vertical" @mousedown="( e ) => start( e, index )"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@use '@/scss/components/sortablelist.scss'
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
queue,
|
||||||
|
queueIdx
|
||||||
|
} from '@/ts/player/state';
|
||||||
|
import CurrentSong from '../player/CurrentSong.vue';
|
||||||
|
import PlayerControls from '../player/PlayerControls.vue';
|
||||||
|
import QueueViewer from '../player/QueueViewer.vue';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="player">
|
||||||
|
<div
|
||||||
|
class="panel"
|
||||||
|
>
|
||||||
|
<div class="current-song-wrapper">
|
||||||
|
<CurrentSong
|
||||||
|
v-model="queue[queueIdx]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<PlayerControls />
|
||||||
|
</div>
|
||||||
|
<div class="panel">
|
||||||
|
<QueueViewer />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.player {
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
width: 45%;
|
||||||
|
margin-left: 2.5%;
|
||||||
|
margin-right: 2.5%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
>.current-song-wrapper {
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
max-height: calc(100% - 15rem);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import AssociationView from '@/composables/AssociationView.vue';
|
||||||
|
import PlayerComponent from './PlayerComponent.vue';
|
||||||
|
import SmallPlayerComponent from './SmallPlayerComponent.vue';
|
||||||
|
import {
|
||||||
|
fullPlayer
|
||||||
|
} from '@/ts/player/state';
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
fullPlayer.value = false;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="player-wrapper">
|
||||||
|
<AssociationView />
|
||||||
|
<SmallPlayerComponent v-model="fullPlayer" />
|
||||||
|
<div :class="['player-container', fullPlayer ? undefined : 'hidden']">
|
||||||
|
<i class="fa-solid fa-xmark" @click="close"></i>
|
||||||
|
<PlayerComponent />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.player-container {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
background-color: var(--secondary-color);
|
||||||
|
transition: bottom 1s ease;
|
||||||
|
transition-delay: 0.25s;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
&.hidden {
|
||||||
|
transition-delay: 0s;
|
||||||
|
bottom: -100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.fa-xmark {
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 10px;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import UserPlaylists from '../playlists/UserPlaylists.vue';
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="playlist-main">
|
||||||
|
<h1>Playlists</h1>
|
||||||
|
<UserPlaylists />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.playlist-main {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
type ComputedRef,
|
||||||
|
computed
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
isPlaying,
|
||||||
|
queue,
|
||||||
|
queueIdx
|
||||||
|
} from '@/ts/player/state';
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
import {
|
||||||
|
beautifyTime
|
||||||
|
} from '@/ts/util/time';
|
||||||
|
import {
|
||||||
|
playbackPercentage
|
||||||
|
} from '@/ts/player/status-tracking';
|
||||||
|
import player from '@/ts/player';
|
||||||
|
|
||||||
|
const closed = defineModel<boolean>( {
|
||||||
|
'required': true
|
||||||
|
} );
|
||||||
|
|
||||||
|
const open = () => {
|
||||||
|
closed.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const song: ComputedRef<Song> = computed( () => {
|
||||||
|
if ( queueIdx.value >= 0 && queue.value.length > queueIdx.value ) {
|
||||||
|
return queue.value[ queueIdx.value ]!;
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
'artwork': '',
|
||||||
|
'additional-info': '',
|
||||||
|
'artist': 'No artist',
|
||||||
|
'duration': -1,
|
||||||
|
'identifier': 'nosong-ident',
|
||||||
|
'name': 'Not Playing',
|
||||||
|
'source': 'local'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div :class="['small-player', closed ? 'hidden' : undefined]">
|
||||||
|
<div>
|
||||||
|
<img
|
||||||
|
v-if="song.artwork"
|
||||||
|
:src="song.artwork"
|
||||||
|
alt="Song cover"
|
||||||
|
class="song-cover"
|
||||||
|
>
|
||||||
|
<i v-else class="fa-solid fa-music song-cover" @click="open"></i>
|
||||||
|
<div @click="open">
|
||||||
|
<h3>{{ song.name }}</h3>
|
||||||
|
<p>{{ song.artist }}</p>
|
||||||
|
</div>
|
||||||
|
<p @click="open">
|
||||||
|
{{ beautifyTime( playbackPercentage * song.duration ) }} / {{ beautifyTime( song.duration ) }}
|
||||||
|
</p>
|
||||||
|
<i v-if="!isPlaying" class="fa-solid fa-play" @click="player.play"></i>
|
||||||
|
<i v-else class="fa-solid fa-pause" @click="player.pause"></i>
|
||||||
|
<i class="fa-solid fa-forward-step" @click="player.next"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.small-player {
|
||||||
|
background-color: var(--secondary-color);
|
||||||
|
width: 80vw;
|
||||||
|
height: 4.5rem;
|
||||||
|
position: fixed;
|
||||||
|
left: 10vw;
|
||||||
|
bottom: 15px;
|
||||||
|
border-radius: 2rem;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: bottom 0.5s ease;
|
||||||
|
transition-delay: 0.75s;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
&.hidden {
|
||||||
|
bottom: -8vh;
|
||||||
|
transition-delay: 0s;
|
||||||
|
}
|
||||||
|
|
||||||
|
>div {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: calc(100% - 6rem);
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
>.song-cover {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 3rem;
|
||||||
|
height: 3rem;
|
||||||
|
font-size: 2.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-right: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
>div {
|
||||||
|
cursor: pointer;
|
||||||
|
margin-right: auto;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: center;
|
||||||
|
flex-direction: column;
|
||||||
|
width: calc(100% - 20rem);
|
||||||
|
overflow-x: hidden;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
>h3 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
>p {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
>p {
|
||||||
|
cursor: pointer;
|
||||||
|
margin-right: 15px;
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.fa-solid {
|
||||||
|
font-size: 2rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
|
||||||
|
const song = defineModel<Song>( {
|
||||||
|
'required': false
|
||||||
|
} );
|
||||||
|
const props = defineProps<{
|
||||||
|
'showAdditionalInfo'?: boolean
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="current-song">
|
||||||
|
<div class="artwork">
|
||||||
|
<img
|
||||||
|
v-if="song?.artwork"
|
||||||
|
:src="song.artwork"
|
||||||
|
alt="Song cover"
|
||||||
|
class="song-cover"
|
||||||
|
>
|
||||||
|
<i v-else class="fa-solid fa-music song-cover"></i>
|
||||||
|
</div>
|
||||||
|
<div class="song-details">
|
||||||
|
<h1>
|
||||||
|
{{ song?.name ?? 'Not playing' }}
|
||||||
|
</h1>
|
||||||
|
<p>{{ song?.artist ?? 'No artist' }}</p>
|
||||||
|
<p v-if="props.showAdditionalInfo">
|
||||||
|
{{ song?.['additional-info'] }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.current-song {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.artwork {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
max-height: calc(100% - 9rem);
|
||||||
|
|
||||||
|
>img, .fa-solid {
|
||||||
|
height: 100%;
|
||||||
|
font-size: 40vh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.song-details {
|
||||||
|
>* {
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
computed,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
import ProgressBar from './ProgressBar.vue';
|
||||||
|
import ShareManagement from './ShareManagement.vue';
|
||||||
|
import {
|
||||||
|
beautifyTime
|
||||||
|
} from '@/ts/util/time';
|
||||||
|
import messages from '@/ts/messages';
|
||||||
|
import player from '@/ts/player';
|
||||||
|
|
||||||
|
const playbackPercentage = player.playbackPercentage;
|
||||||
|
const repeatMode = player.repeat;
|
||||||
|
const shuffleMode = player.shuffle;
|
||||||
|
const showShareMenu = ref( false );
|
||||||
|
|
||||||
|
const seek = () => {
|
||||||
|
player.seekTo( playbackPercentage.value );
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleRepeatMode = () => {
|
||||||
|
switch ( repeatMode.value ) {
|
||||||
|
case 'one':
|
||||||
|
player.setRepeat( 'all' );
|
||||||
|
break;
|
||||||
|
case 'off':
|
||||||
|
player.setRepeat( 'one' );
|
||||||
|
break;
|
||||||
|
case 'all':
|
||||||
|
player.setRepeat( 'off' );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const openShareMenu = () => {
|
||||||
|
showShareMenu.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const current = computed( () => {
|
||||||
|
return beautifyTime( player.playbackPercentage.value * player.duration.value );
|
||||||
|
} );
|
||||||
|
const duration = computed( () => {
|
||||||
|
return beautifyTime( player.duration.value );
|
||||||
|
} );
|
||||||
|
|
||||||
|
messages.useRoomWatchers();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="mp-player">
|
||||||
|
<ShareManagement v-model="showShareMenu" />
|
||||||
|
<div class="controls">
|
||||||
|
<i class="fa-solid fa-backward-step" @click="player.prev"></i>
|
||||||
|
<i class="fa-solid fa-arrow-rotate-left quick-seek" @click="player.back10"></i>
|
||||||
|
<div :class="['play-pause', player.isPlaying.value ? undefined : 'paused']">
|
||||||
|
<i class="fa-solid fa-play" @click="player.play"></i>
|
||||||
|
<i class="fa-solid fa-pause" @click="player.pause"></i>
|
||||||
|
</div>
|
||||||
|
<i class="fa-solid fa-arrow-rotate-right quick-seek" @click="player.skip10"></i>
|
||||||
|
<i class="fa-solid fa-forward-step" @click="player.next"></i>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="time">
|
||||||
|
<p class="current">
|
||||||
|
{{ current }}
|
||||||
|
</p>
|
||||||
|
<p class="duration">
|
||||||
|
{{ duration }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<ProgressBar v-model="playbackPercentage" @move-end="seek" />
|
||||||
|
<div class="bottom-bar">
|
||||||
|
<!-- FA being a POS means need to make own mods to it -->
|
||||||
|
<i
|
||||||
|
:class="[
|
||||||
|
'fa-solid',
|
||||||
|
'fa-repeat',
|
||||||
|
'repeat',
|
||||||
|
repeatMode === 'one' ? 'once' : undefined,
|
||||||
|
repeatMode === 'all' ? 'all' : undefined
|
||||||
|
]"
|
||||||
|
@click="toggleRepeatMode"
|
||||||
|
></i>
|
||||||
|
<i class="fa-solid fa-share-from-square" @click="openShareMenu"></i>
|
||||||
|
<i
|
||||||
|
:class="['fa-solid', 'fa-shuffle', shuffleMode ? 'active' : undefined]"
|
||||||
|
@click="player.setShuffle( !shuffleMode )"
|
||||||
|
></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@use '@/scss/components/player.scss';
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
useTemplateRef
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
const val = defineModel<number>( {
|
||||||
|
'required': true,
|
||||||
|
'default': 0.5
|
||||||
|
} );
|
||||||
|
const moveVal = ref( 0 );
|
||||||
|
const offset = ref( -1 );
|
||||||
|
const isMoving = ref( false );
|
||||||
|
const bar = useTemplateRef( 'bar' );
|
||||||
|
const props = defineProps<{
|
||||||
|
'disallowMove'?: boolean
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const start = ( ev: MouseEvent ) => {
|
||||||
|
if ( props.disallowMove ) return;
|
||||||
|
|
||||||
|
offset.value = bar.value!.getBoundingClientRect().x;
|
||||||
|
isMoving.value = true;
|
||||||
|
moveVal.value = ( ev.x - offset.value ) / bar.value!.clientWidth;
|
||||||
|
emit( 'move-start' );
|
||||||
|
};
|
||||||
|
|
||||||
|
const move = ( ev: MouseEvent ) => {
|
||||||
|
if ( isMoving.value ) {
|
||||||
|
moveVal.value = Math.max( 0, Math.min( ( ev.x - offset.value ) / bar.value!.clientWidth, 1 ) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const end = ( ev: MouseEvent ) => {
|
||||||
|
if ( !isMoving.value ) return;
|
||||||
|
|
||||||
|
val.value = ( ev.x - offset.value ) / bar.value!.clientWidth;
|
||||||
|
offset.value = -1;
|
||||||
|
isMoving.value = false;
|
||||||
|
emit( 'move-end' );
|
||||||
|
};
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
( e: 'move-end' ): void;
|
||||||
|
( e: 'move-start' ): void;
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="progressbar">
|
||||||
|
<div ref="bar" class="back">
|
||||||
|
<div :style="`width: ${ isMoving ? moveVal * 100 : val * 100 }%;`"></div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
:class="['click-target', offset >= 0 ? 'active' : undefined, props.disallowMove ? 'disallowed' : undefined]"
|
||||||
|
@mousedown="start"
|
||||||
|
@mousemove="move"
|
||||||
|
@mouseup="end"
|
||||||
|
@mouseleave="end"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@use '@/scss/components/progressbar.scss';
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
type Ref,
|
||||||
|
type WritableComputedRef,
|
||||||
|
computed,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
import AddSong from '../popups/AddSong.vue';
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
import SongEditor from '../popups/SongEditor.vue';
|
||||||
|
import SortableList from '../SortableList.vue';
|
||||||
|
import {
|
||||||
|
beautifyTime
|
||||||
|
} from '@/ts/util/time';
|
||||||
|
import player from '@/ts/player';
|
||||||
|
import {
|
||||||
|
queueIdx
|
||||||
|
} from '@/ts/player/state';
|
||||||
|
import {
|
||||||
|
savePlaylist
|
||||||
|
} from '@/ts/userPlaylists/save';
|
||||||
|
|
||||||
|
const queue: WritableComputedRef<Song[]> = computed( {
|
||||||
|
get () {
|
||||||
|
return player.queue.value.slice( player.queueIdx.value + 1 );
|
||||||
|
},
|
||||||
|
set ( val ) {
|
||||||
|
player.queue.value = player.queue.value.slice( 0, player.queueIdx.value + 1 ).concat( val );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
const showAddSong = ref( false );
|
||||||
|
const showEditSong = ref( false );
|
||||||
|
const editingSong: Ref<null | Song> = ref( null );
|
||||||
|
|
||||||
|
const addSong = () => {
|
||||||
|
showAddSong.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const editSong = ( idx: number ) => {
|
||||||
|
showEditSong.value = true;
|
||||||
|
editingSong.value = player.queue.value[ idx + queueIdx.value + 1 ]!;
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteSong = ( idx: number ) => {
|
||||||
|
player.removeSong( idx + queueIdx.value + 1 );
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="queue-viewer">
|
||||||
|
<div>
|
||||||
|
<button @click="addSong">
|
||||||
|
<i class="fa-solid fa-plus"></i>
|
||||||
|
Add
|
||||||
|
</button>
|
||||||
|
<button @click="player.clearQueue">
|
||||||
|
<i class="fa-solid fa-xmark"></i>
|
||||||
|
Clear
|
||||||
|
</button>
|
||||||
|
<button @click="editSong( -1 )">
|
||||||
|
<i class="fa-solid fa-pen-to-square"></i>
|
||||||
|
Edit Current
|
||||||
|
</button>
|
||||||
|
<button @click="savePlaylist">
|
||||||
|
<i class="fa-solid fa-save"></i>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<SongEditor v-model="showEditSong" :song="editingSong" />
|
||||||
|
<AddSong v-model="showAddSong" />
|
||||||
|
<div v-if="queue.length > 0" class="queue-container">
|
||||||
|
<SortableList v-slot="{ item: song, index }" v-model="queue">
|
||||||
|
<div class="song-list-element">
|
||||||
|
<div class="song-cover-wrapper">
|
||||||
|
<img
|
||||||
|
v-if="song.artwork"
|
||||||
|
:src="song.artwork"
|
||||||
|
alt="Song cover"
|
||||||
|
class="song-cover"
|
||||||
|
>
|
||||||
|
<i v-else class="fa-solid fa-music song-cover"></i>
|
||||||
|
<div class="play-overlay hover">
|
||||||
|
<i class="fa-solid fa-play" @click="() => player.playIndex( index + queueIdx + 1 )"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="song-details">
|
||||||
|
<h3>{{ song.name }}</h3>
|
||||||
|
<p>{{ song.artist }}</p>
|
||||||
|
<p>{{ song['additional-info'] }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="song-actions">
|
||||||
|
<p>{{ beautifyTime( song.duration ) }}</p>
|
||||||
|
<i v-if="index !== 0" class="fa-solid fa-trash-can" @click="() => deleteSong( index )"></i>
|
||||||
|
<i class="fa-solid fa-pen-to-square" @click="() => editSong( index )"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</SortableList>
|
||||||
|
</div>
|
||||||
|
<div v-else class="queue-container">
|
||||||
|
<p>
|
||||||
|
No more songs in queue
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<button @click="addSong">
|
||||||
|
<i class="fa-solid fa-plus"></i>
|
||||||
|
Add
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@use '@/scss/components/queue.scss';
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import messages, {
|
||||||
|
isConnected
|
||||||
|
} from '@/ts/messages';
|
||||||
|
import PopupElement from '../popups/PopupElement.vue';
|
||||||
|
import {
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
const showPopup = defineModel<boolean>( {
|
||||||
|
'required': true
|
||||||
|
} );
|
||||||
|
const shareName = ref( '' );
|
||||||
|
const useAntiTamper = ref( false );
|
||||||
|
const errorMessage = ref( '' );
|
||||||
|
|
||||||
|
const startShare = async () => {
|
||||||
|
if ( !await messages.createRoom( shareName.value, useAntiTamper.value ) ) {
|
||||||
|
errorMessage.value = 'Invalid room name';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopShare = () => {
|
||||||
|
messages.closeRoom();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<PopupElement v-model="showPopup" show-close>
|
||||||
|
<h2>Share</h2>
|
||||||
|
<div v-if="!isConnected">
|
||||||
|
<p>
|
||||||
|
You can use a share to show what you are currently listening to (and the progress) on a page.
|
||||||
|
</p>
|
||||||
|
<p>{{ errorMessage }}</p>
|
||||||
|
<input v-model="shareName" type="text">
|
||||||
|
<button @click="startShare">
|
||||||
|
Create Share
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<!-- TODO: Need to explain and add controls -->
|
||||||
|
<!-- TODO: How to handle anti-tamper? -->
|
||||||
|
<p>Connected</p>
|
||||||
|
<button @click="stopShare">
|
||||||
|
End share
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</PopupElement>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import PopupElement from '../popups/PopupElement.vue';
|
||||||
|
import {
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
const showPopup = defineModel<boolean>( {
|
||||||
|
'required': true
|
||||||
|
} );
|
||||||
|
|
||||||
|
const addPlaylist = () => {
|
||||||
|
showPopup.value = false;
|
||||||
|
emit( 'add-playlist', playlistName.value );
|
||||||
|
};
|
||||||
|
|
||||||
|
const playlistName = ref( '' );
|
||||||
|
const emit = defineEmits<{
|
||||||
|
( e: 'add-playlist', name: string ): void;
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<PopupElement v-model="showPopup" show-close>
|
||||||
|
<div class="title">
|
||||||
|
<h1>Add Playlist</h1>
|
||||||
|
</div>
|
||||||
|
<input v-model="playlistName" type="text" placeholder="Playlist name">
|
||||||
|
<br>
|
||||||
|
<button @click="addPlaylist">
|
||||||
|
<i class="fa-solid fa-plus"></i>
|
||||||
|
Add Playlist
|
||||||
|
</button>
|
||||||
|
</PopupElement>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.title {
|
||||||
|
>h1 {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
>p {
|
||||||
|
margin: 0;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.song-sources {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
width: 50vw;
|
||||||
|
height: 40vh;
|
||||||
|
justify-content: center;
|
||||||
|
overflow-y: scroll;
|
||||||
|
overflow-x: hidden;
|
||||||
|
|
||||||
|
>div {
|
||||||
|
width: 45%;
|
||||||
|
margin: 0.5%;
|
||||||
|
height: 60%;
|
||||||
|
background-color: var(--accent-background);
|
||||||
|
border-radius: 20px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
>div {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
>.fa-solid {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
>.not-auth-notice {
|
||||||
|
font-size: 0.6rem;
|
||||||
|
margin: 0;
|
||||||
|
width: 70%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
addPlaylist,
|
||||||
|
removePlaylist,
|
||||||
|
selectPlaylist
|
||||||
|
} from '@/ts/userPlaylists';
|
||||||
|
import {
|
||||||
|
editingPlaylists,
|
||||||
|
playlists
|
||||||
|
} from '@/ts/userPlaylists/state';
|
||||||
|
import {
|
||||||
|
getPlaylists,
|
||||||
|
savePlaylists
|
||||||
|
} from '@/ts/userPlaylists/save';
|
||||||
|
import {
|
||||||
|
onMounted,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
import AddPlaylist from './AddPlaylist.vue';
|
||||||
|
import {
|
||||||
|
UnownedError
|
||||||
|
} from '@/ts/request';
|
||||||
|
import router from '@/router';
|
||||||
|
|
||||||
|
const checkingStatus = ref( true );
|
||||||
|
const dots = ref( 0 );
|
||||||
|
const showAddPlaylist = ref( false );
|
||||||
|
|
||||||
|
let interval = -1;
|
||||||
|
|
||||||
|
const loadPlaylists = async () => {
|
||||||
|
if ( interval < 0 ) {
|
||||||
|
interval = setInterval( () => {
|
||||||
|
dots.value = ( dots.value + 1 ) % 4;
|
||||||
|
}, 500 );
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await getPlaylists();
|
||||||
|
} catch ( e ) {
|
||||||
|
if ( e instanceof UnownedError ) {
|
||||||
|
router.push( '/get' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
checkingStatus.value = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
clearInterval( interval );
|
||||||
|
interval = -1;
|
||||||
|
} catch { /* Empty */ }
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted( () => {
|
||||||
|
loadPlaylists();
|
||||||
|
} );
|
||||||
|
|
||||||
|
onMounted( () => {} );
|
||||||
|
|
||||||
|
const openAddPlaylistPopup = () => {
|
||||||
|
showAddPlaylist.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const togglePlaylistEditing = ( idx: number ) => {
|
||||||
|
editingPlaylists.value[ idx ] = !editingPlaylists.value[ idx ];
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="playlists">
|
||||||
|
<AddPlaylist v-model="showAddPlaylist" @add-playlist="addPlaylist" />
|
||||||
|
<div v-if="checkingStatus" class="playlist-wrapper">
|
||||||
|
Loading{{ '.'.repeat( dots ) }}
|
||||||
|
</div>
|
||||||
|
<div v-else-if="playlists.length === 0" class="playlist-wrapper">
|
||||||
|
No playlists
|
||||||
|
<button @click="openAddPlaylistPopup">
|
||||||
|
<i class="fa-solid fa-plus"></i>
|
||||||
|
Add one
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div v-else class="playlist-wrapper">
|
||||||
|
<div class="playlist-actions">
|
||||||
|
<button @click="openAddPlaylistPopup">
|
||||||
|
<i class="fa-solid fa-plus"></i>
|
||||||
|
Add Playlist
|
||||||
|
</button>
|
||||||
|
<button @click="savePlaylists">
|
||||||
|
<i class="fa-solid fa-floppy-disk"></i>
|
||||||
|
Save Changes
|
||||||
|
</button>
|
||||||
|
<button @click="loadPlaylists">
|
||||||
|
<i class="fa-solid fa-rotate"></i>
|
||||||
|
Undo unsaved changes
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="playlist-container">
|
||||||
|
<div v-for="(playlist, index) in playlists" :key="index" class="playlist">
|
||||||
|
<i class="fa-solid fa-circle-play" @click="() => selectPlaylist( index )"></i>
|
||||||
|
<input v-if="editingPlaylists[ index ]" v-model="playlist.name" type="text">
|
||||||
|
<h2 v-else @click="() => selectPlaylist( index )">
|
||||||
|
{{ playlist.name }}
|
||||||
|
</h2>
|
||||||
|
<i class="fa-solid fa-pen-to-square" @click="() => togglePlaylistEditing( index )"></i>
|
||||||
|
<i class="fa-solid fa-trash" @click="() => removePlaylist( index )"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@use '@/scss/components/playlists.scss';
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import DiskLoader from '@/composables/DiskLoader.vue';
|
||||||
|
import ImportTypePicker from '@/composables/ImportTypePicker.vue';
|
||||||
|
import PopupElement from './PopupElement.vue';
|
||||||
|
import player from '@/ts/player';
|
||||||
|
import {
|
||||||
|
sources
|
||||||
|
} from '@/ts/player/state';
|
||||||
|
|
||||||
|
const showPopup = defineModel<boolean>( {
|
||||||
|
'required': true
|
||||||
|
} );
|
||||||
|
|
||||||
|
const addSong = async ( source: string ) => {
|
||||||
|
if ( await player.addSongFromSource( source ) ) {
|
||||||
|
showPopup.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<ImportTypePicker />
|
||||||
|
<DiskLoader />
|
||||||
|
<PopupElement v-model="showPopup" show-close>
|
||||||
|
<div class="title">
|
||||||
|
<h1>Add Song(s)</h1>
|
||||||
|
<p>Pick the source of your songs</p>
|
||||||
|
</div>
|
||||||
|
<div class="song-sources">
|
||||||
|
<div v-for="(source, index) in sources" :key="index" @click="() => addSong( source.id )">
|
||||||
|
<div>
|
||||||
|
<i v-if="source.icon" :class="['fa-solid', 'fa-' + source.icon]"></i>
|
||||||
|
<p>{{ source.name }}</p>
|
||||||
|
</div>
|
||||||
|
<p v-if="!source.authorized.value" class="not-auth-notice">
|
||||||
|
You have not yet logged into this source. Clicking this will start login
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PopupElement>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.title {
|
||||||
|
>h1 {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
>p {
|
||||||
|
margin: 0;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.song-sources {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
width: 50vw;
|
||||||
|
height: 40vh;
|
||||||
|
justify-content: center;
|
||||||
|
overflow-y: scroll;
|
||||||
|
overflow-x: hidden;
|
||||||
|
|
||||||
|
>div {
|
||||||
|
width: 45%;
|
||||||
|
margin: 0.5%;
|
||||||
|
height: 60%;
|
||||||
|
background-color: var(--accent-background);
|
||||||
|
border-radius: 20px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
>div {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
>.fa-solid {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
>.not-auth-notice {
|
||||||
|
font-size: 0.6rem;
|
||||||
|
margin: 0;
|
||||||
|
width: 70%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import PopupElement from './PopupElement.vue';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<PopupElement>
|
||||||
|
<h2></h2>
|
||||||
|
<button>Ok</button>
|
||||||
|
<button>Cancel</button>
|
||||||
|
</PopupElement>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<template>
|
||||||
|
<div :class="['popup', isOpen ? undefined : 'hidden' ]">
|
||||||
|
<div class="popup-backdrop"></div>
|
||||||
|
<div class="popup-main">
|
||||||
|
<i v-if="props.showClose" class="fa-solid fa-xmark close-icon" @click="closePopup()"></i>
|
||||||
|
<slot></slot>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const isOpen = defineModel<boolean>();
|
||||||
|
const props = defineProps<{
|
||||||
|
'showClose'?: boolean
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const closePopup = () => {
|
||||||
|
isOpen.value = false;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.popup {
|
||||||
|
position: fixed;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 1000;
|
||||||
|
transition-delay: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.popup-backdrop {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
position: absolute;
|
||||||
|
background-color: var( --overlay-color );
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
transition: all 0.25s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-main {
|
||||||
|
width: fit-content;
|
||||||
|
height: fit-content;
|
||||||
|
background-color: var( --secondary-color );
|
||||||
|
padding: 2.5%;
|
||||||
|
border-radius: 20px;
|
||||||
|
transform: scale(1);
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
display: block;
|
||||||
|
transition: transform 0.25s ease, opacity 0.25s ease;
|
||||||
|
|
||||||
|
>.close-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 20px;
|
||||||
|
right: 20px;
|
||||||
|
font-size: 1.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.hidden {
|
||||||
|
top: -100vh;
|
||||||
|
transition-delay: 0.25s;
|
||||||
|
|
||||||
|
.popup-main {
|
||||||
|
transform: scale(1.25);
|
||||||
|
opacity: 0;
|
||||||
|
transition: transform 0.15s ease, opacity 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-backdrop {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
type Ref, ref,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
import PopupElement from './PopupElement.vue';
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
import player from '@/ts/player';
|
||||||
|
|
||||||
|
const model = defineModel<boolean>( {
|
||||||
|
'required': true
|
||||||
|
} );
|
||||||
|
const props = defineProps<{
|
||||||
|
'song': Song | null
|
||||||
|
}>();
|
||||||
|
const localSong: Ref<Song> = ref( {
|
||||||
|
'name': '',
|
||||||
|
'artist': '',
|
||||||
|
'artwork': '',
|
||||||
|
'additional-info': '',
|
||||||
|
'duration': -1,
|
||||||
|
'identifier': '',
|
||||||
|
'source': 'local'
|
||||||
|
} );
|
||||||
|
|
||||||
|
watch( props, () => {
|
||||||
|
if ( props.song )
|
||||||
|
localSong.value = props.song;
|
||||||
|
} );
|
||||||
|
|
||||||
|
const search = () => {
|
||||||
|
player.addSongFromSource( 'applemusic', ( songs: Song[] ) => {
|
||||||
|
const song = songs[ 0 ];
|
||||||
|
|
||||||
|
if ( !song ) return;
|
||||||
|
|
||||||
|
localSong.value.artist = song.artist;
|
||||||
|
localSong.value.artwork = song.artwork;
|
||||||
|
localSong.value.name = song.name;
|
||||||
|
}, true );
|
||||||
|
};
|
||||||
|
|
||||||
|
const save = () => {
|
||||||
|
model.value = false;
|
||||||
|
document.dispatchEvent( new CustomEvent( 'musicplayer:update' ) );
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<PopupElement v-model="model" show-close>
|
||||||
|
<h2>Edit Song</h2>
|
||||||
|
<button @click="search">
|
||||||
|
Search song on Apple Music
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<label for="song-name">Song title</label>
|
||||||
|
<input id="song-name" v-model="localSong.name" type="text">
|
||||||
|
|
||||||
|
<label for="song-artist">Artist</label>
|
||||||
|
<input id="song-artist" v-model="localSong.artist" type="text">
|
||||||
|
|
||||||
|
<label for="song-artwork">Artwork URL</label>
|
||||||
|
<input id="song-artwork" v-model="localSong.artwork" type="text">
|
||||||
|
|
||||||
|
<label for="song-add-info">Additional Info</label>
|
||||||
|
<input id="song-add-info" v-model="localSong['additional-info']" type="text">
|
||||||
|
|
||||||
|
<button @click="save">
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</PopupElement>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import PopupElement from '../popups/PopupElement.vue';
|
||||||
|
|
||||||
|
const show = defineModel<boolean>();
|
||||||
|
const props = defineProps<{
|
||||||
|
'title': string;
|
||||||
|
'message'?: string;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
show.value = false;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<PopupElement v-model="show">
|
||||||
|
<h2>{{ props.title }}</h2>
|
||||||
|
<p>{{ props.message }}</p>
|
||||||
|
<button @click="close">
|
||||||
|
Ok
|
||||||
|
</button>
|
||||||
|
</PopupElement>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import PopupElement from '../popups/PopupElement.vue';
|
||||||
|
|
||||||
|
const show = defineModel<boolean>();
|
||||||
|
|
||||||
|
const close = () => {
|
||||||
|
show.value = false;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<!-- TODO: Beacon request when exiting browser (and confirm popup for that!) -->
|
||||||
|
<PopupElement v-model="show">
|
||||||
|
<h2>Settings</h2>
|
||||||
|
<button @click="close">
|
||||||
|
Ok
|
||||||
|
</button>
|
||||||
|
</PopupElement>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
currentQueue,
|
||||||
|
currentQueueIdx,
|
||||||
|
playbackTime,
|
||||||
|
showArtworks
|
||||||
|
} from '@/ts/shared/state';
|
||||||
|
import {
|
||||||
|
computed
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
const songs = computed( () => currentQueue.value?.slice( currentQueueIdx.value + 1 ) ?? [] );
|
||||||
|
const timeToPlay = computed( () => {
|
||||||
|
return ( idx: number ) => {
|
||||||
|
let total = 0;
|
||||||
|
|
||||||
|
for ( let i = 0; i < idx; i++ ) {
|
||||||
|
total += songs.value[ i ]!.duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
total += currentQueue.value[ currentQueueIdx.value ]?.duration ?? 0;
|
||||||
|
total -= playbackTime.value;
|
||||||
|
|
||||||
|
return Math.ceil( total / 60 );
|
||||||
|
};
|
||||||
|
} );
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="queue-viewer">
|
||||||
|
<div class="queue-container">
|
||||||
|
<div v-if="songs.length > 0" class="queue-scroll">
|
||||||
|
<div v-for="(song, index) in songs" :key="index" class="song-list-element">
|
||||||
|
<div class="song-cover-wrapper">
|
||||||
|
<img
|
||||||
|
v-if="song.artwork && showArtworks"
|
||||||
|
:src="song.artwork"
|
||||||
|
alt="Song cover"
|
||||||
|
class="song-cover"
|
||||||
|
>
|
||||||
|
<i v-else class="fa-solid fa-music song-cover"></i>
|
||||||
|
</div>
|
||||||
|
<div class="song-details">
|
||||||
|
<h3>{{ song.name }}</h3>
|
||||||
|
<p>{{ song.artist }}</p>
|
||||||
|
<p>{{ song['additional-info'] }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="song-actions">
|
||||||
|
<p>In {{ '<' + timeToPlay( index ) }}min</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="queue-empty">
|
||||||
|
No upcoming songs
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@use '@/scss/components/queue.scss';
|
||||||
|
|
||||||
|
.queue-scroll {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
margin-top: 20px;
|
||||||
|
justify-content: flex-start !important;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
associationOpts,
|
||||||
|
associationResults,
|
||||||
|
isAnalyzing,
|
||||||
|
isShowingAssociationManager,
|
||||||
|
needsFiles,
|
||||||
|
saveAssociations
|
||||||
|
} from './associationManager';
|
||||||
|
import {
|
||||||
|
fullPlayer,
|
||||||
|
queue
|
||||||
|
} from '@/ts/player/state';
|
||||||
|
import {
|
||||||
|
onMounted,
|
||||||
|
useTemplateRef
|
||||||
|
} from 'vue';
|
||||||
|
import PopupElement from '@/components/popups/PopupElement.vue';
|
||||||
|
import player from '@/ts/player';
|
||||||
|
|
||||||
|
const fileinput = useTemplateRef( 'fileinput' );
|
||||||
|
|
||||||
|
onMounted( () => {
|
||||||
|
fileinput.value?.addEventListener( 'change', async () => {
|
||||||
|
if ( fileinput.value && fileinput.value.files ) {
|
||||||
|
await associationOpts.value?.get( fileinput.value.files );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
|
||||||
|
const deleteSong = ( idx: number ) => {
|
||||||
|
const id = associationResults.value[ idx ]!.song.identifier;
|
||||||
|
|
||||||
|
for ( let i = 0; i < queue.value.length; i++ ) {
|
||||||
|
const song = queue.value[ i ]!;
|
||||||
|
|
||||||
|
if ( song.identifier === id ) {
|
||||||
|
player.removeSong( i );
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
associationResults.value.splice( idx, 1 );
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancel = () => {
|
||||||
|
player.clearQueue();
|
||||||
|
isShowingAssociationManager.value = false;
|
||||||
|
fullPlayer.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const retry = () => {
|
||||||
|
associationResults.value = [];
|
||||||
|
isAnalyzing.value = false;
|
||||||
|
needsFiles.value = true;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<PopupElement v-model="isShowingAssociationManager">
|
||||||
|
<h2>Load from disk</h2>
|
||||||
|
<div v-if="needsFiles">
|
||||||
|
<p>Some songs in this playlist require local files.</p>
|
||||||
|
<!-- TODO: probably need to list songs here somehow -->
|
||||||
|
<input
|
||||||
|
ref="fileinput"
|
||||||
|
type="file"
|
||||||
|
multiple
|
||||||
|
:accept="associationOpts?.mime ?? '*'"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div v-if="needsFiles && !isAnalyzing && associationResults.length > 0" class="association-wrapper">
|
||||||
|
<button @click="saveAssociations">
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
<div v-for="(result, index) in associationResults" :key="index" class="association">
|
||||||
|
<p>
|
||||||
|
<b>{{ result.song.name.length > 30 ? result.song.name.slice( 0, 30 ) + '...' : result.song.name }}</b>
|
||||||
|
by
|
||||||
|
<i>{{ result.song.artist.length > 20 ? result.song.artist.slice( 0, 20 ) + '...' : result.song.artist }}</i>
|
||||||
|
</p>
|
||||||
|
<select v-if="result.match === 'multiple'">
|
||||||
|
<option v-for="(file, idx) in result.possibleFiles" :key="idx" :value="idx">
|
||||||
|
{{ file.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<div v-else-if="result.match === 'none'">
|
||||||
|
<p>
|
||||||
|
No match
|
||||||
|
</p>
|
||||||
|
<i class="fa-solid fa-trash" @click="() => deleteSong( index )"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="associationResults.length === 0"></div>
|
||||||
|
<div v-else>
|
||||||
|
An error occurred. Please try again
|
||||||
|
<button @click="retry">
|
||||||
|
Retry
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<button @click="cancel">
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
</PopupElement>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.association-wrapper {
|
||||||
|
width: 60vw;
|
||||||
|
height: 50vh;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: scroll;
|
||||||
|
|
||||||
|
.association {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 3rem;
|
||||||
|
|
||||||
|
>div, select {
|
||||||
|
display: flex;
|
||||||
|
margin-left: auto;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
>p {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
diskLoaderOpts,
|
||||||
|
isShowingDiskLoader
|
||||||
|
} from './diskLoader';
|
||||||
|
import {
|
||||||
|
onMounted,
|
||||||
|
ref,
|
||||||
|
useTemplateRef
|
||||||
|
} from 'vue';
|
||||||
|
import PopupElement from '@/components/popups/PopupElement.vue';
|
||||||
|
|
||||||
|
const fileinput = useTemplateRef( 'fileinput' );
|
||||||
|
const progress = ref( -1 );
|
||||||
|
|
||||||
|
onMounted( () => {
|
||||||
|
fileinput.value?.addEventListener( 'change', async () => {
|
||||||
|
if ( fileinput.value && fileinput.value.files ) {
|
||||||
|
progress.value = 0;
|
||||||
|
await diskLoaderOpts.value?.process( fileinput.value.files, ( curr: number ) => {
|
||||||
|
progress.value = curr;
|
||||||
|
} );
|
||||||
|
isShowingDiskLoader.value = false;
|
||||||
|
setTimeout( () => {
|
||||||
|
progress.value = -1;
|
||||||
|
}, 1000 );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
} );
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<PopupElement v-model="isShowingDiskLoader" show-close>
|
||||||
|
<h2>Load from disk</h2>
|
||||||
|
<input
|
||||||
|
ref="fileinput"
|
||||||
|
type="file"
|
||||||
|
multiple
|
||||||
|
:accept="diskLoaderOpts?.mime ?? '*'"
|
||||||
|
>
|
||||||
|
<div v-if="progress >= 0">
|
||||||
|
<p style="margin-bottom: 0;">
|
||||||
|
Analyzing, please wait
|
||||||
|
</p>
|
||||||
|
<progress :value="progress" max="1"></progress>
|
||||||
|
</div>
|
||||||
|
</PopupElement>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
type ImportTypes,
|
||||||
|
importers,
|
||||||
|
isShowingImportTypePicker
|
||||||
|
} from './importTypePicker';
|
||||||
|
import PopupElement from '@/components/popups/PopupElement.vue';
|
||||||
|
import SearchView from './SearchView.vue';
|
||||||
|
import {
|
||||||
|
openDiskLoaderInterface
|
||||||
|
} from './diskLoader';
|
||||||
|
import {
|
||||||
|
openSearchInterface
|
||||||
|
} from './searchManager';
|
||||||
|
|
||||||
|
const openPicker = ( source: ImportTypes ) => {
|
||||||
|
isShowingImportTypePicker.value = false;
|
||||||
|
|
||||||
|
|
||||||
|
if ( source.type === 'cloud' ) {
|
||||||
|
openSearchInterface( source );
|
||||||
|
} else {
|
||||||
|
openDiskLoaderInterface( source );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<SearchView />
|
||||||
|
<PopupElement v-model="isShowingImportTypePicker" show-close>
|
||||||
|
<h2>What would you like to add?</h2>
|
||||||
|
<div class="import-type-list">
|
||||||
|
<div v-for="(source, index) in importers" :key="index" @click="openPicker( source )">
|
||||||
|
{{ source.name }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</PopupElement>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.import-type-list {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
width: 50vw;
|
||||||
|
height: 35vh;
|
||||||
|
justify-content: center;
|
||||||
|
overflow-y: scroll;
|
||||||
|
overflow-x: hidden;
|
||||||
|
|
||||||
|
>div {
|
||||||
|
width: 32%;
|
||||||
|
margin: 0.5%;
|
||||||
|
height: 50%;
|
||||||
|
background-color: var(--accent-background);
|
||||||
|
border-radius: 20px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
>.fa-solid {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
isShowingSearchView,
|
||||||
|
query,
|
||||||
|
results,
|
||||||
|
searchOpts
|
||||||
|
} from './searchManager';
|
||||||
|
import PopupElement from '@/components/popups/PopupElement.vue';
|
||||||
|
import {
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
const isSearching = ref( false );
|
||||||
|
const addedIndex = ref( -1 );
|
||||||
|
|
||||||
|
let addedTimeout = -1;
|
||||||
|
let timeout = -1;
|
||||||
|
let searchedForQuery = '';
|
||||||
|
|
||||||
|
const search = ( ev: KeyboardEvent ) => {
|
||||||
|
if ( ev.key === 'Enter' ) {
|
||||||
|
try {
|
||||||
|
clearTimeout( timeout );
|
||||||
|
} catch { /* empty */ }
|
||||||
|
|
||||||
|
doSearch();
|
||||||
|
} else if ( query.value.length > ( searchOpts.value?.minChars ?? 0 ) - 1 ) {
|
||||||
|
try {
|
||||||
|
clearTimeout( timeout );
|
||||||
|
} catch { /* empty */ }
|
||||||
|
|
||||||
|
timeout = setTimeout( doSearch, 250 );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const doSearch = async () => {
|
||||||
|
if ( query.value === searchedForQuery ) return;
|
||||||
|
|
||||||
|
isSearching.value = true;
|
||||||
|
searchedForQuery = query.value;
|
||||||
|
results.value = await searchOpts.value?.search( query.value, 0 ) ?? [];
|
||||||
|
isSearching.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const add = ( idx: number ) => {
|
||||||
|
try {
|
||||||
|
clearTimeout( addedTimeout );
|
||||||
|
} catch { /* empty */ }
|
||||||
|
|
||||||
|
addedIndex.value = idx;
|
||||||
|
searchOpts.value?.addSelected( idx );
|
||||||
|
|
||||||
|
if ( searchOpts.value?.autoClose )
|
||||||
|
isShowingSearchView.value = false;
|
||||||
|
|
||||||
|
addedTimeout = setTimeout( () => {
|
||||||
|
addedIndex.value = -1;
|
||||||
|
}, 2000 );
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<PopupElement v-model="isShowingSearchView" show-close>
|
||||||
|
<h2>Search {{ searchOpts?.name }}</h2>
|
||||||
|
<input
|
||||||
|
v-model="query"
|
||||||
|
type="text"
|
||||||
|
placeholder="Search..."
|
||||||
|
@keypress="search"
|
||||||
|
>
|
||||||
|
<div v-if="!isSearching && results.length > 0" class="search-results-wrapper">
|
||||||
|
<div v-for="(result, index) in results" :key="index" @click="() => add(index)">
|
||||||
|
<img v-if="result.artwork" :src="result.artwork" :alt="'Album artwork of ' + result.name + ' by ' + result.artist">
|
||||||
|
<i v-else class="fa-solid fa-music img-placeholder"></i>
|
||||||
|
<div>
|
||||||
|
<h4>{{ result.name }}</h4>
|
||||||
|
<p>{{ result.artist }}</p>
|
||||||
|
</div>
|
||||||
|
<i v-if="addedIndex === index" class="fa-solid fa-check"></i>
|
||||||
|
</div>
|
||||||
|
<!-- TODO: load more if close to bottom of scroll view -->
|
||||||
|
</div>
|
||||||
|
<div v-else-if="!isSearching && results.length === 0" class="search-results-wrapper placeholder">
|
||||||
|
No results found
|
||||||
|
</div>
|
||||||
|
<div v-else class="search-results-wrapper placeholder">
|
||||||
|
Searching...
|
||||||
|
</div>
|
||||||
|
</PopupElement>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@use '@/scss/components/search.scss';
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import {
|
||||||
|
type Ref,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
import type {
|
||||||
|
AssociationResult
|
||||||
|
} from '@/ts/player/plugins/interface';
|
||||||
|
import player from '@/ts/player';
|
||||||
|
import {
|
||||||
|
queue
|
||||||
|
} from '@/ts/player/state';
|
||||||
|
import {
|
||||||
|
updateIdentifiers
|
||||||
|
} from '@/ts/player/plugins/local/association';
|
||||||
|
|
||||||
|
export const isShowingAssociationManager = ref( false );
|
||||||
|
|
||||||
|
export const needsFiles = ref( true );
|
||||||
|
|
||||||
|
export const isAnalyzing = ref( false );
|
||||||
|
|
||||||
|
export const associationResults: Ref<AssociationResult[]> = ref( [] );
|
||||||
|
|
||||||
|
export const associationOpts: Ref<{
|
||||||
|
'get': ( files: FileList ) => Promise<void>,
|
||||||
|
'mime': string;
|
||||||
|
} | null> = ref( null );
|
||||||
|
|
||||||
|
export const openAssociationManager = ( cb: ( files: FileList ) => Promise<AssociationResult[]>, mime: string ) => {
|
||||||
|
isShowingAssociationManager.value = true;
|
||||||
|
associationResults.value = [];
|
||||||
|
needsFiles.value = true;
|
||||||
|
isAnalyzing.value = false;
|
||||||
|
|
||||||
|
const callback = async ( files: FileList ): Promise<void> => {
|
||||||
|
const results = await cb( files );
|
||||||
|
|
||||||
|
|
||||||
|
if ( results?.length ?? -1 > 0 ) {
|
||||||
|
associationResults.value = associationResults.value.concat( results! );
|
||||||
|
} else {
|
||||||
|
isShowingAssociationManager.value = false;
|
||||||
|
player.playIndex( 0 );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
associationOpts.value = {
|
||||||
|
'get': callback,
|
||||||
|
'mime': mime
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const saveAssociations = () => {
|
||||||
|
for ( const result of associationResults.value ) {
|
||||||
|
for ( const song of queue.value ) {
|
||||||
|
if ( result.song.identifier === song.identifier ) {
|
||||||
|
updateIdentifiers( song, result.possibleFiles[ result.selectedIdx ?? 0 ]! );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( associationResults.value.length === 0 ) {
|
||||||
|
isShowingAssociationManager.value = false;
|
||||||
|
player.playIndex( 0 );
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import {
|
||||||
|
type Ref,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
import type {
|
||||||
|
FileImport
|
||||||
|
} from './importTypePicker';
|
||||||
|
|
||||||
|
export const isShowingDiskLoader = ref( false );
|
||||||
|
|
||||||
|
export const diskLoaderOpts: Ref<FileImport | null> = ref( null );
|
||||||
|
|
||||||
|
export const openDiskLoaderInterface = ( options: FileImport ) => {
|
||||||
|
isShowingDiskLoader.value = true;
|
||||||
|
diskLoaderOpts.value = options;
|
||||||
|
};
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import {
|
||||||
|
type Ref,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
|
||||||
|
export interface CloudImport {
|
||||||
|
'name': string;
|
||||||
|
'type': 'cloud';
|
||||||
|
'search': ( term: string, offset: number ) => Promise<Song[]>;
|
||||||
|
'addSelected': ( index: number ) => void;
|
||||||
|
'minChars'?: number;
|
||||||
|
'autoClose': boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FileImport {
|
||||||
|
'name': string;
|
||||||
|
'type': 'file';
|
||||||
|
'mime': string;
|
||||||
|
'process': ( files: FileList, cb: ( progress: number ) => void ) => Promise<void>;
|
||||||
|
'autoClose': boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ImportTypes = CloudImport | FileImport;
|
||||||
|
|
||||||
|
export const isShowingImportTypePicker = ref( false );
|
||||||
|
|
||||||
|
export const importers: Ref<( CloudImport | FileImport )[]> = ref( [] );
|
||||||
|
|
||||||
|
export const openImportTypePicker = ( options: ( CloudImport | FileImport )[] ) => {
|
||||||
|
isShowingImportTypePicker.value = true;
|
||||||
|
importers.value = options;
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import {
|
||||||
|
type Ref,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
import type {
|
||||||
|
CloudImport
|
||||||
|
} from './importTypePicker';
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
|
||||||
|
export const isShowingSearchView = ref( false );
|
||||||
|
|
||||||
|
export const searchOpts: Ref<CloudImport | null> = ref( null );
|
||||||
|
|
||||||
|
export const results: Ref<Song[]> = ref( [] );
|
||||||
|
|
||||||
|
export const query = ref( '' );
|
||||||
|
|
||||||
|
export const openSearchInterface = ( options: CloudImport ) => {
|
||||||
|
searchOpts.value = options;
|
||||||
|
isShowingSearchView.value = true;
|
||||||
|
results.value = [];
|
||||||
|
query.value = '';
|
||||||
|
};
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import '@fortawesome/fontawesome-free/css/all.css';
|
||||||
|
import App from './App.vue';
|
||||||
|
import Notifications from '@kyvg/vue3-notification';
|
||||||
|
import {
|
||||||
|
createApp
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
createPinia
|
||||||
|
} from 'pinia';
|
||||||
|
import router from './router';
|
||||||
|
|
||||||
|
const app = createApp( App );
|
||||||
|
|
||||||
|
app.use( createPinia() );
|
||||||
|
app.use( router );
|
||||||
|
app.use( Notifications );
|
||||||
|
|
||||||
|
app.mount( '#app' );
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import {
|
||||||
|
createRouter,
|
||||||
|
createWebHistory
|
||||||
|
} from 'vue-router';
|
||||||
|
import {
|
||||||
|
useAuthStore
|
||||||
|
} from '@/stores/authstore';
|
||||||
|
|
||||||
|
const router = createRouter( {
|
||||||
|
'history': createWebHistory( import.meta.env.BASE_URL ),
|
||||||
|
'routes': [
|
||||||
|
{
|
||||||
|
'path': '/',
|
||||||
|
'name': 'home',
|
||||||
|
'component': () => import( '@/views/StartPage.vue' ),
|
||||||
|
'meta': {
|
||||||
|
'title': 'Home',
|
||||||
|
'auth': false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'path': '/app',
|
||||||
|
'name': 'app',
|
||||||
|
'component': () => import( '@/views/AppView.vue' ),
|
||||||
|
'meta': {
|
||||||
|
'title': 'Player',
|
||||||
|
'auth': true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'path': '/share/:name',
|
||||||
|
'name': 'share',
|
||||||
|
'component': () => import( '@/views/SharedView.vue' ),
|
||||||
|
'meta': {
|
||||||
|
'title': 'Shared',
|
||||||
|
'auth': false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'path': '/:pathMatch(.*)*',
|
||||||
|
'name': 'NotFound',
|
||||||
|
'component': () => import( '@/views/404View.vue' ),
|
||||||
|
'meta': {
|
||||||
|
'title': '404 :: Page not found',
|
||||||
|
'transition': 'scale'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
} );
|
||||||
|
|
||||||
|
router.beforeEach( to => {
|
||||||
|
const store = useAuthStore();
|
||||||
|
|
||||||
|
if ( to.meta.auth && !store.isAuth ) {
|
||||||
|
return {
|
||||||
|
'name': 'home'
|
||||||
|
};
|
||||||
|
} else if ( to.name === 'home' && store.isAuth ) {
|
||||||
|
return {
|
||||||
|
'name': 'app'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
router.afterEach( to => {
|
||||||
|
window.scrollTo( {
|
||||||
|
'top': 0,
|
||||||
|
'behavior': 'smooth'
|
||||||
|
} );
|
||||||
|
document.title = to.meta.title ? to.meta.title + ' - MusicPlayer' : 'MusicPlayer';
|
||||||
|
// NProgress.done();
|
||||||
|
} );
|
||||||
|
|
||||||
|
export default router;
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
.mp-player {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
.fa-solid {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: font-size ease 0.5s;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
font-size: 2.7rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
>.controls {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 3rem;
|
||||||
|
|
||||||
|
>.play-pause {
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
>.fa-play {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.paused {
|
||||||
|
>.fa-pause {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.fa-play {
|
||||||
|
display: unset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
>.quick-seek {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: "10";
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 40%;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 5%;
|
||||||
|
height: 95%;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
>.time {
|
||||||
|
display: flex;
|
||||||
|
width: 85%;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
|
||||||
|
>p {
|
||||||
|
margin-top: 0px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.duration {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress {
|
||||||
|
width: 95%;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.bottom-bar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 3rem;
|
||||||
|
margin-top: 15px;
|
||||||
|
|
||||||
|
>.fa-shuffle {
|
||||||
|
&.active {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
color: var(--secondary-color);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
>.repeat {
|
||||||
|
position: relative;
|
||||||
|
padding: 5px;
|
||||||
|
|
||||||
|
&.once,
|
||||||
|
&.all {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
color: var(--secondary-color);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.once::after {
|
||||||
|
position: absolute;
|
||||||
|
content: "1";
|
||||||
|
font-size: 40%;
|
||||||
|
font-family: sans-serif;
|
||||||
|
top: 5px;
|
||||||
|
right: 5px;
|
||||||
|
background-color: var(--accent-color);
|
||||||
|
width: 1.5em;
|
||||||
|
height: 1.5em;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 1em;
|
||||||
|
line-height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
.playlists {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
>.playlist-wrapper {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
|
||||||
|
>.playlist-container {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow-x: scroll;
|
||||||
|
|
||||||
|
>.playlist {
|
||||||
|
width: 50%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
padding: 10px;
|
||||||
|
height: 3rem;
|
||||||
|
|
||||||
|
>h2, >input {
|
||||||
|
margin: 0;
|
||||||
|
margin-right: auto;
|
||||||
|
margin-left: 10px;
|
||||||
|
width: 100%;
|
||||||
|
text-align: start;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
>input {
|
||||||
|
margin-right: auto;
|
||||||
|
margin-left: 10px;
|
||||||
|
width: 50%;
|
||||||
|
min-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.fa-circle-play {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.fa-solid {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
.progressbar {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
>.back {
|
||||||
|
width: 100%;
|
||||||
|
background-color: var(--accent-background);
|
||||||
|
height: 10px;
|
||||||
|
border-radius: 10px;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
>div {
|
||||||
|
background-color: var(--accent-color);
|
||||||
|
height: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
>.click-target {
|
||||||
|
width: 100%;
|
||||||
|
height: 10px;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 10;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
cursor: grabbing;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
transition: none;
|
||||||
|
position: fixed;
|
||||||
|
z-index: 10000;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.disallowed {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
.queue-viewer {
|
||||||
|
height: 100%;
|
||||||
|
width: 90%;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
>.queue-container {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: 90%;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.song-list-element {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
>.song-cover-wrapper {
|
||||||
|
height: 7rem;
|
||||||
|
width: 7rem;
|
||||||
|
position: relative;
|
||||||
|
margin-right: 20px;
|
||||||
|
|
||||||
|
.song-cover,
|
||||||
|
.fa-solid {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
font-size: 6rem;
|
||||||
|
line-height: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.play-overlay {
|
||||||
|
background-color: var(--overlay-color);
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&.hover {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
>.play-overlay.hover {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
>.song-details {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: flex-start;
|
||||||
|
|
||||||
|
>* {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
>h3 {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
>.song-actions {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: flex-end;
|
||||||
|
align-items: center;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: 10px;
|
||||||
|
|
||||||
|
>* {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.fa-solid {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
.search-results-wrapper {
|
||||||
|
width: 70vw;
|
||||||
|
height: 60vh;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: scroll;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
&.placeholder {
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
>div {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
width: 75%;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
>div {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: flex-start;
|
||||||
|
flex-direction: column;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
>* {
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
>.fa-solid {
|
||||||
|
margin-left: auto;
|
||||||
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
>img,
|
||||||
|
.img-placeholder {
|
||||||
|
height: 7rem;
|
||||||
|
width: 7rem;
|
||||||
|
margin-right: 20px;
|
||||||
|
font-size: 6rem;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
.sortable-list {
|
||||||
|
overflow-y: scroll;
|
||||||
|
overflow-x: hidden;
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
>.grip-target {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
cursor: grabbing;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.movable {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
|
||||||
|
&.moving {
|
||||||
|
position: fixed;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
>i {
|
||||||
|
cursor: move;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
.shared-view {
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: row;
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
width: 45%;
|
||||||
|
margin-left: 2.5%;
|
||||||
|
margin-right: 2.5%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
>.current-song-wrapper {
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
max-height: calc(100% - 10rem);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.time {
|
||||||
|
display: flex;
|
||||||
|
width: 85%;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
|
||||||
|
>p {
|
||||||
|
margin-top: 0px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
>.duration {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import {
|
||||||
|
defineStore
|
||||||
|
} from 'pinia';
|
||||||
|
import {
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
export const useAuthStore = defineStore( 'authstore', () => {
|
||||||
|
const isAuth = ref( false );
|
||||||
|
|
||||||
|
return {
|
||||||
|
isAuth
|
||||||
|
};
|
||||||
|
} );
|
||||||
Vendored
+15
@@ -0,0 +1,15 @@
|
|||||||
|
import type {
|
||||||
|
MusicKitObject
|
||||||
|
} from 'musickitjs-v3-types/MusicKit';
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
var MusicKit: MusicKitObject;
|
||||||
|
interface GlobalEventHandlersEventMap {
|
||||||
|
'musicplayer:playpause': CustomEvent<void>;
|
||||||
|
'musicplayer:playindex': CustomEvent<void>;
|
||||||
|
'musicplayer:seek': CustomEvent<void>;
|
||||||
|
'musicplayer:update': CustomEvent<void>;
|
||||||
|
'musicplayer:reauth': CustomEvent<void>;
|
||||||
|
'musicplayer:autherror': CustomEvent<void>;
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
export type RepeatMode = 'off' | 'one' | 'all';
|
||||||
Vendored
+53
@@ -0,0 +1,53 @@
|
|||||||
|
export interface Playlist {
|
||||||
|
'name': string;
|
||||||
|
'songs': PlaylistSongs;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PlaylistSongs = Song[];
|
||||||
|
|
||||||
|
export interface UrlToFileMapping {
|
||||||
|
[key: string]: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Song {
|
||||||
|
/**
|
||||||
|
* Where the song can be found
|
||||||
|
*/
|
||||||
|
'source': 'local' | 'applemusic';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifier for the song so it can be found again (such as Apple Music ID or URL for playback)
|
||||||
|
*/
|
||||||
|
'identifier': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any additional identifiers (such as filename, etc) to associate.
|
||||||
|
* Even if this is not used, set this value if local files are needed
|
||||||
|
*/
|
||||||
|
'additional-identifier'?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Additional info, such as dance type to be displayed on remote screens
|
||||||
|
*/
|
||||||
|
'additional-info': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The artist of the song
|
||||||
|
*/
|
||||||
|
'artist': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the song
|
||||||
|
*/
|
||||||
|
'name': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The cover image as a URL
|
||||||
|
*/
|
||||||
|
'artwork': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Song duration
|
||||||
|
*/
|
||||||
|
'duration': number;
|
||||||
|
}
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
import {
|
||||||
|
isPlaying,
|
||||||
|
queue,
|
||||||
|
queueIdx
|
||||||
|
} from '../player/state';
|
||||||
|
import {
|
||||||
|
onMounted,
|
||||||
|
onUnmounted,
|
||||||
|
ref,
|
||||||
|
watch
|
||||||
|
} from 'vue';
|
||||||
|
import {
|
||||||
|
playbackPercentage
|
||||||
|
} from '../player/status-tracking';
|
||||||
|
import {
|
||||||
|
reauth
|
||||||
|
} from '../util/reauth';
|
||||||
|
import request from '../request';
|
||||||
|
|
||||||
|
const RETRY_CAP = 10;
|
||||||
|
|
||||||
|
export const room = ref( localStorage.getItem( 'room' ) ?? '' );
|
||||||
|
|
||||||
|
export const isConnected = ref( false );
|
||||||
|
|
||||||
|
export const useAntiTamper = ref( false );
|
||||||
|
|
||||||
|
// TODO: Anit-Tamper
|
||||||
|
// const antiTamperClients = [];
|
||||||
|
|
||||||
|
let connection: null | EventSource = null;
|
||||||
|
let retries = 0;
|
||||||
|
|
||||||
|
const createRoom = async ( name: string, antiTamper: boolean ): Promise<boolean> => {
|
||||||
|
if ( !( /^[a-zA-Z0-9-]{3,20}$/ ).test( name ) ) return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await request.get( '/room/create?room=' + name );
|
||||||
|
} catch ( err ) {
|
||||||
|
if ( err === 'ERR_409' ) {
|
||||||
|
return await connect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
localStorage.setItem( 'room', name );
|
||||||
|
useAntiTamper.value = antiTamper;
|
||||||
|
room.value = name;
|
||||||
|
|
||||||
|
document.addEventListener( 'musicplayer:autherror', reauth );
|
||||||
|
|
||||||
|
return await connect();
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeRoom = async () => {
|
||||||
|
// TODO: Trigger close on backend and disconnect.
|
||||||
|
isConnected.value = false;
|
||||||
|
localStorage.removeItem( 'room' );
|
||||||
|
connection?.close();
|
||||||
|
|
||||||
|
try {
|
||||||
|
document.removeEventListener( 'musicplayer:autherror', reauth );
|
||||||
|
} catch { /* empty */ }
|
||||||
|
};
|
||||||
|
|
||||||
|
const connect = (): Promise<boolean> => {
|
||||||
|
return new Promise( ( resolve, reject ) => {
|
||||||
|
if ( !useAntiTamper.value ) {
|
||||||
|
isConnected.value = true;
|
||||||
|
sendPlaylistData();
|
||||||
|
sendStateData();
|
||||||
|
|
||||||
|
return resolve( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
connection = new EventSource( request.backendURL + `/room/${ room.value }/admin`, {
|
||||||
|
'withCredentials': true
|
||||||
|
} );
|
||||||
|
|
||||||
|
connection.onopen = () => {
|
||||||
|
isConnected.value = true;
|
||||||
|
console.log( '[SSE] Connection established successfully' );
|
||||||
|
sendPlaylistData();
|
||||||
|
sendStateData();
|
||||||
|
resolve( true );
|
||||||
|
};
|
||||||
|
|
||||||
|
connection.onmessage = msg => {
|
||||||
|
console.log( msg );
|
||||||
|
};
|
||||||
|
|
||||||
|
connection.onerror = () => {
|
||||||
|
connection?.close();
|
||||||
|
console.error( '[SSE] Reconnecting due to error' );
|
||||||
|
|
||||||
|
if ( !isConnected.value ) reject( 'ERR_CONNECT' );
|
||||||
|
|
||||||
|
if ( retries <= RETRY_CAP ) {
|
||||||
|
retries += 1;
|
||||||
|
|
||||||
|
setTimeout( () => {
|
||||||
|
createRoom( room.value, useAntiTamper.value );
|
||||||
|
}, 1000 * retries );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
// FIXME: This is not a sensible solution, but easy for now (i.e. solve properly)
|
||||||
|
let playlistLock = false;
|
||||||
|
let stateLock = false;
|
||||||
|
|
||||||
|
const sendPlaylistData = () => {
|
||||||
|
if ( isConnected.value && !playlistLock ) {
|
||||||
|
playlistLock = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
request.post( `/room/${ room.value }/update/playlist`, JSON.stringify( {
|
||||||
|
'playlist': queue.value
|
||||||
|
} ) );
|
||||||
|
} catch ( e ) {
|
||||||
|
console.error( e );
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout( () => {
|
||||||
|
playlistLock = false;
|
||||||
|
}, 500 );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const sendStateData = async () => {
|
||||||
|
if ( isConnected.value && !stateLock ) {
|
||||||
|
stateLock = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
request.post( `/room/${ room.value }/update/state`, JSON.stringify( {
|
||||||
|
'playing': isPlaying.value,
|
||||||
|
'index': queueIdx.value,
|
||||||
|
'start': new Date().getTime() - 100,
|
||||||
|
'offset': playbackPercentage.value * ( queue.value[ queueIdx.value ]?.duration ?? 0 )
|
||||||
|
} ) );
|
||||||
|
} catch ( e ) {
|
||||||
|
console.error( e );
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout( () => {
|
||||||
|
stateLock = false;
|
||||||
|
}, 500 );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const useRoomWatchers = () => {
|
||||||
|
watch( queue, sendPlaylistData );
|
||||||
|
|
||||||
|
onMounted( () => {
|
||||||
|
document.addEventListener( 'musicplayer:playindex', sendStateData );
|
||||||
|
document.addEventListener( 'musicplayer:seek', sendStateData );
|
||||||
|
document.addEventListener( 'musicplayer:playpause', sendStateData );
|
||||||
|
document.addEventListener( 'musicplayer:update', sendPlaylistData );
|
||||||
|
} );
|
||||||
|
|
||||||
|
onUnmounted( () => {
|
||||||
|
try {
|
||||||
|
document.addEventListener( 'musicplayer:play', sendStateData );
|
||||||
|
} catch { /* empty */ }
|
||||||
|
|
||||||
|
try {
|
||||||
|
document.addEventListener( 'musicplayer:seek', sendStateData );
|
||||||
|
} catch { /* empty */ }
|
||||||
|
|
||||||
|
try {
|
||||||
|
document.addEventListener( 'musicplayer:playpause', sendStateData );
|
||||||
|
} catch { /* empty */ }
|
||||||
|
|
||||||
|
try {
|
||||||
|
document.addEventListener( 'musicplayer:update', sendPlaylistData );
|
||||||
|
} catch { /* empty */ }
|
||||||
|
} );
|
||||||
|
|
||||||
|
if ( room.value ) connect();
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
createRoom,
|
||||||
|
useRoomWatchers,
|
||||||
|
closeRoom
|
||||||
|
};
|
||||||
@@ -0,0 +1,181 @@
|
|||||||
|
import {
|
||||||
|
addSongList,
|
||||||
|
clearQueue,
|
||||||
|
removeSong,
|
||||||
|
shuffleList
|
||||||
|
} from './playlists/add';
|
||||||
|
import {
|
||||||
|
currentSource,
|
||||||
|
isPlaying,
|
||||||
|
queue,
|
||||||
|
queueIdx,
|
||||||
|
rawQueue,
|
||||||
|
repeat,
|
||||||
|
shuffle,
|
||||||
|
sources
|
||||||
|
} from './state';
|
||||||
|
import {
|
||||||
|
duration,
|
||||||
|
playbackPercentage,
|
||||||
|
startTracking,
|
||||||
|
stopTracking
|
||||||
|
} from './status-tracking';
|
||||||
|
import type {
|
||||||
|
RepeatMode
|
||||||
|
} from '../dtype/player';
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '../dtype/playlist';
|
||||||
|
import {
|
||||||
|
load
|
||||||
|
} from './playlists/loader';
|
||||||
|
import {
|
||||||
|
playIndex
|
||||||
|
} from './playlists';
|
||||||
|
|
||||||
|
const next = () => {
|
||||||
|
playIndex( ( queueIdx.value + 1 ) % queue.value.length );
|
||||||
|
};
|
||||||
|
|
||||||
|
const prev = () => {
|
||||||
|
if ( playbackPercentage.value * duration.value > 7 )
|
||||||
|
return seekTo( 0 );
|
||||||
|
|
||||||
|
playIndex( ( queueIdx.value - 1 + queue.value.length ) % queue.value.length );
|
||||||
|
};
|
||||||
|
|
||||||
|
const play = () => {
|
||||||
|
if ( currentSource.value === '' ) return;
|
||||||
|
|
||||||
|
isPlaying.value = true;
|
||||||
|
|
||||||
|
sources[currentSource.value]?.play();
|
||||||
|
startTracking();
|
||||||
|
document.dispatchEvent( new CustomEvent( 'musicplayer:playpause' ) );
|
||||||
|
};
|
||||||
|
|
||||||
|
const pause = () => {
|
||||||
|
if ( currentSource.value === '' ) return;
|
||||||
|
|
||||||
|
isPlaying.value = false;
|
||||||
|
|
||||||
|
sources[currentSource.value]?.pause();
|
||||||
|
stopTracking();
|
||||||
|
document.dispatchEvent( new CustomEvent( 'musicplayer:playpause' ) );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seek to a specific point in the song
|
||||||
|
* @param pos - Percentage of song, value in [0, 1]
|
||||||
|
*/
|
||||||
|
const seekTo = ( pos: number ) => {
|
||||||
|
if ( currentSource.value === '' ) return;
|
||||||
|
|
||||||
|
sources[currentSource.value]?.seekTo( pos );
|
||||||
|
document.dispatchEvent( new CustomEvent( 'musicplayer:seek' ) );
|
||||||
|
};
|
||||||
|
|
||||||
|
const skip10 = () => {
|
||||||
|
if ( currentSource.value === '' ) return;
|
||||||
|
|
||||||
|
const source = sources[currentSource.value];
|
||||||
|
const duration = source?.getDuration() ?? -1;
|
||||||
|
|
||||||
|
seekTo( ( ( ( source?.getPlaybackPos() ?? 0 ) * duration ) + 10 ) / duration );
|
||||||
|
};
|
||||||
|
|
||||||
|
const back10 = () => {
|
||||||
|
if ( currentSource.value === '' ) return;
|
||||||
|
|
||||||
|
const source = sources[currentSource.value];
|
||||||
|
const duration = source?.getDuration() ?? -1;
|
||||||
|
|
||||||
|
seekTo( ( ( ( source?.getPlaybackPos() ?? 0 ) * duration ) - 10 ) / duration );
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turn on or off shuffle
|
||||||
|
* @param enabled - Whether to enable or disable shuffle
|
||||||
|
*/
|
||||||
|
const setShuffle = ( enabled: boolean ) => {
|
||||||
|
shuffle.value = enabled;
|
||||||
|
|
||||||
|
if ( enabled ) {
|
||||||
|
shuffleList();
|
||||||
|
queueIdx.value = 0;
|
||||||
|
} else {
|
||||||
|
const curr = queue.value[queueIdx.value];
|
||||||
|
|
||||||
|
queue.value = [];
|
||||||
|
|
||||||
|
for ( let i = 0; i < rawQueue.value.length; i++ ) {
|
||||||
|
if ( rawQueue.value[i] === curr )
|
||||||
|
queueIdx.value = i;
|
||||||
|
|
||||||
|
queue.value.push( rawQueue.value[i]! );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the repeat mode
|
||||||
|
* @param mode - The repeat mode to switch into
|
||||||
|
*/
|
||||||
|
const setRepeat = ( mode: RepeatMode ) => {
|
||||||
|
repeat.value = mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getSources = (): string[] => {
|
||||||
|
return Object.keys( sources );
|
||||||
|
};
|
||||||
|
|
||||||
|
const addToSongList = ( songs: Song[] ) => {
|
||||||
|
addSongList( songs );
|
||||||
|
|
||||||
|
if ( currentSource.value === '' ) {
|
||||||
|
playIndex( 0 );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add songs to the playlist from given source
|
||||||
|
* @param source - The ID of the source to add from
|
||||||
|
* @param cb - A custom callback to be executed instead of the default, which adds to queue
|
||||||
|
* @param skipLogin - Whether to skip login checks
|
||||||
|
*/
|
||||||
|
const addSongFromSource = async ( source: string, cb?: ( songs: Song[] ) => void, skipLogin?: boolean ): Promise<boolean> => {
|
||||||
|
if ( sources[source]!.authorized.value || skipLogin ) {
|
||||||
|
sources[source]!.addSongsFromThisSource( cb ? cb : addToSongList, skipLogin ? 0 : undefined, skipLogin );
|
||||||
|
} else {
|
||||||
|
sources[source]!.login!();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
play,
|
||||||
|
pause,
|
||||||
|
seekTo,
|
||||||
|
skip10,
|
||||||
|
back10,
|
||||||
|
setShuffle,
|
||||||
|
setRepeat,
|
||||||
|
playIndex,
|
||||||
|
getSources,
|
||||||
|
addSongFromSource,
|
||||||
|
next,
|
||||||
|
prev,
|
||||||
|
clearQueue,
|
||||||
|
removeSong,
|
||||||
|
queue,
|
||||||
|
queueIdx,
|
||||||
|
duration,
|
||||||
|
playbackPercentage,
|
||||||
|
repeat,
|
||||||
|
shuffle,
|
||||||
|
isPlaying,
|
||||||
|
'loadPlaylist': load
|
||||||
|
};
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
import {
|
||||||
|
currentSource,
|
||||||
|
isPlaying,
|
||||||
|
queue,
|
||||||
|
queueIdx,
|
||||||
|
rawQueue,
|
||||||
|
repeat,
|
||||||
|
shuffle,
|
||||||
|
sources
|
||||||
|
} from '../state';
|
||||||
|
import {
|
||||||
|
duration,
|
||||||
|
playbackPercentage
|
||||||
|
} from '../status-tracking';
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
import {
|
||||||
|
setPlaylistIdx
|
||||||
|
} from '@/ts/userPlaylists';
|
||||||
|
|
||||||
|
export const addSongList = ( songs: Song[] ) => {
|
||||||
|
rawQueue.value = rawQueue.value.concat( songs );
|
||||||
|
queue.value = queue.value.concat( songs );
|
||||||
|
};
|
||||||
|
|
||||||
|
export const clearQueue = () => {
|
||||||
|
setPlaylistIdx( 0 );
|
||||||
|
queue.value = [];
|
||||||
|
rawQueue.value = [];
|
||||||
|
sources[currentSource.value]?.stop();
|
||||||
|
duration.value = -1;
|
||||||
|
playbackPercentage.value = 1;
|
||||||
|
isPlaying.value = false;
|
||||||
|
repeat.value = 'off';
|
||||||
|
shuffle.value = false;
|
||||||
|
|
||||||
|
for ( const song of queue.value ) {
|
||||||
|
sources[ song.source ]?.songUnload( song );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a song from the given queue index
|
||||||
|
* @param idx - The index to remove at
|
||||||
|
* @returns True if successful, False if not
|
||||||
|
*/
|
||||||
|
export const removeSong = ( idx: number ) => {
|
||||||
|
if ( idx <= queueIdx.value ) return false;
|
||||||
|
|
||||||
|
const removed = queue.value.splice( idx, 1 )[0];
|
||||||
|
|
||||||
|
for ( let i = 0; i < rawQueue.value.length; i++ ) {
|
||||||
|
if ( rawQueue.value[ i ] === removed ) {
|
||||||
|
rawQueue.value.splice( i, 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move a song in the queue
|
||||||
|
* @param idx - The index to move
|
||||||
|
* @param newIdx - The index to move it to
|
||||||
|
* @returns True if successful, false if constraints were violated
|
||||||
|
*/
|
||||||
|
export const moveSong = ( idx: number, newIdx: number ) => {
|
||||||
|
if ( idx === newIdx ) return true;
|
||||||
|
|
||||||
|
if ( idx <= queueIdx.value || newIdx <= queueIdx.value || idx > queue.value.length || newIdx > queue.value.length )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Affects only the queue if shuffled, else copy the queue into rawQueue
|
||||||
|
const movedEl = queue.value[ idx ]!;
|
||||||
|
|
||||||
|
if ( idx < newIdx )
|
||||||
|
for ( let i = idx + 1; i < Math.min( queue.value.length, newIdx + 1 ); i++ ) {
|
||||||
|
queue.value[ i - 1 ] = queue.value[ i ]!;
|
||||||
|
}
|
||||||
|
else if ( idx > newIdx )
|
||||||
|
for ( let i = idx + 1; i > Math.max( 0, newIdx + 1 ); i-- ) {
|
||||||
|
queue.value[ i ] = queue.value[ i - 1 ]!;
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.value[ newIdx ] = movedEl;
|
||||||
|
|
||||||
|
if ( !shuffle.value ) {
|
||||||
|
// If we don't shuffle, the rawQueue should also be updated
|
||||||
|
rawQueue.value = [];
|
||||||
|
|
||||||
|
for ( const song of queue.value ) {
|
||||||
|
rawQueue.value.push( song );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Shuffle the song list */
|
||||||
|
export const shuffleList = () => {
|
||||||
|
const shuffled = rawQueue.value
|
||||||
|
.map( ( val, idx ) => {
|
||||||
|
return {
|
||||||
|
val,
|
||||||
|
idx,
|
||||||
|
'sort': Math.random()
|
||||||
|
};
|
||||||
|
} ).sort( ( a, b ) => a.sort - b.sort );
|
||||||
|
const q: Song[] = [];
|
||||||
|
|
||||||
|
// Make current song the first in the list
|
||||||
|
q.push( rawQueue.value[queueIdx.value]! );
|
||||||
|
|
||||||
|
for ( const el of shuffled ) {
|
||||||
|
if ( el.idx !== queueIdx.value )
|
||||||
|
q.push( el.val );
|
||||||
|
}
|
||||||
|
|
||||||
|
queue.value = q;
|
||||||
|
};
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import {
|
||||||
|
currentSource,
|
||||||
|
isPlaying,
|
||||||
|
queue,
|
||||||
|
queueIdx,
|
||||||
|
repeat,
|
||||||
|
sources
|
||||||
|
} from '../state';
|
||||||
|
import {
|
||||||
|
startTracking,
|
||||||
|
stopTracking
|
||||||
|
} from '../status-tracking';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play a song at the given index of the queue. Wraps to 0 and end if index below 0 or above end
|
||||||
|
* @param idx - The index in the queue to play at
|
||||||
|
*/
|
||||||
|
export const playIndex = ( idx: number ) => {
|
||||||
|
if ( idx >= queue.value.length ) {
|
||||||
|
idx = repeat.value === 'all' ? 0 : -1;
|
||||||
|
} else if ( idx < 0 ) {
|
||||||
|
idx = repeat.value === 'all' ? queue.value.length - 1 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
sources[currentSource.value]?.stop();
|
||||||
|
|
||||||
|
if ( idx < 0 ) {
|
||||||
|
isPlaying.value = false;
|
||||||
|
currentSource.value = '';
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
stopTracking();
|
||||||
|
|
||||||
|
const nextSong = queue.value[ idx ]!;
|
||||||
|
|
||||||
|
queueIdx.value = idx;
|
||||||
|
currentSource.value = nextSong.source;
|
||||||
|
sources[currentSource.value]?.playSong( nextSong.identifier );
|
||||||
|
|
||||||
|
startTracking();
|
||||||
|
|
||||||
|
isPlaying.value = true;
|
||||||
|
setTimeout( () => {
|
||||||
|
document.dispatchEvent( new CustomEvent( 'musicplayer:playindex', {} ) );
|
||||||
|
}, 500 );
|
||||||
|
};
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import {
|
||||||
|
fullPlayer,
|
||||||
|
queue,
|
||||||
|
rawQueue,
|
||||||
|
sources
|
||||||
|
} from '../state';
|
||||||
|
import type {
|
||||||
|
AssociationResult
|
||||||
|
} from '../plugins/interface';
|
||||||
|
import type {
|
||||||
|
PlaylistSongs
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
import {
|
||||||
|
openAssociationManager
|
||||||
|
} from '@/composables/associationManager';
|
||||||
|
|
||||||
|
export const load = ( playlist: PlaylistSongs ) => {
|
||||||
|
queue.value = playlist;
|
||||||
|
rawQueue.value = playlist;
|
||||||
|
|
||||||
|
let needToLoadLocalSongs = false;
|
||||||
|
|
||||||
|
for ( const song of playlist ) {
|
||||||
|
if ( song['additional-identifier'] ) {
|
||||||
|
needToLoadLocalSongs = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileLoader = async ( files: FileList ) => {
|
||||||
|
const associationResults: AssociationResult[] = [];
|
||||||
|
|
||||||
|
for ( const song of playlist ) {
|
||||||
|
const source = sources[song.source]!;
|
||||||
|
|
||||||
|
if ( source.loading.requiresLocalFiles === true ) {
|
||||||
|
associationResults.push( await source.loading.association( files as FileList, song ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return associationResults.filter( val => val.match !== 'exact' );
|
||||||
|
};
|
||||||
|
|
||||||
|
if ( needToLoadLocalSongs ) {
|
||||||
|
const mime = Object.values( sources )
|
||||||
|
.map( src => {
|
||||||
|
return src.loading.requiresLocalFiles === true ? src.loading.mime : '';
|
||||||
|
} )
|
||||||
|
.reduce( ( prev, curr ) => {
|
||||||
|
return prev === '' ? curr : prev + ',' + curr;
|
||||||
|
} );
|
||||||
|
|
||||||
|
openAssociationManager( fileLoader, mime );
|
||||||
|
}
|
||||||
|
|
||||||
|
fullPlayer.value = true;
|
||||||
|
};
|
||||||
+129
@@ -0,0 +1,129 @@
|
|||||||
|
import type {
|
||||||
|
Ref
|
||||||
|
} from 'vue';
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
|
||||||
|
export type PlayerSourcePluginInitializer = () => Promise<PlayerSourcePlugin>;
|
||||||
|
|
||||||
|
export interface AssociationResult {
|
||||||
|
'song': Song,
|
||||||
|
'match': 'exact' | 'none' | 'multiple';
|
||||||
|
'possibleFiles': File[],
|
||||||
|
'selectedIdx'?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PlayerSourcePlugin {
|
||||||
|
/**
|
||||||
|
* The name of the source that is displayed in the UI
|
||||||
|
*/
|
||||||
|
'name': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifier used in the playlist files
|
||||||
|
*/
|
||||||
|
'id': string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Font-Awesome icon name (without fa and needs to be of free icons
|
||||||
|
*/
|
||||||
|
'icon'?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describe how files are loaded here
|
||||||
|
*/
|
||||||
|
'loading': {
|
||||||
|
/**
|
||||||
|
* Set to true if the user needs to load files
|
||||||
|
*/
|
||||||
|
'requiresLocalFiles': true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function used to associate the file to the songs of the playlist
|
||||||
|
* @param files - The files that were picked by the user
|
||||||
|
* @param song - The song to update
|
||||||
|
* @returns A promise resolving to the (possibly) updated song and metadata
|
||||||
|
*/
|
||||||
|
'association': ( files: FileList, song: Song ) => Promise<AssociationResult>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function used to update the additional identifier of the song if the file has changed
|
||||||
|
* @param song - The song that needs updating
|
||||||
|
* @param file - The file that it should be updated to
|
||||||
|
* @returns The updated song
|
||||||
|
*/
|
||||||
|
'updateIdentifiers': ( song: Song, file: File ) => Promise<Song>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mime types that this source's files may have
|
||||||
|
*/
|
||||||
|
'mime': string;
|
||||||
|
} | {
|
||||||
|
/**
|
||||||
|
* Set to true if the user needs to load files
|
||||||
|
*/
|
||||||
|
'requiresLocalFiles': false;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement any login flow here. Optional
|
||||||
|
*/
|
||||||
|
'login'?: () => Promise<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play a song by its ID. Should start playing it immediately
|
||||||
|
*/
|
||||||
|
'playSong': ( id: string ) => Promise<void>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Continue playing the song
|
||||||
|
*/
|
||||||
|
'play': () => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pause the currently playing song
|
||||||
|
*/
|
||||||
|
'pause': () => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop / unload the current song. This indicates that either the playlist was cleared
|
||||||
|
* or a next song is about to be loaded (possibly from another plugin)
|
||||||
|
*/
|
||||||
|
'stop': () => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seek to a specific point in the song.
|
||||||
|
* @param pos is always given as a percentage (pos \in [0, 1])
|
||||||
|
*/
|
||||||
|
'seekTo': ( pos: number ) => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the playback position as a percentage of the duration. (return value \in [0, 1])
|
||||||
|
*/
|
||||||
|
'getPlaybackPos': () => number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the song duration in seconds.
|
||||||
|
*/
|
||||||
|
'getDuration': () => number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if source is authorized
|
||||||
|
*/
|
||||||
|
'authorized': Ref<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when user adds another song to the playlist via this source.
|
||||||
|
* You may use the provided interface elements (search bar and popups) to e.g. ask if user wants to use a playlist, album, etc
|
||||||
|
* @param cb - Added songs are the arguments
|
||||||
|
* @param kindIdx - The index in the list of import types that should be used without showing popup. If unset, will show the picker
|
||||||
|
* @param autoClose - Whether or not to automatically close the interface after a single pick
|
||||||
|
*/
|
||||||
|
'addSongsFromThisSource': ( cb: ( songs: Song[] ) => void, kindIdx?: number, autoClose?: boolean ) => void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fully unload a song. This is called on clear of a playlist
|
||||||
|
*/
|
||||||
|
'songUnload': ( song: Song ) => Promise<void>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import type {
|
||||||
|
AssociationResult
|
||||||
|
} from '../interface';
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
|
||||||
|
export const createFileAssociationString = ( file: File ) => {
|
||||||
|
return file.name + '__' + file.size;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const associate = async ( files: FileList, song: Song ): Promise<AssociationResult> => {
|
||||||
|
const candidates: File[] = [];
|
||||||
|
|
||||||
|
if ( !song['additional-identifier'] ) {
|
||||||
|
return {
|
||||||
|
'match': 'none',
|
||||||
|
'song': song,
|
||||||
|
'possibleFiles': []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( const file of files ) {
|
||||||
|
if ( createFileAssociationString( file ) === song['additional-identifier'] ) {
|
||||||
|
candidates.push( file );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( candidates.length === 0 ) {
|
||||||
|
return {
|
||||||
|
'match': 'none',
|
||||||
|
'song': song,
|
||||||
|
'possibleFiles': []
|
||||||
|
};
|
||||||
|
} else if ( candidates.length === 1 ) {
|
||||||
|
song.identifier = URL.createObjectURL( candidates[ 0 ]! );
|
||||||
|
|
||||||
|
return {
|
||||||
|
'match': 'exact',
|
||||||
|
'song': song,
|
||||||
|
'possibleFiles': []
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
'match': 'multiple',
|
||||||
|
'song': song,
|
||||||
|
'possibleFiles': candidates
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const updateIdentifiers = async ( song: Song, file: File ): Promise<Song> => {
|
||||||
|
song.identifier = URL.createObjectURL( file );
|
||||||
|
song['additional-identifier'] = createFileAssociationString( file );
|
||||||
|
|
||||||
|
return song;
|
||||||
|
};
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import type {
|
||||||
|
PlayerSourcePlugin,
|
||||||
|
PlayerSourcePluginInitializer
|
||||||
|
} from '../interface';
|
||||||
|
import {
|
||||||
|
associate,
|
||||||
|
updateIdentifiers
|
||||||
|
} from './association';
|
||||||
|
import {
|
||||||
|
load,
|
||||||
|
unload
|
||||||
|
} from './loader';
|
||||||
|
import {
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
export const useLocalPlayer: PlayerSourcePluginInitializer = async (): Promise<PlayerSourcePlugin> => {
|
||||||
|
const player = new Audio();
|
||||||
|
|
||||||
|
const playSong = async ( id: string ) => {
|
||||||
|
player.src = id;
|
||||||
|
player.play();
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
'authorized': ref( true ),
|
||||||
|
'id': 'local',
|
||||||
|
'name': 'Local Disk',
|
||||||
|
'play': () => player.play(),
|
||||||
|
'getPlaybackPos': () => player.currentTime / player.duration,
|
||||||
|
'getDuration': () => player.duration,
|
||||||
|
playSong,
|
||||||
|
'seekTo': pos => player.currentTime = pos * player.duration,
|
||||||
|
'pause': () => player.pause(),
|
||||||
|
'stop': () => player.src = '',
|
||||||
|
'addSongsFromThisSource': load,
|
||||||
|
'loading': {
|
||||||
|
'requiresLocalFiles': true,
|
||||||
|
'association': associate,
|
||||||
|
'updateIdentifiers': updateIdentifiers,
|
||||||
|
'mime': 'audio/aac,audio/mpeg,audio/wav,audio/mp4,audio/ogg'
|
||||||
|
},
|
||||||
|
'songUnload': unload
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
import {
|
||||||
|
createFileAssociationString
|
||||||
|
} from './association';
|
||||||
|
import {
|
||||||
|
initAppleMusicApiSearch
|
||||||
|
} from '@/ts/util/search';
|
||||||
|
import {
|
||||||
|
openDiskLoaderInterface
|
||||||
|
} from '@/composables/diskLoader';
|
||||||
|
import {
|
||||||
|
parseBlob
|
||||||
|
} from 'music-metadata';
|
||||||
|
|
||||||
|
export const load = ( cb: ( songs: Song[] ) => void ) => {
|
||||||
|
const search = initAppleMusicApiSearch();
|
||||||
|
|
||||||
|
const process = async ( files: FileList, status: ( progress: number ) => void ) => {
|
||||||
|
const songs: Song[] = [];
|
||||||
|
|
||||||
|
for ( let i = 0; i < files.length; i++ ) {
|
||||||
|
const file = files[i]!;
|
||||||
|
|
||||||
|
try {
|
||||||
|
songs.push( await generateSongObject( file ) );
|
||||||
|
} catch ( error ) {
|
||||||
|
console.error( '[LOADER] Failed generating song info for file', file, 'with error', error );
|
||||||
|
}
|
||||||
|
|
||||||
|
status( ( i + 1 ) / files.length );
|
||||||
|
}
|
||||||
|
|
||||||
|
cb( songs );
|
||||||
|
};
|
||||||
|
|
||||||
|
openDiskLoaderInterface( {
|
||||||
|
'name': 'From Disk',
|
||||||
|
'process': process,
|
||||||
|
'type': 'file',
|
||||||
|
'mime': 'audio/aac,audio/mpeg,audio/wav,audio/mp4,audio/ogg'
|
||||||
|
} );
|
||||||
|
|
||||||
|
const generateSongObject = async ( file: File ): Promise<Song> => {
|
||||||
|
console.log( 'Analyzing file', file );
|
||||||
|
const url = URL.createObjectURL( file );
|
||||||
|
const blob = await ( await fetch( url ) ).blob();
|
||||||
|
// Load audio file and parse its metadata
|
||||||
|
const data = await parseBlob( blob );
|
||||||
|
const searchTerm = data.common.title
|
||||||
|
? data.common.title + ( data.common.artist ? ' ' + data.common.artist : '' )
|
||||||
|
: file.name.split( '.' )[ 0 ]!.replace( '_', ' ' );
|
||||||
|
const result = ( await search( searchTerm, 1 ) )[ 0 ];
|
||||||
|
|
||||||
|
if ( result ) {
|
||||||
|
result.source = 'local';
|
||||||
|
result['additional-identifier'] = createFileAssociationString( file );
|
||||||
|
result.identifier = url;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
console.warn( '[LOADER] No results found for', searchTerm );
|
||||||
|
|
||||||
|
return {
|
||||||
|
'additional-identifier': file.name,
|
||||||
|
'source': 'local',
|
||||||
|
'identifier': url,
|
||||||
|
'artist': data.common.artist ?? 'Unknown Artist',
|
||||||
|
'name': data.common.title ?? 'Unknown title',
|
||||||
|
'artwork': '',
|
||||||
|
'additional-info': '',
|
||||||
|
'duration': -1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const unload = async ( song: Song ) => {
|
||||||
|
URL.revokeObjectURL( song.identifier );
|
||||||
|
};
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import type {
|
||||||
|
PlayerSourcePlugin,
|
||||||
|
PlayerSourcePluginInitializer
|
||||||
|
} from '../interface';
|
||||||
|
import {
|
||||||
|
addFromAppleMusic
|
||||||
|
} from './search';
|
||||||
|
import {
|
||||||
|
musicKitPlayback
|
||||||
|
} from './playback';
|
||||||
|
import request from '@/ts/request';
|
||||||
|
|
||||||
|
export const useMusicKit: PlayerSourcePluginInitializer = ( storefront: string = 'ch' ): Promise<PlayerSourcePlugin> => {
|
||||||
|
return new Promise( ( resolve, reject ) => {
|
||||||
|
const init = async ( storefront: string ): Promise<PlayerSourcePlugin> => {
|
||||||
|
const token = await ( await request.get( '/dev-token' ) ).text();
|
||||||
|
const instance = await window.MusicKit.configure( {
|
||||||
|
'developerToken': token,
|
||||||
|
'app': {
|
||||||
|
'name': 'MusicPlayer',
|
||||||
|
'build': '4'
|
||||||
|
// 'icon': 'https://music.janishutz.com/logo.jpg'
|
||||||
|
},
|
||||||
|
'storefrontId': storefront.toUpperCase()
|
||||||
|
} );
|
||||||
|
const controls = musicKitPlayback( instance );
|
||||||
|
|
||||||
|
const login = async (): Promise<boolean> => {
|
||||||
|
try {
|
||||||
|
await instance.authorize();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
'authorized': controls.loggedIn,
|
||||||
|
'play': controls.play,
|
||||||
|
'pause': controls.pause,
|
||||||
|
'stop': controls.stop,
|
||||||
|
'playSong': controls.playSong,
|
||||||
|
'getDuration': controls.getDuration,
|
||||||
|
'getPlaybackPos': controls.getPlaybackPos,
|
||||||
|
'id': 'applemusic',
|
||||||
|
'name': 'Apple Music',
|
||||||
|
'seekTo': controls.seekTo,
|
||||||
|
'login': login,
|
||||||
|
'addSongsFromThisSource': addFromAppleMusic,
|
||||||
|
'loading': {
|
||||||
|
'requiresLocalFiles': false
|
||||||
|
},
|
||||||
|
'songUnload': async () => {}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if ( !window.MusicKit ) {
|
||||||
|
document.addEventListener( 'musickitloaded', () => {
|
||||||
|
init( storefront )
|
||||||
|
.then( resolve )
|
||||||
|
.catch( reject );
|
||||||
|
} );
|
||||||
|
} else {
|
||||||
|
init( storefront )
|
||||||
|
.then( resolve )
|
||||||
|
.catch( reject );
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
};
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import type {
|
||||||
|
MusicKitInstance
|
||||||
|
} from 'musickitjs-v3-types/MusicKitInstance';
|
||||||
|
import {
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
export const musicKitPlayback = ( musickitInstance: MusicKitInstance ) => {
|
||||||
|
const play = () => {
|
||||||
|
musickitInstance.play();
|
||||||
|
};
|
||||||
|
|
||||||
|
const pause = () => {
|
||||||
|
musickitInstance.pause();
|
||||||
|
};
|
||||||
|
|
||||||
|
const seekTo = ( pos: number ) => {
|
||||||
|
musickitInstance.seekToTime( pos * musickitInstance.currentPlaybackDuration );
|
||||||
|
};
|
||||||
|
|
||||||
|
const playSong = async ( id: string ) => {
|
||||||
|
await musickitInstance.setQueue( {
|
||||||
|
'song': id
|
||||||
|
} );
|
||||||
|
musickitInstance.play();
|
||||||
|
};
|
||||||
|
|
||||||
|
const stop = () => {
|
||||||
|
musickitInstance.stop();
|
||||||
|
};
|
||||||
|
|
||||||
|
const getPlaybackPos = (): number => {
|
||||||
|
return musickitInstance.currentPlaybackTime / musickitInstance.currentPlaybackDuration;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDuration = (): number => {
|
||||||
|
return musickitInstance.currentPlaybackDuration;
|
||||||
|
};
|
||||||
|
|
||||||
|
const loggedIn = ref( musickitInstance.isAuthorized );
|
||||||
|
|
||||||
|
musickitInstance.addEventListener( 'authorizationStatusDidChange', () => {
|
||||||
|
loggedIn.value = musickitInstance.isAuthorized;
|
||||||
|
} );
|
||||||
|
|
||||||
|
return {
|
||||||
|
play,
|
||||||
|
pause,
|
||||||
|
seekTo,
|
||||||
|
playSong,
|
||||||
|
stop,
|
||||||
|
getPlaybackPos,
|
||||||
|
getDuration,
|
||||||
|
loggedIn
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import type {
|
||||||
|
Artwork
|
||||||
|
} from 'musickitjs-v3-types/enums';
|
||||||
|
|
||||||
|
export interface AppleMusicApiSearchResult {
|
||||||
|
'results': {
|
||||||
|
'songs': {
|
||||||
|
'data': AppleMusicSongData[],
|
||||||
|
'href': string;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AppleMusicSongData {
|
||||||
|
'id': string,
|
||||||
|
'type': string;
|
||||||
|
'href': string;
|
||||||
|
'attributes': {
|
||||||
|
'albumName': string;
|
||||||
|
'artistName': string;
|
||||||
|
'artwork': Artwork;
|
||||||
|
'name': string;
|
||||||
|
'genreNames': string[];
|
||||||
|
'durationInMillis': number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AppleMusicPlaylistData {
|
||||||
|
'id': string;
|
||||||
|
'type': string;
|
||||||
|
'href': string;
|
||||||
|
'attributes': {
|
||||||
|
'artwork': Artwork;
|
||||||
|
'name': string;
|
||||||
|
},
|
||||||
|
'relationships'?: {
|
||||||
|
'tracks': {
|
||||||
|
'href': string,
|
||||||
|
'next': string,
|
||||||
|
'data': AppleMusicSongData
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import {
|
||||||
|
type CloudImport,
|
||||||
|
openImportTypePicker
|
||||||
|
} from '@/composables/importTypePicker';
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
import {
|
||||||
|
openSearchInterface
|
||||||
|
} from '@/composables/searchManager';
|
||||||
|
import {
|
||||||
|
searchPlaylists
|
||||||
|
} from './playlists';
|
||||||
|
import {
|
||||||
|
searchSongs
|
||||||
|
} from './songs';
|
||||||
|
|
||||||
|
export const addFromAppleMusic = async ( cb: ( songs: Song[] ) => void, kindIdx?: number, autoClose?: boolean ): Promise<void> => {
|
||||||
|
const songs = await searchSongs( cb );
|
||||||
|
const playlists = await searchPlaylists( cb );
|
||||||
|
const kinds: CloudImport[] = [
|
||||||
|
{
|
||||||
|
'name': 'Songs',
|
||||||
|
'type': 'cloud',
|
||||||
|
'addSelected': songs.addSelected,
|
||||||
|
'search': songs.search,
|
||||||
|
'minChars': 3,
|
||||||
|
'autoClose': autoClose ?? false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'name': 'Playlists',
|
||||||
|
'type': 'cloud',
|
||||||
|
'addSelected': playlists.addSelected,
|
||||||
|
'search': playlists.search,
|
||||||
|
'autoClose': autoClose ?? false
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
if ( kindIdx === undefined )
|
||||||
|
openImportTypePicker( kinds );
|
||||||
|
else
|
||||||
|
openSearchInterface( kinds[kindIdx]! );
|
||||||
|
};
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import type {
|
||||||
|
AppleMusicPlaylistData,
|
||||||
|
AppleMusicSongData
|
||||||
|
} from './dtype';
|
||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
|
||||||
|
export const searchPlaylists = async ( cb: ( songs: Song[] ) => void ) => {
|
||||||
|
let playlists: Song[] = [];
|
||||||
|
let filtered: Song[] = [];
|
||||||
|
|
||||||
|
const instance = window.MusicKit.getInstance();
|
||||||
|
|
||||||
|
const search = async ( term: string, offset: number = 0 ): Promise<Song[]> => {
|
||||||
|
if ( playlists.length === 0 ) {
|
||||||
|
playlists = ( ( await instance.api.music( '/v1/me/library/playlists', {
|
||||||
|
'limit': 100,
|
||||||
|
'offset': offset
|
||||||
|
} ) ).data as {
|
||||||
|
'data': AppleMusicPlaylistData[]
|
||||||
|
} ).data.map( val => {
|
||||||
|
return {
|
||||||
|
'artist': 'Playlist',
|
||||||
|
'artwork': val.attributes.artwork ? window.MusicKit.formatArtworkURL( val.attributes.artwork, 1000, 100 ) : '',
|
||||||
|
'duration': 0,
|
||||||
|
'identifier': val.id,
|
||||||
|
'additional-info': '',
|
||||||
|
'name': val.attributes.name,
|
||||||
|
'source': 'applemusic'
|
||||||
|
};
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
term = term.toLocaleLowerCase();
|
||||||
|
filtered = playlists.filter( val => {
|
||||||
|
return val.name.toLocaleLowerCase().includes( term );
|
||||||
|
} );
|
||||||
|
|
||||||
|
return filtered;
|
||||||
|
};
|
||||||
|
|
||||||
|
const addSelected = async ( idx: number ) => {
|
||||||
|
try {
|
||||||
|
const results = ( await instance.api.music( '/v1/me/library/playlists/' + filtered[idx]!.identifier + '/tracks' ) ).data as {
|
||||||
|
'data': AppleMusicSongData[]
|
||||||
|
};
|
||||||
|
const songs: Song[] = results.data
|
||||||
|
.map( val => {
|
||||||
|
return {
|
||||||
|
'identifier': val.id,
|
||||||
|
'additional-info': '',
|
||||||
|
'artist': val.attributes.artistName,
|
||||||
|
'name': val.attributes.name,
|
||||||
|
'artwork': window.MusicKit.formatArtworkURL( val.attributes.artwork, 1000, 1000 ),
|
||||||
|
'duration': val.attributes.durationInMillis * 1000,
|
||||||
|
'source': 'applemusic'
|
||||||
|
};
|
||||||
|
} );
|
||||||
|
|
||||||
|
cb( songs );
|
||||||
|
} catch ( error ) {
|
||||||
|
console.error( '[ADD PLAYLIST] Failed to add playlist due to error', error );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
search,
|
||||||
|
addSelected
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import type {
|
||||||
|
Song
|
||||||
|
} from '@/ts/dtype/playlist';
|
||||||
|
import {
|
||||||
|
initAppleMusicApiSearch
|
||||||
|
} from '@/ts/util/search';
|
||||||
|
|
||||||
|
export const searchSongs = async ( cb: ( songs: Song[] ) => void ) => {
|
||||||
|
let songs: Song[] = [];
|
||||||
|
|
||||||
|
const searchFunc = initAppleMusicApiSearch();
|
||||||
|
|
||||||
|
const search = async ( term: string, offset: number = 0 ) => {
|
||||||
|
songs = await searchFunc( term, 15, offset );
|
||||||
|
|
||||||
|
return songs;
|
||||||
|
};
|
||||||
|
|
||||||
|
const addSelected = async ( idx: number ) => {
|
||||||
|
cb( [ songs[idx]! ] );
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
search,
|
||||||
|
addSelected
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
import {
|
||||||
|
type Ref,
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
import type {
|
||||||
|
PlayerSourcePlugin
|
||||||
|
} from './plugins/interface';
|
||||||
|
import type {
|
||||||
|
PlaylistSongs
|
||||||
|
} from '../dtype/playlist';
|
||||||
|
import type {
|
||||||
|
RepeatMode
|
||||||
|
} from '../dtype/player';
|
||||||
|
import {
|
||||||
|
useLocalPlayer
|
||||||
|
} from './plugins/local';
|
||||||
|
import {
|
||||||
|
useMusicKit
|
||||||
|
} from './plugins/musickit';
|
||||||
|
|
||||||
|
export const sources: {
|
||||||
|
[key: string]: PlayerSourcePlugin
|
||||||
|
} = {};
|
||||||
|
|
||||||
|
export const currentSource = ref( '' );
|
||||||
|
|
||||||
|
export const rawQueue: Ref<PlaylistSongs> = ref( [] );
|
||||||
|
|
||||||
|
export const queueIdx = ref( -1 );
|
||||||
|
|
||||||
|
export const queue: Ref<PlaylistSongs> = ref( [] );
|
||||||
|
|
||||||
|
export const isPlaying = ref( false );
|
||||||
|
|
||||||
|
export const shuffle = ref( false );
|
||||||
|
|
||||||
|
export const repeat: Ref<RepeatMode> = ref( 'off' );
|
||||||
|
|
||||||
|
export const fullPlayer = ref( false );
|
||||||
|
|
||||||
|
const initSources = async () => {
|
||||||
|
try {
|
||||||
|
sources['applemusic'] = await useMusicKit();
|
||||||
|
} catch {
|
||||||
|
console.warn( 'MusicKitJS intialization failed' );
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
sources['local'] = await useLocalPlayer();
|
||||||
|
} catch {
|
||||||
|
console.warn( 'Local Player intialization failed' );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
initSources();
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import {
|
||||||
|
currentSource,
|
||||||
|
queueIdx,
|
||||||
|
repeat,
|
||||||
|
sources
|
||||||
|
} from './state';
|
||||||
|
import {
|
||||||
|
playIndex
|
||||||
|
} from './playlists';
|
||||||
|
import {
|
||||||
|
ref
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
|
// Tracking of time and player status
|
||||||
|
let interval = -1;
|
||||||
|
|
||||||
|
export const playbackPercentage = ref( 1 );
|
||||||
|
|
||||||
|
export const duration = ref( -1 );
|
||||||
|
|
||||||
|
export const startTracking = () => {
|
||||||
|
if ( interval === -1 ) {
|
||||||
|
interval = setInterval( tracker, 250 );
|
||||||
|
}
|
||||||
|
|
||||||
|
duration.value = sources[currentSource.value]?.getDuration() ?? -1;
|
||||||
|
setTimeout( () => {
|
||||||
|
duration.value = sources[currentSource.value]?.getDuration() ?? -1;
|
||||||
|
}, 2000 );
|
||||||
|
};
|
||||||
|
|
||||||
|
const tracker = () => {
|
||||||
|
playbackPercentage.value = sources[currentSource.value]?.getPlaybackPos() ?? -1;
|
||||||
|
|
||||||
|
if ( playbackPercentage.value > 0.995 && duration.value > 0 ) {
|
||||||
|
if ( repeat.value === 'one' ) {
|
||||||
|
sources[currentSource.value]?.seekTo( 0 );
|
||||||
|
} else {
|
||||||
|
stopTracking();
|
||||||
|
playIndex( queueIdx.value + 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const stopTracking = () => {
|
||||||
|
try {
|
||||||
|
clearInterval( interval );
|
||||||
|
} catch {
|
||||||
|
// empty
|
||||||
|
}
|
||||||
|
|
||||||
|
interval = -1;
|
||||||
|
};
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
export class AuthError extends Error {}
|
||||||
|
|
||||||
|
export class UnownedError extends Error {}
|
||||||
|
|
||||||
|
|
||||||
|
const get = async ( url: string ): Promise<Response> => {
|
||||||
|
return await wrapper( url, {
|
||||||
|
'credentials': 'include'
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
const backendURL = import.meta.env.VITE_BACKEND_URL;
|
||||||
|
|
||||||
|
const post = async ( url: string, payload: string, mime: string = 'application/json' ): Promise<Response> => {
|
||||||
|
return await wrapper( url, {
|
||||||
|
'credentials': 'include',
|
||||||
|
'body': payload,
|
||||||
|
'method': 'post',
|
||||||
|
'headers': {
|
||||||
|
'Content-Type': mime ?? 'application/json'
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = async ( url: string, opts: RequestInit ): Promise<Response> => {
|
||||||
|
const res = await fetch( backendURL + url, opts );
|
||||||
|
|
||||||
|
if ( res.ok ) {
|
||||||
|
return res;
|
||||||
|
} else if ( res.status === 403 || res.status === 401 ) {
|
||||||
|
document.dispatchEvent( new CustomEvent( 'musicplayer:autherror' ) );
|
||||||
|
|
||||||
|
throw new AuthError( 'ERR_USER_UNAUTHORIZED' );
|
||||||
|
} else if ( res.status === 402 ) {
|
||||||
|
throw new UnownedError( 'ERR_USER_UNOWNED' );
|
||||||
|
} else {
|
||||||
|
throw new Error( 'ERR_' + res.status );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
get,
|
||||||
|
post,
|
||||||
|
backendURL
|
||||||
|
};
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user