chore: moved to a new branch to save space

This commit is contained in:
Haoyu Xu
2023-03-16 21:49:29 -04:00
commit 6ef70824a1
116 changed files with 23521 additions and 0 deletions

15
.eslintrc.json Normal file
View File

@@ -0,0 +1,15 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
}
}

69
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,69 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

133
.gitignore vendored Normal file
View File

@@ -0,0 +1,133 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
.cache
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# custom
release/*

6
.postcssrc.json Normal file
View File

@@ -0,0 +1,6 @@
{
"map": true,
"plugins": {
"autoprefixer": {}
}
}

3
.stylelintrc.json Normal file
View File

@@ -0,0 +1,3 @@
{
"extends": "stylelint-config-standard-scss"
}

54
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,54 @@
{
"configurations": [
{
"name": "Launch Chrome",
"request": "launch",
"type": "chrome",
"url": "http://localhost:5173",
"webRoot": "${workspaceFolder}",
"runtimeExecutable": "/usr/bin/google-chrome-stable"
},
{
"type": "node-terminal",
"name": "Run Script: charword",
"request": "launch",
"command": "pnpm run charword",
"cwd": "${workspaceFolder}"
},
{
"type": "node-terminal",
"name": "Run Script: build chen",
"request": "launch",
"command": "pnpm run build chen",
"cwd": "${workspaceFolder}"
},
{
"type": "node-terminal",
"name": "Run Script: build-all",
"request": "launch",
"command": "pnpm run build-all",
"cwd": "${workspaceFolder}"
},
{
"type": "node-terminal",
"name": "Run Script: test",
"request": "launch",
"command": "pnpm run test",
"cwd": "${workspaceFolder}"
},
{
"type": "node-terminal",
"name": "Run Script: dev",
"request": "launch",
"command": "pnpm run dev chen",
"cwd": "${workspaceFolder}"
},
{
"type": "node-terminal",
"name": "Run Script: Directory dev",
"request": "launch",
"command": "pnpm run vite:directory:dev",
"cwd": "${workspaceFolder}"
}
]
}

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"yaml.customTags": ["!match", "!include"]
}

674
LICENSE Normal file
View File

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

26
LICENSE_SPINE Normal file
View File

@@ -0,0 +1,26 @@
Spine Runtimes License Agreement
Last updated May 1, 2019. Replaces all prior versions.
Copyright (c) 2013-2019, Esoteric Software LLC
Integration of the Spine Runtimes into software or otherwise creating
derivative works of the Spine Runtimes is permitted under the terms and
conditions of Section 2 of the Spine Editor License Agreement:
http://esotericsoftware.com/spine-editor-license
Otherwise, it is permitted to integrate the Spine Runtimes into software
or otherwise create derivative works of the Spine Runtimes (collectively,
"Products"), provided that each user of the Products must obtain their own
Spine Editor license and redistribution of the Products in any form must
include this license and copyright notice.
THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, BUSINESS
INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

177
README.md Normal file
View File

@@ -0,0 +1,177 @@
# aklive2d
A project that builds showcase webpage for Arknights Live2D-equipped operators. Showcase webpage can be used as a wallpaper for Wallpaper Engine on Windows or [Plash](https://github.com/sindresorhus/Plash) on macOS (not tested).
## Softwares
- For Windows users: Use [Wallpaper Engine](https://www.wallpaperengine.io/en) or other softwares that support using webpage as desktop wallpaper.
- For macOS users: Use [Plash](https://github.com/sindresorhus/Plash), however, I don't have macOS machine, so your mileage may vary.
- For Linux users: You power user should be able to find your solutions!
## Usage
### Command Line Tool
``` bash
$ npm run generate {operator_name}
To generate operator assets for showcase page
```
``` bash
$ npm run dev {operator_name}
Live showcase page server for development
```
``` bash
$ npm run build {operator_name}
Build showcase webpage for an operator
```
``` bash
$ npm run build-all
To generate all operator assets for showcase page
```
``` bash
$ npm run init {operator_name}
To initialize folder and config file for an operator
```
``` bash
$ npm run readme {operator_name}
To add operator info to README.md
```
``` bash
$ npm run directory
To generate directory.json
```
``` bash
$ npm run charword
To generate the latest charword_table.json
```
### Webpage & JavaScript
Add query string `settings` to bring up the settings panel to adjust your settings. Then use appropriate JavaScript code to load your settings
``` javascript
settings.setFPS(integer) // set FPS
settings.setLogoDisplay(boolean) // display logo or not
settings.setLogoRatio(float) // the ratio of the logo
settings.setLogoOpacity(float) // the opacity of the logo
settings.setLogo(url) // change the logo, url: image url, removeInvert: boolean
settings.resetLogoImage() // reset to the default logo
settings.setDefaultBackground(url) // change the default background, url: image filename from `background` folder
settings.setBackgoundImage(url) // change the background, url: image url
settings.resetBackground() // reset to the default background
settings.positionPadding("left", integer) // left padding
settings.positionPadding("right", integer) // right padding
settings.positionPadding("top", integer) // top padding
settings.positionPadding("bottom", integer) // bottom padding
settings.positionReset() // reset the position
settings.open() // open settings panel
settings.close() // close settings panel
settings.reset() // reset settings
```
## Config
### General Config
``` yaml
folder:
operator: ./operator/ # folder for operator assets
release: ./release/ # folder for released showcase page
operators:
chen: !include config/chen.yaml # include the config for the operator under folder `config/chen.yaml`
dusk: !include config/dusk.yaml
dusk_everything_is_a_miracle: !include config/dusk_everything_is_a_miracle.yaml
ling: !include config/ling.yaml
nearl: !include config/nearl.yaml
nian: !include config/nian.yaml
nian_unfettered_freedom: !include config/nian_unfettered_freedom.yaml
phatom_focus: !include config/phatom_focus.yaml
rosmontis: !include config/rosmontis.yaml
skadi: !include config/skadi.yaml
skadi_sublimation: !include config/skadi_sublimation.yaml
w: !include config/w.yaml
w_fugue: !include config/w_fugue.yaml
specter: !include config/specter.yaml
gavial: !include config/gavial.yaml
surtr_colorful_wonderland: !include config/surtr_colorful_wonderland.yaml
lee_trust_your_eyes: !include config/lee_trust_your_eyes.yaml
texas_the_omertosa: !include config/texas_the_omertosa.yaml
nearl_relight: !include config/nearl_relight.yaml
rosmontis_become_anew: !include config/rosmontis_become_anew.yaml
passager_dream_in_a_moment: !include config/passager_dream_in_a_moment.yaml
mizuki_summer_feast: !include config/mizuki_summer_feast.yaml
```
### Operator Config
```yaml
link: chen # the link to access showcase page for this operator
type: operator # operator live2d or skin live2d
date: 2021/08 # release date
title: 'Arknights: Ch''en/Chen the Holungday - 明日方舟:假日威龙陈' # page title
filename: dyn_illust_char_1013_chen2 # live2d assets name
logo: logo_rhodes_override # operator logo
fallback_name: char_1013_chen2_2 # fallback image name
viewport_left: 0 # live2d view port settings
viewport_right: 0
viewport_top: 1
viewport_bottom: 1
invert_filter: false # operator logo invert filter
```
## LICENSE
The `LICENSE` file applies to all files unless listed specifically.
`LICENSE_SPINE` file applies to following files including adapted code for this repo:
- `src/libs/spine-player.css`
- `src/libs/spine-player.js`
`Copyright © 2017 - 2023 Arknights/Hypergryph Co., Ltd` applies to following files:
- all files under `operator` folder and its sub-folders
## Instructions on Extracting In-Game Assets
I'm still struggling to find a command-line tool to extract in-game assets. But [AssetRipper](https://github.com/AssetRipper/AssetRipper) seems to have a command-line interface, I'm too lazy to have a deeper inverstigation.
| Assets Name | Location | Type |
|-------------|----------|------|
| Logos | spritepack/ui_camp_logo_h2_0.ab | Sprite |
| Logos for collaboration | spritepack/ui_camp_logo_h2_linkage_0.ab | Sprite |
| Dynaimc Character | arts/dynchars/ | Texture2D & TextAsset |
| Static Image | Operator: chararts/ ; Skin: skinpack/ | Texture2D |
| Background | arts/ui/homebackground/wrapper/ | Sprite |
| Voice Clips | audio/sound_beta_2/voice{_*}/ | AudioClip |
| Voice Lines<sup>3</sup> | gamedata/excel/charword_table.ab | TextAsset |
| Portrait Images<sup>1</sup> | arts/charportraits | Texture2D |
| Home Music<sup>2</sup> | audio/sound_beta_2/music | AudioClip |
<sup>1</sup>: `portrait_hub` is required to locate the image
<sup>2</sup>: `gamedata/excel/display_meta_table.json->homeBackgroundData`<sup>3</sup> is required to locate the music. A more detailed mapping can be found at [音乐鉴赏/游戏内音乐一览 - PRTS.wiki](https://prts.wiki/w/%E9%9F%B3%E4%B9%90%E9%89%B4%E8%B5%8F/%E6%B8%B8%E6%88%8F%E5%86%85%E9%9F%B3%E4%B9%90%E4%B8%80%E8%A7%88) and [首页场景一览 - PRTS.wiki](https://prts.wiki/w/%E9%A6%96%E9%A1%B5%E5%9C%BA%E6%99%AF%E4%B8%80%E8%A7%88)
<sup>3</sup>: Data is encryped, decryped version can be obtained from [ArknightsGameData](https://github.com/Kengxxiao/ArknightsGameData)
## Supported Operators
| Operator | Live Preview | Steam Workshop |
|----------|--------------|----------------|
| Nian | [Link](https://arknights.halyul.dev/nian/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2564642594) |
| Unfettered Freedom / Nian | [Link](https://arknights.halyul.dev/nian_unfettered_freedom/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2730943815) |
| Focus / Phatom | [Link](https://arknights.halyul.dev/phatom_focus/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2786960745) |
| W | [Link](https://arknights.halyul.dev/w/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2642838078) |
| Wonder / W | [Link](https://arknights.halyul.dev/w_wonder/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2802584758) |
| Rosmontis | [Link](https://arknights.halyul.dev/rosmontis/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2642834981) |
| Dusk | [Link](https://arknights.halyul.dev/dusk/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2730942651) |
| Everything is a Miracle / Dusk | [Link](https://arknights.halyul.dev/dusk_everything_is_a_miracle/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2730943249) |
| Skadi the Corrupting Heart | [Link](https://arknights.halyul.dev/skadi/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2492307783) |
| Sublimation / Skadi the Corrupting Heart | [Link](https://arknights.halyul.dev/skadi_sublimation/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2802570125) |
| Ch'en the Holungday | [Link](https://arknights.halyul.dev/chen/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2564643862) |
| Nearl the Radiant Knight | [Link](https://arknights.halyul.dev/nearl/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2642836787) |
| Ling | [Link](https://arknights.halyul.dev/ling/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2730944363) |
| Specter the Unchained | [Link](https://arknights.halyul.dev/specter/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2802596772) |
| Gavial the Invincible | [Link](https://arknights.halyul.dev/gavial/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2847605961) |
| Colorful Wonderland / Surtr | [Link](https://arknights.halyul.dev/surtr_colorful_wonderland/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2847602015) |
| Trust Your Eyes / Lee | [Link](https://arknights.halyul.dev/lee_trust_your_eyes/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2879452075) |
| Texas the Omertosa | [Link](https://arknights.halyul.dev/texas_the_omertosa/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2883008286) |
| Relight / Nearl | [Link](https://arknights.halyul.dev/nearl_relight/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2883016965) |
| Become Anew / Rosmontis | [Link](https://arknights.halyul.dev/rosmontis_become_anew/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2883012349) |
| Dream in a Moment / Passager | [Link](https://arknights.halyul.dev/passager_dream_in_a_moment/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2883021565) |
| Summer Feast / Mizuki | [Link](https://arknights.halyul.dev/mizuki_summer_feast/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2895953271) |
| Chongyue | [Link](https://arknights.halyul.dev/chongyue/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2919486659) |
| It Does Wash the Strings / Ling | [Link](https://arknights.halyul.dev/ling_it_does_wash_the_strings/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2919482772) |
| Snowy Plains in Words / Позёмка | [Link](https://arknights.halyul.dev/pozemka_snowy_plains_in_words/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=2933544301) |

1
Version Normal file
View File

@@ -0,0 +1 @@
3.5.1

246
aklive2d.js Normal file
View File

@@ -0,0 +1,246 @@
/* eslint-disable no-fallthrough */
/* eslint-disable no-undef */
import assert from 'assert'
import path from 'path'
import { fileURLToPath } from 'url'
import { fork } from 'child_process';
import getConfig from './libs/config.js'
import ProjectJson from './libs/project_json.js'
import EnvGenerator from './libs/env_generator.js'
import { write, rmdir, copy, writeSync, copyDir } from './libs/file.js'
import AssetsProcessor from './libs/assets_processor.js'
import init from './libs/initializer.js'
import directory from './libs/directory.js'
import { appendReadme } from './libs/append.js'
import { increase } from './libs/version.js';
import Background from './libs/background.js'
import CharwordTable from './libs/charword_table.js';
import Music from './libs/music.js';
async function main() {
global.__projectRoot = path.dirname(fileURLToPath(import.meta.url))
global.__config = getConfig()
const op = process.argv[2]
let OPERATOR_NAMES = process.argv.slice(3);
const charwordTable = new CharwordTable()
/**
* Skip all, no need for OPERATOR_NAME
* build-all: build all assets
* directory: build directory
*/
switch (op) {
case 'directory':
assert(OPERATOR_NAMES.length !== 0, 'Please set a mode for Directory.')
fork(path.join(__projectRoot, 'vite.config.js'), [op, OPERATOR_NAMES])
return
case 'build-all':
for (const [key,] of Object.entries(__config.operators)) {
OPERATOR_NAMES.push(key)
}
__config.version.showcase = increase(__projectRoot)
break
case 'preview':
assert(OPERATOR_NAMES.length !== 0, 'Please set the operator name.')
fork(path.join(__projectRoot, 'vite.config.js'), [op, OPERATOR_NAMES])
return
case 'charword':
await charwordTable.process()
process.exit(0)
default:
break
}
assert(OPERATOR_NAMES.length !== 0, 'Please set the operator name.')
const background = new Background()
await background.process()
const backgrounds = ['operator_bg.png', ...background.files]
const { musicToCopy, musicMapping } = Music()
for (const OPERATOR_NAME of OPERATOR_NAMES) {
const OPERATOR_SOURCE_FOLDER = path.join(__projectRoot, __config.folder.operator)
const OPERATOR_RELEASE_FOLDER = path.join(__projectRoot, __config.folder.release, OPERATOR_NAME)
const SHOWCASE_PUBLIC_ASSSETS_FOLDER = path.join(OPERATOR_RELEASE_FOLDER, "assets")
const EXTRACTED_FOLDER = path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, 'extracted')
const VOICE_FOLDERS = __config.folder.voice.sub.map((sub) => path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, __config.folder.voice.main, sub.name))
const OPERATOR_SHARE_FOLDER = path.join(OPERATOR_SOURCE_FOLDER, __config.folder.share)
/**
* Skip assets generation part
* init: init folder and config for an operator
* readme: append a new line to README.md
*/
switch (op) {
case 'init':
init(OPERATOR_NAME, [EXTRACTED_FOLDER, ...VOICE_FOLDERS])
process.exit(0)
case 'readme':
appendReadme(OPERATOR_NAME)
process.exit(0)
default:
break
}
rmdir(OPERATOR_RELEASE_FOLDER)
const charwordTableLookup = charwordTable.lookup(OPERATOR_NAME)
const voiceJson = {}
voiceJson.config = {
default_region: charwordTableLookup.config.default_region.replace("_", "-"),
regions: charwordTableLookup.config.regions.map((item) => item.replace("_", "-")),
}
voiceJson.voiceLangs = {}
voiceJson.subtitleLangs = {}
const subtitleInfo = Object.keys(charwordTableLookup.operator.info)
subtitleInfo.forEach((item) => {
if (Object.keys(charwordTableLookup.operator.info[item]).length > 0) {
const key = item.replace("_", "-")
voiceJson.subtitleLangs[key] = {}
for (const [id, subtitles] of Object.entries(charwordTableLookup.operator.voice[item])) {
const match = id.replace(/(.+?)([A-Z]\w+)/, '$2')
if (match === id) {
voiceJson.subtitleLangs[key].default = subtitles
} else {
voiceJson.subtitleLangs[key][match] = subtitles
}
}
voiceJson.voiceLangs[key] = {}
Object.values(charwordTableLookup.operator.info[item]).forEach((item) => {
voiceJson.voiceLangs[key] = { ...voiceJson.voiceLangs[key], ...item }
})
}
})
const voiceLangs = Object.keys(voiceJson.voiceLangs["zh-CN"])
const subtitleLangs = Object.keys(voiceJson.subtitleLangs)
writeSync(JSON.stringify(voiceJson), path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, 'charword_table.json'))
const envPath = path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, '.env')
writeSync((new EnvGenerator()).generate([
{
key: "link",
value: __config.operators[OPERATOR_NAME].link
}, {
key: "title",
value: __config.operators[OPERATOR_NAME].title
}, {
key: "filename",
value: __config.operators[OPERATOR_NAME].filename.replace('#', '%23')
}, {
key: "logo_filename",
value: __config.operators[OPERATOR_NAME].logo
}, {
key: "fallback_filename",
value: __config.operators[OPERATOR_NAME].fallback_name.replace('#', '%23')
}, {
key: "viewport_left",
value: __config.operators[OPERATOR_NAME].viewport_left
}, {
key: "viewport_right",
value: __config.operators[OPERATOR_NAME].viewport_right
}, {
key: "viewport_top",
value: __config.operators[OPERATOR_NAME].viewport_top
}, {
key: "viewport_bottom",
value: __config.operators[OPERATOR_NAME].viewport_bottom
}, {
key: "invert_filter",
value: __config.operators[OPERATOR_NAME].invert_filter
}, {
key: "image_width",
value: 2048
}, {
key: "image_height",
value: 2048
}, {
key: "background_files",
value: JSON.stringify(backgrounds)
}, {
key: "background_folder",
value: __config.folder.background
}, {
key: "voice_folders",
value: JSON.stringify(__config.folder.voice)
}, {
key: "music_folder",
value: __config.folder.music
}, {
key: "music_mapping",
value: JSON.stringify(musicMapping)
}
]), envPath)
const projectJson = new ProjectJson(OPERATOR_NAME, OPERATOR_SHARE_FOLDER, {
backgrounds,
voiceLangs,
subtitleLangs,
music: Object.keys(musicMapping)
})
projectJson.load().then((content) => {
write(JSON.stringify(content, null, 2), path.join(OPERATOR_RELEASE_FOLDER, 'project.json'))
})
const assetsProcessor = new AssetsProcessor(OPERATOR_NAME, OPERATOR_SHARE_FOLDER)
assetsProcessor.process(EXTRACTED_FOLDER).then((content) => {
write(JSON.stringify(content.assetsJson, null), path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, `assets.json`))
})
const filesToCopy = [
...background.getFilesToCopy(SHOWCASE_PUBLIC_ASSSETS_FOLDER),
...musicToCopy.map(entry => {
return {
...entry,
target: path.join(SHOWCASE_PUBLIC_ASSSETS_FOLDER, __config.folder.music)
}
}),
{
filename: 'preview.jpg',
source: path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME),
target: path.join(OPERATOR_RELEASE_FOLDER)
},
{
filename: 'operator_bg.png',
source: path.join(OPERATOR_SHARE_FOLDER, __config.folder.background),
target: path.join(SHOWCASE_PUBLIC_ASSSETS_FOLDER, __config.folder.background)
},
{
filename: `${__config.operators[OPERATOR_NAME].logo}.png`,
source: path.join(OPERATOR_SHARE_FOLDER, 'logo'),
target: path.join(SHOWCASE_PUBLIC_ASSSETS_FOLDER)
},
{
filename: `${__config.operators[OPERATOR_NAME].fallback_name}.png`,
source: path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME),
target: path.join(SHOWCASE_PUBLIC_ASSSETS_FOLDER)
},
{
filename: `${__config.operators[OPERATOR_NAME].fallback_name}_portrait.png`,
source: path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME),
target: path.join(SHOWCASE_PUBLIC_ASSSETS_FOLDER)
}
]
filesToCopy.forEach((file) => {
copy(path.join(file.source, file.filename), path.join(file.target, file.filename))
})
const foldersToCopy = [
{
source: path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, __config.folder.voice.main),
target: path.join(SHOWCASE_PUBLIC_ASSSETS_FOLDER, __config.folder.voice.main)
}
]
foldersToCopy.forEach((folder) => {
copyDir(folder.source, folder.target)
})
fork(path.join(__projectRoot, 'vite.config.js'), [op, OPERATOR_NAME])
}
directory({ backgrounds, musicMapping })
}
main();

