Public commit
4
.env.example
Normal file
@ -0,0 +1,4 @@
|
||||
CROWDIN_PERSONAL_TOKEN="TOKEN"
|
||||
NEXT_PUBLIC_NAME="Extension"
|
||||
NEXT_PUBLIC_SUPABASE_URL="https://mysupabase.supabase.co"
|
||||
NEXT_PUBLIC_SUPABASE_KEY="TOKEN"
|
11
.eslintrc.js
Normal file
@ -0,0 +1,11 @@
|
||||
const { extendConfig } = require("@aet/eslint-rules")
|
||||
|
||||
module.exports = extendConfig({
|
||||
plugins: ["react", "react-hooks"],
|
||||
rules: {
|
||||
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
|
||||
"@typescript-eslint/no-unsafe-argument": "off",
|
||||
"@typescript-eslint/no-unsafe-assignment": "off",
|
||||
"@typescript-eslint/no-unsafe-member-access": "off",
|
||||
},
|
||||
})
|
47
.github/workflows/builds.yml
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
name: Nightly Build
|
||||
|
||||
on:
|
||||
workflow_dispatch
|
||||
# schedule:
|
||||
# - cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node.js 14.x
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "14.x"
|
||||
cache: "pnpm"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Build
|
||||
run: pnpm run build
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ strftime('%Y-%m-%d-%H-%M-%S', localtime()) }}
|
||||
release_name: Nightly Build ${{ github.sha }}
|
||||
body: Nightly build
|
||||
draft: false
|
||||
prerelease: true
|
||||
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./dist
|
||||
asset_name: Nightly Build ${{ github.sha }}.zip
|
||||
asset_content_type: application/zip
|
149
.gitignore
vendored
Normal file
@ -0,0 +1,149 @@
|
||||
src/generated
|
||||
eslint-local-rules/index.js
|
||||
gecko.zip
|
||||
repl.ts
|
||||
.jest
|
||||
/drafts
|
||||
/.1*.**.*
|
||||
src/context/temp
|
||||
shims
|
||||
*.generated
|
||||
*.generated.*
|
||||
*.module.css.d.ts
|
||||
dist/*.html
|
||||
dist/app
|
||||
dist/vendor
|
||||
dist/_locales/*
|
||||
!dist/_locales/en_US
|
||||
dist/assets/licenses.json
|
||||
src/bundle-analyzer
|
||||
|
||||
# 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
|
||||
|
||||
# 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.*
|
3
.npmrc
Normal file
@ -0,0 +1,3 @@
|
||||
public-hoist-pattern[] = *eslint*
|
||||
public-hoist-pattern[] = *prettier*
|
||||
public-hoist-pattern[] = *immutable*
|
3
.vscode/commands.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"commands": []
|
||||
}
|
12
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"editor.formatOnSave": true,
|
||||
"typescript.inlayHints.parameterNames.enabled": "none",
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["dist/manifest.json"],
|
||||
"url": "https://json.schemastore.org/chrome-manifest.json"
|
||||
}
|
||||
],
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"cSpell.words": ["hookz", "submatch", "submatches"]
|
||||
}
|
674
LICENSE
Normal 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>.
|
58
Makefile
Normal file
@ -0,0 +1,58 @@
|
||||
# This file is generated by `make Makefile`
|
||||
Makefile: scripts/build-makefile.ts
|
||||
@echo "✨ Building Makefile..."
|
||||
@scripts/build-makefile.ts
|
||||
|
||||
makefile: Makefile
|
||||
|
||||
src/shared/theme/tokens.generated.ts src/shared/theme/tokens.generated.css: src/shared/theme/tokens.tsx \
|
||||
scripts/build-theme.tsx
|
||||
@echo "✨ Building theme..."
|
||||
@scripts/build-theme.tsx -o $(@D)
|
||||
|
||||
theme: src/shared/theme/tokens.generated.ts
|
||||
|
||||
src/shared/models/enums.generated.ts src/shared/models/models.generated.ts: src/shared/models/models.yml \
|
||||
./scripts/build-models.ts
|
||||
@echo "✨ Building models..."
|
||||
@./scripts/build-models.ts
|
||||
|
||||
models: src/shared/models/enums.generated.ts
|
||||
|
||||
src/vendor/webextension-polyfill/api-metadata.generated.json: src/vendor/webextension-polyfill/LICENSE \
|
||||
src/vendor/webextension-polyfill/README.md \
|
||||
src/vendor/webextension-polyfill/api-metadata.json \
|
||||
src/vendor/webextension-polyfill/package.json \
|
||||
src/vendor/webextension-polyfill/scripts/compress.ts \
|
||||
src/vendor/webextension-polyfill/src/browser-polyfill.js
|
||||
@echo "✨ Building WebExtensionPolyfill..."
|
||||
@./src/vendor/webextension-polyfill/scripts/compress.ts
|
||||
|
||||
web-extension-polyfill: src/vendor/webextension-polyfill/api-metadata.generated.json
|
||||
|
||||
dist/background.html dist/devtools.html dist/options.html dist/playground.html dist/popup.html dist/reference-bundled.html dist/reference.html: scripts/build-htmls.tsx
|
||||
@echo "✨ Building HTML..."
|
||||
@scripts/build-htmls.tsx
|
||||
|
||||
html: dist/background.html
|
||||
|
||||
dist/_locales/de_DE/messages.json dist/_locales/en_US/messages.json dist/_locales/es_ES/messages.json dist/_locales/fr_CA/messages.json dist/_locales/fr_FR/messages.json dist/_locales/ja_JP/messages.json dist/_locales/ko_KR/messages.json dist/_locales/zh_CN/messages.json dist/_locales/zh_TW/messages.json src/shared/i18n/data.generated.ts: scripts/build-locales.ts
|
||||
@echo "✨ Building locales..."
|
||||
@scripts/build-locales.ts
|
||||
|
||||
locales: dist/_locales/de_DE/messages.json
|
||||
|
||||
dist/vendor/sass/index.js: package.json \
|
||||
./scripts/build-sass.ts
|
||||
@echo "✨ Building sass..."
|
||||
@./scripts/build-sass.ts
|
||||
|
||||
sass: dist/vendor/sass/index.js
|
||||
|
||||
all: makefile \
|
||||
theme \
|
||||
models \
|
||||
web-extension-polyfill \
|
||||
html \
|
||||
locales \
|
||||
sass
|
15
README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# stylebot
|
||||
|
||||
A userstyle manager extension.
|
||||
|
||||
## Screenshot
|
||||
|
||||
<img src="./assets/demo.png" width="700" />
|
||||
|
||||
## Development
|
||||
|
||||
```sh
|
||||
pnpm install
|
||||
make all
|
||||
pnpm run dev
|
||||
```
|
BIN
assets/demo.png
Normal file
After Width: | Height: | Size: 346 KiB |
16
babel.config.js
Normal file
@ -0,0 +1,16 @@
|
||||
/** @type {import('@babel/core').ConfigFunction} */
|
||||
module.exports = api => {
|
||||
if (!api.env("test")) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
presets: [],
|
||||
plugins: [
|
||||
["@babel/plugin-transform-typescript", { allowDeclareFields: true }],
|
||||
["@babel/plugin-proposal-decorators", { version: "legacy" }],
|
||||
"@babel/plugin-transform-modules-commonjs",
|
||||
"babel-plugin-macros",
|
||||
],
|
||||
};
|
||||
};
|
11
crowdin.yml
Normal file
@ -0,0 +1,11 @@
|
||||
project_id: "566071"
|
||||
api_token_env: CROWDIN_PERSONAL_TOKEN
|
||||
base_path: .
|
||||
base_url: https://api.crowdin.com
|
||||
preserve_hierarchy: true
|
||||
files:
|
||||
- source: /src/shared/i18n/resources/en-US/*.json
|
||||
translation: /src/shared/i18n/resources/%locale%/%original_file_name%
|
||||
|
||||
- source: /dist/_locales/en_US/messages.json
|
||||
translation: /dist/_locales/%locale_with_underscore%/%original_file_name%
|
11
dist/_locales/en_US/messages.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"extName": {
|
||||
"message": "Paletterie"
|
||||
},
|
||||
"description": {
|
||||
"message": "User style manager"
|
||||
},
|
||||
"untitled": {
|
||||
"message": "Untitled"
|
||||
}
|
||||
}
|
BIN
dist/assets/fonts/inter/Inter-Black.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Black.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-BlackItalic.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-BlackItalic.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Bold.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Bold.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-BoldItalic.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-BoldItalic.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-ExtraBold.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-ExtraBold.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-ExtraBoldItalic.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-ExtraBoldItalic.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-ExtraLight.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-ExtraLight.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-ExtraLightItalic.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-ExtraLightItalic.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Italic.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Italic.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Light.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Light.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-LightItalic.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-LightItalic.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Medium.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Medium.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-MediumItalic.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-MediumItalic.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Regular.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Regular.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-SemiBold.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-SemiBold.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-SemiBoldItalic.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-SemiBoldItalic.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Thin.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-Thin.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-ThinItalic.woff
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-ThinItalic.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-italic.var.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter-roman.var.woff2
vendored
Normal file
BIN
dist/assets/fonts/inter/Inter.var.woff2
vendored
Normal file
94
dist/assets/fonts/inter/LICENSE.txt
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
Copyright (c) 2016-2020 The Inter Project Authors.
|
||||
"Inter" is trademark of Rasmus Andersson.
|
||||
https://github.com/rsms/inter
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
http://scripts.sil.org/OFL
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION AND CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
199
dist/assets/fonts/inter/inter.css
vendored
Normal file
@ -0,0 +1,199 @@
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 100;
|
||||
font-display: swap;
|
||||
src: url("Inter-Thin.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-Thin.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 100;
|
||||
font-display: swap;
|
||||
src: url("Inter-ThinItalic.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-ThinItalic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 200;
|
||||
font-display: swap;
|
||||
src: url("Inter-ExtraLight.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-ExtraLight.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 200;
|
||||
font-display: swap;
|
||||
src: url("Inter-ExtraLightItalic.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-ExtraLightItalic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 300;
|
||||
font-display: swap;
|
||||
src: url("Inter-Light.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-Light.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 300;
|
||||
font-display: swap;
|
||||
src: url("Inter-LightItalic.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-LightItalic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("Inter-Regular.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-Regular.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
font-display: swap;
|
||||
src: url("Inter-Italic.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-Italic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("Inter-Medium.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-Medium.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 500;
|
||||
font-display: swap;
|
||||
src: url("Inter-MediumItalic.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-MediumItalic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
src: url("Inter-SemiBold.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-SemiBold.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 600;
|
||||
font-display: swap;
|
||||
src: url("Inter-SemiBoldItalic.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-SemiBoldItalic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
src: url("Inter-Bold.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-Bold.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
font-display: swap;
|
||||
src: url("Inter-BoldItalic.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-BoldItalic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 800;
|
||||
font-display: swap;
|
||||
src: url("Inter-ExtraBold.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-ExtraBold.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 800;
|
||||
font-display: swap;
|
||||
src: url("Inter-ExtraBoldItalic.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-ExtraBoldItalic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: normal;
|
||||
font-weight: 900;
|
||||
font-display: swap;
|
||||
src: url("Inter-Black.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-Black.woff?v=3.19") format("woff");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inter";
|
||||
font-style: italic;
|
||||
font-weight: 900;
|
||||
font-display: swap;
|
||||
src: url("Inter-BlackItalic.woff2?v=3.19") format("woff2"),
|
||||
url("Inter-BlackItalic.woff?v=3.19") format("woff");
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------
|
||||
Variable font.
|
||||
Usage:
|
||||
|
||||
html { font-family: 'Inter', sans-serif; }
|
||||
@supports (font-variation-settings: normal) {
|
||||
html { font-family: 'Inter var', sans-serif; }
|
||||
}
|
||||
*/
|
||||
@font-face {
|
||||
font-family: "Inter var";
|
||||
font-weight: 100 900;
|
||||
font-display: swap;
|
||||
font-style: normal;
|
||||
font-named-instance: "Regular";
|
||||
src: url("Inter-roman.var.woff2?v=3.19") format("woff2");
|
||||
}
|
||||
@font-face {
|
||||
font-family: "Inter var";
|
||||
font-weight: 100 900;
|
||||
font-display: swap;
|
||||
font-style: italic;
|
||||
font-named-instance: "Italic";
|
||||
src: url("Inter-italic.var.woff2?v=3.19") format("woff2");
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
[EXPERIMENTAL] Multi-axis, single variable font.
|
||||
|
||||
Slant axis is not yet widely supported (as of February 2019) and thus this
|
||||
multi-axis single variable font is opt-in rather than the default.
|
||||
|
||||
When using this, you will probably need to set font-variation-settings
|
||||
explicitly, e.g.
|
||||
|
||||
* { font-variation-settings: "slnt" 0deg }
|
||||
.italic { font-variation-settings: "slnt" 10deg }
|
||||
|
||||
*/
|
||||
@font-face {
|
||||
font-family: "Inter var experimental";
|
||||
font-weight: 100 900;
|
||||
font-display: swap;
|
||||
font-style: oblique 0deg 10deg;
|
||||
src: url("Inter.var.woff2?v=3.19") format("woff2");
|
||||
}
|
BIN
dist/assets/images/128.png
vendored
Executable file
After Width: | Height: | Size: 6.5 KiB |
BIN
dist/assets/images/128w.png
vendored
Executable file
After Width: | Height: | Size: 6.1 KiB |
BIN
dist/assets/images/16.png
vendored
Executable file
After Width: | Height: | Size: 706 B |
BIN
dist/assets/images/16w.png
vendored
Executable file
After Width: | Height: | Size: 663 B |
BIN
dist/assets/images/19.png
vendored
Executable file
After Width: | Height: | Size: 931 B |
BIN
dist/assets/images/19w.png
vendored
Executable file
After Width: | Height: | Size: 869 B |
BIN
dist/assets/images/256.png
vendored
Executable file
After Width: | Height: | Size: 14 KiB |
BIN
dist/assets/images/256w.png
vendored
Executable file
After Width: | Height: | Size: 13 KiB |
BIN
dist/assets/images/32.png
vendored
Executable file
After Width: | Height: | Size: 1.5 KiB |
BIN
dist/assets/images/32w.png
vendored
Executable file
After Width: | Height: | Size: 1.4 KiB |
BIN
dist/assets/images/38.png
vendored
Executable file
After Width: | Height: | Size: 1.9 KiB |
BIN
dist/assets/images/38w.png
vendored
Executable file
After Width: | Height: | Size: 1.7 KiB |
BIN
dist/assets/images/48.png
vendored
Executable file
After Width: | Height: | Size: 2.3 KiB |
BIN
dist/assets/images/48w.png
vendored
Executable file
After Width: | Height: | Size: 2.2 KiB |
BIN
dist/assets/images/64.png
vendored
Executable file
After Width: | Height: | Size: 3.2 KiB |
BIN
dist/assets/images/64w.png
vendored
Executable file
After Width: | Height: | Size: 3.0 KiB |
56
dist/manifest.json
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"name": "__MSG_extName__",
|
||||
"version": "19.11.6",
|
||||
"description": "__MSG_description__",
|
||||
"manifest_version": 2,
|
||||
"default_locale": "en_US",
|
||||
"icons": {
|
||||
"64": "assets/images/64.png",
|
||||
"128": "assets/images/128.png",
|
||||
"256": "assets/images/256.png"
|
||||
},
|
||||
"permissions": [
|
||||
"tabs",
|
||||
"downloads",
|
||||
"webNavigation",
|
||||
"storage",
|
||||
"http://*/",
|
||||
"https://*/",
|
||||
"chrome://favicon/"
|
||||
],
|
||||
"content_security_policy": "script-src 'unsafe-inline' 'self' http://localhost:8097/; object-src 'self'",
|
||||
"minimum_chrome_version": "90.0",
|
||||
"background": {
|
||||
"page": "background.html",
|
||||
"persistent": true
|
||||
},
|
||||
"devtools_page": "devtools.html",
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["<all_urls>"],
|
||||
"run_at": "document_start",
|
||||
"all_frames": true,
|
||||
"js": ["app/context/index.js"]
|
||||
},
|
||||
{
|
||||
"matches": ["http://userstyles.org/*", "https://userstyles.org/*"],
|
||||
"run_at": "document_end",
|
||||
"all_frames": false,
|
||||
"js": ["app/install/index.js"]
|
||||
}
|
||||
],
|
||||
"options_ui": {
|
||||
"page": "options.html",
|
||||
"open_in_tab": true
|
||||
},
|
||||
"browser_action": {
|
||||
"default_icon": {
|
||||
"16": "assets/images/16w.png",
|
||||
"19": "assets/images/19w.png",
|
||||
"32": "assets/images/32w.png",
|
||||
"38": "assets/images/38w.png"
|
||||
},
|
||||
"default_title": "__MSG_extName__",
|
||||
"default_popup": "popup.html"
|
||||
}
|
||||
}
|
62
eslint-local-rules/no-deep-relative-import.ts
Normal file
@ -0,0 +1,62 @@
|
||||
import type { Rule } from "eslint"
|
||||
|
||||
interface RuleOptions {
|
||||
/**
|
||||
* The maximum number of times a relative path import can go to the parent directory.
|
||||
*/
|
||||
maxDepth?: number
|
||||
}
|
||||
|
||||
const rule: Rule.RuleModule = {
|
||||
meta: {
|
||||
type: "suggestion",
|
||||
docs: {
|
||||
description:
|
||||
"Bans relative path imports that go to the parent directory too many times",
|
||||
category: "Best Practices",
|
||||
recommended: true,
|
||||
},
|
||||
fixable: "code",
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
maxDepth: {
|
||||
type: "integer",
|
||||
minimum: 1,
|
||||
},
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
create(context) {
|
||||
const { maxDepth = 3 } = (context.options[0] || {}) as RuleOptions
|
||||
const errorMessage = `Relative path imports cannot go to the parent directory more than ${maxDepth} levels`
|
||||
|
||||
return {
|
||||
ImportDeclaration(node) {
|
||||
const { source } = node
|
||||
if (
|
||||
source.type === "Literal" &&
|
||||
typeof source.value === "string" &&
|
||||
source.value.startsWith("..")
|
||||
) {
|
||||
const depth = source.value.match(/\.\.\//g)?.length ?? 0
|
||||
if (depth > maxDepth) {
|
||||
context.report({
|
||||
node: source,
|
||||
message: errorMessage,
|
||||
fix(fixer) {
|
||||
const newValue = (source.value as string)!.replace(/\.\.\//g, "")
|
||||
return fixer.replaceText(source, `'${newValue}'`)
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default rule
|
212
jest.config.ts
Normal file
@ -0,0 +1,212 @@
|
||||
import type { Config } from "@jest/types";
|
||||
/*
|
||||
* For a detailed explanation regarding each configuration property and type check, visit:
|
||||
* https://jestjs.io/docs/configuration
|
||||
*/
|
||||
|
||||
const config: Partial<Config.InitialOptions> & {
|
||||
[key: string]: any;
|
||||
} = {
|
||||
// All imported modules in your tests should be mocked automatically
|
||||
// automock: false,
|
||||
|
||||
// Stop running tests after `n` failures
|
||||
// bail: 0,
|
||||
|
||||
// The directory where Jest should store its cached dependency information
|
||||
// cacheDirectory: "/private/var/folders/cz/tgksgqzx1vsg96sc_zk1sql00000gn/T/jest_dx",
|
||||
|
||||
// Automatically clear mock calls, instances, contexts and results before every test
|
||||
clearMocks: true,
|
||||
|
||||
// Indicates whether the coverage information should be collected while executing the test
|
||||
collectCoverage: true,
|
||||
|
||||
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
||||
// collectCoverageFrom: undefined,
|
||||
|
||||
// The directory where Jest should output its coverage files
|
||||
coverageDirectory: ".jest/coverage",
|
||||
|
||||
// An array of regexp pattern strings used to skip coverage collection
|
||||
// coveragePathIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// Indicates which provider should be used to instrument code for coverage
|
||||
coverageProvider: "v8",
|
||||
|
||||
// A list of reporter names that Jest uses when writing coverage reports
|
||||
// coverageReporters: [
|
||||
// "json",
|
||||
// "text",
|
||||
// "lcov",
|
||||
// "clover"
|
||||
// ],
|
||||
|
||||
// An object that configures minimum threshold enforcement for coverage results
|
||||
// coverageThreshold: undefined,
|
||||
|
||||
// A path to a custom dependency extractor
|
||||
// dependencyExtractor: undefined,
|
||||
|
||||
// Make calling deprecated APIs throw helpful error messages
|
||||
// errorOnDeprecated: false,
|
||||
|
||||
// The default configuration for fake timers
|
||||
// fakeTimers: {
|
||||
// "enableGlobally": false
|
||||
// },
|
||||
|
||||
// Force coverage collection from ignored files using an array of glob patterns
|
||||
// forceCoverageMatch: [],
|
||||
|
||||
// A path to a module which exports an async function that is triggered once before all test suites
|
||||
// globalSetup: undefined,
|
||||
|
||||
// A path to a module which exports an async function that is triggered once after all test suites
|
||||
// globalTeardown: undefined,
|
||||
|
||||
// A set of global variables that need to be available in all test environments
|
||||
// globals: {},
|
||||
|
||||
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
||||
// maxWorkers: "50%",
|
||||
|
||||
// An array of directory names to be searched recursively up from the requiring module's location
|
||||
// moduleDirectories: [
|
||||
// "node_modules"
|
||||
// ],
|
||||
|
||||
// An array of file extensions your modules use
|
||||
// moduleFileExtensions: [
|
||||
// "js",
|
||||
// "mjs",
|
||||
// "cjs",
|
||||
// "jsx",
|
||||
// "ts",
|
||||
// "tsx",
|
||||
// "json",
|
||||
// "node"
|
||||
// ],
|
||||
|
||||
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
||||
moduleNameMapper: {
|
||||
"^~/(.*)$": "<rootDir>/src/$1",
|
||||
},
|
||||
|
||||
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
||||
// modulePathIgnorePatterns: [],
|
||||
|
||||
// Activates notifications for test results
|
||||
// notify: false,
|
||||
|
||||
// An enum that specifies notification mode. Requires { notify: true }
|
||||
// notifyMode: "failure-change",
|
||||
|
||||
// A preset that is used as a base for Jest's configuration
|
||||
// preset: undefined,
|
||||
|
||||
// Run tests from one or more projects
|
||||
// projects: undefined,
|
||||
|
||||
// Use this configuration option to add custom reporters to Jest
|
||||
reporters: [
|
||||
"default",
|
||||
[
|
||||
"jest-html-reporters",
|
||||
{
|
||||
publicPath: ".jest/reports",
|
||||
filename: "index.html",
|
||||
darkTheme: true,
|
||||
},
|
||||
],
|
||||
],
|
||||
|
||||
// Automatically reset mock state before every test
|
||||
// resetMocks: false,
|
||||
|
||||
// Reset the module registry before running each individual test
|
||||
// resetModules: false,
|
||||
|
||||
// A path to a custom resolver
|
||||
// resolver: undefined,
|
||||
|
||||
// Automatically restore mock state and implementation before every test
|
||||
// restoreMocks: false,
|
||||
|
||||
// The root directory that Jest should scan for tests and modules within
|
||||
// rootDir: undefined,
|
||||
|
||||
// A list of paths to directories that Jest should use to search for files in
|
||||
// roots: [
|
||||
// "<rootDir>"
|
||||
// ],
|
||||
|
||||
// Allows you to use a custom runner instead of Jest's default test runner
|
||||
// runner: "jest-runner",
|
||||
|
||||
// The paths to modules that run some code to configure or set up the testing environment before each test
|
||||
// setupFiles: [],
|
||||
|
||||
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
||||
setupFilesAfterEnv: ["./src/setupTest.ts"],
|
||||
|
||||
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
||||
// slowTestThreshold: 5,
|
||||
|
||||
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
||||
// snapshotSerializers: [],
|
||||
|
||||
// The test environment that will be used for testing
|
||||
testEnvironment: "node",
|
||||
|
||||
// Options that will be passed to the testEnvironment
|
||||
// testEnvironmentOptions: {},
|
||||
|
||||
// Adds a location field to test results
|
||||
// testLocationInResults: false,
|
||||
|
||||
// The glob patterns Jest uses to detect test files
|
||||
// testMatch: [
|
||||
// "**/__tests__/**/*.[jt]s?(x)",
|
||||
// "**/?(*.)+(spec|test).[tj]s?(x)"
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
||||
// testPathIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// The regexp pattern or array of patterns that Jest uses to detect test files
|
||||
// testRegex: [],
|
||||
|
||||
// This option allows the use of a custom results processor
|
||||
// testResultsProcessor: undefined,
|
||||
|
||||
// This option allows use of a custom test runner
|
||||
// testRunner: "jest-circus/runner",
|
||||
|
||||
// A map from regular expressions to paths to transformers
|
||||
// transform: undefined,
|
||||
|
||||
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
||||
// transformIgnorePatterns: [
|
||||
// "/node_modules/",
|
||||
// "\\.pnp\\.[^\\/]+$"
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
||||
// unmockedModulePathPatterns: undefined,
|
||||
|
||||
// Indicates whether each individual test should be reported during the run
|
||||
// verbose: undefined,
|
||||
|
||||
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
||||
// watchPathIgnorePatterns: [],
|
||||
|
||||
// Whether to use watchman for file crawling
|
||||
// watchman: true,
|
||||
};
|
||||
|
||||
export default config;
|
164
package.json
Normal file
@ -0,0 +1,164 @@
|
||||
{
|
||||
"name": "extension",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"license": "GPL-3.0",
|
||||
"scripts": {
|
||||
"dev": "NODE_ENV=development yarn build apps -w",
|
||||
"build:app": "NODE_ENV=production yarn build apps",
|
||||
"build:gecko": "build-gecko ./dist -name test -o ./gecko.zip",
|
||||
"build": "./scripts/build.sh",
|
||||
"watch": "npm run dev",
|
||||
"codegen": "./scripts/build-gql.ts",
|
||||
"preinstall": "node ./scripts/build-shims.js",
|
||||
"typecheck": "tsc --noEmit --skipLibCheck"
|
||||
},
|
||||
"resolutions": {
|
||||
"cross-fetch": "./shims/cross-fetch",
|
||||
"is-number": "./shims/is-number"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@aet/eslint-rules": "0.0.1-beta.23",
|
||||
"@aet/gql-tools": "0.0.1-beta.3",
|
||||
"@aet/hooks": "npm:@proteria/hooks@^0.0.2",
|
||||
"@aet/icons": "0.0.1-beta.5",
|
||||
"@apollo/client": "^3.7.17",
|
||||
"@babel/core": "^7.22.9",
|
||||
"@babel/template": "^7.22.5",
|
||||
"@babel/types": "^7.22.5",
|
||||
"@csstools/postcss-sass": "^5.0.1",
|
||||
"@emotion/babel-plugin": "^11.11.0",
|
||||
"@emotion/css": "^11.11.2",
|
||||
"@emotion/hash": "^0.9.1",
|
||||
"@emotion/memoize": "^0.8.1",
|
||||
"@emotion/react": "^11.11.1",
|
||||
"@emotion/serialize": "^1.1.2",
|
||||
"@emotion/styled": "^11.11.0",
|
||||
"@graphql-codegen/add": "^5.0.0",
|
||||
"@graphql-codegen/plugin-helpers": "^5.0.1",
|
||||
"@graphql-codegen/typescript": "^4.0.1",
|
||||
"@graphql-codegen/typescript-operations": "^4.0.1",
|
||||
"@graphql-tools/code-file-loader": "^8.0.2",
|
||||
"@graphql-tools/graphql-file-loader": "^8.0.0",
|
||||
"@headlessui/react": "^1.7.16",
|
||||
"@monaco-editor/react": "^4.5.1",
|
||||
"@primer/primitives": "^7.11.14",
|
||||
"@react-hookz/web": "^23.1.0",
|
||||
"@szhsin/react-menu": "4.0.2",
|
||||
"@types/babel-plugin-macros": "^3.1.0",
|
||||
"@types/babel__core": "^7.20.1",
|
||||
"@types/babel__template": "^7.4.1",
|
||||
"@types/chrome": "^0.0.242",
|
||||
"@types/convert-source-map": "^2.0.0",
|
||||
"@types/debug": "^4.1.8",
|
||||
"@types/dedent": "^0.7.0",
|
||||
"@types/element-resize-detector": "^1.1.3",
|
||||
"@types/glob-to-regexp": "^0.4.1",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/lodash": "^4.14.196",
|
||||
"@types/lodash-es": "^4.17.8",
|
||||
"@types/node": "^20.4.5",
|
||||
"@types/pouchdb-browser": "^6.1.3",
|
||||
"@types/prettier": "^2.7.3",
|
||||
"@types/react": "^18.2.18",
|
||||
"@types/react-dom": "^18.2.7",
|
||||
"@types/react-helmet": "^6.1.6",
|
||||
"@types/react-window": "^1.8.5",
|
||||
"@types/stylis": "^4.2.0",
|
||||
"@types/ua-parser-js": "^0.7.36",
|
||||
"@types/w3c-css-typed-object-model-level-1": "20180410.0.5",
|
||||
"@types/webextension-polyfill": "^0.10.1",
|
||||
"@vscode/codicons": "^0.0.33",
|
||||
"async-mutex": "^0.4.0",
|
||||
"babel-plugin-macros": "3.1.0",
|
||||
"babel-plugin-transform-minify-gql-template-literals": "1.1.1",
|
||||
"browserslist": "^4.21.10",
|
||||
"comlink": "^4.4.1",
|
||||
"commander": "^11.0.0",
|
||||
"debug": "^4.3.4",
|
||||
"dedent": "1.5.1",
|
||||
"dotenv": "^16.3.1",
|
||||
"esbin": "0.0.1-beta.2",
|
||||
"esbuild": "0.18.17",
|
||||
"esbuild-plugin-sass": "^1.0.1",
|
||||
"eslint": "8.46.0",
|
||||
"eslint-plugin-unicorn": "^48.0.1",
|
||||
"fast-glob": "^3.3.1",
|
||||
"fuse.js": "^6.6.2",
|
||||
"glob-to-regexp": "^0.4.1",
|
||||
"graphiql": "^3.0.5",
|
||||
"graphql": "^16.7.1",
|
||||
"graphql-type-json": "^0.3.2",
|
||||
"hooks.macro": "^1.1.2",
|
||||
"i18next": "^23.4.1",
|
||||
"i18next-http-backend": "2.2.1",
|
||||
"i18next-icu": "^2.3.0",
|
||||
"idb-keyval": "^6.2.1",
|
||||
"immer": "^10.0.2",
|
||||
"intl-messageformat": "^10.5.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
"lodash.noop": "^3.0.1",
|
||||
"lru-cache": "^10.0.0",
|
||||
"memoize-one": "6.0.0",
|
||||
"monaco-editor": "^0.40.0",
|
||||
"nanoid": "^4.0.2",
|
||||
"normalize.css": "^8.0.1",
|
||||
"postcss": "^8.4.27",
|
||||
"postcss-modules": "^6.0.0",
|
||||
"pouchdb-browser": "^8.0.1",
|
||||
"prettier": "^3.0.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-helmet": "^6.1.0",
|
||||
"react-hot-toast": "^2.4.1",
|
||||
"react-i18next": "^13.0.3",
|
||||
"react-window": "^1.8.9",
|
||||
"reflect-metadata": "0.1.13",
|
||||
"sass": "^1.64.2",
|
||||
"scheduler": "^0.23.0",
|
||||
"src": "npm:lodash.noop@3.0.1",
|
||||
"superjson": "^1.13.1",
|
||||
"tiny-invariant": "^1.3.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsconfig-paths": "^4.2.0",
|
||||
"tslib": "^2.6.1",
|
||||
"tua-body-scroll-lock": "^1.4.0",
|
||||
"typed-emitter": "^2.1.0",
|
||||
"typescript": "5.2.0-beta",
|
||||
"typescript-plugin-css-modules": "^5.0.1",
|
||||
"ua-parser-js": "^1.0.35",
|
||||
"use-context-selector": "^1.4.1",
|
||||
"webextension-polyfill": "^0.10.0",
|
||||
"zod": "^3.21.4"
|
||||
},
|
||||
"prettier": {
|
||||
"arrowParens": "avoid",
|
||||
"tabWidth": 2,
|
||||
"printWidth": 90,
|
||||
"semi": false,
|
||||
"singleQuote": false,
|
||||
"trailingComma": "all"
|
||||
},
|
||||
"imports": {
|
||||
"#src/*": "./src/*"
|
||||
},
|
||||
"eslintIgnore": [
|
||||
"dist"
|
||||
],
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"@apollo/client@3.7.17": "patches/@apollo__client@3.7.17.patch",
|
||||
"@headlessui/react@1.7.16": "patches/@headlessui__react@1.7.16.patch",
|
||||
"i18next-http-backend@2.2.1": "patches/i18next-http-backend@2.2.1.patch",
|
||||
"monaco-editor@0.40.0": "patches/monaco-editor@0.40.0.patch",
|
||||
"@aet/gql-tools@0.0.1-beta.3": "patches/@aet__gql-tools@0.0.1-beta.3.patch"
|
||||
},
|
||||
"overrides": {
|
||||
"cross-fetch": "./shims/cross-fetch",
|
||||
"node-gyp": "./node_modules/lodash.noop",
|
||||
"@graphql-tools/relay-operation-optimizer": "./node_modules/lodash.noop"
|
||||
}
|
||||
}
|
||||
}
|
21
patches/@aet__gql-tools@0.0.1-beta.3.patch
Normal file
@ -0,0 +1,21 @@
|
||||
diff --git a/type-graphql.mjs b/type-graphql.mjs
|
||||
index 1723cb707fb365a7e68d073093f75960e405a463..4a36c76eeced8c2009c5480a154c150006361e7d 100644
|
||||
--- a/type-graphql.mjs
|
||||
+++ b/type-graphql.mjs
|
||||
@@ -3,7 +3,6 @@ import { GraphQLError, GraphQLScalarType, GraphQLFloat, GraphQLBoolean, GraphQLS
|
||||
export { GraphQLFloat as Float, GraphQLID as ID, GraphQLInt as Int } from 'graphql';
|
||||
import { GraphQLBigInt, GraphQLDateTimeISO } from 'graphql-scalars';
|
||||
export { GraphQLBigInt, GraphQLDateTimeISO as GraphQLISODateTime, GraphQLTimestamp } from 'graphql-scalars';
|
||||
-import { PubSub as PubSub$1, withFilter } from 'graphql-subscriptions';
|
||||
|
||||
class ArgumentValidationError extends GraphQLError {
|
||||
constructor(validationErrors) {
|
||||
@@ -903,7 +902,7 @@ class BuildContext {
|
||||
disableInferringDefaultValues;
|
||||
#pubSub;
|
||||
get pubSub() {
|
||||
- return this.#pubSub ?? (this.#pubSub = new PubSub$1());
|
||||
+ return this.#pubSub;
|
||||
}
|
||||
/**
|
||||
* Set static fields with current building context data
|
13
patches/@apollo__client@3.7.17.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/react/context/ApolloProvider.d.ts b/react/context/ApolloProvider.d.ts
|
||||
index 3d12c9e1e8bf6b33f603cdb2504142edc818eff7..ccc569dc90b7f0fa40b5347dd33c025894539ba1 100644
|
||||
--- a/react/context/ApolloProvider.d.ts
|
||||
+++ b/react/context/ApolloProvider.d.ts
|
||||
@@ -2,7 +2,7 @@ import * as React from 'react';
|
||||
import { ApolloClient } from '../../core';
|
||||
export interface ApolloProviderProps<TCache> {
|
||||
client: ApolloClient<TCache>;
|
||||
- children: React.ReactNode | React.ReactNode[] | null;
|
||||
+ children?: React.ReactNode | React.ReactNode[] | null;
|
||||
}
|
||||
export declare const ApolloProvider: React.FC<ApolloProviderProps<any>>;
|
||||
//# sourceMappingURL=ApolloProvider.d.ts.map
|
13
patches/@headlessui__react@1.7.16.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/dist/components/popover/popover.d.ts b/dist/components/popover/popover.d.ts
|
||||
index 3c7ee4ecbd5ac4411fbcc19f777876331bb0d640..080665fd90eaeb1370c7ec1e1f3281b6e2301bb3 100644
|
||||
--- a/dist/components/popover/popover.d.ts
|
||||
+++ b/dist/components/popover/popover.d.ts
|
||||
@@ -3,7 +3,7 @@ import { Props } from '../../types.js';
|
||||
import { PropsForFeatures, HasDisplayName, RefProp } from '../../utils/render.js';
|
||||
type MouseEvent<T> = Parameters<MouseEventHandler<T>>[0];
|
||||
declare let DEFAULT_POPOVER_TAG: "div";
|
||||
-interface PopoverRenderPropArg {
|
||||
+export interface PopoverRenderPropArg {
|
||||
open: boolean;
|
||||
close(focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null> | MouseEvent<HTMLElement>): void;
|
||||
}
|
22
patches/i18next-http-backend@2.2.1.patch
Normal file
@ -0,0 +1,22 @@
|
||||
diff --git a/esm/getFetch.cjs b/esm/getFetch.cjs
|
||||
deleted file mode 100644
|
||||
index 9e99af3cae1cb4e1ebb543c510132741bc7036e5..0000000000000000000000000000000000000000
|
||||
diff --git a/esm/getFetch.js b/esm/getFetch.js
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7b36684e2e54181eb45f5d2b718f3da5a925ea40
|
||||
--- /dev/null
|
||||
+++ b/esm/getFetch.js
|
||||
@@ -0,0 +1 @@
|
||||
+export default globalThis.fetch;
|
||||
diff --git a/esm/request.js b/esm/request.js
|
||||
index b6a6e8976beab48feaa9eedcd44fc2945f27952d..02ccb089b571bb8627a297abaa131c6657861481 100644
|
||||
--- a/esm/request.js
|
||||
+++ b/esm/request.js
|
||||
@@ -1,6 +1,6 @@
|
||||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
||||
import { defaults, hasXMLHttpRequest } from './utils.js';
|
||||
-import * as fetchNode from './getFetch.cjs';
|
||||
+import * as fetchNode from './getFetch.js';
|
||||
var fetchApi;
|
||||
if (typeof fetch === 'function') {
|
||||
if (typeof global !== 'undefined' && global.fetch) {
|
70
patches/monaco-editor@0.40.0.patch
Normal file
@ -0,0 +1,70 @@
|
||||
diff --git a/esm/vs/language/css/css.worker.js b/esm/vs/language/css/css.worker.js
|
||||
index 4ba8b6ca8fda98d7f6c23a4e7f46549991b0085a..828be81d67eee01891ca1a8a47378d4877e22243 100644
|
||||
--- a/esm/vs/language/css/css.worker.js
|
||||
+++ b/esm/vs/language/css/css.worker.js
|
||||
@@ -17983,6 +17983,9 @@ var cssData = {
|
||||
{
|
||||
"name": "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif"
|
||||
},
|
||||
+ {
|
||||
+ "name": "system-ui, sans-serif"
|
||||
+ },
|
||||
{
|
||||
"name": "Arial, Helvetica, sans-serif"
|
||||
},
|
||||
@@ -30198,6 +30201,55 @@ var cssData = {
|
||||
"identifier"
|
||||
]
|
||||
},
|
||||
+ {
|
||||
+ "name": "-webkit-font-smoothing",
|
||||
+ "browsers": [
|
||||
+ "S4",
|
||||
+ "C5"
|
||||
+ ],
|
||||
+ "values": [
|
||||
+ {
|
||||
+ "name": "auto",
|
||||
+ "description": "Let the browser decide (Uses subpixel anti-aliasing when available; this is the default)"
|
||||
+ },
|
||||
+ {
|
||||
+ "name": "none",
|
||||
+ "description": "Turn font smoothing off; display text with jagged sharp edges."
|
||||
+ },
|
||||
+ {
|
||||
+ "name": "antialiased",
|
||||
+ "description": "Smooth the font on the level of the pixel, as opposed to the subpixel. Switching from subpixel rendering to antialiasing for light text on dark backgrounds makes it look lighter."
|
||||
+ },
|
||||
+ {
|
||||
+ "name": "subpixel-antialiased",
|
||||
+ "description": "On most non-retina displays, this will give the sharpest text."
|
||||
+ }
|
||||
+ ],
|
||||
+ "description": "Controls the application of anti-aliasing when fonts are rendered.",
|
||||
+ "restrictions": [
|
||||
+ "identifier"
|
||||
+ ]
|
||||
+ },
|
||||
+ {
|
||||
+ "name": "-moz-osx-font-smoothing",
|
||||
+ "browsers": [
|
||||
+ "F25"
|
||||
+ ],
|
||||
+ "values": [
|
||||
+ {
|
||||
+ "name": "auto",
|
||||
+ "description": "Allow the browser to select an optimization for font smoothing, typically grayscale."
|
||||
+ },
|
||||
+ {
|
||||
+ "name": "grayscale",
|
||||
+ "description": "Render text with grayscale antialiasing, as opposed to the subpixel. Switching from subpixel rendering to antialiasing for light text on dark backgrounds makes it look lighter."
|
||||
+ }
|
||||
+ ],
|
||||
+ "description": "Controls the application of anti-aliasing when fonts are rendered.",
|
||||
+ "restrictions": [
|
||||
+ "identifier"
|
||||
+ ]
|
||||
+ },
|
||||
{
|
||||
"name": "-webkit-font-feature-settings",
|
||||
"browsers": [
|
7325
pnpm-lock.yaml
generated
Normal file
300
scripts/build-apps.ts
Executable file
@ -0,0 +1,300 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import "dotenv/config"
|
||||
import { promises as fs } from "fs"
|
||||
import { resolve } from "path"
|
||||
import glob from "fast-glob"
|
||||
import { program } from "commander"
|
||||
import sass from "esbuild-plugin-sass"
|
||||
import * as esbuild from "esbuild"
|
||||
import type { PluginItem } from "@babel/core"
|
||||
import { c } from "./utils"
|
||||
import { cssModules } from "./plugins/esbuild-css-modules"
|
||||
import { babelPlugin as babel } from "./plugins/esbuild-babel"
|
||||
import { externalDep } from "./plugins/esbuild-external-dep"
|
||||
import { stringImport } from "./plugins/esbuild-string-import"
|
||||
import { yamlPlugin as yaml } from "./plugins/esbuild-yaml"
|
||||
import { alias } from "./plugins/esbuild-alias"
|
||||
import { getDefaultTarget } from "./plugins/esbuild-browserslist"
|
||||
|
||||
const dist = "dist"
|
||||
const SERVE_PORT = 3114
|
||||
|
||||
program
|
||||
.option("-g, --grep <pattern>", "only build packages that match <pattern>")
|
||||
.option("-s, --silent", "hide all output")
|
||||
.option(
|
||||
"-e, --env <env>",
|
||||
"set the NODE_ENV environment variable",
|
||||
process.env.NODE_ENV || "production",
|
||||
)
|
||||
.option("-w, --watch", "watch for changes and rebuild")
|
||||
.parse()
|
||||
|
||||
const { grep, silent, env, watch } = program.opts()
|
||||
const __PROD__ = env === "production"
|
||||
|
||||
const log = silent ? () => {} : console.log
|
||||
|
||||
async function main() {
|
||||
const queue = new Queue([
|
||||
new Build("src/options/index.tsx", `${dist}/app/options`, { serve: true }),
|
||||
new Build("src/popup/index.tsx", `${dist}/app/popup`),
|
||||
new Build("src/server/index.ts", `${dist}/app/server`, {
|
||||
platform: "node",
|
||||
format: "cjs",
|
||||
splitting: false,
|
||||
minify: false,
|
||||
}),
|
||||
new Build("src/background/index.ts", `${dist}/app/background`),
|
||||
new Build("src/background/compiler.ts", `${dist}/app/background/compiler`),
|
||||
new Build("src/context/index.ts", `${dist}/app/context`, {
|
||||
format: "iife",
|
||||
splitting: false,
|
||||
}),
|
||||
new Build("src/devtools/index.ts", `${dist}/app/devtools`),
|
||||
new Build("src/install/index.ts", `${dist}/app/install`),
|
||||
new Build("src/graphiql/index.tsx", `${dist}/app/playground`),
|
||||
new Build("src/reference/index.tsx", `${dist}/app/reference`, {
|
||||
format: "iife",
|
||||
splitting: false,
|
||||
}),
|
||||
]).filter(grep ? task => task.entry.includes(grep) : () => true)
|
||||
|
||||
if (!queue.length) {
|
||||
return
|
||||
}
|
||||
|
||||
await queue.run(task => task.clean())
|
||||
|
||||
log(
|
||||
watch ? "Watching" : "Building",
|
||||
`${c.blue(queue.length)} package(s) in ${c.blue(env)}`,
|
||||
)
|
||||
if (queue.length < 5) {
|
||||
log(queue.tasks.map((t, i) => ` ${i + 1}. ${c.green(t.entry)}`).join("\n"))
|
||||
}
|
||||
|
||||
await queue.build()
|
||||
|
||||
if (__PROD__) {
|
||||
await printBundleSize()
|
||||
}
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
Promise.resolve()
|
||||
.then(() => main())
|
||||
.catch(e => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
type BuildOptions = Pick<
|
||||
esbuild.BuildOptions,
|
||||
"entryPoints" | "outdir" | "format" | "splitting" | "platform" | "minify"
|
||||
> & {
|
||||
serve?: boolean
|
||||
}
|
||||
|
||||
export const getBasicOptions = ({
|
||||
entryPoints,
|
||||
minify = __PROD__,
|
||||
plugins = [],
|
||||
babelPlugins = [],
|
||||
}: {
|
||||
entryPoints: [string]
|
||||
minify?: boolean
|
||||
plugins?: esbuild.Plugin[]
|
||||
babelPlugins?: PluginItem[]
|
||||
}): Partial<esbuild.BuildOptions> => ({
|
||||
entryPoints,
|
||||
define: {
|
||||
...Object.entries(process.env).reduce(
|
||||
(acc, [key, value]) =>
|
||||
key.startsWith("NEXT_PUBLIC_")
|
||||
? { ...acc, [`process.env.${key}`]: JSON.stringify(value) }
|
||||
: acc,
|
||||
{} as Record<string, string>,
|
||||
),
|
||||
"process.env.NODE_ENV": JSON.stringify(env),
|
||||
"process.env.NODE_DEBUG": "false",
|
||||
"process.env.SERVE_PORT": String(SERVE_PORT),
|
||||
"process.browser": "true",
|
||||
global: "globalThis",
|
||||
},
|
||||
bundle: true,
|
||||
format: "esm",
|
||||
external: ["path", "glob", "fs", "util", "monaco-editor"],
|
||||
plugins: [
|
||||
...plugins,
|
||||
externalDep(["prettier", "sass"]),
|
||||
babel(babelPlugins),
|
||||
yaml(),
|
||||
stringImport(),
|
||||
alias({
|
||||
lodash: require.resolve("lodash-es"),
|
||||
"webextension-polyfill": require.resolve("../src/vendor/webextension-polyfill"),
|
||||
"monaco-editor": require.resolve("../src/options/monaco.ts"),
|
||||
|
||||
// https://github.com/MichalLytek/type-graphql/issues/366#issuecomment-511075437
|
||||
"libphonenumber-js": require.resolve("lodash.noop"),
|
||||
// we never use graphql-subscriptions
|
||||
"graphql-subscriptions": require.resolve("lodash.noop"),
|
||||
|
||||
// Make esbuild use the module version
|
||||
graphql: require.resolve("graphql/index.mjs"),
|
||||
|
||||
...(entryPoints[0].includes("graphiql") || __PROD__
|
||||
? {}
|
||||
: {
|
||||
react: require.resolve("../src/vendor/why-did-you-render/index.js"),
|
||||
"react/jsx-runtime": require.resolve(
|
||||
"../src/vendor/why-did-you-render/jsx-runtime",
|
||||
),
|
||||
}),
|
||||
}),
|
||||
cssModules({
|
||||
generateScopedName: __PROD__
|
||||
? "[hash:base64:6]"
|
||||
: "[name]__[local]___[hash:base64:5]",
|
||||
localsConvention: "camelCaseOnly",
|
||||
}),
|
||||
sass(),
|
||||
].filter(Boolean),
|
||||
target: getDefaultTarget(),
|
||||
banner: {
|
||||
js: "/* eslint-disable */",
|
||||
},
|
||||
legalComments: "none",
|
||||
keepNames: false,
|
||||
tsconfig: "./tsconfig.json",
|
||||
sourcemap: "linked",
|
||||
minify,
|
||||
splitting: true,
|
||||
metafile: true,
|
||||
loader: {
|
||||
".eot": "file",
|
||||
".png": "file",
|
||||
".ttf": "file",
|
||||
".woff": "file",
|
||||
".woff2": "file",
|
||||
},
|
||||
})
|
||||
|
||||
async function printBundleSize() {
|
||||
const root = resolve(dist, "app")
|
||||
const files = await glob(["**/*", "!**/*.map", "!**/meta.json"], {
|
||||
cwd: root,
|
||||
onlyFiles: true,
|
||||
})
|
||||
const sizes = await Promise.all(
|
||||
files.map(async file => {
|
||||
const { size } = await fs.stat(resolve(root, file))
|
||||
return { file, size }
|
||||
}),
|
||||
)
|
||||
|
||||
const list = sizes
|
||||
.filter(a => a.size > 50000)
|
||||
.sort((a, b) => b.size - a.size)
|
||||
.slice(0, 10)
|
||||
|
||||
for (const { file, size } of list) {
|
||||
log(
|
||||
c.blue(`./dist/app/${file.padEnd(38, " ")}`),
|
||||
c.green(`${humanFileSize(size).padStart(9, " ")}`),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function humanFileSize(bytes: number, si = false, dp = 1) {
|
||||
const thresh = si ? 1000 : 1024
|
||||
|
||||
if (Math.abs(bytes) < thresh) {
|
||||
return bytes + " B"
|
||||
}
|
||||
|
||||
const units = si
|
||||
? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
||||
: ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]
|
||||
let u = -1
|
||||
const r = 10 ** dp
|
||||
|
||||
do {
|
||||
bytes /= thresh
|
||||
++u
|
||||
} while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1)
|
||||
|
||||
return bytes.toFixed(dp) + " " + units[u]
|
||||
}
|
||||
|
||||
class Build {
|
||||
enabled = true
|
||||
|
||||
constructor(
|
||||
readonly entry: string,
|
||||
readonly outdir: string,
|
||||
readonly options?: BuildOptions,
|
||||
) {}
|
||||
|
||||
disable() {
|
||||
this.enabled = false
|
||||
return this
|
||||
}
|
||||
|
||||
async clean() {
|
||||
if (!this.enabled) return
|
||||
|
||||
await fs.rm(this.outdir, { recursive: true, force: true })
|
||||
}
|
||||
|
||||
async build() {
|
||||
if (!this.enabled) return
|
||||
|
||||
const { outdir, options: { serve, ...options } = {} } = this
|
||||
|
||||
const ctx = await esbuild.context({
|
||||
...getBasicOptions({
|
||||
entryPoints: [this.entry],
|
||||
}),
|
||||
...options,
|
||||
outdir,
|
||||
})
|
||||
|
||||
const { metafile } = await ctx.rebuild()
|
||||
|
||||
if (__PROD__) {
|
||||
await fs.writeFile(resolve(outdir, "meta.json"), JSON.stringify(metafile))
|
||||
}
|
||||
|
||||
if (watch) {
|
||||
await ctx.watch()
|
||||
if (serve) {
|
||||
await ctx.serve({ port: SERVE_PORT })
|
||||
}
|
||||
} else {
|
||||
await ctx.dispose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Queue {
|
||||
constructor(public tasks: readonly Build[]) {}
|
||||
|
||||
get length() {
|
||||
return this.tasks.length
|
||||
}
|
||||
|
||||
filter(predicate: (task: Build) => boolean) {
|
||||
return new Queue(this.tasks.filter(predicate))
|
||||
}
|
||||
|
||||
run(fn: (task: Build) => Promise<void>) {
|
||||
return Promise.all(this.tasks.map(fn))
|
||||
}
|
||||
|
||||
build() {
|
||||
return this.run(task => task.build())
|
||||
}
|
||||
}
|
29
scripts/build-css-module-def.ts
Executable file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import fs from "fs"
|
||||
import { uniq } from "lodash"
|
||||
import { writeFormatted } from "./utils"
|
||||
|
||||
const modules = [
|
||||
"src/vendor/allotment/src/allotment.module.css",
|
||||
"src/vendor/allotment/src/sash.module.css",
|
||||
]
|
||||
|
||||
for (const module of modules) {
|
||||
const source = fs.readFileSync(module, "utf8")
|
||||
const classNames = uniq(
|
||||
Array.from(source.matchAll(/\.([a-z][a-z0-9_-]+)/gi), m => m[1]),
|
||||
)
|
||||
|
||||
writeFormatted(
|
||||
module + ".d.ts",
|
||||
[
|
||||
"// This file is generated by scripts/build-css-module-def.ts",
|
||||
"",
|
||||
"declare const classNames: {", //
|
||||
...classNames.map(c => ` "${c}": string;`),
|
||||
"}",
|
||||
"",
|
||||
"export default classNames;",
|
||||
].join("\n"),
|
||||
)
|
||||
}
|
91
scripts/build-gql.ts
Executable file
@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import { promises as fs } from "node:fs"
|
||||
import { format } from "prettier"
|
||||
import { CodeFileLoader } from "@graphql-tools/code-file-loader"
|
||||
import { GraphQLFileLoader } from "@graphql-tools/graphql-file-loader"
|
||||
import * as typescript from "@graphql-codegen/typescript"
|
||||
import * as typescriptOperations from "@graphql-codegen/typescript-operations"
|
||||
import * as add from "@graphql-codegen/add"
|
||||
import { plugin as _, codegen, typedDocumentNodePlugin } from "@aet/gql-tools/codegen"
|
||||
import { buildSchema } from "./build-schema-file"
|
||||
|
||||
async function main() {
|
||||
await buildSchema()
|
||||
|
||||
const scalars: Record<string, string> = {
|
||||
DateTime: "Date",
|
||||
}
|
||||
|
||||
const context = await codegen({
|
||||
schema: {
|
||||
source: "./src/generated/schema.gql",
|
||||
loaders: [new GraphQLFileLoader()],
|
||||
},
|
||||
documents: {
|
||||
source: ["./src/**/*.{ts,tsx}", "!/src/generated/**/*.{ts,tsx}"],
|
||||
loaders: [new CodeFileLoader({ pluckConfig: { skipIndent: true } })],
|
||||
},
|
||||
})
|
||||
|
||||
const content = await context.generate({
|
||||
plugins: [
|
||||
_(typescript, {
|
||||
immutableTypes: true,
|
||||
useTypeImports: true,
|
||||
declarationKind: "interface",
|
||||
allowEnumStringTypes: true,
|
||||
enumsAsTypes: true,
|
||||
scalars,
|
||||
}),
|
||||
_(typescriptOperations, {
|
||||
declarationKind: "interface",
|
||||
allowEnumStringTypes: true,
|
||||
scalars,
|
||||
}),
|
||||
_(add, {
|
||||
content: /* js */ `
|
||||
/* eslint-disable */
|
||||
import { gql as _gql } from "@apollo/client";
|
||||
import type { DocumentNode } from "graphql";
|
||||
export { ApolloClient, useQuery, useApolloClient, useLazyQuery, useMutation } from "@apollo/client";
|
||||
|
||||
export const gql = _gql as unknown as {
|
||||
<K extends keyof DocumentMap>(
|
||||
literals: string | readonly string[],
|
||||
...args: any[]
|
||||
): DocumentMap[K];
|
||||
(
|
||||
literals: string | readonly string[],
|
||||
...args: any[]
|
||||
): DocumentNode;
|
||||
}
|
||||
`,
|
||||
}),
|
||||
_(typedDocumentNodePlugin, {
|
||||
createDocumentMap: true,
|
||||
exportDocumentNodes: true,
|
||||
}),
|
||||
],
|
||||
pipeline: [
|
||||
source =>
|
||||
source
|
||||
.replace(/Scalars\['String']\['(in|out)put']/g, "string")
|
||||
.replace(/Scalars\['ID']\['(in|out)put']/g, "string")
|
||||
.replace(/Scalars\['Boolean']\['(in|out)put']/g, "boolean")
|
||||
.replace(/Scalars\['Int']\['(in|out)put']/g, "number")
|
||||
.replace(/Scalars\['Float']\['(in|out)put']/g, "number")
|
||||
.replaceAll("Scalars['DateTime']['input']", "Date")
|
||||
.replaceAll("Scalars['JSON']['input']", "any")
|
||||
.replace(/(\w+) \| `\$\{\1}`/g, " $1")
|
||||
.replace(/: (Input)?Maybe<([['\]\w<> ]+)>/g, ": $2 | null")
|
||||
.replace(/: Array<([\w<> ]+)>/g, ": $1[]")
|
||||
.replace(/export type (\w+) = {/g, "export interface $1 {")
|
||||
.replace(/export type (Make|Maybe|InputMaybe|Exact|Incremental)/g, "type $1"),
|
||||
code => format(code, { parser: "typescript" }),
|
||||
],
|
||||
})
|
||||
|
||||
await fs.writeFile("./src/generated/graphql.ts", content)
|
||||
}
|
||||
|
||||
void main()
|
91
scripts/build-htmls.tsx
Executable file
@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import fs from "fs"
|
||||
import React from "react"
|
||||
import { renderToStaticMarkup } from "react-dom/server"
|
||||
|
||||
const __DEV__ = process.env.NODE_ENV !== "production"
|
||||
|
||||
const Head: FC<{
|
||||
children: React.ReactNode
|
||||
}> = ({ children }) => (
|
||||
<head>
|
||||
<meta charSet="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
{children}
|
||||
</head>
|
||||
)
|
||||
|
||||
const files: {
|
||||
[path: string]: React.ReactElement
|
||||
} = {
|
||||
"./dist/background.html": (
|
||||
<html>
|
||||
<Head>
|
||||
<script type="module" src="app/background/index.js" />
|
||||
</Head>
|
||||
</html>
|
||||
),
|
||||
"./dist/devtools.html": (
|
||||
<html>
|
||||
<Head>
|
||||
<script type="module" src="app/devtools/index.js" />
|
||||
</Head>
|
||||
</html>
|
||||
),
|
||||
"./dist/options.html": (
|
||||
<html data-theme="github-dark">
|
||||
<Head>
|
||||
<link rel="stylesheet" href="app/options/index.css" />
|
||||
<link rel="stylesheet" href="/vendor/primer/github-dark.css" />
|
||||
</Head>
|
||||
<body>
|
||||
{__DEV__ && (
|
||||
// React DevTools
|
||||
// curl -s http://localhost:8097 | openssl dgst -sha384 -binary | openssl base64 -A
|
||||
<script src="http://localhost:8097" crossOrigin="anonymous" />
|
||||
)}
|
||||
<div id="not-loaded" />
|
||||
<div id="root" />
|
||||
<script type="module" src="app/options/index.js" />
|
||||
</body>
|
||||
</html>
|
||||
),
|
||||
"./dist/playground.html": (
|
||||
<html>
|
||||
<Head>
|
||||
<link rel="stylesheet" href="app/playground/index.css" />
|
||||
</Head>
|
||||
<body>
|
||||
<div id="root" />
|
||||
<script type="module" src="app/playground/index.js" />
|
||||
</body>
|
||||
</html>
|
||||
),
|
||||
"./dist/popup.html": (
|
||||
<html>
|
||||
<Head>
|
||||
<link rel="stylesheet" href="app/popup/index.css" />
|
||||
</Head>
|
||||
<body>
|
||||
<div id="root" />
|
||||
<script type="module" src="app/popup/index.js" />
|
||||
</body>
|
||||
</html>
|
||||
),
|
||||
"./dist/reference.html": (
|
||||
<html>
|
||||
<Head>
|
||||
<link rel="stylesheet" href="app/reference/index.css" />
|
||||
</Head>
|
||||
<body>
|
||||
<div id="root" />
|
||||
<script src="app/reference/index.js" />
|
||||
</body>
|
||||
</html>
|
||||
),
|
||||
}
|
||||
|
||||
for (const [path, content] of Object.entries(files)) {
|
||||
const html = "<!DOCTYPE html>" + renderToStaticMarkup(content)
|
||||
fs.writeFileSync(path, html)
|
||||
}
|
145
scripts/build-license.ts
Executable file
@ -0,0 +1,145 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import fs from "node:fs"
|
||||
import { resolve } from "node:path"
|
||||
import { load } from "js-yaml"
|
||||
|
||||
process.chdir(resolve(__dirname, ".."))
|
||||
|
||||
const candidates = [
|
||||
"master/LICENSE",
|
||||
"master/LICENCE",
|
||||
"master/LICENSE.md",
|
||||
"master/license.md",
|
||||
"main/LICENSE.txt",
|
||||
]
|
||||
|
||||
async function getLicense(repo: string) {
|
||||
for (const candidate of candidates) {
|
||||
const path = `https://raw.githubusercontent.com/${repo}/${candidate}`
|
||||
const res = await fetch(path)
|
||||
if (!res.ok) continue
|
||||
const text = await res.text()
|
||||
return text
|
||||
}
|
||||
throw new Error(`Could not find license for ${repo}`)
|
||||
}
|
||||
|
||||
async function getSDPXLicense(license: string) {
|
||||
const path = `https://raw.githubusercontent.com/spdx/license-list-data/main/text/${license}.txt`
|
||||
const res = await fetch(path)
|
||||
if (!res.ok) throw new Error(`Could not find license ${license}`)
|
||||
const text = await res.text()
|
||||
return text
|
||||
}
|
||||
|
||||
function getVendorLicenses() {
|
||||
return fs
|
||||
.readdirSync("src/vendor")
|
||||
.map(name => ({ name, path: `src/vendor/${name}/LICENSE` }))
|
||||
.filter(({ path }) => fs.existsSync(path))
|
||||
.map(({ name, path }) => [name, fs.readFileSync(path, "utf8")])
|
||||
}
|
||||
|
||||
async function getPackageLicense(pkg: string) {
|
||||
const files = ["LICENSE", "LICENCE", "license.md"]
|
||||
for (const file of files) {
|
||||
const path = `node_modules/${pkg}/${file}`
|
||||
if (fs.existsSync(path)) {
|
||||
return fs.readFileSync(path, "utf8")
|
||||
}
|
||||
}
|
||||
|
||||
const pkgJson = JSON.parse(fs.readFileSync(`node_modules/${pkg}/package.json`, "utf8"))
|
||||
const licenseName = pkgJson.license as string
|
||||
if (!licenseName) throw new Error(`Could not find license for ${pkg}`)
|
||||
|
||||
return getSDPXLicense(licenseName)
|
||||
}
|
||||
|
||||
function getPackageLicenses() {
|
||||
const {
|
||||
dependencies = {},
|
||||
devDependencies = {},
|
||||
peerDependencies = {},
|
||||
} = JSON.parse(fs.readFileSync("package.json", "utf8"))
|
||||
const packages = Object.keys({
|
||||
...dependencies,
|
||||
...devDependencies,
|
||||
...peerDependencies,
|
||||
})
|
||||
return Promise.all(packages.map(async pkg => [pkg, await getPackageLicense(pkg)]))
|
||||
}
|
||||
|
||||
class Licenses {
|
||||
libs = new Set<string>()
|
||||
|
||||
constructor(readonly json: Record<string, string>) {}
|
||||
|
||||
set(name: string, license: string) {
|
||||
this.libs.add(name)
|
||||
this.json[name] = license
|
||||
}
|
||||
|
||||
async setIfAbsent(name: string, license: () => Promise<string>) {
|
||||
if (!this.json[name]) {
|
||||
const text = await license()
|
||||
this.set(name, text)
|
||||
}
|
||||
}
|
||||
|
||||
assign(others: Record<string, string>) {
|
||||
for (const [name, license] of Object.entries(others)) {
|
||||
this.set(name, license)
|
||||
}
|
||||
}
|
||||
|
||||
purge() {
|
||||
for (const name of Object.keys(this.json)) {
|
||||
if (!this.libs.has(name)) {
|
||||
delete this.json[name]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return this.json
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const outPath = "src/generated/licenses.json"
|
||||
if (!fs.existsSync(outPath)) {
|
||||
fs.writeFileSync(outPath, "{}")
|
||||
}
|
||||
const res = new Licenses(
|
||||
JSON.parse(fs.readFileSync(outPath, "utf8")) as Record<string, string>,
|
||||
)
|
||||
const config = load(fs.readFileSync("src/licenses.yml", "utf8")) as {
|
||||
github: string[]
|
||||
licenses: { [name: string]: string }
|
||||
}
|
||||
|
||||
// res.set("archive", await getSPLicense("AGPL-3.0-or-later"));
|
||||
for (const repo of config.github) {
|
||||
await res.setIfAbsent(repo, () => getLicense(repo))
|
||||
}
|
||||
for (const [name, license] of Object.entries(config.licenses)) {
|
||||
await res.setIfAbsent(name, () => getSDPXLicense(license))
|
||||
}
|
||||
res.assign(Object.fromEntries(getVendorLicenses()))
|
||||
res.assign(Object.fromEntries(await getPackageLicenses()))
|
||||
res.purge()
|
||||
|
||||
fs.writeFileSync(
|
||||
outPath,
|
||||
JSON.stringify(
|
||||
Object.fromEntries(
|
||||
Object.entries(res.toJSON()).sort(([a], [b]) => a.localeCompare(b)),
|
||||
),
|
||||
null,
|
||||
2,
|
||||
) + "\n",
|
||||
)
|
||||
}
|
||||
|
||||
void main()
|
42
scripts/build-locales.ts
Executable file
@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import { execSync } from "child_process"
|
||||
import { resolve } from "path"
|
||||
import en from "../src/shared/i18n/resources/en-US/index.json"
|
||||
import { writeFormatted } from "./utils"
|
||||
|
||||
const languages = process.argv.slice(2).includes("-f")
|
||||
? execSync("crowdin list languages --code=locale --plain")
|
||||
.toString()
|
||||
.trim()
|
||||
.split("\n")
|
||||
.concat("en-US")
|
||||
.sort()
|
||||
: ["de-DE", "en-US", "es-ES", "fr-CA", "fr-FR", "ja-JP", "ko-KR", "zh-CN", "zh-TW"]
|
||||
|
||||
const keys: string[] = Array.from(
|
||||
(function* keys(
|
||||
obj: Record<string, unknown>,
|
||||
prefixes: string[] = [],
|
||||
): Generator<string, void, undefined> {
|
||||
for (const [key, value] of Object.entries(obj)) {
|
||||
if (value != null && typeof value === "object") {
|
||||
yield* keys(value as any, prefixes.concat(key))
|
||||
} else {
|
||||
yield prefixes.concat(key).join(".")
|
||||
}
|
||||
}
|
||||
})(en),
|
||||
).sort()
|
||||
|
||||
const code = [
|
||||
`export const languages = ${JSON.stringify(languages, null, 2)};`,
|
||||
"",
|
||||
"export type TranslationKey =",
|
||||
keys.map(key => " | " + JSON.stringify(key)).join("\n"),
|
||||
";\n",
|
||||
]
|
||||
|
||||
writeFormatted(
|
||||
resolve(__dirname, "../src/shared/i18n/data.generated.ts"),
|
||||
code.join("\n"),
|
||||
)
|
116
scripts/build-makefile.ts
Executable file
@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import { promises as fs } from "fs"
|
||||
import { resolve } from "path"
|
||||
import { kebabCase } from "lodash"
|
||||
import { sync as glob } from "fast-glob"
|
||||
import { ensureArray as arr } from "~/shared/ensureArray"
|
||||
// import _ from "dedent";
|
||||
|
||||
interface Task {
|
||||
deps: string | string[]
|
||||
target: string | string[]
|
||||
command: string | string[]
|
||||
}
|
||||
|
||||
// Variables for Makefile
|
||||
// $@: The file name of the target of the rule.
|
||||
// $<: The name of the first prerequisite.
|
||||
// $?: The names of all the prerequisites that are newer than the target, with spaces between them.
|
||||
// $^: The names of all the prerequisites, with spaces between them.
|
||||
|
||||
const tasks: { [name: string]: () => Task } = {
|
||||
Makefile: (script = "scripts/build-makefile.ts") => ({
|
||||
command: script,
|
||||
target: "Makefile",
|
||||
deps: [script],
|
||||
}),
|
||||
|
||||
theme: (script = "scripts/build-theme.tsx") => ({
|
||||
command: `${script} -o $(@D)`,
|
||||
target: [
|
||||
"src/shared/theme/tokens.generated.ts",
|
||||
"src/shared/theme/tokens.generated.css",
|
||||
],
|
||||
deps: ["src/shared/theme/tokens.tsx", script],
|
||||
}),
|
||||
|
||||
models: (
|
||||
models = "src/shared/models",
|
||||
source = `${models}/models.yml`,
|
||||
script = "./scripts/build-models.ts",
|
||||
) => ({
|
||||
command: `${script}`,
|
||||
target: glob(`${models}/*.generated.ts`),
|
||||
deps: [source, script],
|
||||
}),
|
||||
|
||||
WebExtensionPolyfill: (base = "src/vendor/webextension-polyfill") => ({
|
||||
target: `${base}/api-metadata.generated.json`,
|
||||
deps: glob(`${base}/**/*`),
|
||||
command: `./${base}/scripts/compress.ts`,
|
||||
}),
|
||||
|
||||
HTML: (script = "scripts/build-htmls.tsx") => ({
|
||||
target: glob("dist/*.html"),
|
||||
deps: script,
|
||||
command: script,
|
||||
}),
|
||||
|
||||
locales: (script = "scripts/build-locales.ts") => ({
|
||||
target: [
|
||||
...glob(["dist/_locales/**/*.json", "src/shared/i18n/resources"]),
|
||||
"src/shared/i18n/data.generated.ts",
|
||||
],
|
||||
deps: script,
|
||||
command: script,
|
||||
}),
|
||||
|
||||
// monaco: (
|
||||
// script = "./scripts/build-monaco.ts",
|
||||
// dist = "dist/vendor/monaco-editor/index.js",
|
||||
// ) => ({
|
||||
// target: dist,
|
||||
// deps: ["package.json", script],
|
||||
// command: [script, `touch ${dist}`],
|
||||
// }),
|
||||
|
||||
sass: (script = "./scripts/build-sass.ts") => ({
|
||||
target: "dist/vendor/sass/index.js",
|
||||
deps: ["package.json", script],
|
||||
command: script,
|
||||
}),
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const sep = " \\\n "
|
||||
|
||||
function* generate() {
|
||||
yield "# This file is generated by `make Makefile`"
|
||||
|
||||
const instances = Object.entries(tasks).map(([name, t]) => [name, t()] as const)
|
||||
for (const [name, task] of instances) {
|
||||
const { target } = task
|
||||
yield arr(target).join(" ") +
|
||||
": " +
|
||||
arr(task.deps)
|
||||
.filter(d => !glob(d).some(file => target.includes(file)))
|
||||
.join(sep)
|
||||
|
||||
yield `\t@echo "✨ Building ${name}..."`
|
||||
for (const cmd of arr(task.command)) {
|
||||
yield `\t@${cmd}`
|
||||
}
|
||||
yield ""
|
||||
yield `${kebabCase(name)}: ${arr(target)[0]}`
|
||||
yield ""
|
||||
}
|
||||
|
||||
yield "all: " + instances.map(task => kebabCase(task[0])).join(sep)
|
||||
yield ""
|
||||
}
|
||||
|
||||
const makefile = [...generate()].join("\n")
|
||||
await fs.writeFile(resolve(__dirname, "../Makefile"), makefile)
|
||||
}
|
||||
|
||||
main()
|
68
scripts/build-manifest.ts
Executable file
@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import "dotenv/config"
|
||||
import fs from "fs"
|
||||
import { resolve } from "path"
|
||||
import type { Manifest } from "webextension-polyfill"
|
||||
|
||||
const manifest: Manifest.WebExtensionManifest = {
|
||||
name: "__MSG_extName__",
|
||||
version: "19.11.6",
|
||||
description: "__MSG_description__",
|
||||
manifest_version: 2,
|
||||
default_locale: "en_US",
|
||||
icons: {
|
||||
64: "assets/images/64.png",
|
||||
128: "assets/images/128.png",
|
||||
256: "assets/images/256.png",
|
||||
},
|
||||
permissions: [
|
||||
"tabs",
|
||||
"downloads",
|
||||
"webNavigation",
|
||||
"storage",
|
||||
"http://*/",
|
||||
"https://*/",
|
||||
"chrome://favicon/",
|
||||
],
|
||||
content_security_policy:
|
||||
"script-src 'unsafe-inline' 'self' http://localhost:8097/; object-src 'self'",
|
||||
minimum_chrome_version: "90.0",
|
||||
background: {
|
||||
page: "background.html",
|
||||
persistent: true,
|
||||
},
|
||||
devtools_page: "devtools.html",
|
||||
content_scripts: [
|
||||
{
|
||||
matches: ["<all_urls>"],
|
||||
run_at: "document_start",
|
||||
all_frames: true,
|
||||
js: ["app/context/index.js"],
|
||||
},
|
||||
{
|
||||
matches: ["http://userstyles.org/*", "https://userstyles.org/*"],
|
||||
run_at: "document_end",
|
||||
all_frames: false,
|
||||
js: ["app/install/index.js"],
|
||||
},
|
||||
],
|
||||
options_ui: {
|
||||
page: "options.html",
|
||||
open_in_tab: true,
|
||||
},
|
||||
browser_action: {
|
||||
default_icon: {
|
||||
16: "assets/images/16w.png",
|
||||
19: "assets/images/19w.png",
|
||||
32: "assets/images/32w.png",
|
||||
38: "assets/images/38w.png",
|
||||
},
|
||||
default_title: "__MSG_extName__",
|
||||
default_popup: "popup.html",
|
||||
},
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
resolve(__dirname, "../dist", "manifest.json"),
|
||||
JSON.stringify(manifest, null, 2),
|
||||
)
|
321
scripts/build-models.ts
Executable file
@ -0,0 +1,321 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import "dotenv/config"
|
||||
import { promises as fs } from "fs"
|
||||
import { resolve } from "path"
|
||||
import { assign, camelCase } from "lodash"
|
||||
import yaml from "js-yaml"
|
||||
import { writeFormatted } from "./utils"
|
||||
|
||||
// type Outputs = "partial input" | "input" | "object" | "inputAndObject" | "args" | "zod";
|
||||
type Output =
|
||||
| ["input", { partial?: boolean; name?: string }] //
|
||||
| ["object"]
|
||||
| ["args"]
|
||||
| ["zod"]
|
||||
|
||||
interface Model {
|
||||
as: Output[]
|
||||
extends?: string
|
||||
fields: string
|
||||
extra?: Record<string, string>
|
||||
}
|
||||
|
||||
const FIELD_REGEX =
|
||||
/^(?<name>\w+)(?<optional>\?)?(:\s*(?<type>[\w\s[\]|]+))?(\s*=\s*(?<defaultValue>.+))?$/
|
||||
|
||||
function parseField(field: string) {
|
||||
const groups = field.match(FIELD_REGEX)?.groups
|
||||
if (!groups) {
|
||||
throw new Error(`Invalid field: ${field}`)
|
||||
}
|
||||
|
||||
if (!groups.type && groups.defaultValue) {
|
||||
const v = groups.defaultValue
|
||||
if (v === "true" || v === "false") {
|
||||
groups.type = "boolean"
|
||||
}
|
||||
}
|
||||
|
||||
return groups as {
|
||||
name: string
|
||||
optional?: "?"
|
||||
type: string
|
||||
defaultValue: string
|
||||
}
|
||||
}
|
||||
|
||||
function parseFields(value: any) {
|
||||
if (typeof value === "object") {
|
||||
value = Object.entries(value)
|
||||
.map(([name, type]) => `${name}: ${type}`)
|
||||
.join("\n")
|
||||
}
|
||||
|
||||
return (value as string).trim().split("\n").map(parseField)
|
||||
}
|
||||
|
||||
const getInputName = (name: string) => (name.startsWith("Input") ? name : `Input${name}`)
|
||||
|
||||
type Generate = Generator<string | false | undefined, void, unknown>
|
||||
|
||||
async function main() {
|
||||
const folder = resolve(__dirname, "../src/shared/models")
|
||||
const source = await fs.readFile(resolve(folder, "models.yml"), "utf8")
|
||||
const json = yaml.load(source) as {
|
||||
enums: Record<string, string[]>
|
||||
imports?: string
|
||||
models: Record<string, Model>
|
||||
}
|
||||
|
||||
const models = Object.entries(json.models).map(
|
||||
([name, { as, extends: _, fields, extra }]) => ({
|
||||
name,
|
||||
as: as.map(t =>
|
||||
Array.isArray(t) ? [t[0], (assign as any)(...t.slice(1))] : [t, {}],
|
||||
) as Output[],
|
||||
extends: _,
|
||||
fields: parseFields(fields),
|
||||
extra,
|
||||
}),
|
||||
)
|
||||
|
||||
for (const model of models) {
|
||||
if (model.extends) {
|
||||
const parent = models.find(m => m.name === model.extends)
|
||||
if (!parent) {
|
||||
throw new Error(`Could not find parent ${model.extends}`)
|
||||
}
|
||||
model.fields = parent.fields.concat(model.fields)
|
||||
}
|
||||
}
|
||||
|
||||
const importedEnums = new Set<string>()
|
||||
const enumNames = Object.keys(json.enums)
|
||||
|
||||
function getReifiedType(type: string): string {
|
||||
if (type.endsWith("| null")) {
|
||||
type = type.slice(0, -6).trim()
|
||||
}
|
||||
if (type.endsWith("[]")) {
|
||||
return `[${getReifiedType(type.slice(0, -2))}]`
|
||||
}
|
||||
switch (type) {
|
||||
case "string":
|
||||
case "String":
|
||||
return "String"
|
||||
case "int":
|
||||
case "Int":
|
||||
return "Int"
|
||||
case "boolean":
|
||||
case "Boolean":
|
||||
return "Boolean"
|
||||
default:
|
||||
if (enumNames.includes(type)) {
|
||||
importedEnums.add(type)
|
||||
}
|
||||
if (/^\d+$/.test(type)) {
|
||||
return "Int"
|
||||
}
|
||||
return type
|
||||
}
|
||||
}
|
||||
|
||||
function getVirtualType(type: string): string {
|
||||
if (type.endsWith("[]")) {
|
||||
return `${getVirtualType(type.slice(0, -2))}[]`
|
||||
} else if (type.endsWith("| null")) {
|
||||
return `${getVirtualType(type.slice(0, -6).trim())} | null`
|
||||
}
|
||||
switch (type) {
|
||||
case "int":
|
||||
case "Int":
|
||||
return "number"
|
||||
case "ID":
|
||||
case "String":
|
||||
return "string"
|
||||
case "Boolean":
|
||||
return "boolean"
|
||||
default:
|
||||
if (enumNames.includes(type)) {
|
||||
importedEnums.add(type)
|
||||
}
|
||||
return type
|
||||
}
|
||||
}
|
||||
|
||||
function getZodType(type: string): string {
|
||||
if (type.endsWith("[]")) {
|
||||
return `z.array(${getZodType(type.slice(0, -2))})`
|
||||
} else if (type.endsWith("| null")) {
|
||||
return `${getZodType(type.slice(0, -6).trim())}.optional()`
|
||||
}
|
||||
switch (type) {
|
||||
case "int":
|
||||
case "Int":
|
||||
return "z.number()"
|
||||
case "string":
|
||||
return "z.string()"
|
||||
case "boolean":
|
||||
return "z.boolean()"
|
||||
default:
|
||||
if (/^[\d.]+$/.test(type)) {
|
||||
return `z.literal(${type})`
|
||||
}
|
||||
|
||||
if (enumNames.includes(type)) {
|
||||
return `z.nativeEnum(${type})`
|
||||
}
|
||||
return `z.instanceof(${type})`
|
||||
}
|
||||
}
|
||||
|
||||
const banners: string[] = [
|
||||
`import { ArgsType, Field, ID, InputType, Int, ObjectType } from "@aet/gql-tools/macro";`,
|
||||
// `import { z } from "zod";`,
|
||||
]
|
||||
|
||||
/* eslint-disable @typescript-eslint/consistent-type-imports, @typescript-eslint/no-unused-vars, @typescript-eslint/no-inferrable-types */
|
||||
const getModels = function* (): Generate {
|
||||
for (const model of models) {
|
||||
let attachInputToObject = false
|
||||
for (const type of model.as) {
|
||||
let { name } = model
|
||||
let isInput = false
|
||||
let isPartialInput = false
|
||||
|
||||
switch (type[0]) {
|
||||
case "input":
|
||||
isInput = true
|
||||
isPartialInput = type[1].partial ?? false
|
||||
|
||||
if (
|
||||
Object.keys(type[1]).length === 0 &&
|
||||
model.as.some(t => t[0] === "object")
|
||||
) {
|
||||
attachInputToObject = true
|
||||
continue
|
||||
} else {
|
||||
name = type[1].name ?? getInputName(name)
|
||||
yield `@InputType("${name}")\n`
|
||||
}
|
||||
break
|
||||
|
||||
case "object":
|
||||
if (attachInputToObject) {
|
||||
yield `/** Input and object type for ${name} */\n`
|
||||
yield `@InputType("${getInputName(name)}")\n`
|
||||
}
|
||||
yield `@ObjectType("${name}")\n`
|
||||
break
|
||||
|
||||
case "args":
|
||||
yield `@ArgsType()\n`
|
||||
break
|
||||
|
||||
case "zod":
|
||||
continue
|
||||
}
|
||||
|
||||
yield `export class ${name} {`
|
||||
for (const field of model.fields) {
|
||||
const optional = field.optional || isPartialInput
|
||||
yield "@Field("
|
||||
|
||||
yield `() => ${getReifiedType(field.type)},`
|
||||
if (optional) {
|
||||
yield "{ nullable: true },"
|
||||
}
|
||||
yield ")\n"
|
||||
if (!field.defaultValue) {
|
||||
yield "declare "
|
||||
}
|
||||
yield `${field.name}`
|
||||
if (optional) {
|
||||
yield "?"
|
||||
}
|
||||
yield ":"
|
||||
yield getVirtualType(field.type)
|
||||
if (isInput && field.defaultValue) {
|
||||
yield ` = ${field.defaultValue}`
|
||||
}
|
||||
yield ";\n\n"
|
||||
}
|
||||
|
||||
let constructorType = name
|
||||
if (model.extra) {
|
||||
const omits: string[] = []
|
||||
for (const [name, type] of Object.entries(model.extra)) {
|
||||
if (type.includes("=")) {
|
||||
omits.push(name.replace(/\?$/, ""))
|
||||
}
|
||||
yield `${name}: ${type}\n`
|
||||
}
|
||||
constructorType = `Omit<${name}, ${omits.map(o => `"${o}"`).join(" | ")}>`
|
||||
}
|
||||
|
||||
yield /* js */ `
|
||||
/**
|
||||
* Create an instance of ${name} from a plain object.
|
||||
*/
|
||||
constructor(fields: ${constructorType}) {
|
||||
Object.assign(this, fields);
|
||||
}
|
||||
`
|
||||
|
||||
// if (1 === 3) {
|
||||
// yield "\n";
|
||||
// yield `/** Zod schema for ${name} */\n`;
|
||||
// yield "static zod = z.object({\n";
|
||||
// for (const field of model.fields) {
|
||||
// yield `${field.name}: ${getZodType(field.type)},\n`;
|
||||
// }
|
||||
// yield `}).strict();`;
|
||||
// }
|
||||
|
||||
yield "}\n\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function* getEnums() {
|
||||
for (const [name, values] of Object.entries(json.enums)) {
|
||||
yield `export const ${name} = {`
|
||||
for (const value of values) {
|
||||
yield `${value}: "${value}",\n`
|
||||
}
|
||||
yield "} as const;\n"
|
||||
yield
|
||||
yield `export type ${name} = typeof ${name}[keyof typeof ${name}];\n`
|
||||
yield
|
||||
yield `export const ${camelCase(name)}s = [${values
|
||||
.map(v => `"${v}"`)
|
||||
.join(", ")}] as ${name}[];\n`
|
||||
yield
|
||||
}
|
||||
}
|
||||
|
||||
await writeTS(resolve(folder, "models.generated.ts"), getModels, () =>
|
||||
banners.concat(
|
||||
importedEnums.size
|
||||
? `import { ${Array.from(importedEnums)
|
||||
.sort()
|
||||
.join(", ")} } from "./enums.generated";`
|
||||
: [],
|
||||
),
|
||||
)
|
||||
await writeTS(resolve(folder, "enums.generated.ts"), getEnums, () => [])
|
||||
}
|
||||
|
||||
async function writeTS(path: string, generator: () => Generate, banner: () => string[]) {
|
||||
const code = Array.from(generator(), x => x ?? "\n").join("")
|
||||
await writeFormatted(path, banner().join("\n") + "\n\n" + code)
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
Promise.resolve()
|
||||
.then(() => main())
|
||||
.catch(e => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
})
|
||||
}
|
17
scripts/build-primer-ref.ts
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import fs from "fs"
|
||||
import { resolve } from "path"
|
||||
|
||||
const path = resolve(__dirname, "../dist/reference.html")
|
||||
const html = fs
|
||||
.readFileSync(path, "utf8")
|
||||
.replace(/<script src="([\w/.]+)"><\/script>/g, (_, $1) => {
|
||||
const script = fs.readFileSync(resolve(__dirname, "../dist", $1), "utf8")
|
||||
return `<script>${script}</script>`
|
||||
})
|
||||
.replace(/<link rel="stylesheet" href="([\w/.]+)"\/>/, (_, $1) => {
|
||||
const css = fs.readFileSync(resolve(__dirname, "../dist", $1), "utf8")
|
||||
return `<style>${css}</style>`
|
||||
})
|
||||
|
||||
fs.writeFileSync(path.replace(".html", "-bundled.html"), html)
|
86
scripts/build-sass.ts
Executable file
@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import fs from "fs"
|
||||
import { resolve } from "path"
|
||||
import * as esbuild from "esbuild"
|
||||
import { file } from "./utils"
|
||||
import { getDefaultTarget } from "./plugins/esbuild-browserslist"
|
||||
|
||||
const outdir = resolve(__dirname, "../dist/vendor/sass")
|
||||
fs.rmSync(outdir, { recursive: true, force: true })
|
||||
|
||||
const prefix = `
|
||||
let window = globalThis;
|
||||
|
||||
let process = {
|
||||
env: {},
|
||||
stdout: {
|
||||
write: console.log
|
||||
},
|
||||
stderr: {
|
||||
write: console.error,
|
||||
},
|
||||
};
|
||||
`
|
||||
|
||||
const sass = fs.readFileSync(
|
||||
resolve(__dirname, "../node_modules", "sass/sass.dart.js"),
|
||||
"utf-8",
|
||||
)
|
||||
|
||||
const replaced: string = sass
|
||||
.replaceAll(/typeof Buffer/g, '"undefined"')
|
||||
.replaceAll("process.stdout.isTTY", "undefined")
|
||||
.replaceAll("self.location", "window.location")
|
||||
.replace(/require\("(chokidar|readline|fs|util)"\)/g, "{}")
|
||||
.replace(
|
||||
/(accept|accept\$1|add|call|toString|parse|write|scope\$1|parse[A-Z]\w+)\$(\d): function\(/g,
|
||||
"$1$$$2(",
|
||||
)
|
||||
.replace(/\w+\.util\.inspect\.custom/g, "Symbol()")
|
||||
.replace(/(\$eq|toString|get\$\w+|join\$0): function\(/g, "$1(")
|
||||
.replace("if (dartNodeIsActuallyNode) {", "if (false) {")
|
||||
// CSP
|
||||
.replaceAll(
|
||||
/new\s+self\.Function\(\s*("[^"\\]*(?:\\.[^"\\]*)*")\s*,\s*("[^"\\]*(?:\\.[^"\\]*)*")\s*\)/g,
|
||||
(_, $1, $2) => `((${JSON.parse($1)}) => { ${JSON.parse($2)} })`,
|
||||
)
|
||||
.replaceAll(
|
||||
/new\s+self\.Function\(\s*("[^"\\]*(?:\\.[^"\\]*)*")\s*,\s*('[^'\\]*(?:\\.[^'\\]*)*')\s*\)/g,
|
||||
(_, $1, $2) =>
|
||||
`((${JSON.parse($1)}) => { ${JSON.parse(
|
||||
'"' + $2.slice(1, -1).replaceAll('"', '\\"') + '"',
|
||||
)} })`,
|
||||
)
|
||||
.trim()
|
||||
|
||||
const temporary = file.js(prefix + replaced)
|
||||
|
||||
const entry = file.js(/* js */ `
|
||||
import "${temporary.path}";
|
||||
const sass = globalThis._cliPkgExports.pop();
|
||||
sass.load({});
|
||||
|
||||
export default sass;
|
||||
`)
|
||||
|
||||
try {
|
||||
esbuild.buildSync({
|
||||
entryPoints: [entry.path],
|
||||
outfile: resolve(outdir, "index.js"),
|
||||
bundle: true,
|
||||
minify: true,
|
||||
format: "esm",
|
||||
sourcemap: "external",
|
||||
target: getDefaultTarget(),
|
||||
external: ["fs", "chokidar", "readline"],
|
||||
banner: { js: "/* eslint-disable */" },
|
||||
legalComments: "linked",
|
||||
define: {
|
||||
"process.env.NODE_ENV": '"production"',
|
||||
"process.env.NODE_DEBUG": "undefined",
|
||||
},
|
||||
})
|
||||
} finally {
|
||||
temporary.rm()
|
||||
entry.rm()
|
||||
}
|
103
scripts/build-schema-file.ts
Executable file
@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import fs from "fs"
|
||||
import { build } from "esbuild"
|
||||
import { printSchema } from "graphql"
|
||||
import type { Visitor } from "@babel/core"
|
||||
import { getBasicOptions } from "./build-apps"
|
||||
import { file } from "./utils"
|
||||
import { dependencies, devDependencies } from "../package.json"
|
||||
import type * as schema from "../src/background/graphql/schema"
|
||||
|
||||
const output = file.js()
|
||||
|
||||
const DEBUG = !!process.env.DEBUG
|
||||
|
||||
const babelPlugin: Visitor<{ filename: string }> = {
|
||||
ClassMethod({ node }) {
|
||||
node.params = []
|
||||
node.async = false
|
||||
node.body.body = []
|
||||
},
|
||||
ClassPrivateMethod(path) {
|
||||
path.remove()
|
||||
},
|
||||
ClassProperty({ node }) {
|
||||
node.value = null
|
||||
},
|
||||
FunctionDeclaration({ node }, { filename }) {
|
||||
if (!filename.includes("graphql")) {
|
||||
node.body.body = []
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export async function buildSchema() {
|
||||
await build({
|
||||
...getBasicOptions({
|
||||
entryPoints: ["src/background/graphql/schema.ts"],
|
||||
babelPlugins: [() => ({ visitor: babelPlugin })],
|
||||
plugins: [
|
||||
{
|
||||
name: "no-lib",
|
||||
setup(build) {
|
||||
const noop = require.resolve("lodash/noop")
|
||||
const whitelist = new Set([
|
||||
"graphql-type-json",
|
||||
"reflect-metadata",
|
||||
"tslib",
|
||||
"lodash",
|
||||
"@aet/gql-tools/marco",
|
||||
"@aet/gql-tools/type-graphql",
|
||||
])
|
||||
const noopRes = { path: noop, external: false }
|
||||
|
||||
build.onResolve({ filter: /.*/ }, ({ path }) => {
|
||||
if (
|
||||
path.includes("couchdb") ||
|
||||
path.includes("idb") ||
|
||||
path.includes("compiler") ||
|
||||
path.includes("webextension")
|
||||
) {
|
||||
return noopRes
|
||||
}
|
||||
if (/^(~|\.\.?)\//.test(path)) {
|
||||
return null
|
||||
}
|
||||
if (whitelist.has(path)) {
|
||||
return { path: require.resolve(path), external: true }
|
||||
}
|
||||
return noopRes
|
||||
})
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
outfile: output.path,
|
||||
target: "node20",
|
||||
format: "cjs",
|
||||
minify: !DEBUG,
|
||||
keepNames: true,
|
||||
legalComments: "none",
|
||||
sourcemap: false,
|
||||
splitting: false,
|
||||
external: Object.keys(dependencies || {})
|
||||
.concat(Object.keys(devDependencies))
|
||||
.concat("@aet/gql-tools/type-graphql"),
|
||||
})
|
||||
.then(() => {
|
||||
const { getSchema } = require("../" + output.path) as typeof schema
|
||||
const result = printSchema(getSchema())
|
||||
fs.writeFileSync("./src/generated/schema.gql", result)
|
||||
|
||||
return result
|
||||
})
|
||||
.finally(() => {
|
||||
if (!DEBUG) {
|
||||
output.rm()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
void buildSchema()
|
||||
}
|
59
scripts/build-shims.js
Executable file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env node
|
||||
/* eslint-disable spaced-comment */
|
||||
// @ts-check
|
||||
const fs = require("fs")
|
||||
const { resolve } = require("path")
|
||||
const pkg = require("../package.json")
|
||||
|
||||
/**
|
||||
* @param {TemplateStringsArray} args
|
||||
*/
|
||||
function _([source]) {
|
||||
return {
|
||||
"index.js": `module.exports = ${source};\n`,
|
||||
"index.mjs": `export default ${source};\n`,
|
||||
"package.json": JSON.stringify({ module: "index.mjs", version: "1.0.0" }),
|
||||
}
|
||||
}
|
||||
|
||||
const { entries, fromEntries } = Object
|
||||
|
||||
/**
|
||||
* @param {Record<string, Record<string, string>>} list
|
||||
*/
|
||||
function createShims(list) {
|
||||
/** @type {Record<string, string>} */
|
||||
const resolutions = fromEntries(
|
||||
entries(pkg.resolutions).filter(([, path]) => !path.startsWith("./shims")),
|
||||
)
|
||||
|
||||
for (const [name, content] of entries(list)) {
|
||||
const dir = resolve(__dirname, "../shims", name)
|
||||
fs.mkdirSync(dir, { recursive: true })
|
||||
content["package.json"] ??= "{}"
|
||||
|
||||
for (let [fileName, text] of entries(content)) {
|
||||
if (fileName === "package.json") {
|
||||
text = JSON.stringify({ name, ...JSON.parse(text) })
|
||||
}
|
||||
fs.writeFileSync(resolve(dir, fileName), text)
|
||||
}
|
||||
|
||||
resolutions[name] = `./shims/${name}`
|
||||
}
|
||||
|
||||
pkg.resolutions =
|
||||
/** @type {any} */
|
||||
(fromEntries(entries(resolutions).sort(([a], [b]) => a.localeCompare(b))))
|
||||
|
||||
fs.writeFileSync(resolve(__dirname, "../package.json"), JSON.stringify(pkg, null, 2))
|
||||
}
|
||||
|
||||
createShims({
|
||||
"cross-fetch": {
|
||||
"index.js": /*js*/ `module.exports = fetch; const headers = Headers; module.exports.Headers = headers;`,
|
||||
"index.mjs": /*js*/ `export default fetch; const headers = Headers; export { headers as Headers };`,
|
||||
"package.json": JSON.stringify({ module: "index.mjs", version: "1.0.0" }),
|
||||
},
|
||||
"is-number": _/*js*/ `value => typeof value === "number"`,
|
||||
})
|
110
scripts/build-theme.tsx
Executable file
@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env -S node -r esbin
|
||||
import { promises as fs } from "fs"
|
||||
import { resolve } from "path"
|
||||
import sass from "sass"
|
||||
import { kebabCase } from "lodash"
|
||||
import { tokenSource } from "~/shared/theme/tokens"
|
||||
|
||||
const trim = (s: string) => s.trim()
|
||||
|
||||
const [, outdir] = process.argv.slice(2)
|
||||
// This file is used to `make theme`.
|
||||
namespace primer {
|
||||
// https://github.com/primer/github-vscode-theme/commit/5f08d0cc4de8abc33e13c3f63fe92288824a11cf
|
||||
// prettier-ignore
|
||||
const classic = {
|
||||
black: "#1b1f23",
|
||||
white: "#fff",
|
||||
gray: ["#fafbfc", "#f6f8fa", "#e1e4e8", "#d1d5da", "#959da5", "#6a737d", "#586069", "#444d56", "#2f363d", "#24292e"],
|
||||
blue: ["#f1f8ff", "#dbedff", "#c8e1ff", "#79b8ff", "#2188ff", "#0366d6", "#005cc5", "#044289", "#032f62", "#05264c"],
|
||||
green: ["#f0fff4", "#dcffe4", "#bef5cb", "#85e89d", "#34d058", "#28a745", "#22863a", "#176f2c", "#165c26", "#144620"],
|
||||
yellow: ["#fffdef", "#fffbdd", "#fff5b1", "#ffea7f", "#ffdf5d", "#ffd33d", "#f9c513", "#dbab09", "#b08800", "#735c0f"],
|
||||
orange: ["#fff8f2", "#ffebda", "#ffd1ac", "#ffab70", "#fb8532", "#f66a0a", "#e36209", "#d15704", "#c24e00", "#a04100"],
|
||||
red: ["#ffeef0", "#ffdce0", "#fdaeb7", "#f97583", "#ea4a5a", "#d73a49", "#cb2431", "#b31d28", "#9e1c23", "#86181d"],
|
||||
purple: ["#f5f0ff", "#e6dcfd", "#d1bcf9", "#b392f0", "#8a63d2", "#6f42c1", "#5a32a3", "#4c2889", "#3a1d6e", "#29134e"],
|
||||
pink: ["#ffeef8", "#fedbf0", "#f9b3dd", "#f692ce", "#ec6cb9", "#ea4aaa", "#d03592", "#b93a86", "#99306f", "#6d224f"]
|
||||
};
|
||||
|
||||
function addClassic(css: string, dark: boolean) {
|
||||
const r = (name: string, value?: string) =>
|
||||
(css = css.replace(
|
||||
RegExp(/(--color-NAME: )([^;]+);/.source.replace("NAME", name)),
|
||||
(_, name, originalValue) => `${name}${value ?? originalValue};`,
|
||||
))
|
||||
|
||||
r("canvas-default", dark ? "#1f2428" : undefined)
|
||||
return css
|
||||
}
|
||||
|
||||
function sassCompile(code: string) {
|
||||
return sass.compileString(code, {
|
||||
loadPaths: [resolve(__dirname, "../node_modules")],
|
||||
style: "compressed",
|
||||
}).css
|
||||
}
|
||||
|
||||
export async function main() {
|
||||
const outputDir = resolve(__dirname, "../dist/vendor/primer")
|
||||
await fs.mkdir(outputDir, { recursive: true })
|
||||
|
||||
const themes = {
|
||||
dark: "dark-default",
|
||||
dark_colorblind: undefined,
|
||||
dark_dimmed: undefined,
|
||||
dark_high_contrast: undefined,
|
||||
dark_tritanopia: undefined,
|
||||
light: "light-default",
|
||||
light_colorblind: undefined,
|
||||
light_high_contrast: undefined,
|
||||
light_tritanopia: undefined,
|
||||
}
|
||||
|
||||
const toRoot = (name: string, themeName = name) =>
|
||||
sassCompile(/* scss */ `
|
||||
@use "@primer/primitives/dist/scss/colors/_${name}.scss" as *;
|
||||
:root[data-theme="github-${themeName}"] {
|
||||
@include primer-colors-${name};
|
||||
}
|
||||
`)
|
||||
|
||||
await Promise.all([
|
||||
...Object.entries(themes).map(([source, name = source]) =>
|
||||
fs.writeFile(resolve(outputDir, `github-${name}.css`), toRoot(source, name)),
|
||||
),
|
||||
fs.writeFile(
|
||||
resolve(outputDir, "github-dark.css"),
|
||||
addClassic(toRoot("dark"), true),
|
||||
),
|
||||
fs.writeFile(
|
||||
resolve(outputDir, "github-light.css"),
|
||||
addClassic(toRoot("light"), false),
|
||||
),
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
async function tokens() {
|
||||
const declarations = Object.entries(tokenSource).map(([name, value]) => {
|
||||
const [light, dark] = value.trim().split(",").map(trim)
|
||||
return { name, light, dark }
|
||||
})
|
||||
|
||||
await fs.writeFile(
|
||||
resolve(outdir, "tokens.generated.css"),
|
||||
[
|
||||
"body{",
|
||||
...declarations.map(({ name, light }) => `--${kebabCase(name)}:${light};`),
|
||||
"}",
|
||||
"body.dark{",
|
||||
...declarations.map(({ name, dark }) => `--${kebabCase(name)}:${dark};`),
|
||||
"}",
|
||||
].join(""),
|
||||
)
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await tokens()
|
||||
await primer.main()
|
||||
}
|
||||
|
||||
main()
|
29
scripts/build.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
if [ "$1" = "monaco" ]; then
|
||||
rm -rf "dist/vendor/vs"
|
||||
path=$(dirname "$(node -p "require.resolve('monaco-editor/package.json')")")/min/vs
|
||||
cp -r "$path" "dist/vendor/vs"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
export NODE_ENV=production
|
||||
make all
|
||||
echo "✨ Downloading locales..."
|
||||
# crowdin download
|
||||
echo "✨ Building gql..."
|
||||
./scripts/build-gql.ts
|
||||
echo "✨ Building apps..."
|
||||
./scripts/build-apps.ts -s
|
||||
echo "✨ Building license..."
|
||||
./scripts/build-license.ts
|
||||
else
|
||||
path=$(find ./scripts -type f -name "build-$1.*")
|
||||
if [ -z "$path" ]; then
|
||||
echo "Unknown task '$1'."
|
||||
exit 1
|
||||
fi
|
||||
$path "$@"
|
||||
fi
|
37
scripts/plugins/babel-component-name.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import type { BabelPlugin } from "./esbuild-babel"
|
||||
|
||||
export const componentName =
|
||||
(): BabelPlugin =>
|
||||
({ types: t }) => ({
|
||||
name: "babel-plugin-component-name",
|
||||
visitor: {
|
||||
ReturnStatement(path) {
|
||||
if (!t.isJSXElement(path.node.argument)) return
|
||||
|
||||
const funcParent = path.getFunctionParent()
|
||||
if (funcParent == null || !t.isArrowFunctionExpression(funcParent.node)) return
|
||||
|
||||
let id: string | undefined
|
||||
|
||||
if (
|
||||
t.isCallExpression(funcParent.parent) &&
|
||||
t.isIdentifier(funcParent.parent.callee) &&
|
||||
t.isVariableDeclarator(funcParent.parentPath.parent) &&
|
||||
t.isIdentifier(funcParent.parentPath.parent.id)
|
||||
) {
|
||||
id = funcParent.parentPath.parent.id.name
|
||||
} else if (
|
||||
t.isVariableDeclarator(funcParent.parent) &&
|
||||
t.isIdentifier(funcParent.parent.id)
|
||||
) {
|
||||
id = funcParent.parent.id.name
|
||||
}
|
||||
|
||||
if (id != null) {
|
||||
path.node.argument.openingElement.attributes.unshift(
|
||||
t.jsxAttribute(t.jsxIdentifier("data-component"), t.stringLiteral(id)),
|
||||
)
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
100
scripts/plugins/babel-constant-element.ts
Normal file
@ -0,0 +1,100 @@
|
||||
// https://github.com/babel/babel/blob/c38bf12f010520ea7abe8a286f62922b2d1e1f1b/packages/babel-plugin-transform-react-constant-elements/src/index.ts
|
||||
import type { Visitor } from "@babel/core"
|
||||
import type { PluginObj, types as t } from "@babel/core"
|
||||
|
||||
interface PluginState {
|
||||
isImmutable: boolean
|
||||
mutablePropsAllowed?: boolean
|
||||
}
|
||||
|
||||
export default (allowMutablePropsOnTags?: string[]): PluginObj => {
|
||||
const HOISTED = new WeakSet()
|
||||
|
||||
const immutabilityVisitor: Visitor<PluginState> = {
|
||||
enter(path, state) {
|
||||
const stop = () => {
|
||||
state.isImmutable = false
|
||||
path.stop()
|
||||
}
|
||||
|
||||
if (path.isJSXClosingElement()) {
|
||||
path.skip()
|
||||
return
|
||||
}
|
||||
|
||||
// Elements with refs are not safe to hoist.
|
||||
if (
|
||||
path.isJSXIdentifier({ name: "ref" }) &&
|
||||
path.parentPath.isJSXAttribute({ name: path.node })
|
||||
) {
|
||||
return stop()
|
||||
}
|
||||
|
||||
// Ignore identifiers & JSX expressions.
|
||||
if (path.isJSXIdentifier() || path.isIdentifier() || path.isJSXMemberExpression()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!path.isImmutable()) {
|
||||
// If it's not immutable, it may still be a pure expression, such as string concatenation.
|
||||
// It is still safe to hoist that, so long as its result is immutable.
|
||||
// If not, it is not safe to replace as mutable values (like objects) could be mutated after render.
|
||||
// https://github.com/facebook/react/issues/3226
|
||||
if (path.isPure()) {
|
||||
const { confident, value } = path.evaluate()
|
||||
if (confident) {
|
||||
// We know the result; check its mutability.
|
||||
const isMutable =
|
||||
(!state.mutablePropsAllowed && value && typeof value === "object") ||
|
||||
typeof value === "function"
|
||||
if (!isMutable) {
|
||||
// It evaluated to an immutable value, so we can hoist it.
|
||||
path.skip()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
stop()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
return {
|
||||
name: "transform-react-constant-elements",
|
||||
|
||||
visitor: {
|
||||
Program(program) {
|
||||
program.traverse({
|
||||
JSXElement(path) {
|
||||
if (HOISTED.has(path.node)) return
|
||||
HOISTED.add(path.node)
|
||||
|
||||
const state: PluginState = { isImmutable: true }
|
||||
|
||||
// This transform takes the option `allowMutablePropsOnTags`, which is an array
|
||||
// of JSX tags to allow mutable props (such as objects, functions) on. Use sparingly
|
||||
// and only on tags you know will never modify their own props.
|
||||
if (allowMutablePropsOnTags != null) {
|
||||
// Get the element's name. If it's a member expression, we use the last part of the path.
|
||||
// So the option ["FormattedMessage"] would match "Intl.FormattedMessage".
|
||||
let namePath = path.get("openingElement").get("name")
|
||||
while (namePath.isJSXMemberExpression()) {
|
||||
namePath = namePath.get("property")
|
||||
}
|
||||
|
||||
const elementName = (namePath.node as t.JSXIdentifier).name
|
||||
state.mutablePropsAllowed = allowMutablePropsOnTags.includes(elementName)
|
||||
}
|
||||
|
||||
// Traverse all props passed to this element for immutability.
|
||||
path.traverse(immutabilityVisitor, state)
|
||||
|
||||
if (state.isImmutable) {
|
||||
path.hoist(path.scope)
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
54
scripts/plugins/babel-dynamic-import.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import { dirname } from "path"
|
||||
import glob from "fast-glob"
|
||||
import type { types } from "@babel/core"
|
||||
import type { BabelPlugin } from "./esbuild-babel"
|
||||
|
||||
const skip = new WeakSet<types.CallExpression>()
|
||||
|
||||
export const dynamicImport =
|
||||
(filePath: string): BabelPlugin =>
|
||||
({ types: t }) => ({
|
||||
name: "dynamic-import",
|
||||
visitor: {
|
||||
Import(path) {
|
||||
if (
|
||||
!t.isCallExpression(path.parent) ||
|
||||
path.parent.arguments.length !== 1 ||
|
||||
skip.has(path.parent)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
const [arg] = path.parent.arguments
|
||||
if (!t.isTemplateLiteral(arg)) {
|
||||
return
|
||||
}
|
||||
|
||||
const key = path.scope.generateDeclaredUidIdentifier("key")
|
||||
|
||||
const globText = arg.quasis.map(x => x.value.raw).join("*")
|
||||
const globCandidates = glob.sync(globText, {
|
||||
cwd: dirname(filePath),
|
||||
})
|
||||
|
||||
const clone = t.cloneNode(path.parent, true)
|
||||
skip.add(clone)
|
||||
|
||||
const cond = globCandidates.reduceRight(
|
||||
(accum: types.Expression, cur) =>
|
||||
t.conditionalExpression(
|
||||
t.binaryExpression("===", key, t.stringLiteral(cur)),
|
||||
t.callExpression(t.import(), [t.stringLiteral(cur)]),
|
||||
accum,
|
||||
),
|
||||
clone,
|
||||
)
|
||||
|
||||
t.cloneNode(path.parent)
|
||||
|
||||
path.parentPath.replaceWith(
|
||||
t.sequenceExpression([t.assignmentExpression("=", key, arg), cond]),
|
||||
)
|
||||
},
|
||||
},
|
||||
})
|
30
scripts/plugins/babel-filename.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { basename, dirname } from "path"
|
||||
import type { BabelPlugin } from "./esbuild-babel"
|
||||
|
||||
export const fileName =
|
||||
({
|
||||
hasFileName,
|
||||
hasDirName,
|
||||
path,
|
||||
}: {
|
||||
hasFileName: boolean
|
||||
hasDirName: boolean
|
||||
path: string
|
||||
}): BabelPlugin =>
|
||||
({ types: t }) => ({
|
||||
name: "__filename polyfill",
|
||||
visitor: {
|
||||
Program(program) {
|
||||
const assign = (id: string, value: string) =>
|
||||
t.variableDeclaration("var", [
|
||||
t.variableDeclarator(t.identifier(id), t.stringLiteral(value)),
|
||||
])
|
||||
if (hasFileName) {
|
||||
program.node.body.unshift(assign("__filename", basename(path)))
|
||||
}
|
||||
if (hasDirName) {
|
||||
program.node.body.unshift(assign("__dirname", dirname(path)))
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|