59
changelogs.yaml Normal file
View File

@@ -0,0 +1,59 @@
showcase:
2023/03/15:
- Added background music
2023/03/03:
- Performance optimization
2023/02/26:
- Rename w_fugue to w_wonder
2023/02/14:
- Added pozemka_snowy_plains_in_words
2023/02/11:
- Added Insights
- Added Operator Voice
2023/02/05:
- Added ability to move Operator Logo around
- Added VCs
2023/01/17:
- Added ling, chongyue
2023/01/16:
- Refactor the project to use nodeJS
2022/12/01:
- Added mizuki_summer_feast
2022/10/31:
- Added texas, relight/neral, become anew/rosmon, dream/passager
2022/10/24:
- Added lee_trust_your_eyes
2022/08/11:
- Added gavial, surtr#9
2022/05/01:
- Added w_fugue, specter, and skadi_sublimation
2022/03/29:
- Moved to Spine 3.8.99
- Added phatom
2022/01/23:
- Added dusk, ling, everything is a miracle/dusk, unfettered freedom/nian
2021/11/01:
- Added Nearl, W, and Rosmontis
2021/08/21:
- Updated skadi
- Added nian, chen
2021/05/26:
- First commit
directory:
2023/03/15:
- Added background music
2023/03/03:
- Fixed Voice and VLs issues
2023/03/02:
- Added Voice, VLs, Operator Logo
2023/03/01:
- Added Operator page
- Added Changelogs page
2023/02/28:
- Init Operator page
2023/02/26:
- Added Home page
2023/02/25:
- Added portrait images
2023/02/21:
- Init Directory

56
config.yaml Normal file
View File

@@ -0,0 +1,56 @@
folder:
operator: ./operator/
release: ./release/
background: background
music: music
directory: _assets
share: _share
voice:
main: voice
sub:
- name: jp
lang: JP
- name: cn
lang: CN_MANDARIN
- name: en
lang: EN
- name: kr
lang: KR
- name: custom
lang: CUSTOM
share:
title:
zh-CN: "明日方舟:"
en-US: "Arknights: "
directory:
title: AKLive2D
voice: jp/CN_037.ogg
error:
files: !include config/_directory.yaml
voice: CN_034.ogg
operators:
chen: !include config/chen.yaml
dusk: !include config/dusk.yaml
dusk_everything_is_a_miracle: !include config/dusk_everything_is_a_miracle.yaml
ling: !include config/ling.yaml
nearl: !include config/nearl.yaml
nian: !include config/nian.yaml
nian_unfettered_freedom: !include config/nian_unfettered_freedom.yaml
phatom_focus: !include config/phatom_focus.yaml
rosmontis: !include config/rosmontis.yaml
skadi: !include config/skadi.yaml
skadi_sublimation: !include config/skadi_sublimation.yaml
w: !include config/w.yaml
w_wonder: !include config/w_wonder.yaml
specter: !include config/specter.yaml
gavial: !include config/gavial.yaml
surtr_colorful_wonderland: !include config/surtr_colorful_wonderland.yaml
lee_trust_your_eyes: !include config/lee_trust_your_eyes.yaml
texas_the_omertosa: !include config/texas_the_omertosa.yaml
nearl_relight: !include config/nearl_relight.yaml
rosmontis_become_anew: !include config/rosmontis_become_anew.yaml
passager_dream_in_a_moment: !include config/passager_dream_in_a_moment.yaml
mizuki_summer_feast: !include config/mizuki_summer_feast.yaml
chongyue: !include config/chongyue.yaml
ling_it_does_wash_the_strings: !include config/ling_it_does_wash_the_strings.yaml
pozemka_snowy_plains_in_words: !include config/pozemka_snowy_plains_in_words.yaml

12
config/_directory.yaml Normal file
View File

@@ -0,0 +1,12 @@
- key: build_char_128_plosis_epoque#3
paddings:
left: -120
right: 150
top: 10
bottom: 0
- key: build_char_128_plosis
paddings:
left: -90
right: 100
top: 10
bottom: 0

320
config/_project_json.yaml Normal file
View File

@@ -0,0 +1,320 @@
description: !match "~{split('config', 'title' ,' - ')[0]} Live 2D\n~{split('config', 'title' ,' - ')[1]} Live 2D\nThe model is extracted from game with Spine support.\n模型来自游戏内提取支持Spine\nPlease set your FPS target in Wallpaper Engine > Settings > Performance > FPS\n\nLive preview on: https://arknights.halyul.dev/~{var('config', 'link')}\nGithub: https://github.com/Halyul/aklive2d\nCheck out our privacy policy at https://privacy.halyul.dev"
localization:
en-us:
ui_notice_title: <hr><h4>📝 Notes</h4><hr>
ui_notice_changelog: <span><b>Now supports Background Music!</b></span>
ui_notice_set_fps: <span><b>Set FPS target in Settings</b></span>
ui_notice_github: "Github: https://github.com/Halyul/aklive2d"
ui_notice_other_operators: "Previews: https://arknights.halyul.dev/"
ui_notice_version: !match "~{version('<span>Version: ', '</span>')}"
ui_background_title: <hr><h4>🖼️ Background</h4><hr>
ui_custom_background: Custom Background
ui_default_background: Default Background
ui_logo_title: <hr><h4>😐 Logo</h4><hr>
ui_logo_image: Logo Image
ui_logo_opacity: Logo Opacity
ui_logo_ratio: Logo Ratio
ui_operator_logo: Operator Logo
ui_translate_x: X Axis Position
ui_translate_y: Y Axis Position
ui_position_title: <hr><h4>⚠️ Posistion</h4><hr>
ui_position_padding_bottom: Padding Bottom
ui_position_padding_left: Padding Left
ui_position_padding_right: Padding Right
ui_position_padding_top: Padding Top
ui_voice_title: <hr><h4>🔈Voice</h4><hr>
ui_voice_lang: Voice Language
ui_voice_idle: Idle Timeout
ui_voice_next: Voice Interval
ui_subtitle_title: <hr><h4>📑 Subtitle</h4><hr>
ui_subtitle_lang: Subtitle Language
ui_voice_actor_title: <hr><h4>🗣️ Voice Actor</h4><hr>
ui_privacy_title: <hr><h4>📜 Privacy</h4><hr>
ui_privacy_text: <span><b>Check out our privacy policy at https://privacy.halyul.dev</b></span>
ui_privacy_do_not_track: Send usage data
ui_music_title: <hr><h4>📝 Music</h4><hr>
ui_music_notice: <span><b>Please adjust the 'Offset' value if you notice audio cutoff</b></span>
ui_music_notice1: <span><b>'bg_rhodes_day.png' and 'operator_bg.png' use the same music, it is not a bug.</b></span>
ui_music_selection: Music
ui_music_volume: Volume
ui_music_offset: Offset
zh-chs:
ui_notice_title: <hr><h4>📝 通知</h4><hr>
ui_notice_changelog: <span><b>现在支持背景音乐! </b></span>
ui_notice_set_fps: <span><b>在设置中设定FPS目标</b></span>
ui_notice_github: "Github: https://github.com/Halyul/aklive2d"
ui_notice_other_operators: "预览: https://arknights.halyul.dev/"
ui_notice_version: !match "~{version('<span>版本: ', '</span>')}"
ui_background_title: <hr><h4>🖼️ 背景</h4><hr>
ui_custom_background: 背景图片
ui_default_background: 默认背景
ui_logo_title: <hr><h4>😐 图标</h4><hr>
ui_logo_image: 图标图片
ui_logo_opacity: 图标透明度
ui_logo_ratio: 图标比例
ui_operator_logo: 干员图标
ui_translate_x: X 轴位置
ui_translate_y: Y 轴位置
ui_position_title: <hr><h4>⚠️ 位置</h4><hr>
ui_position_padding_bottom: 底部距离
ui_position_padding_left: 左部距离
ui_position_padding_right: 右部距离
ui_position_padding_top: 上部距离
ui_voice_title: <hr><h4>🔈语音</h4><hr>
ui_voice_lang: 语音语言
ui_voice_idle: 待机间隔
ui_voice_next: 下一条语音间隔
ui_subtitle_title: <hr><h4>📑 字幕</h4><hr>
ui_subtitle_lang: 字幕语言
ui_voice_actor_title: <hr><h4>🗣️ 声优</h4><hr>
ui_privacy_title: <hr><h4>📜 隐私</h4><hr>
ui_privacy_text: <span><b>在 https://privacy.halyul.dev 查看我们的隐私政策</b></span>
ui_privacy_do_not_track: 发送使用数据
ui_music_title: <hr><h4>🎵 音乐</h4><hr>
ui_music_notice: <span><b>如若发现音频截止,请调节 '弥补' 数值</b></span>
ui_music_notice1: <span><b>'bg_rhodes_day.png' 和 'operator_bg.png' 使用同样的音乐并非Bug</b></span>
ui_music_selection: 音乐
ui_music_volume: 音量
ui_music_offset: 弥补
properties:
- key: notice_title
value:
text: ui_notice_title
- key: notice_changelog
value:
text: ui_notice_changelog
- key: notice_set_fps
value:
text: ui_notice_set_fps
- key: notice_github
value:
text: ui_notice_github
- key: notice_other_operators
value:
text: ui_notice_other_operators
- key: notice_version
value:
text: ui_notice_version
- key: logo_title
value:
text: ui_logo_title
- key: logo
value:
text: ui_operator_logo
type: bool
value: true
- key: logoimage
value:
text: ui_logo_image
type: file
value: ""
condition: logo.value == true
- key: logoratio
value:
text: ui_logo_ratio
type: "slider"
value: 61.8
condition: logo.value == true
fraction: true
max: 100
min: 0
step: 0.1
precision: 1
- key: logoopacity
value:
text: ui_logo_opacity
type: slider
value: 30
condition: logo.value == true
fraction: false
max: 100
min: 0
- key: logox
value:
text: ui_translate_x
type: slider
value: 0
condition: logo.value == true
fraction: false
max: 100
min: 0
- key: logoy
value:
text: ui_translate_y
type: slider
value: 0
condition: logo.value == true
fraction: false
max: 100
min: 0
- key: background_title
value:
text: ui_background_title
- key: defaultbackground
value:
text: ui_default_background
type: combo
value: !match ~{var('assets', "backgrounds")[0]}
options: !match ~{var('assets', "backgroundsOptions")}
- key: background
value:
text: ui_custom_background
type: file
value: ""
- key: voicetitle
value:
text: ui_voice_title
type: bool
value: false
- key: voicelanguage
value:
text: ui_voice_lang
type: combo
condition: voicetitle.value == true
value: !match ~{var('assets', "voiceLangs")[0]}
options: !match ~{var('assets', "voiceLangsOptions")}
- key: voiceidle
value:
text: ui_voice_idle
type: textinput
value: 10
condition: voicetitle.value == true
fraction: false
min: 0
- key: voicenext
value:
text: ui_voice_next
type: textinput
value: 3
condition: voicetitle.value == true
fraction: false
min: 0
- key: voicesubtitle
value:
text: ui_subtitle_title
condition: voicetitle.value == true
type: bool
value: false
- key: voicesubtitlelanguage
value:
text: ui_subtitle_lang
type: combo
condition: voicesubtitle.value == true
value: !match ~{var('assets', "subtitleLangs")[0]}
options: !match ~{var('assets', "subtitleLangsOptions")}
- key: voicesubtitlex
value:
text: ui_translate_x
type: slider
value: 0
condition: voicesubtitle.value == true
fraction: false
max: 100
min: 0
- key: voicesubtitley
value:
text: ui_translate_y
type: slider
value: 100
condition: voicesubtitle.value == true
fraction: false
max: 100
min: 0
- key: voiceactor
value:
text: ui_voice_actor_title
condition: voicesubtitle.value == true
type: bool
value: false
- key: music_title
value:
text: ui_music_title
type: bool
value: false
- key: music_notice
value:
text: ui_music_notice
condition: music_title.value == true
- key: music_notice1
value:
text: ui_music_notice1
condition: music_title.value == true
- key: music_selection
value:
text: ui_music_selection
condition: music_title.value == true
type: combo
value: !match ~{var('assets', "music")[0]}
options: !match ~{var('assets', "musicOptions")}
- key: music_volume
value:
text: ui_music_volume
type: slider
value: 50
condition: music_title.value == true
fraction: false
max: 100
min: 0
- key: music_offset
value:
text: ui_music_offset
type: slider
value: 0.3
condition: music_title.value == true
fraction: true
precision: 2
step: 0.01
max: 1
min: 0
- key: position
value:
text: ui_position_title
type: bool
value: false
- key: paddingleft
value:
text: ui_position_padding_left
type: slider
value: !match ~{var('config', "viewport_left")}
condition: position.value == true
fraction: false
max: 100
min: -100
- key: paddingright
value:
text: ui_position_padding_right
type: slider
value: !match ~{var('config', "viewport_right")}
condition: position.value == true
fraction: false
max: 100
min: -100
- key: paddingtop
value:
text: ui_position_padding_top
type: slider
value: !match ~{var('config', "viewport_top")}
condition: position.value == true
fraction: false
max: 100
min: -100
- key: paddingbottom
value:
text: ui_position_padding_bottom
type: slider
value: !match ~{var('config', "viewport_bottom")}
condition: position.value == true
fraction: false
max: 100
min: -100
- key: privacytitle
value:
text: ui_privacy_title
- key: privacy_text
value:
text: ui_privacy_text
- key: privacydonottrack
value:
text: ui_privacy_do_not_track
type: bool
value: true

13
config/_template.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2021/08
filename: dyn_illust_char_1013_chen2
logo: logo_rhodes_override
fallback_name: char_1013_chen2_2
viewport_left: 0
viewport_right: 0
viewport_top: 1
viewport_bottom: 1
invert_filter: false
color: rgba(14, 126, 239, 0.85)
codename:
zh-CN: 假日威龙陈
en-US: Ch'en/Chen the Holungday

13
config/chen.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2021/08
filename: dyn_illust_char_1013_chen2
logo: logo_rhodes_override
fallback_name: char_1013_chen2_2
viewport_left: 0
viewport_right: 0
viewport_top: 1
viewport_bottom: 1
invert_filter: false
color: rgba(14, 126, 239, 0.85)
codename:
zh-CN: 假日威龙陈
en-US: Ch'en/Chen the Holungday

13
config/chongyue.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2023/01
filename: dyn_illust_char_2024_chyue
logo: logo_sui
fallback_name: char_2024_chyue_2
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgb(255, 133, 34)
codename:
zh-CN: 重岳
en-US: Chongyue

13
config/dusk.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2021/02
filename: dyn_illust_char_2015_dusk
logo: logo_sui
fallback_name: char_2015_dusk_2
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgb(9, 212, 208)
codename:
zh-CN:
en-US: Dusk

View File

@@ -0,0 +1,13 @@
date: 2022/01
filename: dyn_illust_char_2015_dusk_nian#7
logo: logo_sui
fallback_name: char_2015_dusk_nian#7
viewport_left: 10
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgb(78, 201, 187)
codename:
zh-CN: 染尘烟 · 夕
en-US: Everything is a Miracle / Dusk

13
config/gavial.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2022/08
filename: dyn_illust_char_1026_gvial2
logo: logo_rhodes_override
fallback_name: char_1026_gvial2_2
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: false
color: rgb(29, 185, 53)
codename:
zh-CN: 百练嘉维尔
en-US: Gavial the Invincible

View File

@@ -0,0 +1,13 @@
date: 2022/10
filename: dyn_illust_char_322_lmlee_witch#3
logo: logo_lee
fallback_name: char_322_lmlee_witch#3
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgb(206, 0, 0)
codename:
zh-CN: 手到牌来 · 老鲤
en-US: Trust Your Eyes / Lee

13
config/ling.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2022/01
filename: dyn_illust_char_2023_ling
logo: logo_sui
fallback_name: char_2023_ling_2
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgb(15, 206, 216)
codename:
zh-CN:
en-US: Ling

View File

@@ -0,0 +1,13 @@
date: 2023/01
filename: dyn_illust_char_2023_ling_nian#9
logo: logo_sui
fallback_name: char_2023_ling_nian#9
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgb(37, 148, 197)
codename:
zh-CN: 濯缨 · 令
en-US: It Does Wash the Strings / Ling

View File

@@ -0,0 +1,13 @@
date: 2022/12
filename: dyn_illust_char_437_mizuki_sale#7
logo: logo_higashi
fallback_name: char_437_mizuki_sale#7
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgb(156, 210, 246)
codename:
zh-CN: 夏日餮宴 · 水月
en-US: Summer Feast / Mizuki

13
config/nearl.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2021/11
filename: dyn_illust_char_1014_nearl2
logo: logo_kazimierz
fallback_name: char_1014_nearl2_2
viewport_left: 2
viewport_right: 3
viewport_top: 10
viewport_bottom: 0
invert_filter: true
color: rgba(253, 236, 189, 0.95)
codename:
zh-CN: 耀骑士临光
en-US: Nearl the Radiant Knight

13
config/nearl_relight.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2022/11
filename: dyn_illust_char_1014_nearl2_epoque#17
logo: logo_kazimierz
fallback_name: char_1014_nearl2_epoque#17
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgb(141, 213, 228)
codename:
zh-CN: 复现荣光 · 耀骑士临光
en-US: Relight / Nearl

13
config/nian.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2020/01
filename: dyn_illust_char_2014_nian
logo: logo_sui
fallback_name: char_2014_nian_2
viewport_left: 2
viewport_right: 2
viewport_top: 3
viewport_bottom: 5
invert_filter: true
color: rgb(255, 48, 0)
codename:
zh-CN:
en-US: Nian

View File

@@ -0,0 +1,13 @@
date: 2021/02
filename: dyn_illust_char_2014_nian_nian#4
logo: logo_sui
fallback_name: char_2014_nian_nian#4
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgb(187, 163, 106)
codename:
zh-CN: 乐逍遥 · 年
en-US: Unfettered Freedom / Nian

View File

@@ -0,0 +1,13 @@
date: 2022/11
filename: dyn_illust_char_472_pasngr_epoque#17
logo: logo_sargon
fallback_name: char_472_pasngr_epoque#17
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgb(231, 166, 144)
codename:
zh-CN: 今昔须臾之梦 · 异客
en-US: Dream in a Moment / Passager

13
config/phatom_focus.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2022/04
filename: dyn_illust_char_250_phatom_sale#4
logo: logo_victoria
fallback_name: char_250_phatom_sale#4
viewport_left: 0
viewport_right: 0
viewport_top: 5
viewport_bottom: 1
invert_filter: true
color: rgb(158, 2, 2)
codename:
zh-CN: 焦点 · 傀影
en-US: Focus / Phatom

View File

@@ -0,0 +1,13 @@
date: 2023/02
filename: dyn_illust_char_4055_bgsnow_wild#7
logo: logo_rhodes_override
fallback_name: char_4055_bgsnow_wild#7
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: false
color: rgb(145, 220, 253)
codename:
zh-CN: 字句中的雪原 · 鸿雪
en-US: Snowy Plains in Words / Позёмка

13
config/rosmontis.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2020/11
filename: dyn_illust_char_391_rosmon
logo: logo_elite
fallback_name: char_391_rosmon_2
viewport_left: 0
viewport_right: -14
viewport_top: -38
viewport_bottom: -1
invert_filter: true
color: rgb(23, 210, 236)
codename:
zh-CN: 迷迭香
en-US: Rosmontis

View File

@@ -0,0 +1,13 @@
date: 2022/11
filename: dyn_illust_char_391_rosmon_epoque#17
logo: logo_elite
fallback_name: char_391_rosmon_epoque#17
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgb(116, 177, 222)
codename:
zh-CN: 拥抱新生 · 迷迭香
en-US: Become Anew / Rosmontis

13
config/skadi.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2021/05
filename: dyn_illust_char_1012_skadi2
logo: logo_egir
fallback_name: char_1012_skadi2_2
viewport_left: -5
viewport_right: -10
viewport_top: 0
viewport_bottom: -12
invert_filter: true
color: rgb(226, 96, 96)
codename:
zh-CN: 浊心斯卡蒂
en-US: Skadi the Corrupting Heart

View File

@@ -0,0 +1,13 @@
date: 2022/05
filename: dyn_illust_char_1012_skadi2_boc#4
logo: logo_egir
fallback_name: char_1012_skadi2_boc#4
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgba(95, 116, 187, 0.74)
codename:
zh-CN: 升华 · 浊心斯卡蒂
en-US: Sublimation / Skadi the Corrupting Heart

13
config/specter.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2022/05
filename: dyn_illust_char_1023_ghost2
logo: logo_abyssal
fallback_name: char_1023_ghost2_2
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgba(14, 124, 203, 0.86)
codename:
zh-CN: 归溟幽灵鲨
en-US: Specter the Unchained

View File

@@ -0,0 +1,13 @@
date: 2022/08
filename: dyn_illust_char_350_surtr_summer#9
logo: logo_rhodes_override
fallback_name: char_350_surtr_summer#9
viewport_left: 0
viewport_right: 6
viewport_top: 1
viewport_bottom: 0
invert_filter: false
color: rgb(177, 226, 249)
codename:
zh-CN: 缤纷奇境 CW03 · 史尔特尔
en-US: Colorful Wonderland CW03 / Surtr

View File

@@ -0,0 +1,13 @@
date: 2022/11
filename: dyn_illust_char_1028_texas2
logo: logo_penguin
fallback_name: char_1028_texas2_2
viewport_left: 0
viewport_right: 0
viewport_top: 0
viewport_bottom: 0
invert_filter: true
color: rgba(34, 37, 255, 0.9)
codename:
zh-CN: 缄默德克萨斯
en-US: Texas the Omertosa

13
config/w.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2020/05
filename: dyn_illust_char_113_cqbw
logo: logo_babel
fallback_name: char_113_cqbw_2
viewport_left: 3
viewport_right: -3
viewport_top: 0
viewport_bottom: 1
invert_filter: true
color: rgb(228, 54, 56)
codename:
zh-CN: W
en-US: W

13
config/w_wonder.yaml Normal file
View File

@@ -0,0 +1,13 @@
date: 2020/11
filename: dyn_illust_char_113_cqbw_epoque#7
logo: logo_babel
fallback_name: char_113_cqbw_epoque#7
viewport_left: 0
viewport_right: 0
viewport_top: 1
viewport_bottom: -4
invert_filter: true
color: rgba(0, 0, 0, 0.83)
codename:
zh-CN: 恍惚 · W
en-US: Wonder / W

9
directory/.env Normal file
View File

@@ -0,0 +1,9 @@
VITE_APP_TITLE=AKLive2D
VITE_APP_VOICE_URL=jp/CN_037.ogg
VITE_VOICE_FOLDERS={"main":"voice","sub":[{"name":"jp","lang":"JP"},{"name":"cn","lang":"CN_MANDARIN"},{"name":"en","lang":"EN"},{"name":"kr","lang":"KR"},{"name":"custom","lang":"CUSTOM"}]}
VITE_DIRECTORY_FOLDER="_assets"
VITE_BACKGROUND_FOLDER="background"
VITE_AVAILABLE_OPERATORS=["chen","dusk","dusk_everything_is_a_miracle","ling","nearl","nian","nian_unfettered_freedom","phatom_focus","rosmontis","skadi","skadi_sublimation","w","w_wonder","specter","gavial","surtr_colorful_wonderland","lee_trust_your_eyes","texas_the_omertosa","nearl_relight","rosmontis_become_anew","passager_dream_in_a_moment","mizuki_summer_feast","chongyue","ling_it_does_wash_the_strings","pozemka_snowy_plains_in_words"]
VITE_ERROR_FILES={"files":[{"key":"build_char_128_plosis_epoque%233","paddings":{"left":-120,"right":150,"top":10,"bottom":0}},{"key":"build_char_128_plosis","paddings":{"left":-90,"right":100,"top":10,"bottom":0}}],"voice":"CN_034.ogg"}
VITE_MUSIC_FOLDER=music
VITE_MUSIC_MAPPING={"operator_bg.png":{"intro":"m_sys_void_intro.ogg","loop":"m_sys_void_loop.ogg"},"bg_anniversary_1.png":{"intro":"m_dia_nightoflongmen_intro.ogg","loop":"m_dia_nightoflongmen_loop.ogg"},"bg_iberia_1.png":{"intro":"m_sys_act18d3d0_intro.ogg","loop":"m_sys_act18d3d0_loop.ogg"},"bg_kazimierz_1.png":{"intro":"m_dia_street_intro.ogg","loop":"m_dia_street_loop.ogg"},"bg_main_victoria_1.png":{"intro":"m_avg_ghosthunter_intro.ogg","loop":"m_avg_ghosthunter_loop.ogg"},"bg_rhodes_day.png":{"intro":"m_sys_void_intro.ogg","loop":"m_sys_void_loop.ogg"},"bg_rhodes_night.png":{"intro":"m_sys_tech_intro.ogg","loop":"m_sys_tech_loop.ogg"},"bg_rogue_1.png":{"intro":null,"loop":"m_avg_rglk1secretevent_loop.ogg"},"bg_siesta_1.png":{"intro":"m_sys_ddd_intro.ogg","loop":"m_sys_ddd_loop.ogg"},"bg_ursus_1.png":{"intro":"m_avg_loneliness_intro.ogg","loop":"m_avg_loneliness_loop.ogg"},"bg_yan_1.png":{"intro":null,"loop":"m_sys_bitw_loop.ogg"}}

24
directory/.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

1
directory/Version Normal file
View File

@@ -0,0 +1 @@
1.2.3

14
directory/index.html Normal file
View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>aklive2d directory</title>
<script async defer data-website-id="05ee2d3d-66e0-429b-89ba-db112743a8c2" src="https://insights.halyul.dev/insights.js"
data-do-not-track="true" data-auto-track="false"></script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/App.jsx"></script>
</body>
</html>

24
directory/src/App.jsx Normal file
View File

@@ -0,0 +1,24 @@
import React from 'react';
import ReactDOM from 'react-dom/client'
import {
createBrowserRouter,
RouterProvider,
} from "react-router-dom";
import Root from "@/routes/Root";
import Error from "@/routes/Error";
import routes from "@/routes";
import '@/App.scss';
import 'reset-css';
const router = createBrowserRouter([{
path: "/",
element: <Root />,
errorElement: <Error />,
children: routes.filter((item) => item.routeable),
},]);
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<RouterProvider router={router} />
</React.StrictMode>
)

39
directory/src/App.scss Normal file
View File

@@ -0,0 +1,39 @@
@import 'https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap';
@import 'https://fonts.cdnfonts.com/css/bender';
@import 'https://fonts.cdnfonts.com/css/geometos';
:root {
--text-color: rgba(255, 255, 255, 87%);
--text-color-full: #fff;
--secondary-text-color: #686a72;
--date-color: rgba(255, 255, 255, 20%);
--border-color: #707070;
--link-highlight-color: #33b5e5;
--drawer-background-color: rgba(0, 0, 0, 88%);
--root-background-color: #131313;
--home-item-hover-background-color: rgba(67, 67, 67, 30%);
--home-item-background-linear-gradient-color: rgba(255, 255, 255, 10%);
--home-item-outline-color: rgba(214, 214, 214, 30%);
--button-color: #666;
font-family: Geometos, "Noto Sans SC", sans-serif;
font-size: 16px;
line-height: 1.2em;
font-weight: 400;
color: var(--text-color);
background-color: var(--root-background-color);
min-height: 100vh;
}
#root {
display: flex;
flex-flow: column nowrap;
justify-content: flex-start;
align-items: stretch;
min-height: 100vh;
}
a {
color: var(--text-color);
text-decoration: none;
}

View File

@@ -0,0 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import classes from './scss/border.module.scss';
export default function Border(props) {
return (
<section className={classes.border}>
{props.children}
</section>
)
}
Border.propTypes = {
children: PropTypes.node,
};

View File

@@ -0,0 +1,20 @@
import React from 'react';
import PropTypes from 'prop-types';
export default function CharIcon(props) {
return (
<svg xmlns="http://www.w3.org/2000/svg" viewBox={props.viewBox}>
{
props.type === 'operator' ?
<g><path d="M89 17.5 30.4 57 24.3 71.4 82.9 32.6Z"></path><path d="M0 17.5 58.6 57 64.7 71.4 6.1 32.7Z"> </path><path d="M89 0 30.4 39.5 24.3 53.9 82.9 15.1Z"> </path><path d="M0 0 58.6 39.5 64.7 53.9 6.1 15.2Z"> </path></g>
:
<path d="M90.4 50.6l-39.8-23.5v-4c0-4.5-5-6.5-5-6.5a5.4 5.4 0 012.2-10.1c2.7 0 5.3 1.5 5.5 4.8.4 5.3 6.4 3.9 6.4-.3a11.7 11.7 0 00-12-11c-9 0-11.6 8.8-11.6 11.6a11.5 11.5 0 001.6 6.2c2.2 3.8 6.6 4.3 6.6 6.8v2.5L4.2 50.7c-4 2.3-4.7 7.3-3.8 10.3a9.1 9.1 0 009.1 6.4h75.2c5.9 0 8.6-3.4 9.5-6.3C95 58.1 95 53.4 90.4 50.6Zm-5.6 10.3h-75.2c-2.4.1-4-3.3-1.5-4.8l39.2-22.9 39 22.8A2.7 2.7 0 0184.7 60.8Z" />
}
</svg>
)
}
CharIcon.propTypes = {
viewBox: PropTypes.string,
type: PropTypes.string,
};

View File

@@ -0,0 +1,58 @@
import React, {
useState
} from 'react'
import PropTypes from 'prop-types';
import classes from './scss/dropdown.module.scss'
export default function Dropdown(props) {
const [hidden, setHidden] = useState(true)
const toggleDropdown = () => {
setHidden(!hidden)
}
return (
<>
<section className={`${classes.dropdown} ${hidden ? '' : classes.active} ${props.className ? props.className : ''}`} >
<section
className={classes.text}
onClick={() => toggleDropdown()}
>
<span className={classes.content}>{props.text}</span>
<span className={classes.icon}></span>
</section>
<ul className={classes.menu} style={props.activeColor}>
{
props.menu.map((item) => {
return (
<li
key={item.name}
className={`${classes.item} ${item.name === props.text || (props.activeRule && props.activeRule(item)) ? classes.active : ''}`}
onClick={() => {
props.onClick(item)
toggleDropdown()
}}
>
<section className={classes.text}>{item.name}</section>
</li>
)
})
}
</ul>
<section
className={classes.overlay}
hidden={hidden}
onClick={() => toggleDropdown()}
/>
</section>
</>
)
}
Dropdown.propTypes = {
className: PropTypes.string,
text: PropTypes.string,
menu: PropTypes.array,
onClick: PropTypes.func,
activeColor: PropTypes.object,
activeRule: PropTypes.func,
};

View File

@@ -0,0 +1,42 @@
import React, {
useState,
} from 'react'
import classes from './scss/popup.module.scss';
import ReturnButton from '@/component/return_button';
import Border from '@/component/border';
import PropTypes from 'prop-types';
export default function Popup(props) {
const [hidden, setHidden] = useState(true)
const toggle = () => {
setHidden(!hidden)
}
return (<>
<section className={`${classes.popup} ${hidden ? '' : classes.active}`}>
<section className={classes.wrapper}>
<section className={classes.title}>
<section className={classes.text}>{props.title}</section>
<ReturnButton onClick={toggle} className={classes["return-button"]} />
</section>
<Border />
<section className={classes.content}>
{props.children}
</section>
</section>
<section className={`${classes.overlay} ${hidden ? '' : classes.active}`}
onClick={() => toggle()} />
</section>
<span
className={classes['entry-text']}
onClick={toggle}
>
{props.title}
</span>
</>)
}
Popup.propTypes = {
title: PropTypes.string,
children: PropTypes.node,
};

View File

@@ -0,0 +1,39 @@
import React from 'react';
import PropTypes from 'prop-types';
import classes from './scss/return_button.module.scss'
export default function ReturnButton(props) {
return (
<>
<section className={`${classes['return-button']} ${props.className ? props.className : ''}`}
onClick={() => props.onClick()}
>
<section className={classes.wrapper}>
<section className={classes["arrow-left"]}></section>
<section className={classes.bar}></section>
<section className={classes["arrow-right"]}></section>
</section>
<section className={classes.wrapper}>
<section className={classes["arrow-left"]}></section>
<section className={classes.bar}></section>
<section className={classes["arrow-right"]}></section>
</section>
<section className={classes.wrapper}>
<section className={classes["arrow-left"]}></section>
<section className={classes.bar}></section>
<section className={classes["arrow-right"]}></section>
</section>
<section className={classes.wrapper}>
<section className={classes["arrow-left"]}></section>
<section className={classes.bar}></section>
<section className={classes["arrow-right"]}></section>
</section>
</section>
</>
)
}
ReturnButton.propTypes = {
onClick: PropTypes.func,
className: PropTypes.string,
};

View File

@@ -0,0 +1,22 @@
.border {
position: relative;
bottom: 1px;
border-bottom: 1px solid var(--text-color);
&:before,
&:after {
content: "";
display: block;
position: absolute;
width: 5px;
height: 5px;
top: -2px;
background-color: var(--text-color);
}
&:before {
right: 100%;
}
&:after {
left: 100%;
}
}

View File

@@ -0,0 +1,111 @@
.dropdown {
position: relative;
display: inline-block;
user-select: none;
z-index: 2;
padding: 0.5rem;
cursor: pointer;
.text {
display: flex;
flex-direction: row;
align-items: center;
color: var(--text-color);
}
.content {
padding-right: 0.5rem;
}
.icon {
position: absolute;
bottom: 0.5rem;
right: -0.1rem;
width: 0.5em;
height: 0.5em;
display: inline-block;
vertical-align: middle;
border-left: 0.15em solid var(--text-color);
border-bottom: 0.15em solid var(--text-color);
border-right: 0.15em solid var(--text-color);
border-top: 0.15em solid var(--text-color);
transform: translate(0, -0.15em) rotate(-45deg);
}
.menu {
opacity: 0;
position: absolute;
background-color: var(--root-background-color);
width: max-content;
z-index: -1;
top: 2rem;
right: 0;
gap: 0.5rem;
display: flex;
align-items: center;
flex-direction: column;
flex-wrap: nowrap;
transition: all cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
overflow: hidden;
padding: 0.5rem;
border: 1px solid var(--border-color);
visibility: hidden;
color: var(--link-highlight-color);
cursor: auto;
.item {
cursor: pointer;
padding: 0.5rem;
font-size: 1rem;
width: max-content;
height: max-content;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
flex-wrap: nowrap;
transition: color cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
&:hover,
&:focus,
&.active {
.text {
color: currentColor;
}
}
}
}
.overlay {
z-index: -1;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100vw;
height: 100vh;
cursor: auto;
}
&.active,
&:hover {
.icon {
animation: icon-flash 2s cubic-bezier(0.65, 0.05, 0.36, 1) infinite;
}
}
&.active {
.menu {
visibility: visible;
opacity: 1;
z-index: 2;
}
}
}
@keyframes icon-flash {
50% {
opacity: 0.2;
}
}

View File

@@ -0,0 +1,94 @@
.entry-text {
cursor: pointer;
}
.popup {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: hidden;
opacity: 0;
z-index: -1;
border: unset;
transition: all cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 1.2rem;
.wrapper {
display: flex;
flex-direction: column;
align-items: stretch;
flex-wrap: nowrap;
max-width: 480px;
height: fit-content;
margin: 0 auto;
background-color: var(--root-background-color);
border: 1px solid var(--border-color);
padding: 2rem;
}
.title {
font-size: 3rem;
font-weight: 700;
display: flex;
flex-direction: row;
justify-content: space-between;
align-content: center;
align-items: center;
text-transform: uppercase;
font-family: "Geometos", "Noto Sans SC", sans-serif;
.return-button {
color: var(--button-color);
transition: color cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
&:hover {
color: var(--text-color);
}
}
}
.text {
flex-grow: 1;
margin-right: 3rem;
}
.content {
line-height: 1.3em;
padding: 1rem 1rem 0 1rem;
user-select: text;
}
.overlay {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: -1;
opacity: 0;
background-color: var(--root-background-color);
transition: all cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
&.active {
opacity: 0.5;
visibility: visible;
}
}
&.active {
opacity: 1;
z-index: 10;
}
@media (max-width: 768px) {
.title {
font-size: 2rem;
}
.content {
font-size: 1rem;
}
.return-button {
transform: scale(0.8);
}
}
}

View File

@@ -0,0 +1,46 @@
.return-button {
%arrow-shared {
border-top: 0.24rem solid transparent;
border-bottom: 0.24rem solid transparent;
}
display: flex;
flex-direction: column;
align-items: flex-start;
padding: 0.6rem 0;
width: 3rem;
cursor: pointer;
.wrapper {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
&:nth-child(1) {
transform: translateY(-0.1rem) rotate(45deg);
}
&:nth-child(2) {
transform: translateY(-0.1rem) translate(90%, -100%) rotate(-45deg);
}
&:nth-child(3) {
transform: translateY(-0.1rem) translateY(150%) rotate(315deg);
}
&:nth-child(4) {
transform: translateY(-0.1rem) translate(90%, 50%) rotate(225deg);
}
}
.bar {
width: 1rem;
height: 0.4rem;
background-color: currentColor;
transition: transform cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
}
.arrow-left {
@extend %arrow-shared;
border-right: 0.3rem solid currentColor;
}
.arrow-right {
@extend %arrow-shared;
border-left: 0.3rem solid currentColor;
}
}

View File

@@ -0,0 +1,60 @@
.switch {
position: relative;
user-select: none;
z-index: 2;
padding: 8px 36px 8px 8px;
cursor: pointer;
display: flex;
flex-direction: row;
align-items: center;
color: var(--secondary-text-color);
transition: color cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
.content {
padding-right: 8px;
}
.wrapper {
color: var(--secondary-text-color);
transition: all cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
.icon {
position: absolute;
bottom: 8px;
right: 18px;
width: 8px;
height: 8px;
display: inline-block;
vertical-align: middle;
border-left: 2px solid currentColor;
border-bottom: 2px solid currentColor;
border-right: 2px solid currentColor;
border-top: 2px solid currentColor;
transform: translate(0, -2px) rotate(-45deg);
transition: right cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s,
background-color cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
}
.line {
position: absolute;
bottom: 15px;
right: 6px;
width: 18px;
height: 2px;
display: inline-block;
vertical-align: middle;
background-color: currentColor;
z-index: -1;
}
}
&.active {
color: var(--text-color);
.wrapper {
color: var(--text-color-full);
.icon {
background-color: currentColor;
right: 0;
}
}
}
}

View File

@@ -0,0 +1,37 @@
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import classes from './scss/switch.module.scss';
import {
useI18n
} from '@/state/language'
export default function Switch(props) {
const [on, setOn] = useState(props.on)
const { i18n } = useI18n()
useEffect(() => {
setOn(props.on)
}, [props.on])
return (
<section
className={`${classes.switch} ${on ? classes.active : ''}`}
onClick={() => {
if (props.handleOnClick) {
props.handleOnClick(!on)
}
}}
>
<span className={classes.text}>{i18n(props.text)}</span>
<section className={classes.wrapper}>
<span className={classes.line}></span>
<span className={classes.icon}></span>
</section>
</section>
)
}
Switch.propTypes = {
on: PropTypes.bool,
text: PropTypes.string,
handleOnClick: PropTypes.func,
};

View File

@@ -0,0 +1,53 @@
import React, {
useEffect,
useRef,
} from "react"
import PropTypes from 'prop-types';
export default function VoiceElement({
src,
replay,
handleAduioStateChange,
}) {
const audioRef = useRef(null)
useEffect(() => {
if (src) {
audioRef.current.src = src
audioRef.current.play()
} else {
audioRef.current.pause()
}
}, [src])
useEffect(() => {
if (replay) {
audioRef.current.currentTime = 0
audioRef.current.play()
}
}, [replay])
return (
<audio
ref={audioRef}
preload="auto"
autoPlay
onEnded={(e) => {
if (handleAduioStateChange) handleAduioStateChange(e, 'ended')
}}
onPlay={(e) => {
if (handleAduioStateChange) handleAduioStateChange(e, 'play')
}}
onPause={(e) => {
if (handleAduioStateChange) handleAduioStateChange(e, 'pause')
}}
>
<source type="audio/ogg" />
</audio>
)
}
VoiceElement.propTypes = {
src: PropTypes.string,
handleAduioStateChange: PropTypes.func,
replay: PropTypes.bool,
}

143
directory/src/i18n.json Normal file
View File

@@ -0,0 +1,143 @@
{
"available": [
"zh-CN", "en-US"
],
"key": {
"dynamic_compile": {
"zh-CN": "动态集录",
"en-US": "Dynamic Compile"
},
"home": {
"zh-CN": "首页",
"en-US": "Home"
},
"changelogs": {
"zh-CN": "更新日志",
"en-US": "Changelogs"
},
"offical_page": {
"zh-CN": "官方页面",
"en-US": "Offical Page"
},
"disclaimer": {
"zh-CN": "免责声明",
"en-US": "Disclaimer"
},
"disclaimer_content": {
"zh-CN": "本网站由 Halyul 设立并为明日方舟社区服务Halyul 声明本网站完全独立运营,与 上海鹰角网络科技有限公司, Esoteric Software LLC 或其任何关联实体并无任何联系。",
"en-US": "This website is set up and operated by Halyul for the benefit of the Arknights Community. Halyul hereby states that this website is dedicated, but not related to Hypergryph Co., Ltd, Esoteric Software LLC or any of its affiliated entity."
},
"privacy_policy": {
"zh-CN": "隐私政策",
"en-US": "Privacy Policy"
},
"contact_us": {
"zh-CN": "联系我们",
"en-US": "Contact Us"
},
"all": {
"zh-CN": "综合",
"en-US": "All"
},
"operator": {
"zh-CN": "精英2",
"en-US": "Elite 2"
},
"skin": {
"zh-CN": "时装",
"en-US": "Skin"
},
"voice": {
"zh-CN": "语音",
"en-US": "Voice"
},
"showcase": {
"zh-CN": "壁纸",
"en-US": "Wallpaper"
},
"directory": {
"zh-CN": "目录页",
"en-US": "Directory Page"
},
"animation": {
"zh-CN": "动画",
"en-US": "Animation"
},
"backgrounds": {
"zh-CN": "背景",
"en-US": "Backgrounds"
},
"CN_MANDARIN": {
"zh-CN": "普通话",
"en-US": "Mandarin"
},
"JP": {
"zh-CN": "日语",
"en-US": "Japanese"
},
"KR": {
"zh-CN": "韩语",
"en-US": "Korean"
},
"EN": {
"zh-CN": "英语",
"en-US": "English"
},
"ITA": {
"zh-CN": "意大利语",
"en-US": "Italian"
},
"CN_TOPOLECT": {
"zh-CN": "中文方言",
"en-US": "Chinese Topolect"
},
"steam_workshop": {
"zh-CN": "壁纸引擎版",
"en-US": "Wallpaper Engine Version"
},
"external_links": {
"zh-CN": "外部链接",
"en-US": "External Links"
},
"web_version": {
"zh-CN": "全功能网页版",
"en-US": "Full Feature Web Version"
},
"idle": {
"zh-CN": "待机",
"en-US": "Idle"
},
"interact": {
"zh-CN": "交互",
"en-US": "Interact"
},
"special": {
"zh-CN": "特殊",
"en-US": "Special"
},
"subtitle": {
"zh-CN": "字幕",
"en-US": "Subtitle"
},
"zh-CN": {
"zh-CN": "简体中文",
"en-US": "Chinese (Simplified)"
},
"en-US": {
"zh-CN": "英语",
"en-US": "English"
},
"zh-TW": {
"zh-CN": "繁体中文",
"en-US": "Chinese (Traditional)"
},
"ja-JP": {
"zh-CN": "日语",
"en-US": "Japanese"
},
"ko-KR": {
"zh-CN": "韩语",
"en-US": "Korean"
}
}
}

View File

@@ -0,0 +1,191 @@
import React, {
useState,
useEffect,
useMemo,
useRef,
useCallback
} from "react";
import {
useNavigate,
useRouteError
} from "react-router-dom";
import header from '@/scss/root/header.module.scss'
import classes from '@/scss/error/Error.module.scss'
import { useAtom } from 'jotai'
import { atomWithStorage } from 'jotai/utils';
import Switch from '@/component/switch';
import ReturnButton from "@/component/return_button";
import { Typewriter } from 'react-simple-typewriter'
import { useHeader } from '@/state/header';
import VoiceElement from '@/component/voice';
import spine from '!/libs/spine-player'
import '!/libs/spine-player.css'
import useUmami from '@parcellab/react-use-umami';
const voiceOnAtom = atomWithStorage('voiceOn', false)
const config = JSON.parse(import.meta.env.VITE_ERROR_FILES)
const obj = config.files[Math.floor((Math.random() * config.files.length))]
const filename = obj.key.replace("#", "%23")
const padding = obj.paddings
let lastVoiceState = 'ended'
export default function Error() {
// eslint-disable-next-line no-unused-vars
const _trackEvt = useUmami('/error')
const error = useRouteError();
const navigate = useNavigate();
const {
setTitle,
} = useHeader()
const [voiceOn, setVoiceOn] = useAtom(voiceOnAtom)
const [spineDone, _setSpineDone] = useState(false)
const spineRef = useRef(null)
const [spineData, setSpineData] = useState(null)
const spineDoneRef = useRef(spineDone)
const voiceOnRef = useRef(voiceOn)
const [voiceSrc, setVoiceSrc] = useState(null)
const [voiceReplay, setVoiceReplay] = useState(false)
const [spinePlayer, setSpinePlayer] = useState(null)
const setSpineDone = (data) => {
spineDoneRef.current = data
_setSpineDone(data)
}
const content = useMemo(() => ['エラー発生。', '发生错误。', 'Error occured.', '에러 발생.', '發生錯誤。'], [])
useEffect(() => {
console.log(error)
fetch(`/${import.meta.env.VITE_DIRECTORY_FOLDER}/${filename}.json`).then(res => res.json()).then(data => {
setSpineData(data)
})
}, [error])
useEffect(() => {
setTitle(content[0])
}, [content, setTitle])
useEffect(() => {
if (!voiceOn) {
setVoiceSrc(null)
} else {
setVoiceSrc(`/${import.meta.env.VITE_DIRECTORY_FOLDER}/error.ogg`)
if (spinePlayer) {
spinePlayer.animationState.setAnimation(0, "Interact", false, 0);
spinePlayer.animationState.addAnimation(0, "Relax", true, 0);
}
}
}, [voiceOn])
useEffect(() => {
voiceOnRef.current = voiceOn
}, [voiceOn])
const playVoice = useCallback(() => {
if (lastVoiceState === 'ended' && voiceSrc !== null) {
setVoiceReplay(true)
}
}, [voiceSrc])
const handleAduioStateChange = useCallback((e, state) => {
lastVoiceState = state
if (state === 'ended') {
setVoiceReplay(false)
}
}, [])
useEffect(() => {
if (spineRef.current?.children.length === 0 && spineData) {
setSpinePlayer(new spine.SpinePlayer(spineRef.current, {
skelUrl: `./assets/${filename}.skel`,
atlasUrl: `./assets/${filename}.atlas`,
rawDataURIs: spineData,
animation: 'Relax',
premultipliedAlpha: true,
alpha: true,
backgroundColor: "#00000000",
viewport: {
debugRender: false,
padLeft: `${padding.left}%`,
padRight: `${padding.right}%`,
padTop: `${padding.top}%`,
padBottom: `${padding.bottom}%`,
x: 0,
y: 0,
},
showControls: false,
touch: false,
fps: 60,
defaultMix: 0.3,
success: (player) => {
let isPlayingInteract = false
player.animationState.addListener({
end: (e) => {
if (e.animation.name == "Interact") {
isPlayingInteract = false;
}
}
});
setSpineDone(true)
const ani = () => {
if (isPlayingInteract) {
return;
}
isPlayingInteract = true;
player.animationState.setAnimation(0, "Interact", false, 0);
player.animationState.addAnimation(0, "Relax", true, 0);
if (voiceOnRef.current) playVoice()
}
ani()
player.canvas.onclick = () => {
ani()
}
player.canvas.onmouseenter = () => {
ani()
}
}
}))
}
}, [playVoice, spineData]);
return (
<section className={classes.error}>
<header className={`${header.header} ${classes.header}`}>
<ReturnButton
onClick={() => navigate(-1, { replace: true })}
/>
<Switch
key="voice"
text='voice'
on={voiceOn}
handleOnClick={() => setVoiceOn(!voiceOn)}
/>
</header>
<main className={classes.main}>
{
content.map((item, index) => {
return (
<section key={index} className={classes.content}>
<Typewriter
words={[item]}
cursor
cursorStyle='|'
typeSpeed={100}
/>
</section>
)
})
}
<section
className={`${classes.spine} ${spineDone ? classes.active : ''}`}
ref={spineRef}
/>
<VoiceElement
src={voiceSrc}
replay={voiceReplay}
handleAduioStateChange={handleAduioStateChange}
/>
</main>
</section>
);
}

View File

@@ -0,0 +1,291 @@
import React, {
useState,
useEffect,
useMemo,
useCallback
} from 'react'
import PropTypes from 'prop-types';
import {
Outlet,
Link,
NavLink,
useNavigate,
ScrollRestoration
} from "react-router-dom";
import classes from '@/scss/root/Root.module.scss'
import header from '@/scss/root/header.module.scss'
import footer from '@/scss/root/footer.module.scss'
import drawer from '@/scss/root/drawer.module.scss'
import routes from '@/routes'
import { useConfig } from '@/state/config';
import { useHeader } from '@/state/header';
import { useAppbar } from '@/state/appbar';
import {
useI18n,
useLanguage,
} from '@/state/language'
import { useBackgrounds } from '@/state/background';
import Dropdown from '@/component/dropdown';
import Popup from '@/component/popup';
import ReturnButton from '@/component/return_button';
import Border from '@/component/border';
import CharIcon from '@/component/char_icon';
const currentYear = new Date().getFullYear()
export default function Root() {
const [drawerHidden, setDrawerHidden] = useState(true)
const {
title,
tabs,
setCurrentTab,
headerIcon
} = useHeader()
const {
extraArea,
} = useAppbar()
const { fetchConfig, fetchVersion } = useConfig()
const { fetchBackgrounds } = useBackgrounds()
const headerTabs = useMemo(() => {
return (
tabs?.map((item) => {
return (
<HeaderTabsElement
key={item.key}
item={item}
/>
)
})
)
}, [tabs])
const toggleDrawer = useCallback((value) => {
setDrawerHidden(value || !drawerHidden)
}, [drawerHidden])
useEffect(() => {
if (tabs.length > 0) {
setCurrentTab(tabs[0].key)
} else {
setCurrentTab(null)
}
}, [setCurrentTab, tabs])
useEffect(() => {
fetchConfig()
fetchVersion()
fetchBackgrounds()
}, [fetchBackgrounds, fetchConfig, fetchVersion])
return (
<>
<header className={header.header}>
<section
className={`${header.navButton} ${drawerHidden ? '' : header.active}`}
onClick={() => toggleDrawer()}
>
<section className={header.bar} />
<section className={header.bar} />
<section className={header.bar} />
</section>
<section className={header.spacer} />
<section className={header['extra-area']}>
{extraArea}
<LanguageDropdown />
</section>
</header>
<nav className={`${drawer.drawer} ${drawerHidden ? '' : drawer.active}`}>
<section
className={drawer.links}
>
<DrawerDestinations
toggleDrawer={toggleDrawer}
/>
</section>
<section
className={`${drawer.overlay} ${drawerHidden ? '' : drawer.active}`}
onClick={() => toggleDrawer()}
/>
</nav>
<main className={classes.main}>
<section className={classes.header}>
<section className={classes.title}>
{headerIcon && (
<section className={classes.icon}>
<CharIcon
type={headerIcon}
viewBox={
headerIcon === 'operator' ? '0 0 88.969 71.469' : '0 0 94.563 67.437'
}
/>
</section>
)}
{title}
</section>
<section className={classes.tab}>
{headerTabs}
</section>
</section>
<HeaderReturnButton />
<Outlet />
<ScrollRestoration />
</main>
<FooterElement />
</>
)
}
function FooterElement() {
const { i18n } = useI18n()
const { version } = useConfig()
const navigate = useNavigate()
return useMemo(() => {
return (
<footer className={footer.footer}>
<section className={`${footer.links} ${footer.section}`}>
<section className={footer.item}>
<Popup
className={footer.link}
title={i18n('disclaimer')}
>
{i18n('disclaimer_content')}
</Popup>
</section>
<section className={footer.item}>
<Link reloadDocument to="https://privacy.halyul.dev" target="_blank" className={footer.link}>{i18n('privacy_policy')}</Link>
</section>
<section className={footer.item}>
<Link reloadDocument to="https://github.com/Halyul/aklive2d" target="_blank" className={footer.link}>GitHub</Link>
</section>
<section className={footer.item}>
<Popup
className={footer.link}
title={i18n('contact_us')}
>
ak#halyul.dev
</Popup>
</section>
</section>
<section className={`${footer.copyright} ${footer.section}`} onDoubleClick={() => {
navigate('/error')
}}>
<span>Spine Runtimes © 2013 - 2019 Esoteric Software LLC</span>
<span>Assets © 2017 - {currentYear} Arknights/Hypergryph Co., Ltd</span>
<span>Source Code © 2021 - {currentYear} Halyul</span>
<span>Directory @ {version.directory}</span>
<span>Showcase @ {version.showcase}</span>
</section>
</footer>
)
}, [i18n, navigate, version.directory, version.showcase])
}
function DrawerDestinations({ toggleDrawer }) {
const { i18n } = useI18n()
const { textDefaultLang, alternateLang } = useLanguage()
return (
routes.filter((item) => item.inDrawer).map((item) => {
if (typeof item.element.type === 'string') {
return (
<Link reloadDocument
key={item.name}
to={item.path}
target="_blank"
className={drawer.link}
onClick={() => toggleDrawer(false)}
>
<section>
{i18n(item.name, textDefaultLang)}
</section>
<section>
{i18n(item.name, alternateLang)}
</section>
</Link>
)
} else {
return (
<NavLink
to={item.path}
key={item.name}
className={({ isActive, }) =>
`${drawer.link} ${isActive ? drawer.active : ''}`
}
onClick={() => toggleDrawer(false)}
>
<section>
{i18n(item.name, textDefaultLang)}
</section>
<section>
{i18n(item.name, alternateLang)}
</section>
</NavLink>
)
}
})
)
}
function LanguageDropdown() {
const { language, setLanguage } = useLanguage()
const { i18n, i18nValues } = useI18n()
return useMemo(() => {
return (
<Dropdown
text={i18n(language)}
menu={i18nValues.available.map((item) => {
return {
name: i18n(item),
value: item
}
})}
onClick={(item) => {
setLanguage(item.value)
}}
/>
)
}, [i18n, i18nValues.available, language, setLanguage])
}
function HeaderTabsElement({ item }) {
const {
currentTab, setCurrentTab,
} = useHeader()
const { i18n } = useI18n()
return (
<section
className={`${classes.item} ${currentTab === item.key ? classes.active : ''}`}
onClick={(e) => {
setCurrentTab(item.key)
item.onClick && item.onClick(e, currentTab)
}}
style={item.style}
>
<section className={classes['text-wrapper']}>
<span>{i18n(item.key)}</span>
</section>
</section>
)
}
HeaderTabsElement.propTypes = {
item: PropTypes.object.isRequired,
}
function HeaderReturnButton() {
const navigate = useNavigate()
return useMemo(() => {
return (
<Border>
<ReturnButton
className={classes['return-button']}
onClick={() => navigate("/")}
/>
</Border>
)
}, [navigate])
}

View File

@@ -0,0 +1,36 @@
import React from "react";
import Home from "@/routes/path/Home";
import Operator from "@/routes/path/Operator";
import Changelogs from "@/routes/path/Changelogs";
export default [
{
path: "/",
index: true,
name: "home",
element: <Home />,
inDrawer: true,
routeable: true
}, {
path: "changelogs",
index: false,
name: "changelogs",
element: <Changelogs />,
inDrawer: true,
routeable: true
}, {
path: "https://ak.hypergryph.com/archive/dynamicCompile/",
index: false,
name: "offical_page",
element: <a/>,
inDrawer: true,
routeable: false
}, {
path: ":key",
index: false,
name: "operator",
element: <Operator />,
inDrawer: false,
routeable: true
},
]

View File

@@ -0,0 +1,76 @@
import React, {
useState,
useEffect,
useMemo
} from 'react'
import classes from '@/scss/changelogs/Changelogs.module.scss'
import { useHeader } from '@/state/header';
import { useAppbar } from '@/state/appbar';
import useUmami from '@parcellab/react-use-umami'
import Border from '@/component/border';
export default function Changelogs() {
// eslint-disable-next-line no-unused-vars
const _trackEvt = useUmami('/changelogs')
const {
setTitle,
setTabs,
currentTab,
setHeaderIcon,
} = useHeader()
const {
setExtraArea,
} = useAppbar()
const [changelogs, setChangelogs] = useState([])
useEffect(() => {
setTitle('changelogs')
setExtraArea([])
setHeaderIcon(null)
fetch('/_assets/changelogs.json').then(res => res.json()).then(data => {
setChangelogs(data)
})
}, [setExtraArea, setHeaderIcon, setTitle])
useEffect(() => {
setTabs(changelogs.map((item) => {
return {
key: item[0].key
}
}))
}, [changelogs, setTabs])
const content = useMemo(() => {
return (
changelogs.map((v) => {
return (
v.map((item) => {
return (
<section className={classes.wrapper} key={item.date} hidden={currentTab !== item.key}>
<section className={classes.group}>
<section className={classes.info}>
{item.content.map((entry, index) => {
return (
<section className={classes.content} key={index}>
{entry}
</section>
)
})}
</section>
<section className={classes.date}>{item.date}</section>
</section>
<Border />
</section>
)
})
)
})
)
}, [changelogs, currentTab])
return (
<section>
{content}
</section>
)
}

View File

@@ -0,0 +1,201 @@
import React, {
useState,
useEffect,
useCallback,
useMemo
} from 'react'
import PropTypes from 'prop-types';
import {
NavLink,
} from "react-router-dom";
import classes from '@/scss/home/Home.module.scss'
import { useConfig } from '@/state/config';
import {
useLanguage
} from '@/state/language'
import { useHeader } from '@/state/header';
import { useAppbar } from '@/state/appbar';
import VoiceElement from '@/component/voice';
import { useAtom } from 'jotai'
import { atomWithStorage } from 'jotai/utils';
import CharIcon from '@/component/char_icon';
import Border from '@/component/border';
import useUmami from '@parcellab/react-use-umami';
import Switch from '@/component/switch';
const voiceOnAtom = atomWithStorage('voiceOn', false)
let lastVoiceState = 'ended'
export default function Home() {
// eslint-disable-next-line no-unused-vars
const _trackEvt = useUmami('/')
const {
setTitle,
setTabs,
currentTab,
setHeaderIcon
} = useHeader()
const { config } = useConfig()
const [content, setContent] = useState([])
const [voiceOn] = useAtom(voiceOnAtom)
const [voiceSrc, setVoiceSrc] = useState(null)
const [voiceReplay, setVoiceReplay] = useState(false)
useEffect(() => {
setTitle('dynamic_compile')
setTabs([{
key: 'all'
}, {
key: 'operator'
}, {
key: 'skin'
}])
setHeaderIcon(null)
}, [setHeaderIcon, setTabs, setTitle])
useEffect(() => {
setContent(config?.operators || [])
}, [config])
const handleAduioStateChange = useCallback((e, state) => {
lastVoiceState = state
if (state === 'ended') {
setVoiceReplay(false)
}
}, [])
const isShown = useCallback((type) => currentTab === 'all' || currentTab === type, [currentTab])
const handleVoicePlay = useCallback((src) => {
if (!voiceOn) {
setVoiceSrc(null)
} else {
if (src === voiceSrc && lastVoiceState === 'ended') {
setVoiceReplay(true)
} else {
setVoiceSrc(src)
}
}
}, [voiceOn, voiceSrc])
return (
<section>
{
content.map((v) => {
const length = v.filter((v) => isShown(v.type)).length
return (
<section key={v[0].date} hidden={length === 0}>
<section className={classes.group}>
{v.map(item => {
return (
<OperatorElement
key={item.link}
item={item}
hidden={!isShown(item.type)}
handleVoicePlay={handleVoicePlay}
/>
)
})}
<section className={classes.date}>{v[0].date}</section>
</section>
<Border />
</section>
)
})
}
<VoiceSwitchElement
src={voiceSrc}
handleAduioStateChange={handleAduioStateChange}
replay={voiceReplay}
/>
</section>
)
}
function OperatorElement({ item, hidden, handleVoicePlay }) {
const { textDefaultLang, language, alternateLang } = useLanguage()
return useMemo(() => {
return (
<NavLink
to={`/${item.link}`}
className={classes.item}
hidden={hidden}
>
<section
onMouseEnter={() => handleVoicePlay(`/${item.link}/assets/${JSON.parse(import.meta.env.VITE_VOICE_FOLDERS).main}/${import.meta.env.VITE_APP_VOICE_URL}`)}
>
<section className={classes['background-filler']} />
<section className={classes.outline} />
<section className={classes.img}>
<ImageElement
item={item}
/>
</section>
<section className={classes.info}>
<section className={classes.container}>
<section className={classes.title}>{item.codename[language]}</section>
<section className={classes.type}>
<CharIcon
type={item.type}
viewBox={
item.type === 'operator' ? '0 0 88.969 71.469' : '0 0 94.563 67.437'
} />
</section>
</section>
<section className={classes.wrapper}>
<span className={classes.text}>{item.codename[language.startsWith("en") ? alternateLang : textDefaultLang]}</span>
</section>
<section className={classes.background} style={{
color: item.color
}} />
</section>
</section>
</NavLink>
)
}, [item, hidden, language, alternateLang, textDefaultLang, handleVoicePlay])
}
function VoiceSwitchElement({ src, replay, handleAduioStateChange }) {
const [voiceOn, setVoiceOn] = useAtom(voiceOnAtom)
const {
setExtraArea,
} = useAppbar()
useEffect(() => {
setExtraArea([
(
<Switch
key="voice"
text='voice'
on={voiceOn}
handleOnClick={() => setVoiceOn(!voiceOn)}
/>
)
])
}, [voiceOn, setExtraArea, setVoiceOn])
return (
<VoiceElement
src={src}
replay={replay}
handleAduioStateChange={handleAduioStateChange}
/>
)
}
VoiceSwitchElement.propTypes = {
src: PropTypes.string,
replay: PropTypes.bool,
handleAduioStateChange: PropTypes.func,
}
function ImageElement({ item }) {
const { language } = useLanguage()
return <img src={`/${item.link}/assets/${item.fallback_name.replace("#", "%23")}_portrait.png`} alt={item.codename[language]} />
}
ImageElement.propTypes = {
item: PropTypes.object.isRequired,
fallback_name: PropTypes.string,
codename: PropTypes.object,
}

View File

@@ -0,0 +1,554 @@
import React, {
useState,
useEffect,
useRef,
useCallback,
useMemo
} from 'react'
import {
useParams,
useNavigate,
Link
} from "react-router-dom";
import classes from '@/scss/operator/Operator.module.scss'
import { useConfig } from '@/state/config';
import {
useLanguage,
} from '@/state/language'
import { useHeader } from '@/state/header';
import { useAppbar } from '@/state/appbar';
import { useBackgrounds } from '@/state/background';
import VoiceElement from '@/component/voice';
import useUmami from '@parcellab/react-use-umami'
import spine from '!/libs/spine-player'
import '!/libs/spine-player.css'
import Border from '@/component/border';
import { useI18n } from '@/state/language';
import Switch from '@/component/switch';
import { atom, useAtom } from 'jotai'
const musicMapping = JSON.parse(import.meta.env.VITE_MUSIC_MAPPING)
const getVoiceFoler = (lang) => {
const folderObject = JSON.parse(import.meta.env.VITE_VOICE_FOLDERS)
const voiceFolder = folderObject.sub.find(e => e.lang === lang) || folderObject.sub.find(e => e.name === 'custom')
return `${folderObject.main}/${voiceFolder.name}`
}
const defaultSpineAnimation = 'Idle'
const backgroundAtom = atom(null)
const getTabName = (item, language) => {
if (item.type === 'operator') {
return 'operator'
} else {
return item.codename[language].replace(/^(.+)( )(·|\/)()(.+)$/, '$1')
}
}
export default function Operator() {
const navigate = useNavigate()
const { operators } = useConfig()
const { language } = useLanguage()
const { key } = useParams();
const {
setTitle,
setTabs,
setHeaderIcon
} = useHeader()
const { setExtraArea } = useAppbar()
const [config, setConfig] = useState(null)
const [spineData, setSpineData] = useState(null)
// eslint-disable-next-line no-unused-vars
const _trackEvt = useUmami(`/${key}`)
const spineRef = useRef(null)
const [spineAnimation, setSpineAnimation] = useState(defaultSpineAnimation)
const { i18n } = useI18n()
const [spinePlayer, setSpinePlayer] = useState(null)
const [voiceLang, _setVoiceLang] = useState(null)
const { backgrounds } = useBackgrounds()
const [currentBackground, setCurrentBackground] = useAtom(backgroundAtom)
const [voiceConfig, setVoiceConfig] = useState(null)
const [subtitleLang, setSubtitleLang] = useState(null)
const [hideSubtitle, setHideSubtitle] = useState(true)
const [subtitleObj, _setSubtitleObj] = useState(null)
const [currentVoiceId, setCurrentVoiceId] = useState(null)
const voiceLangRef = useRef(voiceLang)
const subtitleObjRef = useRef(subtitleObj)
const configRef = useRef(config)
const [voiceSrc, setVoiceSrc] = useState(null)
const [isVoicePlaying, _setIsVoicePlaying] = useState(false)
const isVoicePlayingRef = useRef(isVoicePlaying)
const setVoiceLang = (value) => {
voiceLangRef.current = value
_setVoiceLang(value)
}
const setSubtitleObj = (value) => {
subtitleObjRef.current = value
_setSubtitleObj(value)
}
const setIsVoicePlaying = (value) => {
isVoicePlayingRef.current = value
_setIsVoicePlaying(value)
}
useEffect(() => {
setExtraArea([])
}, [setExtraArea])
useEffect(() => {
if (backgrounds.length > 0) setCurrentBackground(backgrounds[0])
}, [backgrounds, setCurrentBackground])
useEffect(() => {
setSpineData(null)
const config = operators.find((item) => item.link === key)
if (config) {
setConfig(config)
configRef.current = config
fetch(`/${import.meta.env.VITE_DIRECTORY_FOLDER}/${config.filename.replace("#", "%23")}.json`).then(res => res.json()).then(data => {
setSpineAnimation(defaultSpineAnimation)
setSpineData(data)
})
setHeaderIcon(config.type)
if (spineRef.current?.children.length > 0) {
spineRef.current?.removeChild(spineRef.current?.children[0])
}
fetch(`/${import.meta.env.VITE_DIRECTORY_FOLDER}/voice_${config.link}.json`).then(res => res.json()).then(data => {
setVoiceConfig(data)
})
}
}, [key, operators, setHeaderIcon])
const coverToTab = useCallback((item, language) => {
const key = getTabName(item, language)
return {
key: key,
style: {
color: item.color
},
onClick: (e, tab) => {
if (tab === key) return
navigate(`/${item.link}`)
}
}
}, [navigate])
const otherEntries = useMemo(() => {
if (!config || !language) return null
return operators.filter((item) => item.id === config.id && item.link !== config.link).map((item) => {
return coverToTab(item, language)
})
}, [config, language, operators, coverToTab])
useEffect(() => {
if (config) {
setTabs(
[
coverToTab(config, language),
...otherEntries
]
)
}
}, [config, key, coverToTab, setTabs, otherEntries, language])
useEffect(() => {
if (config) {
setTitle(config.codename[language])
}
}, [config, language, key, setTitle])
useEffect(() => {
if (spineRef.current?.children.length === 0 && spineData && config) {
setSpinePlayer(new spine.SpinePlayer(spineRef.current, {
skelUrl: `./assets/${config.filename.replace('#', '%23')}.skel`,
atlasUrl: `./assets/${config.filename.replace('#', '%23')}.atlas`,
rawDataURIs: spineData,
animation: spineAnimation,
premultipliedAlpha: true,
alpha: true,
backgroundColor: "#00000000",
viewport: {
debugRender: false,
padLeft: `${config.viewport_left}%`,
padRight: `${config.viewport_right}%`,
padTop: `${config.viewport_top}%`,
padBottom: `${config.viewport_bottom}%`,
x: 0,
y: 0,
},
showControls: false,
touch: false,
fps: 60,
defaultMix: 0.3,
success: (player) => {
let lastVoiceId = null
let currentVoiceId = null
player.canvas.onclick = () => {
if (!voiceLangRef.current) return
const voiceId = () => {
const keys = Object.keys(subtitleObjRef.current)
const id = keys[Math.floor((Math.random() * keys.length))]
return id === lastVoiceId ? voiceId() : id
}
const id = voiceId()
currentVoiceId = id
setCurrentVoiceId(id)
setVoiceSrc(`/${configRef.current.link}/assets/${getVoiceFoler(voiceLangRef.current)}/${id}.ogg`)
lastVoiceId = currentVoiceId
}
}
}))
}
}, [config, spineData, spineAnimation]);
useEffect(() => {
if (voiceConfig && voiceLang) {
let subtitleObj = voiceConfig.subtitleLangs[subtitleLang || 'zh-CN']
let subtitleKey = 'default'
if (subtitleObj[voiceLang]) {
subtitleKey = voiceLang
}
setSubtitleObj(subtitleObj[subtitleKey])
}
}, [subtitleLang, voiceConfig, voiceLang])
const handleAduioStateChange = useCallback((e, state) => {
switch (state) {
case 'play':
setIsVoicePlaying(true)
break
default:
setIsVoicePlaying(false)
break
}
}, [])
useEffect(() => {
if (subtitleLang) {
if (isVoicePlaying) {
setHideSubtitle(false)
} else {
const autoHide = () => {
if (isVoicePlayingRef.current) return
setHideSubtitle(true)
}
setTimeout(autoHide, 5 * 1000)
return () => {
clearTimeout(autoHide)
}
}
} else {
setHideSubtitle(true)
}
}, [subtitleLang, isVoicePlaying])
useEffect(() => {
if (voiceLang && isVoicePlaying) {
const audioUrl = `/assets/${getVoiceFoler(voiceLang)}/${currentVoiceId}.ogg`
if (voiceSrc !== (window.location.href.replace(/\/$/g, '') + audioUrl)) {
setVoiceSrc(`/${config.link}${audioUrl}`)
}
}
}, [voiceLang, isVoicePlaying, currentVoiceId, config, voiceSrc])
const playAnimationVoice = useCallback((animation) => {
if (voiceLangRef.current) {
let id = null
if (animation === 'Idle') id = 'CN_011'
if (animation === 'Interact') id = 'CN_034'
if (animation === 'Special') id = 'CN_042'
if (id) {
setCurrentVoiceId(id)
setVoiceSrc(`/${key}/assets/${getVoiceFoler(voiceLangRef.current)}/${id}.ogg`)
}
}
}, [key])
useEffect(() => {
if (!voiceLang) {
setVoiceSrc(null)
}
}, [voiceLang])
const spineSettings = [
{
name: 'animation',
options: [
{
name: 'idle',
onClick: () => {
const animation = "Idle"
playAnimationVoice(animation)
spinePlayer.animationState.setAnimation(0, animation, true, 0)
setSpineAnimation(animation)
},
activeRule: () => {
return spineAnimation === 'Idle'
}
}, {
name: 'interact',
onClick: () => {
const animation = "Interact"
playAnimationVoice(animation)
spinePlayer.animationState.setAnimation(0, animation, true, 0)
setSpineAnimation(animation)
},
activeRule: () => {
return spineAnimation === 'Interact'
}
}, {
name: 'special',
onClick: () => {
const animation = "Special"
playAnimationVoice(animation)
spinePlayer.animationState.setAnimation(0, animation, true, 0)
setSpineAnimation(animation)
},
activeRule: () => {
return spineAnimation === 'Special'
}
}
]
}, {
name: 'voice',
options: voiceConfig && Object.keys(voiceConfig?.voiceLangs["zh-CN"]).map((item) => {
return {
name: i18n(item),
onClick: () => {
if (voiceLang !== item) {
setVoiceLang(item)
} else {
setVoiceLang(null)
}
if (!isVoicePlayingRef.current) {
playAnimationVoice(spineAnimation)
}
},
activeRule: () => {
return voiceLang === item
}
}
}) || []
}, {
name: 'subtitle',
options: voiceConfig && Object.keys(voiceConfig?.subtitleLangs).map((item) => {
return {
name: i18n(item),
onClick: () => {
if (subtitleLang !== item) {
setSubtitleLang(item)
} else {
setSubtitleLang(null)
}
},
activeRule: () => {
return subtitleLang === item
}
}
}) || []
}, {
name: 'music',
el: <MusicElement />
}, {
name: 'backgrounds',
options: backgrounds.map((item) => {
return {
name: item,
onClick: () => {
setCurrentBackground(item)
},
activeRule: () => {
return currentBackground === item
}
}
}) || []
}
]
if (!JSON.parse(import.meta.env.VITE_AVAILABLE_OPERATORS).includes(key)) {
throw new Error('Operator not found')
}
return (
<section className={classes.operator}>
<section className={classes.main}>
<section className={classes.settings} style={{
color: config?.color
}}>
{
spineSettings.map((item) => {
if (item.el) {
return (
<section key={item.name}>
{item.el}
</section>
)
}
if (item.options.length === 0) return null
return (
<section key={item.name}>
<section className={classes.title}>
<section className={classes.text}>{i18n(item.name)}</section>
</section>
<section className={classes['styled-selection']}>
{item.options.map((option) => {
return (
<section className={`${classes.content} ${option.activeRule && option.activeRule() ? classes.active : ''}`} onClick={(e) => option.onClick(e)} key={option.name}>
<section className={classes.option}>
<section className={classes.outline} />
<section className={classes.text}>{i18n(option.name)}</section>
<section className={classes['tick-icon']} />
</section>
</section>
)
})}
</section>
</section>
)
})
}
<section>
<section className={classes.title}>
<section className={classes.text}>{i18n('external_links')}</section>
</section>
<section className={classes['styled-selection']}>
<Link
reloadDocument
to={`./index.html?settings`}
target='_blank'
style={{
color: config?.color
}}
>
<section className={classes.content}>
<section className={classes.option}>
<section className={classes.outline} />
<section className={classes.text}>
{i18n('web_version')}
</section>
</section>
</section>
</Link>
{
config?.workshopId && (
<Link
reloadDocument
to={`https://steamcommunity.com/sharedfiles/filedetails/?id=${config.workshopId}`}
target='_blank'
style={{
color: config?.color
}}>
<section className={classes.content}>
<section className={classes.option}>
<section className={classes.outline} />
<section className={classes.text}>
{i18n('steam_workshop')}
</section>
</section>
</section>
</Link>
)
}
</section>
</section>
</section>
<section className={classes.container} style={currentBackground && {
backgroundImage: `url(/chen/assets/${import.meta.env.VITE_BACKGROUND_FOLDER}/${currentBackground})`
}} >
{
config && (
<img src={`/${config.link}/assets/${config.logo}.png`} alt={config?.codename[language]} className={classes.logo} />
)
}
<section ref={spineRef} className={classes.wrapper} />
{currentVoiceId && subtitleObj && (
<section className={`${classes.voice} ${hideSubtitle ? '' : classes.active}`}>
<section className={classes.type}>{subtitleObj[currentVoiceId]?.title}</section>
<section className={classes.subtitle}>
<span>{subtitleObj[currentVoiceId]?.text}</span>
<span className={classes.triangle} />
</section>
</section>)
}
</section>
</section>
<Border />
<VoiceElement
src={voiceSrc}
handleAduioStateChange={handleAduioStateChange}
/>
</section>
)
}
function MusicElement() {
const [enableMusic, setEnableMusic] = useState(false)
const { i18n } = useI18n()
const musicIntroRef = useRef(null)
const musicLoopRef = useRef(null)
const [background,] = useAtom(backgroundAtom)
useEffect(() => {
if (musicIntroRef.current && musicIntroRef.current) {
musicIntroRef.current.volume = 0.5
musicLoopRef.current.volume = 0.5
}
}, [musicIntroRef, musicLoopRef])
useEffect(() => {
if (!enableMusic || background) {
musicIntroRef.current.pause()
musicLoopRef.current.pause()
}
}, [enableMusic, background])
useEffect(() => {
if (background && enableMusic) {
const introOgg = musicMapping[background].intro
const intro = `./chen/assets/${import.meta.env.VITE_MUSIC_FOLDER}/${introOgg}`
const loop = `./chen/assets/${import.meta.env.VITE_MUSIC_FOLDER}/${musicMapping[background].loop}`
musicLoopRef.current.src = loop
if (introOgg) {
musicIntroRef.current.src = intro || loop
} else {
musicLoopRef.current.play()
}
}
}, [background, enableMusic])
const handleIntroTimeUpdate = useCallback(() => {
if (musicIntroRef.current.currentTime >= musicIntroRef.current.duration - 0.3) {
musicIntroRef.current.pause()
musicLoopRef.current.play()
}
}, [])
const handleLoopTimeUpdate = useCallback(() => {
if (musicLoopRef.current.currentTime >= musicLoopRef.current.duration - 0.3) {
musicLoopRef.current.currentTime = 0
musicLoopRef.current.play()
}
}, [])
return (
<section>
<section
className={classes.title}
onClick={() => setEnableMusic(!enableMusic)}
>
<section className={classes.text}>{i18n('music')}</section>
<section className={classes.switch}>
<Switch on={enableMusic} />
</section>
</section>
<audio ref={musicIntroRef} preload="auto" autoPlay onTimeUpdate={() => handleIntroTimeUpdate()}>
<source type="audio/ogg" />
</audio>
<audio ref={musicLoopRef} preload="auto" onTimeUpdate={() => handleLoopTimeUpdate()}>
<source type="audio/ogg"/>
</audio>
</section>
)
}

View File

@@ -0,0 +1,13 @@
.main {
flex-grow: 1;
display: flex;
flex-direction: column;
align-items: stretch;
justify-content: flex-start;
padding-bottom: 3rem;
margin: 0 auto;
width: 70%;
max-width: 100rem;
padding-top: 5rem;
min-height: calc(100vh - 5rem - 3rem);
}

View File

@@ -0,0 +1,150 @@
.group {
padding: 1rem;
display: flex;
align-items: flex-end;
flex-wrap: wrap;
user-select: none;
.date {
margin: 1.5rem;
font-family: "Bender";
font-weight: bold;
text-align: right;
color: var(--date-color);
font-size: 1.5rem;
letter-spacing: 0.1rem;
flex: auto;
user-select: none;
}
.item {
position: relative;
cursor: pointer;
width: 180px;
margin: 1.25rem;
background-image: repeating-linear-gradient(
90deg,
var(--home-item-background-linear-gradient-color) 0,
var(--home-item-background-linear-gradient-color) 1px,
transparent 1px,
transparent 5px
);
.background-filler {
border-right: 1px solid var(--home-item-background-linear-gradient-color);
position: absolute;
top: 0;
left: 0;
right: -1px;
bottom: 0;
}
.outline {
display: block;
position: absolute;
opacity: 0;
visibility: hidden;
transition: all cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
width: 100%;
height: 100%;
left: -6px;
top: -6px;
border: var(--home-item-outline-color) 1px dashed;
padding: 6px;
&:before,
&:after {
content: "";
display: block;
position: absolute;
left: -3px;
height: 3px;
width: 100%;
border-left: var(--text-color) solid 3px;
border-right: var(--text-color) solid 3px;
}
&:before {
top: -3px;
}
&:after {
bottom: -3px;
}
}
.img {
height: 360px;
width: 100%;
transition: background-color cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
}
.info {
white-space: nowrap;
position: relative;
padding: 0.8rem 0.4rem;
line-height: 1.2em;
height: 36px;
.container {
color: var(--text-color-full);
display: flex;
justify-content: space-between;
align-items: center;
font-size: 1.25rem;
font-weight: bold;
.title {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
line-height: 1.3em;
height: auto;
}
.type {
display: flex;
flex-direction: row;
align-items: baseline;
text-align: center;
width: 1.5rem;
fill: var(--text-color);
}
}
.wrapper {
overflow: hidden;
text-overflow: ellipsis;
color: var(--secondary-text-color);
.text {
font-size: 0.75rem;
font-family: "Geometos";
margin-top: 1rem;
}
}
.background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
visibility: hidden;
transition: all cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
background-image: linear-gradient(
70deg,
transparent 40%,
currentColor 150%
);
}
}
&:hover {
.img {
background-color: var(--home-item-hover-background-color);
}
.outline,
.info .background {
opacity: 1;
visibility: visible;
}
}
}
}

View File

@@ -0,0 +1,19 @@
@use '@/scss/_page_base.scss';
.group {
flex-direction: column;
align-items: stretch;
.info {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
padding-left: 1rem;
word-break: break-word;
.content {
font-size: 1.5rem;
display: list-item;
}
}
}

View File

@@ -0,0 +1,57 @@
@use '@/scss/_main_share.scss';
.error {
min-height: 100vh;
display: flex;
flex-direction: column;
font-size: 16px;
user-select: none;
.header {
padding: 1rem;
justify-content: space-between;
pointer-events: auto;
}
.main {
flex: 1;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
padding-top: 10rem;
font-size: 3rem;
gap: 2rem;
padding-bottom: 0;
}
.spine {
max-width: 600px;
flex: 1;
visibility: hidden;
opacity: 0;
&.active {
visibility: visible;
opacity: 1;
}
}
@media (max-width: 768px) {
.main {
padding-top: 6rem;
max-height: calc(100vh - 6rem);
}
.content {
font-size: 2rem;
}
}
@media (max-width: 480px) {
.main {
padding-top: 4rem;
max-height: calc(100vh - 4rem);
}
.content {
font-size: 1.5rem;
}
}
}

View File

@@ -0,0 +1 @@
@use '@/scss/_page_base.scss';

View File

@@ -0,0 +1,95 @@
@use '@/scss/_main_share.scss';
.main {
.header {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-end;
flex-wrap: wrap;
position: relative;
padding-right: 2rem;
.title {
font-size: 3rem;
font-weight: 700;
text-transform: uppercase;
line-height: 1.2em;
.icon {
width: 3.88rem;
margin-right: 1.88rem;
fill: var(--text-color);
display: inline-block;
vertical-align: middle;
}
@media (max-width: 600px) {
font-size: 2.5rem;
}
@media (max-width: 480px) {
font-size: 2rem;
}
}
.tab {
flex: auto;
white-space: pre;
user-select: none;
display: flex;
flex-direction: row;
justify-content: flex-end;
overflow: hidden;
z-index: 1;
.item {
font-size: 1.25rem;
line-height: 3em;
font-weight: 700;
padding: 0 1rem;
text-transform: uppercase;
cursor: pointer;
border-bottom: 0.3rem solid transparent;
display: inline-block;
cursor: pointer;
text-decoration: none;
overflow: hidden;
text-overflow: ellipsis;
.text-wrapper {
overflow: hidden;
text-overflow: ellipsis;
color: var(--text-color);
transition: color cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
}
&.active,
&:hover {
color: var(--link-highlight-color);
.text-wrapper,
.text {
color: currentColor;
}
}
&.active {
border-bottom-color: currentColor;
}
}
}
}
.return-button {
position: absolute;
right: -4rem;
bottom: -24px;
color: var(--button-color);
transition: color cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
&:hover {
color: var(--text-color);
}
@media (max-width: 768px) {
right: -3.4rem;
}
}
}

View File

@@ -0,0 +1,54 @@
.drawer {
position: fixed;
top: 0;
left: -15rem;
width: 15rem;
height: 100%;
z-index: 2;
pointer-events: none;
transition: left cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
text-align: center;
display: flex;
flex-direction: row;
align-items: flex-start;
user-select: none;
.links {
padding: 8rem 0;
display: flex;
flex-direction: column;
align-items: center;
gap: 1rem;
background-color: var(--drawer-background-color);
height: 100%;
width: 15rem;
.link {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.2rem;
color: var(--text-color);
font-size: 0.8rem;
font-weight: 500;
transition: color cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
text-transform: uppercase;
&:hover,
&.active {
color: var(--link-highlight-color);
}
}
}
.overlay {
height: 100%;
flex-grow: 1;
z-index: 2;
}
&.active {
pointer-events: all;
left: 0;
width: 100vw;
}
}

View File

@@ -0,0 +1,35 @@
.footer {
user-select: none;
.section {
border-top: 1px solid var(--border-color);
padding: 1rem 0;
display: flex;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
font-family: "Noto Sans SC", sans-serif;
}
.links {
flex-direction: row;
height: 2rem;
.item {
padding: 0 1rem;
border-left: 2px solid var(--border-color);
height: inherit;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex-wrap: wrap;
&:first-of-type {
border-left: none;
}
}
}
.copyright {
flex-direction: column;
gap: 0.5rem;
font-size: 12px;
}
}

View File

@@ -0,0 +1,74 @@
.header {
width: auto;
position: fixed;
left: 0;
top: 0;
right: 0;
padding: 1rem;
z-index: 3;
height: 3rem;
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: nowrap;
justify-content: flex-start;
pointer-events: none;
.spacer {
flex-grow: 1;
}
.dropdown {
margin-left: auto;
}
.extra-area {
display: flex;
flex-direction: row;
align-items: center;
pointer-events: auto;
}
}
.navButton {
padding: 0.5rem;
font-size: 2rem;
width: 2rem;
height: 2rem;
cursor: pointer;
display: flex;
justify-content: center;
align-items: flex-start;
flex-direction: column;
z-index: 2;
pointer-events: auto;
.bar {
width: 2rem;
height: 0.2rem;
background-color: var(--text-color);
transition: transform cubic-bezier(0.65, 0.05, 0.36, 1) 0.3s;
&:nth-child(1) {
transform: translate(0, -200%);
}
&:nth-child(3) {
transform: translate(0, 200%);
}
}
&.active {
.bar {
&:nth-child(1) {
transform: translate(0, 100%) rotateZ(45deg) scaleX(0.5) translate(-50%);
}
&:nth-child(2) {
transform: rotateZ(-45deg);
}
&:nth-child(3) {
transform: translate(0, -100%) rotateZ(45deg) scaleX(0.5) translate(50%);
}
}
}
}

View File

@@ -0,0 +1,10 @@
import { atom, useAtom } from 'jotai';
const extraAreaAtom = atom([]);
export function useAppbar() {
const [extraArea, setExtraArea] = useAtom(extraAreaAtom);
return {
extraArea, setExtraArea
}
}

View File

@@ -0,0 +1,19 @@
import { useCallback } from 'react';
import { atom, useAtom } from 'jotai';
const backgroundsAtom = atom([]);
export function useBackgrounds() {
const [backgrounds, setBackgrounds] = useAtom(backgroundsAtom);
const fetchBackgrounds = useCallback(async () => {
const res = await fetch('/_assets/backgrounds.json')
const data = await res.json()
setBackgrounds(data)
}, [setBackgrounds])
return {
backgrounds,
fetchBackgrounds
};
}

View File

@@ -0,0 +1,31 @@
import { useCallback } from 'react';
import { atom, useAtom } from 'jotai';
const configAtom = atom([]);
const operatorsAtom = atom([]);
const versionAtom = atom({});
export function useConfig() {
const [config, setConfig] = useAtom(configAtom);
const [version, setVersion] = useAtom(versionAtom);
const [operators, setOperators] = useAtom(operatorsAtom);
const fetchConfig = useCallback(async () => {
const res = await fetch('/_assets/directory.json')
const data = await res.json()
setConfig(data);
let operatorsList = []
data.operators.forEach((item) => {
operatorsList = [...operatorsList, ...item]
})
setOperators(operatorsList)
}, [setConfig, setOperators])
const fetchVersion = useCallback(async () => {
const res = await fetch('/_assets/version.json')
const data = await res.json()
setVersion(data);
}, [setVersion])
return { config, version, operators, fetchConfig, fetchVersion };
}

View File

@@ -0,0 +1,34 @@
import { useEffect } from 'react';
import { atom, useAtom } from 'jotai';
import { useI18n } from "@/state/language"
const keyAtom = atom('');
const titleAtom = atom('');
const tabsAtom = atom([]);
const currentTabAtom = atom(null);
const appbarExtraAreaAtom = atom([]);
const headerIconAtom = atom(null);
export function useHeader() {
const [key, setTitle] = useAtom(keyAtom);
const [title, setRealTitle] = useAtom(titleAtom);
const [tabs, setTabs] = useAtom(tabsAtom);
const [currentTab, setCurrentTab] = useAtom(currentTabAtom);
const [appbarExtraArea, setAppbarExtraArea] = useAtom(appbarExtraAreaAtom);
const [headerIcon, setHeaderIcon] = useAtom(headerIconAtom);
const { i18n } = useI18n()
useEffect(() => {
const newTitle = i18n(key)
document.title = `${newTitle} - ${import.meta.env.VITE_APP_TITLE}`;
setRealTitle(newTitle)
}, [i18n, key, setRealTitle])
return {
title, setTitle,
tabs, setTabs,
currentTab, setCurrentTab,
appbarExtraArea, setAppbarExtraArea,
headerIcon, setHeaderIcon
}
}

View File

@@ -0,0 +1,35 @@
import { atom, useAtom, useAtomValue } from 'jotai';
import { atomWithStorage } from 'jotai/utils';
import i18nObject from '@/i18n'
const language = i18nObject.available.includes(navigator.language) ? navigator.language : "en-US"
const textDefaultLang = "en-US"
const languageAtom = atomWithStorage('language', language)
const alternateLangAtom = atom((get) => {
const language = get(languageAtom)
return language.startsWith("en") ? "zh-CN" : language
})
export function useI18n() {
const language = useAtomValue(languageAtom)
return {
i18n: (key, preferredLanguage = language) => {
if (i18nObject.key[key]) {
return i18nObject.key[key][preferredLanguage]
}
return key
},
i18nValues: i18nObject,
}
}
export function useLanguage() {
const [language, setLanguage] = useAtom(languageAtom)
const alternateLang = useAtomValue(alternateLangAtom)
return {
textDefaultLang,
language, setLanguage,
alternateLang,
}
}

17
index.html Normal file
View File

@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="renderer" content="webkit">
<title>aklive2d</title>
<script async defer data-website-id="05ee2d3d-66e0-429b-89ba-db112743a8c2"
src="https://insights.halyul.dev/insights.js" data-do-not-track="true" data-auto-track="false"></script>
</head>
<body style="background-image: url('./assets/background/operator_bg.png');">
<div id="app"></div>
<script type="module" src="/src/index.js"></script>
<script src="/wallpaper_engine.js"></script>
</body>
</html>

9
jsconfig.json Normal file
View File

@@ -0,0 +1,9 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"exclude": ["node_modules", "**/node_modules", "dist", "operator", "release"]
}

31
libs/alpha_composite.js Normal file
View File

@@ -0,0 +1,31 @@
import sharp from "sharp";
import path from "path";
export default class AlphaComposite {
async process(filename, maskFilename, extractedDir) {
const image = sharp(path.join(extractedDir, filename))
.removeAlpha()
const imageMeta = await image.metadata()
const imageBuffer = await image.toBuffer()
const mask = await sharp(path.join(extractedDir, maskFilename))
.extractChannel("blue")
.resize(imageMeta.width, imageMeta.height)
.toBuffer();
return sharp(imageBuffer)
.joinChannel(mask)
.toBuffer()
}
async crop(buffer, rect) {
const left = rect.y
const top = rect.x
const width = rect.h
const height = rect.w
const rotate = rect.rotate === 0 ? -90 : 0
const newImage = await sharp(buffer).rotate(90).extract({ left: left, top: top, width: width, height: height }).resize(width, height).extract({ left: 0, top: 0, width: width, height: height }).toBuffer()
return await sharp(newImage).rotate(rotate).toBuffer()
}
}

19
libs/append.js Normal file
View File

@@ -0,0 +1,19 @@
/* eslint-disable no-undef */
import path from 'path'
import { appendSync, readSync } from './file.js'
export function appendReadme(operatorName) {
const operatorConfig = __config.operators[operatorName]
const projectJson = JSON.parse(readSync(path.join(__projectRoot, __config.folder.operator, operatorName, 'project.json')))
appendSync(
`\n| ${operatorConfig.codename["en-US"]} | [Link](https://arknights.halyul.dev/${operatorConfig.link}/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=${projectJson.workshopid}) |`,
path.join(__projectRoot, 'README.md')
)
}
export function appendMainConfig(operatorName) {
appendSync(
`\n ${operatorName}: !include config/${operatorName}.yaml`,
path.join(__projectRoot, 'config.yaml')
)
}

64
libs/assets_processor.js Normal file
View File

@@ -0,0 +1,64 @@
/* eslint-disable no-undef */
import path from 'path'
import { read, write, readSync } from './file.js'
import AlphaComposite from './alpha_composite.js'
export default class AssetsProcessor {
#operatorSourceFolder
#alphaCompositer
#operatorName
#shareFolder
constructor(operatorName, shareFolder) {
this.#operatorSourceFolder = path.join(__projectRoot, __config.folder.operator)
this.#alphaCompositer = new AlphaComposite()
this.#operatorName = operatorName
this.#shareFolder = shareFolder
}
async process(extractedDir) {
const fallback_name = __config.operators[this.#operatorName].fallback_name
const fallbackFilename = `${fallback_name}.png`
const fallbackBuffer = await this.#alphaCompositer.process(fallbackFilename, `${path.parse(fallbackFilename).name}[alpha].png`, extractedDir)
await write(fallbackBuffer, path.join(this.#operatorSourceFolder, this.#operatorName, fallbackFilename))
// generate portrait
const portraitDir = path.join(this.#shareFolder, "portraits")
const portraitHub = JSON.parse(readSync(path.join(portraitDir, "MonoBehaviour", "portrait_hub.json")))
const portraitAtlas = portraitHub._sprites.find((item) => item.name === fallback_name).atlas
const portraitJson = JSON.parse(readSync(path.join(portraitDir, "MonoBehaviour", `portraits#${portraitAtlas}.json`)))
const item = portraitJson._sprites.find((item) => item.name === fallback_name)
const rect = {
...item.rect,
rotate: item.rotate
}
const protraitFilename = `portraits#${portraitAtlas}.png`
const portraitBuffer = await this.#alphaCompositer.process(protraitFilename, `${path.parse(protraitFilename).name}a.png`, path.join(portraitDir, "Texture2D"))
const croppedBuffer = await this.#alphaCompositer.crop(portraitBuffer, rect)
await write(croppedBuffer, path.join(this.#operatorSourceFolder, this.#operatorName, `${fallback_name}_portrait.png`))
return await this.generateAssets(__config.operators[this.#operatorName].filename, extractedDir)
}
async generateAssets(filename, extractedDir) {
const BASE64_BINARY_PREFIX = 'data:application/octet-stream;base64,'
const BASE64_PNG_PREFIX = 'data:image/png;base64,'
const assetsJson = {}
const skelFilename = `${filename}.skel`
const skel = await read(path.join(extractedDir, skelFilename), null)
const atlasFilename = `${filename}.atlas`
const atlas = await read(path.join(extractedDir, atlasFilename))
const dimensions = atlas.match(new RegExp(/^size:(.*),(.*)/gm))[0].replace('size: ', '').split(',')
const matches = atlas.match(new RegExp(/(.*).png/g))
for (const item of matches) {
const buffer = await this.#alphaCompositer.process(item, `${path.parse(item).name}[alpha].png`, extractedDir)
assetsJson[`./assets/${item}`] = BASE64_PNG_PREFIX + buffer.toString('base64')
}
assetsJson[`./assets/${skelFilename.replace('#', '%23')}`] = BASE64_BINARY_PREFIX + skel.toString('base64')
assetsJson[`./assets/${atlasFilename.replace('#', '%23')}`] = BASE64_BINARY_PREFIX + Buffer.from(atlas).toString('base64')
return {
dimensions,
assetsJson
}
}
}

64
libs/background.js Normal file
View File

@@ -0,0 +1,64 @@
/* eslint-disable no-undef */
import path from 'path';
import fs from 'fs';
import sharp from "sharp";
export default class Background {
#backgroundFolder
#extractFolder
#files
constructor() {
this.#backgroundFolder = path.join(__projectRoot, __config.folder.operator, __config.folder.share, __config.folder.background);
this.#extractFolder = path.join(this.#backgroundFolder, 'extracted');
}
async process() {
this.#files = fs.readdirSync(this.#extractFolder).filter((f) => {
return f.endsWith('.png') && f.includes('_left');
})
if (this.#files.length + 2 !== fs.readdirSync(this.#backgroundFolder).length) {
await Promise.all(this.#files.map(async (f) => {
const filenamePrefix = path.parse(f).name.replace('_left', '');
await this.#composite(filenamePrefix, '.png');
}))
} else {
console.log('Background images already exist, skip generation.')
}
}
async #composite(filenamePrefix, fileExt) {
const image = sharp(path.join(this.#extractFolder, `${filenamePrefix}_left${fileExt}`))
const metadata = await image.metadata()
image
.resize(2 * metadata.width, metadata.height, {
kernel: sharp.kernel.nearest,
fit: 'contain',
position: 'left top',
background: { r: 255, g: 255, b: 255, alpha: 0 }
})
.composite([
{
input: path.join(this.#extractFolder, `${filenamePrefix}_right${fileExt}`),
top: 0,
left: metadata.width,
},
])
.toFile(path.join(this.#backgroundFolder, `${filenamePrefix}${fileExt}`));
}
get files() {
return this.#files.map(f => f.replace('_left', ''))
}
getFilesToCopy(publicAssetsDir) {
return this.#files.map((f) => {
return {
filename: f.replace('_left', ''),
source: path.join(this.#backgroundFolder),
target: path.join(publicAssetsDir, __config.folder.background)
};
})
}
}

246
libs/charword_table.js Normal file
View File

@@ -0,0 +1,246 @@
/* eslint-disable no-undef */
import fetch from "node-fetch"
import path from "path"
import dotenv from "dotenv"
import { exists, writeSync, readdirSync, rm, readSync } from "./file.js"
dotenv.config()
// zh_TW uses an older version of charword_table.json
const REGIONS = ["zh_CN", "en_US", "ja_JP", "ko_KR", "zh_TW"]
const DEFAULT_REGION = REGIONS[0]
const NICKNAME = {
"zh_CN": "博士",
"en_US": "Doctor",
"ja_JP": "ドクター",
"ko_KR": "박사",
"zh_TW": "博士",
}
export function getOperatorId(operatorConfig) {
return operatorConfig.filename.replace(/^(dyn_illust_)(char_[\d]+)(_[\w]+)(|(_.+))$/g, '$2$3$4')
}
export default class CharwordTable {
#operatorIDs = Object.values(__config.operators).map(operator => { return getOperatorId(operator) })
#charwordTablePath = path.join(__projectRoot, __config.folder.operator, __config.folder.share)
#charwordTableFile = path.join(this.#charwordTablePath, 'charword_table.json')
#charwordTable = JSON.parse(readSync(this.#charwordTableFile)) || {
config: {
default_region: DEFAULT_REGION,
regions: REGIONS,
},
operators: {},
}
async process() {
const regionObject = REGIONS.reduce((acc, cur) => ({ ...acc, [cur]: {} }), {})
this.#operatorIDs.forEach(id => {
this.#charwordTable.operators[id] = {
alternativeId: id.replace(/^(char_)([\d]+)(_[\w]+)(|(_.+))$/g, '$1$2$3'),
voice: JSON.parse(JSON.stringify(regionObject)), // deep copy
info: JSON.parse(JSON.stringify(regionObject)), // deep copy
}
})
await this.#load(DEFAULT_REGION)
await Promise.all(REGIONS.slice(1).map(async (region) => {await this.#load(region)}))
writeSync(JSON.stringify(this.#charwordTable), this.#charwordTableFile)
}
lookup(operatorName) {
const operatorId = getOperatorId(__config.operators[operatorName])
const operatorBlock = this.#charwordTable.operators[operatorId]
return {
config: this.#charwordTable.config,
operator: operatorBlock.ref ? this.#charwordTable.operators[operatorBlock.alternativeId] : operatorBlock,
}
}
async #load(region) {
if (region === 'zh_TW') {
return await this.#zhTWLoad()
}
const data = await this.#download(region)
// put voice actor info into charword_table
for (const [id, element] of Object.entries(this.#charwordTable.operators)) {
let operatorId = id
let useAlternativeId = false
if (typeof data.voiceLangDict[operatorId] === 'undefined') {
operatorId = element.alternativeId
useAlternativeId = true
}
if (region === DEFAULT_REGION) {
element.infile = this.#operatorIDs.includes(operatorId);
element.ref = useAlternativeId && element.infile;
}
// not available in other region
if (typeof data.voiceLangDict[operatorId] === 'undefined') {
console.log(`Voice actor info of ${id} is not available in ${region}.`)
continue
}
if (element.infile && useAlternativeId) {
// if using alternative id and infile is true, means data can be
// refered inside the file
// if infile is false, useAlternativeId is always true
// if useAlternativeId is false, infile is always true
// | case | infile | useAlternativeId | Note |
// | ------------------- | ------ | ---------------- | --------------- |
// | lee_trust_your_eyes | false | true | skin only |
// | nearl_relight | true | true | skin, operator, no voice |
// | nearl | true | false | operator only |
// | w_fugue | true | false | skin, operator, voice |
continue
}
Object.values(data.voiceLangDict[operatorId].dict).forEach(item => {
if (typeof element.info[region][item.wordkey] === 'undefined') {
element.info[region][item.wordkey] = {}
}
element.info[region][item.wordkey][item.voiceLangType] = [...(typeof item.cvName === 'string' ? [item.cvName] : item.cvName)]
})
}
// put voice lines into charword_table
Object.values(data.charWords).forEach(item => {
const operatorInfo = Object.values(this.#charwordTable.operators).filter(element => element.info[region][item.wordKey])
if (operatorInfo.length > 0) {
if (typeof operatorInfo[0].voice[region][item.wordKey] === 'undefined') {
operatorInfo[0].voice[region][item.wordKey] = {}
}
operatorInfo[0].voice[region][item.wordKey][item.voiceId] = {
title: item.voiceTitle,
text: item.voiceText.replace(/{@nickname}/g, NICKNAME[region]),
}
}
})
}
async #download(region) {
const historyResponse = await fetch(`https://api.github.com/repos/Kengxxiao/ArknightsGameData/commits?path=${region}/gamedata/excel/charword_table.json`)
const historyData = await historyResponse.json()
const lastCommit = historyData[0]
const lastCommitDate = new Date(lastCommit.commit.committer.date)
const filepath = path.join(this.#charwordTablePath, `charword_table_${region}_${lastCommitDate.getTime()}.json`)
console.log(`Last commit date: ${lastCommitDate.getTime()}`)
if (exists(filepath)) {
console.log(`charword_table_${region}.json is the latest version.`)
return JSON.parse(readSync(filepath))
}
const response = await fetch(`https://raw.githubusercontent.com/Kengxxiao/ArknightsGameData/master/${region}/gamedata/excel/charword_table.json`)
const data = await response.json()
writeSync(JSON.stringify(data), filepath)
console.log(`charword_table_${region}.json is updated.`)
// remove old file
const files = readdirSync(path.join(__projectRoot, __config.folder.operator, __config.folder.share))
for (const file of files) {
if (file.startsWith(`charword_table_${region}`) && file !== path.basename(filepath)) {
rm(path.join(__projectRoot, __config.folder.operator, __config.folder.share, file))
}
}
return data
}
async #zhTWLoad() {
const region = 'zh_TW'
const downloaded = await this.#zhTWDownload()
const data = downloaded.data
const handbook = downloaded.handbook
// put voice actor info into charword_table
for (const [id, element] of Object.entries(this.#charwordTable.operators)) {
let operatorId = id
let useAlternativeId = false
if (typeof handbook.handbookDict[operatorId] === 'undefined') {
operatorId = element.alternativeId
useAlternativeId = true
}
// not available in other region
if (typeof handbook.handbookDict[operatorId] === 'undefined') {
console.log(`Voice actor info of ${id} is not available in ${region}.`)
continue
}
if (element.infile && useAlternativeId) {
continue
}
const charId = handbook.handbookDict[operatorId].charID
if (typeof element.info[region][charId] === 'undefined') {
element.info[region][charId] = {}
}
element.info[region][charId].JP = [...[handbook.handbookDict[operatorId].infoName]]
}
// put voice lines into charword_table
Object.values(data).forEach(item => {
const operatorInfo = Object.values(this.#charwordTable.operators).filter(element => element.info[region][item.wordKey])
if (operatorInfo.length > 0) {
if (typeof operatorInfo[0].voice[region][item.wordKey] === 'undefined') {
operatorInfo[0].voice[region][item.wordKey] = {}
}
operatorInfo[0].voice[region][item.wordKey][item.voiceId] = {
title: item.voiceTitle,
text: item.voiceText.replace(/{@nickname}/g, NICKNAME[region]),
}
}
})
}
async #zhTWDownload() {
const output = {}
const region = 'zh_TW'
const historyResponse = await fetch(`https://api.github.com/repos/Kengxxiao/ArknightsGameData/commits?path=${region}/gamedata/excel/charword_table.json`)
const handbookHistoryResponse = await fetch(`https://api.github.com/repos/Kengxxiao/ArknightsGameData/commits?path=${region}/gamedata/excel/handbook_info_table.json`)
const historyData = await historyResponse.json()
const handbookHistoryData = await handbookHistoryResponse.json()
const lastCommit = historyData[0]
const handboookLastCommit = handbookHistoryData[0]
const lastCommitDate = new Date(lastCommit.commit.committer.date)
const handbookLastCommitDate = new Date(handboookLastCommit.commit.committer.date)
const filepath = path.join(this.#charwordTablePath, `charword_table_${region}_${lastCommitDate.getTime()}.json`)
const handbookFilepath = path.join(this.#charwordTablePath, `handbook_info_table_${region}_${handbookLastCommitDate.getTime()}.json`)
console.log(`Last commit date: ${lastCommitDate.getTime()}`)
console.log(`Handbook last commit date: ${handbookLastCommitDate.getTime()}`)
if (exists(filepath)) {
console.log(`charword_table_${region}.json is the latest version.`)
output.data = JSON.parse(readSync(filepath))
} else {
const response = await fetch(`https://raw.githubusercontent.com/Kengxxiao/ArknightsGameData/master/${region}/gamedata/excel/charword_table.json`)
const data = await response.json()
writeSync(JSON.stringify(data), filepath)
console.log(`charword_table_${region}.json is updated.`)
// remove old file
const files = readdirSync(path.join(__projectRoot, __config.folder.operator, __config.folder.share))
for (const file of files) {
if (file.startsWith(`charword_table_${region}`) && file !== path.basename(filepath)) {
rm(path.join(__projectRoot, __config.folder.operator, __config.folder.share, file))
}
}
output.data = data
}
if (exists(handbookFilepath)) {
console.log(`handbook_info_table_${region}.json is the latest version.`)
output.handbook = JSON.parse(readSync(handbookFilepath))
} else {
const response = await fetch(`https://raw.githubusercontent.com/Kengxxiao/ArknightsGameData/master/${region}/gamedata/excel/handbook_info_table.json`)
const data = await response.json()
writeSync(JSON.stringify(data), handbookFilepath)
console.log(`handbook_info_table_${region}.json is updated.`)
// remove old file
const files = readdirSync(path.join(__projectRoot, __config.folder.operator, __config.folder.share))
for (const file of files) {
if (file.startsWith(`handbook_info_table_${region}`) && file !== path.basename(handbookFilepath)) {
rm(path.join(__projectRoot, __config.folder.operator, __config.folder.share, file))
}
}
output.handbook = data
}
return output
}
}

32
libs/config.js Normal file
View File

@@ -0,0 +1,32 @@
/* eslint-disable no-undef */
import path from 'path'
import { read } from './yaml.js'
import { read as readVersion } from './version.js'
import { getOperatorId } from './charword_table.js'
export default function () {
return process(read(path.join(__projectRoot, 'config.yaml')))
}
function process(config) {
for (const [operatorName, operator] of Object.entries(config.operators)) {
// add title
operator.title = `${config.share.title["en-US"]}${operator.codename["en-US"]} - ${config.share.title["zh-CN"]}${operator.codename["zh-CN"]}`
// add type
operator.type = operator.codename["zh-CN"].includes('·') ? 'skin' : 'operator'
// add link
operator.link = operatorName
// id
operator.id = getOperatorId(operator).replace(/^(char_)(\d+)(_.+)$/g, '$2')
}
// version
config.version = {
showcase: readVersion(path.join(__projectRoot)),
directory: readVersion(path.join(__projectRoot, 'directory')),
}
return config
}

68
libs/content_processor.js Normal file
View File

@@ -0,0 +1,68 @@
/* eslint-disable no-undef */
export default class Matcher {
#start
#end
#reExp
#config
#assets
constructor(start, end, config, assets) {
this.#start = start
this.#end = end
this.#reExp = new RegExp(`${start}.+?${end}`, 'g')
this.#config = config
this.#assets = assets
}
get result() {
const matches = this.content.match(this.#reExp)
if (matches !== null) {
matches.forEach((match) => {
const name = match.replace(this.#start, '').replace(this.#end, '')
const result = (new Function(
'Evalable',
'config',
'assets',
`return new Evalable(config, assets).${name}`)
)(Evalable, this.#config, this.#assets)
this.content = matches.length > 1 ? this.content.replace(match, result) : result
})
}
return this.content
}
}
class Evalable {
#config
#assets
constructor(config, assets) {
this.#config = config
this.#assets = assets
}
split(location, varName, separator) {
return this.#step(location, varName).split(separator)
}
var(location, varName) {
return this.#step(location, varName)
}
version(prefix, suffix) {
return `${prefix}${__config.version.showcase}${suffix}`
}
#step(location, varName) {
let content = this.#config
if (location === 'assets') content = this.#assets
varName.split("->").forEach((item) => {
try {
content = content[item]
} catch (e) {
throw new Error(`Cannot step ${varName}.`)
}
})
return content
}
}

99
libs/directory.js Normal file
View File

@@ -0,0 +1,99 @@
/* eslint-disable no-undef */
import path from 'path'
import { writeSync, copy, readSync as readFile } from './file.js'
import { read } from './yaml.js';
import AssetsProcessor from './assets_processor.js'
import EnvGenerator from './env_generator.js'
export default function ({ backgrounds, musicMapping }) {
const extractedFolder = path.join(__projectRoot, __config.folder.operator, '_directory')
const targetFolder = path.join(__projectRoot, __config.folder.release, __config.folder.directory);
const sourceFolder = path.join(__projectRoot, __config.folder.operator);
const filesToCopy = Object.keys(__config.operators)
const directoryJson = {
operators: Object.values(
Object.values(__config.operators)
.reduce((acc, cur) => {
const date = cur.date
if (acc[date]) {
acc[date].push(cur)
} else {
acc[date] = [cur]
}
cur.workshopId = null
try {
cur.workshopId = JSON.parse(readFile(path.join(__projectRoot, __config.folder.operator, cur.link, 'project.json'))).workshopid
} catch (e) {
console.log(`No workshop id for ${cur.link}!`, e)
}
return acc
}, {}))
.sort((a, b) => Date.parse(b[0].date) - Date.parse(a[0].date)),
}
const versionJson = __config.version
const changelogs = read(path.join(__projectRoot, 'changelogs.yaml'))
const changelogsArray = Object.keys(changelogs).reduce((acc, cur) => {
const array = []
Object.keys(changelogs[cur]).map((item) => {
array.push({
key: cur,
date: item,
content: [...changelogs[cur][item]]
})
})
acc.push(array)
return acc
}, [])
__config.directory.error.files.forEach((key) => {
const assetsProcessor = new AssetsProcessor()
assetsProcessor.generateAssets(key.key, extractedFolder).then((content) => {
writeSync(JSON.stringify(content.assetsJson, null), path.join(targetFolder, `${key.key}.json`))
})
})
writeSync((new EnvGenerator()).generate([
{
key: "app_title",
value: __config.directory.title
}, {
key: "app_voice_url",
value: __config.directory.voice
}, {
key: "voice_folders",
value: JSON.stringify(__config.folder.voice)
}, {
key: "directory_folder",
value: JSON.stringify(__config.folder.directory)
}
, {
key: "background_folder",
value: JSON.stringify(__config.folder.background)
}, {
key: "available_operators",
value: JSON.stringify(Object.keys(__config.operators))
}, {
key: "error_files",
value: JSON.stringify(__config.directory.error).replace('#', '%23')
}, {
key: "music_folder",
value: __config.folder.music
}, {
key: "music_mapping",
value: JSON.stringify(musicMapping)
}
]), path.join(__projectRoot, 'directory', '.env'))
writeSync(JSON.stringify(directoryJson, null), path.join(targetFolder, "directory.json"))
writeSync(JSON.stringify(versionJson, null), path.join(targetFolder, "version.json"))
writeSync(JSON.stringify(changelogsArray, null), path.join(targetFolder, "changelogs.json"))
writeSync(JSON.stringify(backgrounds, null), path.join(targetFolder, "backgrounds.json"))
filesToCopy.forEach((key) => {
copy(path.join(sourceFolder, key, 'assets.json'), path.join(targetFolder, `${__config.operators[key].filename}.json`))
copy(path.join(sourceFolder, key, 'charword_table.json'), path.join(targetFolder, `voice_${key}.json`))
})
copy(path.join(extractedFolder, __config.directory.error.voice), path.join(targetFolder, `error.ogg`))
}

7
libs/env_generator.js Normal file
View File

@@ -0,0 +1,7 @@
export default class EnvGenerator {
generate(values) {
return values.map((value) => {
return `VITE_${value.key.toUpperCase()}=${value.value}`
}).join('\n')
}
}

71
libs/file.js Normal file
View File

@@ -0,0 +1,71 @@
import fs, { promises as fsP } from 'fs'
import path from 'path'
export async function write(content, filePath) {
mkdir(path.dirname(filePath))
return await fsP.writeFile(filePath, content, { flag: 'w' })
}
export function writeSync(content, filePath) {
mkdir(path.dirname(filePath))
return fs.writeFileSync(filePath, content, { flag: 'w' })
}
export async function read(filePath, encoding = 'utf8') {
return await fsP.readFile(filePath, encoding, { flag: 'r' })
}
export function readSync(filePath, encoding = 'utf8') {
if (exists(filePath)) {
return fs.readFileSync(filePath, encoding, { flag: 'r' })
}
return null
}
export function exists(filePath) {
return fs.existsSync(filePath)
}
export function rmdir(dir) {
if (exists(dir)) {
fs.rmSync(dir, { recursive: true })
}
}
export function rm(file) {
if (exists(file)) {
fs.rmSync(file)
}
}
export function mkdir(dir) {
if (!exists(dir)) {
fs.mkdirSync(dir, { recursive: true })
}
}
export async function copy(sourcePath, targetPath) {
if (!exists(sourcePath)) {
console.warn(`Source file ${sourcePath} does not exist.`)
return
}
mkdir(path.dirname(targetPath))
return await fsP.copyFile(sourcePath, targetPath)
}
export async function copyDir(sourcePath, targetPath) {
if (!exists(sourcePath)) {
console.warn(`Source file ${sourcePath} does not exist.`)
return
}
mkdir(targetPath)
return await fsP.cp(sourcePath, targetPath, { recursive: true })
}
export function appendSync(content, filePath) {
return fs.appendFileSync(filePath, content, 'utf8');
}
export function readdirSync(dir) {
return fs.readdirSync(dir)
}

18
libs/initializer.js Normal file
View File

@@ -0,0 +1,18 @@
/* eslint-disable no-undef */
import path from 'path'
import { stringify } from 'yaml'
import { read as readYAML } from './yaml.js'
import { mkdir, writeSync } from './file.js'
import { appendMainConfig } from './append.js'
export default function init(operatorName, extractedDir) {
extractedDir.forEach((dir) => {
mkdir(dir)
})
const date = new Date()
const template = readYAML(path.join(__projectRoot, 'config', '_template.yaml'))
template.link = operatorName
template.date = `${date.getFullYear()}/${(date.getMonth() + 1).toString().padStart(2, '0') }`
writeSync(stringify(template), path.join(__projectRoot, 'config', `${operatorName}.yaml`))
appendMainConfig(operatorName)
}

19
libs/music.js Normal file
View File

@@ -0,0 +1,19 @@
/* eslint-disable no-undef */
import path from 'path';
import { read } from './yaml.js';
export default function () {
const musicFolder = path.join(__projectRoot, __config.folder.operator, __config.folder.share, __config.folder.music);
const musicMapping = read(path.join(musicFolder, 'mapping.yaml'));
const musicToCopy = Object.values(musicMapping).map(entry => Object.values(entry)).flat(1).filter(entry => entry !== null).map(entry => {
return {
filename: entry,
source: musicFolder,
}
})
return {
musicToCopy,
musicMapping,
}
}

90
libs/project_json.js Normal file
View File

@@ -0,0 +1,90 @@
/* eslint-disable no-undef */
import path from 'path'
import Matcher from './content_processor.js'
import { read as readFile, exists } from './file.js'
import { read as readYAML } from './yaml.js'
export default class ProjectJson {
#json
#operatorName
#operatorSourceFolder
#operatorShareFolder
#assets
#template
constructor(operatorName, operatorShareFolder, assets) {
this.#operatorName = operatorName
this.#operatorSourceFolder = path.join(__projectRoot, __config.folder.operator)
this.#operatorShareFolder = operatorShareFolder
this.#assets = assets
}
async load() {
// load json from file
this.#json = JSON.parse(await readFile(this.#getPath()))
const matcher = new Matcher('~{', '}', __config.operators[this.#operatorName], {
...this.#assets,
...(() => {
const output = {}
for (const [key, value] of Object.entries(this.#assets)) {
output[`${key}Options`] = value.map((b) => {
return {
"label": b,
"value": b
}
})
}
return output
})()
})
const match = {
identify: value => value.startsWith('!match'),
tag: '!match',
resolve(str) {
matcher.content = str
return matcher.result
}
}
this.#template = readYAML(path.join(__projectRoot, 'config', '_project_json.yaml'), [match])
this.#process()
return this.#json
}
#getPath() {
// if exists, do not use the template
const defaultPath = path.join(this.#operatorSourceFolder, this.#operatorName, 'project.json')
if (exists(defaultPath)) {
return defaultPath
} else {
return path.join(this.#operatorShareFolder, 'project.json')
}
}
#process() {
this.#json = {
...this.#json,
description: this.#template.description,
title: __config.operators[this.#operatorName].title,
general: {
...this.#json.general,
localization: this.#template.localization,
properties: {
...this.#properties
}
},
}
}
get #properties() {
const properties = this.#template.properties
const output = {}
for (let i = 0; i < properties.length; i++) {
output[properties[i].key] = {
index: i,
order: 100 + i,
...properties[i].value
}
}
return output
}
}

15
libs/version.js Normal file
View File

@@ -0,0 +1,15 @@
import path from 'path'
import { readSync, writeSync } from './file.js'
export function read (dir) {
return readSync(path.join(dir, 'Version'))
}
export function increase(dir) {
// release version will be lagged by 0.0.1
const version = read(dir)
const [major, minor, patch] = version.split('.')
const newVersion = `${major}.${minor}.${+patch + 1}`
writeSync(newVersion, path.join(dir, 'Version'))
return newVersion
}

19
libs/yaml.js Normal file
View File

@@ -0,0 +1,19 @@
import path from 'path'
import { parse } from 'yaml'
import fs from 'fs'
export function read(file_dir, customTags = []) {
const include = {
identify: value => value.startsWith('!include'),
tag: '!include',
resolve(str) {
const dir = path.resolve(path.dirname(file_dir), str)
const data = read(dir)
return data
}
}
const file = fs.readFileSync(file_dir, 'utf8')
return parse(file, {
customTags: [include, ...customTags],
})
}

55
package.json Normal file
View File

@@ -0,0 +1,55 @@
{
"name": "showcase",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"generate": "node aklive2d generate",
"dev": "node aklive2d dev",
"build": "node aklive2d build",
"build-all": "node aklive2d build-all",
"preview": "node aklive2d preview",
"init": "node aklive2d init",
"readme": "node aklive2d readme",
"directory": "node aklive2d directory",
"charword": "node aklive2d charword",
"vite:dev": "vite",
"vite:build": "vite build",
"vite:preview": "vite preview",
"vite:directory:dev": "vite dev",
"vite:directory:build": "vite build",
"vite:directory:preview": "vite preview"
},
"devDependencies": {
"@perfsee/rollup": "^1.3.0",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@vitejs/plugin-react-swc": "^3.2.0",
"autoprefixer": "^10.4.14",
"eslint": "^8.35.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"postcss": "^8.4.21",
"prop-types": "^15.8.1",
"rollup": "^3.17.3",
"sass": "^1.59.2",
"stylelint": "^15.2.0",
"stylelint-config-standard": "^30.0.1",
"stylelint-config-standard-scss": "^7.0.1",
"vite": "^4.1.4"
},
"dependencies": {
"@parcellab/react-use-umami": "^2.0.1",
"dotenv": "^16.0.3",
"jotai": "^2.0.2",
"node-fetch": "^3.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-refresh": "^0.14.0",
"react-router-dom": "^6.8.1",
"react-simple-typewriter": "^5.0.1",
"reset-css": "^5.0.1",
"sharp": "^0.31.3",
"yaml": "^2.2.1"
}
}

3424
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More