36 Commits

Author SHA1 Message Date
Simon Schneegans
ba92b7eb01 🔧 Try downgrading the node version 2023-11-14 05:28:19 +01:00
Simon Schneegans
e9a478b161 📝 Use new action version in README 2023-10-19 08:43:38 +02:00
Simon Schneegans
9c9369564f 🎉 Set release date 2023-10-19 08:40:26 +02:00
Simon Schneegans
0b9acddcd9 🚚 Rename workflow 2023-10-15 14:14:37 +02:00
Simon Schneegans
6fc1f63194 🪲 Fix checks.yml 2023-10-15 14:13:54 +02:00
Simon Schneegans
21aa491bfe 🔧 Add REUSE CI check 2023-10-15 14:11:49 +02:00
Simon Schneegans
85d3a60c7c 📝 Add REUSE badge 2023-10-15 14:11:31 +02:00
Simon Schneegans
4f84090196 ©️ Make source code compliant with the REUSE specification 2023-10-15 14:05:42 +02:00
Simon Schneegans
df99dd9ef9 📝 Add funding information 2023-10-15 13:45:58 +02:00
Simon Schneegans
15bd3e7cdb 📝 Add emoji badges 2023-10-10 05:18:21 +02:00
Simon Schneegans
6f4d615b2f 🪲 Fix emoji labels or messages 2023-10-09 08:24:17 +02:00
Simon Schneegans
856e1f2e74 📝 Add changelog entry 2023-10-07 20:24:07 +02:00
Simon Schneegans
e7fa53f37a 🪲 Fix check of previous content 2023-10-07 20:21:16 +02:00
Simon Schneegans
37eecceda2 🔥 Remove obsolete .clang-format file 2023-10-07 19:31:40 +02:00
Simon Schneegans
5ab7837fab Format with prettier 2023-10-07 19:31:13 +02:00
Simon Schneegans
d5f166a320 📝 Fix typos 2023-10-07 19:28:48 +02:00
Simon Schneegans
1929292faa 🔀 Merge pull request #27 from Schneegans/feature/configurable-host 2023-10-07 19:26:49 +02:00
Simon Schneegans
d57076bbf1 📝 Add changelog entry 2023-10-07 18:54:07 +02:00
Simon Schneegans
cb47279d08 📝 Add example enterprise host 2023-10-07 18:53:56 +02:00
Simon Schneegans
5dcfe114e3 📝 Document new host parameter 2023-10-07 18:49:42 +02:00
Simon Schneegans
606d12105c 🎉 Add host parameter 2023-10-07 18:49:27 +02:00
Simon Schneegans
efee8f7380 🪲 Fix JSON format 2023-10-07 18:42:04 +02:00
Simon Schneegans
ab9ff3b656 🔧 Do not use flat style for SVG badge 2023-10-07 18:38:06 +02:00
Simon Schneegans
a8a8d67cdc 🔀 Merge pull request #26 from Schneegans/feature/save-svg 2023-10-07 18:31:49 +02:00
Simon Schneegans
f2c09261b6 📝 Add changelog entry 2023-10-07 14:25:35 +02:00
Simon Schneegans
2312543959 📝 Tweak SVG mode docs 2023-10-07 14:20:51 +02:00
Simon Schneegans
8a2e8ac875 🔧 Run action on master 2023-10-07 14:20:31 +02:00
Simon Schneegans
125de5dc2e 📝 Add notes on SVG mode 2023-10-07 14:07:39 +02:00
Simon Schneegans
a87eb6e585 Format README 2023-10-07 13:35:03 +02:00
Simon Schneegans
e403e5ef44 🔧 Try some svg badge option 2023-10-05 20:36:08 +02:00
Simon Schneegans
371e351370 🔧 Use test branch 2023-10-05 19:55:47 +02:00
Simon Schneegans
f8242b8176 🪲 Fix YML 2023-10-05 19:53:38 +02:00
Simon Schneegans
bedec0d40d 🎉 Add test svg badge 2023-10-05 19:52:33 +02:00
Simon Schneegans
1f41b12ce6 🔀 Merge pull request #25 from runarberg/implement-direct-svg-badges 2023-10-05 19:47:41 +02:00
Rúnar Berg
a2d3829b14 Add save svg-badge directly to gist
This adds the posibility of saving an SVG badge generated by the same
shields.io dirictly to the gist. Instead of prepering a JSON file to
be sent to their service, we use their library directly, which outputs
an SVG file that we can save to the user’s gist.

Filenames ending in `.svg` will use this library automatically.

Additionally there is a major refactoring where the older `node:http`
library has been swapped out for `fetch`.

Also swap from node 16 to node 20

fixes #24
2023-10-05 08:29:45 -07:00
Simon Schneegans
b7809ee0af 📝 Add note on Dependabot 2022-11-07 19:57:47 +01:00
74 changed files with 5174 additions and 264 deletions

View File

@@ -1,4 +0,0 @@
BasedOnStyle: Google
ColumnLimit: 90
AlignConsecutiveAssignments: true
KeepEmptyLinesAtTheStartOfBlocks: true

10
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
# SPDX-License-Identifier: CC0-1.0
github: schneegans
ko_fi: schneegans
custom:
[
"https://www.paypal.com/donate/?hosted_button_id=3F7UFL8KLVPXE",
https://schneegans.cb.id,
]

View File

@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
# SPDX-License-Identifier: CC0-1.0
name: Build Badges
on: [push]
@@ -21,6 +24,21 @@ jobs:
maxColorRange: 100
minColorRange: 0
svg-badge:
name: Create SVG Badge
runs-on: ubuntu-latest
steps:
- name: Create the Badge
uses: schneegans/dynamic-badges-action@master
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 2ab8f1d386f13aaebccbd87dac94068d
filename: badge.svg
label: This is
message: an SVG badge
color: red
labelColor: blue
color-range-badges:
name: "Create Color Range Badges"
runs-on: ubuntu-latest
@@ -56,4 +74,3 @@ jobs:
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ matrix.total }}

18
.github/workflows/checks.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
# SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
# SPDX-License-Identifier: CC0-1.0
name: Checks
on:
push:
branches:
- "**"
jobs:
reuse:
name: Check REUSE
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1

41
.reuse/dep5 Normal file
View File

@@ -0,0 +1,41 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files: package.json package-lock.json node_modules/.package-lock.json
Copyright: Simon Schneegans <code@simonschneegans.de>
License: CC0-1.0
Files: node_modules/@actions/*
Copyright: GitHub
License: MIT
Files: node_modules/anafanafo/* node_modules/char-width-table-consumer/*
Copyright: Metabolize LLC
License: MIT
Files: node_modules/badge-maker/*
Copyright: Thaddée Tyl <thaddee.tyl@gmail.com>
License: CC0-1.0
Files: node_modules/binary-search/*
Copyright: The Dark Sky Company, LLC
License: CC0-1.0
Files: node_modules/color-convert/*
Copyright: Heather Arthur <fayearthur@gmail.com>
License: MIT
Files: node_modules/color-name/*
Copyright: DY <dfcreative@gmail.com>
License: MIT
Files: node_modules/css-color-converter/* node_modules/css-unit-converter/*
Copyright: Andy Jansson
License: MIT
Files: node_modules/tunnel/*
Copyright: Koichi Kobayashi
License: MIT
Files: node_modules/uuid/*
Copyright: Robert Kieffer and other contributors
License: MIT

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 Simon Schneegans
Copyright (c) 2023 Simon Schneegans
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

156
LICENSES/CC-BY-4.0.txt Normal file
View File

@@ -0,0 +1,156 @@
Creative Commons Attribution 4.0 International
Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors.
Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensors permission is not necessary for any reasonfor example, because of any applicable exception or limitation to copyrightthen that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public.
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
Section 1 Definitions.
a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights under this Public License.
i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
Section 2 Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
A. reproduce and Share the Licensed Material, in whole or in part; and
B. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
3. Term. The term of this Public License is specified in Section 6(a).
4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
5. Downstream recipients.
A. Offer from the Licensor Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this Public License.
3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties.
Section 3 License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified form), You must:
A. retain the following if it is supplied by the Licensor with the Licensed Material:
i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of warranties;
v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License.
Section 4 Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database;
b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
Section 5 Disclaimer of Warranties and Limitation of Liability.
a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
Section 6 Term and Termination.
a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
2. upon express reinstatement by the Licensor.
c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
Section 7 Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
Section 8 Interpretation.
a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
Creative Commons may be contacted at creativecommons.org.

121
LICENSES/CC0-1.0.txt Normal file
View File

@@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.

9
LICENSES/MIT.txt Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

159
README.md
View File

@@ -1,15 +1,23 @@
# Dynamic Badges Action
<!--
SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
SPDX-License-Identifier: CC-BY-4.0
-->
# 🏷️ Dynamic Badges Action
[![badges](https://github.com/Schneegans/dynamic-badges-action/workflows/Build%20Badges/badge.svg)](https://github.com/Schneegans/dynamic-badges-action/actions)
[![license](https://img.shields.io/badge/License-MIT-purple.svg)](LICENSE)
[![reuse](https://api.reuse.software/badge/github.com/schneegans/dynamic-badges-action)](https://api.reuse.software/info/github.com/schneegans/dynamic-badges-action)
[![market](https://img.shields.io/badge/Get_it-on_the_Marketplace-informational.svg)](https://github.com/marketplace/actions/dynamic-badges)
[![donations](https://gist.githubusercontent.com/Schneegans/2d06edf0937c480951feb86b9e719304/raw/weekly.svg)](https://schneegans.github.io/sponsors/)
This action allows you to create badges for your README.md with [shields.io](https://shields.io) which may change with every commit. To do this, this action does not need to push anything to your repository!
This action supports all [configuration options of shields.io/endpoint](https://shields.io/endpoint) and can be used in various ways:
* Show custom CI statistics from GitHub actions, such as code coverage or detailed test results.
* Show metadata of your repository such as [lines of code, comment line percentage](https://schneegans.github.io/tutorials/2022/04/18/badges), ...
* Basically anything which may change from commit to commit!
- Show custom CI statistics from GitHub actions, such as code coverage or detailed test results.
- Show metadata of your repository such as [lines of code, comment line percentage](https://schneegans.github.io/tutorials/2022/04/18/badges), ...
- Basically anything which may change from commit to commit!
## How Does It Work?
@@ -25,33 +33,56 @@ This JSON object may look like this:
}
```
This JSON object is then uploaded as a file to a *gist* ([click here for an example](https://gist.github.com/Schneegans/2ab8f1d386f13aaebccbd87dac94068d)) and can be transformed to a badge like [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/hello-world.json)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/hello-world.json) with the **shields.io/endpoint**. Here is the URL of this example badge:
This JSON object is then uploaded to a _gist_ ([click here for an example](https://gist.github.com/Schneegans/2ab8f1d386f13aaebccbd87dac94068d)) and automatically transformed to [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/hello-world.json)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/hello-world.json) with the **shields.io/endpoint**.
```
https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/hello-world.json
<details><summary>Show Markdown of this Badge!</summary>
```md
![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/hello-world.json)
```
## Configuration
</details>
### SVG Mode
The action also supports an _SVG mode_ in which the badge is created directly by the action and uploaded as image to the gist.
This mode does not support all features of shields.io but is useful if you cannot use shields.io for some reason.
[![badge](https://gist.githubusercontent.com/Schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/badge.svg)](https://gist.githubusercontent.com/Schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/badge.svg) which is directly stored in a gist.
<details><summary>Show Markdown of this Badge!</summary>
```md
![badge](https://gist.githubusercontent.com/Schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/badge.svg)
```
</details>
### Use Emoji!
Both, JSON and SVG mode support emoji in the label and message.
However, this is especially great in SVG mode which does not support icons. Here's an SVG emoji badge which does not use shields.io at all: ![badge](https://gist.githubusercontent.com/Schneegans/2d06edf0937c480951feb86b9e719304/raw/weekly.svg).
## 🛠️ Configuration
1. Head over to [gist.github.com](https://gist.github.com/) and create a new gist. You can name the file `test.json`, but this can be changed later as well. You will need the ID of the gist (this is the long alphanumerical part of its URL) later.
2. Navigate to [github.com/settings/tokens](https://github.com/settings/tokens) and create a new token with the *gist* scope.
3. Go to the *Secrets* page of the settings of your repository and add this token as a new secret. You can give it any name, for example `GIST_SECRET`.
2. Navigate to [github.com/settings/tokens](https://github.com/settings/tokens) and create a new token with the _gist_ scope.
3. Go to the _Secrets_ page of the settings of your repository (Settings > Secrets > Actions) and add this token as a new secret. You can give it any name, for example `GIST_SECRET`. **If you use Dependabot to automatically update dependencies of your repository, you also have to add this secret to Dependabot's secrets (Settings > Secrets > Dependabot).**
4. Add something like the following to your workflow:
```yml
- name: Create Awesome Badge
uses: schneegans/dynamic-badges-action@v1.6.0
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: <gist-ID>
filename: test.json
filename: test.json # Use test.svg if you want to use the SVG mode.
label: Hello
message: World
color: orange
```
Once the action is executed, go to your gist.
There should be a new file called `test.json`.
You can view the raw content of this file at `https://gist.githubusercontent.com/<user>/<gist-ID>/raw/test.json`.
There should be a new file called `test.json` (or `test.svg` if you used SVG mode).
Embed the badge with:
```markdown
@@ -60,39 +91,38 @@ Embed the badge with:
### Required Input Parameters
Parameter | Description
----------|------------
`auth` | A secret token with the *gist* scope.
`gistID` | The ID of the target gist. Something like `8f6459c2417de7534f64d98360dde866`.
`filename` | The target filename - each gist may contain several files. This should have the `.json` extension.
| Parameter | Description |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `auth` | A secret token with the _gist_ scope. |
| `gistID` | The ID of the target gist. Something like `8f6459c2417de7534f64d98360dde866`. |
| `filename` | The target filename - each gist may contain several files. This should have a `.json` extension if you want to use **shields.io/endpoint** or an `.svg` extension if you want to use the **SVG mode** described above. |
### Optional Input Parameters
Parameter | Description
----------|------------
`forceUpdate` | Default is `false`. If set to `true`, the gist will be updated even if the content did not change.
| Parameter | Description | Supported in SVG Mode |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
| `host` | Default is `https://api.github.com/gists/`. You can change this if you're using GitHub enterprise. The URL will be something like `github-enterprise-hostname/api/v3/gists`. | ✅ |
| `forceUpdate` | Default is `false`. If set to `true`, the gist will be updated even if the content did not change. | ✅ |
### Shields.io Parameters (optional)
All these parameters are optional.
They are directly passed to [shields.io](https://shields.io). See the [official documentation](https://shields.io/endpoint) for more detailed explanations.
Parameter | Description
----------|------------
`label` | Required. The left text of the badge.
`message` | Required. The right text of the badge.
`labelColor` | The left color of the badge.
`color` | The right color of the badge. For custom colors wrap color string in quotes `"#bf155b"`. This parameter is ignored if the `valColorRange`, `maxColorRange`, and `minColorRange` are set.
`isError` | The color will be red and cannot be overridden.
`namedLogo` | A logo name from [simpleicons.org](http://simpleicons.org/).
`logoSvg` | An svg-string to be used as logo.
`logoColor` | The color for the logo.
`logoWidth` | The space allocated for the logo.
`logoPosition` | The position of the logo.
`style` | The style like "flat" or "social".
`cacheSeconds` | The cache lifetime in seconds (must be greater than 300).
| Parameter | Description | Supported in SVG Mode |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
| `label` | Required. The left text of the badge. | ✅ |
| `message` | Required. The right text of the badge. | ✅ |
| `labelColor` | The left color of the badge. | ✅ |
| `color` | The right color of the badge. For custom colors wrap color string in quotes `"#bf155b"`. This parameter is ignored if the `valColorRange`, `maxColorRange`, and `minColorRange` are set. | ✅ |
| `isError` | The color will be red and cannot be overridden. | |
| `namedLogo` | A logo name from [simpleicons.org](http://simpleicons.org/). | |
| `logoSvg` | An svg-string to be used as logo. | |
| `logoColor` | The color for the logo. | |
| `logoWidth` | The space allocated for the logo. | |
| `logoPosition` | The position of the logo. | |
| `style` | The style like "flat" or "social". | ✅ |
| `cacheSeconds` | The cache lifetime in seconds (must be greater than 300). | |
### Color Range Parameters (optional)
@@ -112,15 +142,14 @@ Starting with version 1.3.0 of this action, the color of the right side of the b
For this, the following parameters can be used.
Parameter | Description
----------|------------
`valColorRange` | A numerical value used to define the message color. Usually this should be between `maxColorRange` and `minColorRange`. This is required if you want to use the color range feature.
`maxColorRange` | If `valColorRange` assumes this value, the badge will be green. This is required if you want to use the color range feature.
`minColorRange` | If `valColorRange` assumes this value, the badge will be red. This is required if you want to use the color range feature.
`invertColorRange` | If the range should be inverted, causing a smaller value to have green color. Defaults to `false`.
`colorRangeSaturation` | Saturation used by the color range feature. Defaults to 100.
`colorRangeLightness` | Lightness used by the color range feature. Defaults to 40.
| Parameter | Description | Supported in SVG Mode |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------- |
| `valColorRange` | A numerical value used to define the message color. Usually this should be between `maxColorRange` and `minColorRange`. This is required if you want to use the color range feature. | ✅ |
| `maxColorRange` | If `valColorRange` assumes this value, the badge will be green. This is required if you want to use the color range feature. | ✅ |
| `minColorRange` | If `valColorRange` assumes this value, the badge will be red. This is required if you want to use the color range feature. | ✅ |
| `invertColorRange` | If the range should be inverted, causing a smaller value to have green color. Defaults to `false`. | ✅ |
| `colorRangeSaturation` | Saturation used by the color range feature. Defaults to 100. | ✅ |
| `colorRangeLightness` | Lightness used by the color range feature. Defaults to 40. | ✅ |
### Using Environment Variables as Parameters [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)
@@ -134,7 +163,7 @@ For all values in between, the color will be interpolated.
- name: Get the Numbers
run: echo "ANSWER=42" >> $GITHUB_ENV
- name: Create the Badge
uses: schneegans/dynamic-badges-action@v1.6.0
uses: schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: <gist-ID>
@@ -148,30 +177,30 @@ For all values in between, the color will be interpolated.
## Contributing to Dynamic Badges Action
Whenever you encounter a :beetle: **bug** or have :tada: **feature request**,
report this via [Github issues](https://github.com/schneegans/dynamic-badges-action/issues).
Whenever you encounter a :beetle: **bug** or have :tada: **feature request**,
report this via [GitHub issues](https://github.com/schneegans/dynamic-badges-action/issues).
We are happy to receive contributions in the form of **pull requests** via Github.
We are happy to receive contributions in the form of **pull requests** via GitHub.
Feel free to fork the repository, implement your changes and create a merge request to the `master` branch.
### Git Commit Messages
Commits should start with a Capital letter and should be written in present tense (e.g. __:tada: Add cool new feature__ instead of __:tada: Added cool new feature__).
Commits should start with a Capital letter and should be written in present tense (e.g. **:tada: Add cool new feature** instead of **:tada: Added cool new feature**).
You should also start your commit message with **one** applicable emoji. This does not only look great but also makes you rethink what to add to a commit. Make many but small commits!
Emoji | Description
------|------------
:tada: `:tada:` | When you added a cool new feature.
:wrench: `:wrench:` | When you refactored / improved a small piece of code.
:hammer: `:hammer:` | When you refactored / improved large parts of the code.
:sparkles: `:sparkles:` | When you applied clang-format.
:art: `:art:` | When you improved / added assets like themes.
:rocket: `:rocket:` | When you improved performance.
:memo: `:memo:` | When you wrote documentation.
:beetle: `:beetle:` | When you fixed a bug.
:twisted_rightwards_arrows: `:twisted_rightwards_arrows:` | When you merged a branch.
:fire: `:fire:` | When you removed something.
:truck: `:truck:` | When you moved / renamed something.
| Emoji | Description |
| --------------------------------------------------------- | ------------------------------------------------------- |
| :tada: `:tada:` | When you added a cool new feature. |
| :wrench: `:wrench:` | When you refactored / improved a small piece of code. |
| :hammer: `:hammer:` | When you refactored / improved large parts of the code. |
| :sparkles: `:sparkles:` | When you applied clang-format. |
| :art: `:art:` | When you improved / added assets like themes. |
| :rocket: `:rocket:` | When you improved performance. |
| :memo: `:memo:` | When you wrote documentation. |
| :beetle: `:beetle:` | When you fixed a bug. |
| :twisted_rightwards_arrows: `:twisted_rightwards_arrows:` | When you merged a branch. |
| :fire: `:fire:` | When you removed something. |
| :truck: `:truck:` | When you moved / renamed something. |
### Version Numbers

View File

@@ -1,76 +1,83 @@
name: 'Dynamic Badges'
description: 'Create badges via shields.io/endpoint for your README.md which may change with every commit.'
# SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
# SPDX-License-Identifier: MIT
name: "Dynamic Badges"
description: "Create badges via shields.io/endpoint for your README.md which may change with every commit."
branding:
icon: 'tag'
color: 'green'
icon: "tag"
color: "green"
inputs:
auth:
description: 'Your secret with the gist scope'
description: "Your secret with the gist scope"
required: true
gistID:
description: 'The ID of the gist to use'
description: "The ID of the gist to use"
required: true
filename:
description: 'The *.json filename of the badge data'
description: "The *.json or *.svg filename of the badge data"
required: true
label:
description: 'The left text of the badge'
description: "The left text of the badge"
required: true
message:
description: 'The right text of the badge'
description: "The right text of the badge"
required: true
host:
description: "The base URL of the gist API"
default: "https://api.github.com/gists/"
required: false
forceUpdate:
description: 'If set to true, the gist will be updated even if the content did not change'
default: 'false'
description: "If set to true, the gist will be updated even if the content did not change"
default: "false"
required: false
labelColor:
description: 'The left color of the badge'
description: "The left color of the badge"
required: false
color:
description: 'The right color of the badge'
description: "The right color of the badge"
required: false
isError:
description: 'The color will be red and cannot be overridden'
description: "The color will be red and cannot be overridden"
required: false
namedLogo:
description: 'A logo name from simpleicons.org'
description: "A logo name from simpleicons.org"
required: false
logoSvg:
description: 'An svg-string to be used as logo'
description: "An svg-string to be used as logo"
required: false
logoColor:
description: 'The color for the logo'
description: "The color for the logo"
required: false
logoWidth:
description: 'The space allocated for the logo'
description: "The space allocated for the logo"
required: false
logoPosition:
description: 'The position of the logo'
description: "The position of the logo"
required: false
style:
description: 'The style like "flat" or "social"'
required: false
cacheSeconds:
description: 'The cache lifetime in seconds (must be greater than 300)'
description: "The cache lifetime in seconds (must be greater than 300)"
required: false
valColorRange:
description: 'A numerical value used to define the message color. Usually this should be between maxColorRange and minColorRange. This is required if you want to use the color range feature.'
description: "A numerical value used to define the message color. Usually this should be between maxColorRange and minColorRange. This is required if you want to use the color range feature."
required: false
maxColorRange:
description: 'If valColorRange assumes this value, the badge will be green. This is required if you want to use the color range feature.'
description: "If valColorRange assumes this value, the badge will be green. This is required if you want to use the color range feature."
required: false
minColorRange:
description: 'If valColorRange assumes this value, the badge will be red. This is required if you want to use the color range feature.'
description: "If valColorRange assumes this value, the badge will be red. This is required if you want to use the color range feature."
required: false
invertColorRange:
description: 'If the range should be inverted, causing a smaller value to have green color. Defaults to false.'
description: "If the range should be inverted, causing a smaller value to have green color. Defaults to false."
required: false
colorRangeSaturation:
description: 'Saturation used by the color range feature. Defaults to 100.'
description: "Saturation used by the color range feature. Defaults to 100."
required: false
colorRangeLightness:
description: 'Lightness used by the color range feature. Defaults to 40.'
description: "Lightness used by the color range feature. Defaults to 40."
required: false
runs:
using: 'node16'
main: 'index.js'
using: "node16"
main: "index.js"

View File

@@ -1,13 +1,30 @@
<!--
SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
SPDX-License-Identifier: CC-BY-4.0
-->
# Changelog of the Dynamic Badges Action
## [Dynamic Badges Action 1.7.0](https://github.com/Schneegans/dynamic-badges-action/tree/v1.7.0)
**Release Date:** 2023-10-19
#### Changes
- **SVG Mode:** If your gist filename ends with `.svg` instead of `.json`, the action will now generate an SVG badge instead of a JSON file. This is useful if you cannot use shields.io for some reason. However, this SVG mode does not support all features of shields.io. Thanks to [@runarberg](https://github.com/runarberg) for this contribution!
- **New `host` Parameter:** You can now specify the host for the gist API. This is useful if you want to use the action on a GitHub enterprise instance. Thanks to [@LucBerge](https://github.com/LucBerge) for this idea!
- Fixed a bug which caused the gist not to be updated if the label or message of the badge contained characters which have a different encoding length in UTF8 and UTF16,
- The code has received some major refactoring. If you encounter any problems, please open an issue!
- The action now runs on Node 20 instead of Node 16.
- The repository is now compliant with the [REUSE Specification](https://reuse.software/) of the Free Software Foundation Europe.
## [Dynamic Badges Action 1.6.0](https://github.com/Schneegans/dynamic-badges-action/tree/v1.6.0)
**Release Date:** 2022-10-13
#### Changes
* The action now runs on Node 16 instead of the deprecated Node 12.
- The action now runs on Node 16 instead of the deprecated Node 12.
## [Dynamic Badges Action 1.5.0](https://github.com/Schneegans/dynamic-badges-action/tree/v1.5.0)
@@ -15,9 +32,9 @@
#### Changes
* The gist is now not updated anymore if the content did not change. This prevents many gist revisions without actual changes. You can restore the original behavior by setting the optional `forceUpdate` parameter to `true`. A BIG thanks to [@MishaKav](https://github.com/MishaKav) for this contribution!
* Example color range badges have been added to the README.
* All node dependencies have been updated.
- The gist is now not updated anymore if the content did not change. This prevents many gist revisions without actual changes. You can restore the original behavior by setting the optional `forceUpdate` parameter to `true`. A BIG thanks to [@MishaKav](https://github.com/MishaKav) for this contribution!
- Example color range badges have been added to the README.
- All node dependencies have been updated.
## [Dynamic Badges Action 1.4.0](https://github.com/Schneegans/dynamic-badges-action/tree/v1.4.0)
@@ -25,7 +42,7 @@
#### Changes
* Fixed a bug which caused the action to fail if the value for the automatic color range was out of bounds. Thanks to [@LucasWolfgang](https://github.com/LucasWolfgang) for this fix!
- Fixed a bug which caused the action to fail if the value for the automatic color range was out of bounds. Thanks to [@LucasWolfgang](https://github.com/LucasWolfgang) for this fix!
## [Dynamic Badges Action 1.3.0](https://github.com/Schneegans/dynamic-badges-action/tree/v1.3.0)
@@ -33,7 +50,7 @@
#### Changes
* Added the possibility to generate the badge color automatically between red and green based on a numerical value and its bounds. Thanks to [@LucasWolfgang](https://github.com/LucasWolfgang) for this contribution!
- Added the possibility to generate the badge color automatically between red and green based on a numerical value and its bounds. Thanks to [@LucasWolfgang](https://github.com/LucasWolfgang) for this contribution!
## [Dynamic Badges Action 1.2.0](https://github.com/Schneegans/dynamic-badges-action/tree/v1.2.0)
@@ -41,9 +58,8 @@
#### Changes
* The action does not log the response of writing the Gist anymore.
* Added this changelog.
- The action does not log the response of writing the Gist anymore.
- Added this changelog.
## [Dynamic Badges Action 1.1.0](https://github.com/Schneegans/dynamic-badges-action/tree/v1.1.0)
@@ -51,9 +67,8 @@
#### Changes
* The action now logs an error message when writing the Gist failed.
* Used new API for setting environment variables in the README.md examples.
- The action now logs an error message when writing the Gist failed.
- Used new API for setting environment variables in the README.md examples.
## [Dynamic Badges Action 1.0.0](https://github.com/Schneegans/dynamic-badges-action/tree/v1.0.0)
@@ -61,5 +76,4 @@
#### Changes
* Initial publication on GitHub.
- Initial publication on GitHub.

280
index.js
View File

@@ -1,222 +1,210 @@
//////////////////////////////////////////////////////////////////////////////////////////
// This file is part of the Dynamic Badges Action //
// It may be used under the terms of the MIT license. See the LICENSE file for details. //
// Copyright: (c) 2020 Simon Schneegans //
//////////////////////////////////////////////////////////////////////////////////////////
const core = require('@actions/core');
const http = require('https');
// SPDX-FileCopyrightText: Simon Schneegans <code@simonschneegans.de>
// SPDX-License-Identifier: MIT
// Performs an HTTP request and returns a Promise accordingly. See docs of
// http.request() for the available options.
function doRequest(options, data) {
return new Promise((resolve, reject) => {
const req = http.request(options, res => {
res.setEncoding('utf8');
let responseBody = '';
import core from "@actions/core";
import { makeBadge } from "badge-maker";
res.on('data', (chunk) => {
responseBody += chunk;
});
res.on('end', () => {
const {statusCode, statusMessage} = res;
resolve({statusCode, statusMessage, body: JSON.parse(responseBody)});
});
});
req.on('error', (err) => {
reject(err);
});
req.write(data)
req.end();
});
}
const gistUrl = new URL(core.getInput("gistID"), core.getInput("host"));
// This uses the method above to update a gist with the given data. The user agent is
// required as defined in https://developer.github.com/v3/#user-agent-required
function updateGist(data) {
const updateGistOptions = {
host: 'api.github.com',
path: '/gists/' + core.getInput('gistID'),
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length,
'User-Agent': 'Schneegans',
'Authorization': 'token ' + core.getInput('auth'),
}
};
async function updateGist(body) {
const headers = new Headers([
["Content-Type", "application/json"],
["Content-Length", new TextEncoder().encode(body).length],
["User-Agent", "Schneegans"],
["Authorization", `token ${core.getInput("auth")}`],
]);
doRequest(updateGistOptions, data).then(res => {
if (res.statusCode < 200 || res.statusCode >= 400) {
core.setFailed(
'Failed to create gist, response status code: ' + res.statusCode +
', status message: ' + res.statusMessage);
} else {
console.log('Success!');
}
const response = await fetch(gistUrl, {
method: "POST",
headers,
body,
});
if (!response.ok) {
core.setFailed(
`Failed to create gist, response status code: ${response.status} ${response.statusText}`
);
return;
}
console.log("Success!");
}
// We wrap the entire action in a try / catch block so we can set it to "failed" if
// something goes wrong.
try {
// This object will be stringified and uploaded to the gist. The schemaVersion, label
// and message attributes are always required. All others are optional and added to the
// content object only if they are given to the action.
let content = {
schemaVersion: 1,
label: core.getInput('label'),
message: core.getInput('message')
let data = {
label: core.getInput("label"),
message: core.getInput("message"),
};
// Compute the message color based on the given inputs.
const color = core.getInput('color');
const valColorRange = core.getInput('valColorRange');
const minColorRange = core.getInput('minColorRange');
const maxColorRange = core.getInput('maxColorRange');
const invertColorRange = core.getInput('invertColorRange');
const colorRangeSaturation = core.getInput('colorRangeSaturation');
const colorRangeLightness = core.getInput('colorRangeLightness');
const filename = core.getInput("filename");
const isSvgFile = filename.endsWith(".svg");
if (minColorRange != '' && maxColorRange != '' && valColorRange != '') {
if (!isSvgFile) {
data.schemaVersion = 1;
}
// Compute the message color based on the given inputs.
const color = core.getInput("color");
const valColorRange = core.getInput("valColorRange");
const minColorRange = core.getInput("minColorRange");
const maxColorRange = core.getInput("maxColorRange");
const invertColorRange = core.getInput("invertColorRange");
const colorRangeSaturation = core.getInput("colorRangeSaturation");
const colorRangeLightness = core.getInput("colorRangeLightness");
if (minColorRange != "" && maxColorRange != "" && valColorRange != "") {
const max = parseFloat(maxColorRange);
const min = parseFloat(minColorRange);
let val = parseFloat(valColorRange);
let val = parseFloat(valColorRange);
if (val < min) val = min;
if (val > max) val = max;
let hue = 0;
if (invertColorRange == '') {
hue = Math.floor((val - min) / (max - min) * 120);
if (invertColorRange == "") {
hue = Math.floor(((val - min) / (max - min)) * 120);
} else {
hue = Math.floor((max - val) / (max - min) * 120);
hue = Math.floor(((max - val) / (max - min)) * 120);
}
let sat = 100;
if (colorRangeSaturation != '') {
if (colorRangeSaturation != "") {
sat = parseFloat(colorRangeSaturation);
}
let lig = 40;
if (colorRangeLightness != '') {
if (colorRangeLightness != "") {
lig = parseFloat(colorRangeLightness);
}
content.color = 'hsl(' + hue + ', ' + sat + '%, ' + lig + '%)';
} else if (color != '') {
content.color = color;
data.color = "hsl(" + hue + ", " + sat + "%, " + lig + "%)";
} else if (color != "") {
data.color = color;
}
// Get all optional attributes and add them to the content object if given.
const labelColor = core.getInput('labelColor');
const isError = core.getInput('isError');
const namedLogo = core.getInput('namedLogo');
const logoSvg = core.getInput('logoSvg');
const logoColor = core.getInput('logoColor');
const logoWidth = core.getInput('logoWidth');
const logoPosition = core.getInput('logoPosition');
const style = core.getInput('style');
const cacheSeconds = core.getInput('cacheSeconds');
const filename = core.getInput('filename');
const labelColor = core.getInput("labelColor");
const isError = core.getInput("isError");
const namedLogo = core.getInput("namedLogo");
const logoSvg = core.getInput("logoSvg");
const logoColor = core.getInput("logoColor");
const logoWidth = core.getInput("logoWidth");
const logoPosition = core.getInput("logoPosition");
const style = core.getInput("style");
const cacheSeconds = core.getInput("cacheSeconds");
if (labelColor != '') {
content.labelColor = labelColor;
if (labelColor != "") {
data.labelColor = labelColor;
}
if (isError != '') {
content.isError = isError;
if (!isSvgFile && isError != "") {
data.isError = isError;
}
if (namedLogo != '') {
content.namedLogo = namedLogo;
if (!isSvgFile && namedLogo != "") {
data.namedLogo = namedLogo;
}
if (logoSvg != '') {
content.logoSvg = logoSvg;
if (!isSvgFile && logoSvg != "") {
data.logoSvg = logoSvg;
}
if (logoColor != '') {
content.logoColor = logoColor;
if (!isSvgFile && logoColor != "") {
data.logoColor = logoColor;
}
if (logoWidth != '') {
content.logoWidth = parseInt(logoWidth);
if (!isSvgFile && logoWidth != "") {
data.logoWidth = parseInt(logoWidth);
}
if (logoPosition != '') {
content.logoPosition = logoPosition;
if (!isSvgFile && logoPosition != "") {
data.logoPosition = logoPosition;
}
if (style != '') {
content.style = style;
if (style != "") {
data.style = style;
}
if (cacheSeconds != '') {
content.cacheSeconds = parseInt(cacheSeconds);
if (!isSvgFile && cacheSeconds != "") {
data.cacheSeconds = parseInt(cacheSeconds);
}
let content = "";
if (isSvgFile) {
content = makeBadge(data);
} else {
content = JSON.stringify(data);
}
// For the POST request, the above content is set as file contents for the
// given filename.
const request =
JSON.stringify({files: {[filename]: {content: JSON.stringify(content)}}});
const body = JSON.stringify({ files: { [filename]: { content } } });
// If "forceUpdate" is set to true, we can simply update the gist. If not, we have to
// get the gist data and compare it to the new value before.
if (core.getBooleanInput('forceUpdate')) {
updateGist(request);
if (core.getBooleanInput("forceUpdate")) {
updateGist(body);
} else {
// Get the old gist.
const getGistOptions = {
host: 'api.github.com',
path: '/gists/' + core.getInput('gistID'),
method: 'GET',
headers: {
'Content-Type': 'application/json',
'User-Agent': 'Schneegans',
'Authorization': 'token ' + core.getInput('auth'),
}
};
doRequest(getGistOptions, JSON.stringify({})).then(oldGist => {
if (oldGist.statusCode < 200 || oldGist.statusCode >= 400) {
// print the error, but don't fail the action.
console.log(
'Failed to get gist, response status code: ' + oldGist.statusCode +
', status message: ' + oldGist.statusMessage);
}
let shouldUpdate = true;
if (oldGist && oldGist.body && oldGist.body.files && oldGist.body.files[filename]) {
const oldContent = oldGist.body.files[filename].content;
if (oldContent === JSON.stringify(content)) {
console.log(`Content did not change, not updating gist at ${filename}.`);
shouldUpdate = false;
}
}
if (shouldUpdate) {
if (oldGist.body.files[filename]) {
console.log(`Content changed, updating gist at ${filename}.`);
} else {
console.log(`Content didn't exist, creating gist at ${filename}.`);
fetch(gistUrl, {
method: "GET",
headers: new Headers([
["Content-Type", "application/json"],
["User-Agent", "Schneegans"],
["Authorization", `token ${core.getInput("auth")}`],
]),
})
.then((response) => {
if (!response.ok) {
return Promise.reject(
`Failed to get gist: ${response.status} ${response.statusText}`
);
}
updateGist(request);
}
});
return response.json();
})
.then((oldGist) => {
let shouldUpdate = true;
if (oldGist?.files?.[filename]) {
const oldContent = oldGist.files[filename].content;
if (oldContent === content) {
console.log(
`Content did not change, not updating gist at ${filename}.`
);
shouldUpdate = false;
}
}
if (shouldUpdate) {
if (oldGist?.files?.[filename]) {
console.log(`Content changed, updating gist at ${filename}.`);
} else {
console.log(`Content didn't exist, creating gist at ${filename}.`);
}
updateGist(body);
}
})
.catch((error) => {
core.setFailed(error);
});
}
} catch (error) {
core.setFailed(error);
}

1
node_modules/.bin/badge generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../badge-maker/lib/badge-cli.js

64
node_modules/.package-lock.json generated vendored
View File

@@ -1,7 +1,7 @@
{
"name": "dynamic-badges-action",
"version": "1.5.0",
"lockfileVersion": 2,
"lockfileVersion": 3,
"requires": true,
"packages": {
"node_modules/@actions/core": {
@@ -21,6 +21,68 @@
"tunnel": "^0.0.6"
}
},
"node_modules/anafanafo": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/anafanafo/-/anafanafo-2.0.0.tgz",
"integrity": "sha512-Nlfq7NC4AOkTJerWRIZcOAiMNtIDVIGWGvQ98O7Jl6Kr2Dk0dX5u4MqN778kSRTy5KRqchpLdF2RtLFEz9FVkQ==",
"dependencies": {
"char-width-table-consumer": "^1.0.0"
}
},
"node_modules/badge-maker": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/badge-maker/-/badge-maker-3.3.1.tgz",
"integrity": "sha512-OO/PS7Zg2E6qaUWzHEHt21Q5VjcFBAJVA8ztgT/fIdSZFBUwoyeo0ZhA6V5tUM8Vcjq8DJl6jfGhpjESssyqMQ==",
"dependencies": {
"anafanafo": "2.0.0",
"css-color-converter": "^2.0.0"
},
"bin": {
"badge": "lib/badge-cli.js"
},
"engines": {
"node": ">= 10",
"npm": ">= 5"
}
},
"node_modules/binary-search": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/binary-search/-/binary-search-1.3.6.tgz",
"integrity": "sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA=="
},
"node_modules/char-width-table-consumer": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/char-width-table-consumer/-/char-width-table-consumer-1.0.0.tgz",
"integrity": "sha512-Fz4UD0LBpxPgL9i29CJ5O4KANwaMnX/OhhbxzvNa332h+9+nRKyeuLw4wA51lt/ex67+/AdsoBQJF3kgX2feYQ==",
"dependencies": {
"binary-search": "^1.3.5"
}
},
"node_modules/color-convert": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-0.5.3.tgz",
"integrity": "sha512-RwBeO/B/vZR3dfKL1ye/vx8MHZ40ugzpyfeVG5GsiuGnrlMWe2o8wxBbLCpw9CsxV+wHuzYlCiWnybrIA0ling=="
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/css-color-converter": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/css-color-converter/-/css-color-converter-2.0.0.tgz",
"integrity": "sha512-oLIG2soZz3wcC3aAl/7Us5RS8Hvvc6I8G8LniF/qfMmrm7fIKQ8RIDDRZeKyGL2SrWfNqYspuLShbnjBMVWm8g==",
"dependencies": {
"color-convert": "^0.5.2",
"color-name": "^1.1.4",
"css-unit-converter": "^1.1.2"
}
},
"node_modules/css-unit-converter": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/css-unit-converter/-/css-unit-converter-1.1.2.tgz",
"integrity": "sha512-IiJwMC8rdZE0+xiEZHeru6YoONC4rfPMqGm2W85jMIbkFvv5nFTwJVFHam2eFrN6txmoUYFAFXiv8ICVeTO0MA=="
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",

43
node_modules/anafanafo/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,43 @@
# Changelog
## 2.0.0 Oct 15, 2020
Same as 2.0.0-beta.1.
### BREAKING CHANGES
- Support the font variants used by Shields:
- 10px Verdana
- bold 10px Verdana
- 11px Verdana
- bold 11px Helvetica
## 2.0.0-beta.1 Oct 11, 2020
### BREAKING CHANGES
- Support the font variants used by Shields:
- 10px Verdana
- bold 10px Verdana
- 11px Verdana
- bold 11px Helvetica
## 2.0.0-beta.0 Oct 11, 2020
### BREAKING CHANGES
- Support 10px and 11px Verdana, in normal and bold.
## 1.0.0 Apr 12, 2018
- Update dependencies.
- Stable API.
## 0.1.1 Nov 15, 2018
- Require the JSON file (instead of `loadSync`-ing it) to play well with
module bundlers.
## 0.1.0 Nov 13, 2018
Initial release.

21
node_modules/anafanafo/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Metabolize LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

40
node_modules/anafanafo/README.md generated vendored Normal file
View File

@@ -0,0 +1,40 @@
# anafanafo
[![version](https://img.shields.io/npm/v/anafanafo?style=flat-square)][npm]
[![license](https://img.shields.io/npm/l/anafanafo?style=flat-square)][npm]
[![build](https://img.shields.io/circleci/project/github/metabolize/anafanafo/main?style=flat-square)][build]
[![bundle size](https://img.shields.io/bundlephobia/minzip/anafanafo?style=flat-square)][bundlephobia]
[![code style](https://img.shields.io/badge/code_style-prettier-ff69b4?style=flat-square)][prettier]
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff?style=flat-square)][lerna]
[npm]: https://npmjs.com/anafanafo
[build]: https://circleci.com/gh/metabolize/anafanafo/tree/main
[bundlephobia]: https://bundlephobia.com/result?p=anafanafo
[prettier]: https://prettier.io/
[lerna]: https://lernajs.io/
Efficiently compute text width in Verdana and Helvetica using
[char-width-table-consumer][] and lookup tables.
Built with [Shields][] in mind.
(And because Verdana always makes me think of [this][the name game].)
[char-width-table-consumer]: https://www.npmjs.com/package/char-width-table-consumer
[shields]: https://github.com/badges/shields/
[the name game]: https://www.youtube.com/watch?v=5MJLi5_dyn0
## Usage
```js
const anafanafo = require('anafanafo')
// Supports '11px Verdana', '10px Verdana', 'bold 10px Verdana', and 'bold 11px Helvetica'.
const width = anafanafo('Shirley Shirley', { font: '11px Verdana' })
```
## License
All rights to Verdana are owned by Microsoft Corp.
The remainder of this project is licensed under the MIT license.

1
node_modules/anafanafo/data/helvetica-11px-bold.json generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/anafanafo/data/verdana-10px-bold.json generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/anafanafo/data/verdana-10px-normal.json generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/anafanafo/data/verdana-11px-normal.json generated vendored Normal file

File diff suppressed because one or more lines are too long

22
node_modules/anafanafo/index.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
'use strict'
const { createConsumer } = require('char-width-table-consumer')
const consumers = {
'10px Verdana': createConsumer(require('./data/verdana-10px-normal.json')),
'bold 10px Verdana': createConsumer(require('./data/verdana-10px-bold.json')),
'11px Verdana': createConsumer(require('./data/verdana-11px-normal.json')),
'bold 11px Helvetica': createConsumer(
require('./data/helvetica-11px-bold.json')
),
}
module.exports = function measure(text, { font, ...rest }) {
const consumer = consumers[font]
if (!consumer) {
throw Error(
`Unknown font "${font}", expected ${Object.keys(consumers).join(', ')}`
)
}
return consumer.widthOf(text, { ...rest })
}

18
node_modules/anafanafo/package.json generated vendored Normal file
View File

@@ -0,0 +1,18 @@
{
"name": "anafanafo",
"version": "2.0.0",
"repository": "metabolize/anafanafo",
"description": "Compute text width in Verdana",
"scripts": {
"test": "../../node_modules/.bin/mocha test.js"
},
"author": "Metabolize",
"license": "MIT",
"dependencies": {
"char-width-table-consumer": "^1.0.0"
},
"files": [
"index.js",
"data/*.json"
]
}

277
node_modules/badge-maker/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,277 @@
# Changelog
## 3.3.1
- Improve font measuring in for-the-badge and social styles
- Make for-the-badge letter spacing more predictable
## 3.3.0
- Readability improvements: a dark font color is automatically used when the badge's background is too light. For example: ![](https://img.shields.io/badge/hello-world-white)
- Better CSS color compliance: thanks to a switch from _is-css-color_ to _[css-color-converter](https://www.npmjs.com/package/css-color-converter)_, you can use a wider range of color formats from the latest CSS specification, for example `rgb(0 255 0)`
- Less dependencies: _badge-maker_ no longer depends on _camelcase_
## 3.2.0
- Accessibility improvements: Help users of assistive technologies to read the badges when used inline
## 3.1.0
- Add TypeScript definitions
## 3.0.1
- Fix missing dependency
## 3.0.0
### Breaking Changes
- Dropped support for node < 10
- Package name has changed to `badge-maker` and moved to https://www.npmjs.com/package/badge-maker
- `BadgeFactory` class is removed and replaced by `makeBadge()` function.
- Deprecated parameters have been removed. In version 2.2.0 the `colorA`, `colorB` and `colorscheme` params were deprecated. In version 3.0.0 these have been removed.
- Only SVG output format is now provided. JSON format has been dropped and the `format` key has been removed.
- The `text` array has been replaced by `label` and `message` keys.
- The `template` key has been renamed `style`.
To upgrade from v2.1.1, change your code from:
```js
const { BadgeFactory } = require('gh-badges')
const bf = new BadgeFactory()
const svg = bf.create({
text: ['build', 'passed'],
format: 'svg',
template: 'flat-square',
})
```
to:
```js
const { makeBadge } = require('badge-maker')
const svg = makeBadge({
label: 'build',
message: 'passed',
style: 'flat-square',
})
```
- `ValidationError` had been added and inputs are now validated. In previous releases, invalid inputs would be discarded and replaced with defaults. For example, in 2.2.1
```js
const { BadgeFactory } = require('gh-badges')
const bf = new BadgeFactory()
const svg = bf.create({
text: ['build', 'passed'],
template: 'some invalid value',
})
```
would generate an SVG badge. In version >=3
```js
const { makeBadge } = require('badge-maker')
const svg = makeBadge({
label: 'build',
message: 'passed',
style: 'some invalid value',
})
```
will throw a `ValidationError`.
- Raster support has been removed from the CLI. It will now only output SVG. On the console, the output of `badge` can be piped to a utility like [imagemagick](https://imagemagick.org/script/command-line-processing.php). If you were previously using
```sh
badge build passed :green .gif
```
this could be replaced by
```sh
badge build passed :green | magick svg:- gif:-
```
### Security
- Removed dependency on doT library which has known vulnerabilities.
## 2.2.1 - 2019-05-30
### Fixes
- Escape logos to prevent XSS vulnerability
- Update docblock for BadgeFactory.create()
## 2.2.0 - 2019-05-29
### Deprecations
- `labelColor` and `color` are now the recommended attribute names for label color and message color.
- `colorA` (now an alias for `labelColor`),
- `colorB` (now an alias for `color`) and
- `colorscheme` (now an alias for `color`)
are now deprecated and will be removed in some future release.
### New Features
- Semantic color aliases. Add support for:
- ![success](https://img.shields.io/badge/success-success.svg)
- ![important](https://img.shields.io/badge/important-important.svg)
- ![critical](https://img.shields.io/badge/critical-critical.svg)
- ![informational](https://img.shields.io/badge/informational-informational.svg)
- ![inactive](https://img.shields.io/badge/inactive-inactive.svg)
- Add directory field to package.json (to help tools find this package in the repo)
### Bug Fixes
- Prevent bad letter spacing when whitespace surrounds badge text
### Dependencies
- Bump anafanafo
- Use caret instead of tilde for dependencies
### Internals
- Generate JSON badges without using a template
- Refactoring
- Testing improvements
### Node support
- Declare support for all currently maintained Node versions
- Explicitly test on all supported versions
## 2.1.0 - 2018-11-18
gh-badges v2.1.0 implements a new text width measurer which uses a lookup table, removing the dependency
on PDFKit. It is no longer necessary to provide a local copy of Verdana for accurate text width computation.
As such, the `fontPath` and `precomputeWidths` parameters are now deprecated. The recommended call to create an instance of `BadgeFactory` is now
```js
const bf = new BadgeFactory()
```
For backwards compatibility you can still construct an instance of `BadgeFactory` with a call like
```js
const bf = new BadgeFactory({
fontPath: '/path/to/Verdana.ttf',
precomputeWidths: true,
})
```
However, the function will issue a warning.
To clear the warning, change the code to:
```js
const bf = new BadgeFactory()
```
These arguments will be removed in a future release.
To upgrade from v1.3.0, change your code from:
```js
const badge = require('gh-badges')
const format = {
text: ['build', 'passed'],
colorscheme: 'green',
template: 'flat',
}
badge.loadFont('/path/to/Verdana.ttf', err => {
badge(format, (svg, err) => {
// svg is a string containing your badge
})
})
```
to:
```js
const { BadgeFactory } = require('gh-badges')
const bf = new BadgeFactory()
const format = {
text: ['build', 'passed'],
colorscheme: 'green',
template: 'flat',
}
const svg = bf.create(format)
```
### Other changes in this release:
- Remove unnecessary dependencies
- Documentation improvements
## 2.0.0 - 2018-11-09
gh-badges v2.0.0 declares a new public interface which is synchronous.
If your version 1.3.0 code looked like this:
```js
const badge = require('gh-badges')
const format = {
text: ['build', 'passed'],
colorscheme: 'green',
template: 'flat',
}
badge.loadFont('/path/to/Verdana.ttf', err => {
badge(format, (svg, err) => {
// svg is a string containing your badge
})
})
```
To upgrade to version 2.0.0, refactor you code to:
```js
const { BadgeFactory } = require('gh-badges')
const bf = new BadgeFactory({ fontPath: '/path/to/Verdana.ttf' })
const format = {
text: ['build', 'passed'],
colorscheme: 'green',
template: 'flat',
}
const svg = bf.create(format)
```
You can generate badges without a copy of Verdana, however font width computation is approximate and badges may be distorted.
```js
const bf = new BadgeFactory({ fallbackFontPath: 'Helvetica' })
```
## 1.3.0 - 2016-09-07
Add support for optionally specifying the path to `Verdana.ttf`. In earlier versions, the file needed to be in the directory containing Shields.
Without font path:
```js
const badge = require('gh-badges')
badge({ text: ['build', 'passed'], colorscheme: 'green' }, (svg, err) => {
// svg is a string containing your badge
})
```
With font path:
```js
const badge = require('gh-badges')
// Optional step, to have accurate text width computation.
badge.loadFont('/path/to/Verdana.ttf', err => {
badge(
{ text: ['build', 'passed'], colorscheme: 'green', template: 'flat' },
(svg, err) => {
// svg is a string containing your badge
}
)
})
```

116
node_modules/badge-maker/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,116 @@
CC0 1.0 Universal
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator and
subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for the
purpose of contributing to a commons of creative, cultural and scientific
works ("Commons") that the public can reliably and without fear of later
claims of infringement build upon, modify, incorporate in other works, reuse
and redistribute as freely as possible in any form whatsoever and for any
purposes, including without limitation commercial purposes. These owners may
contribute to the Commons to promote the ideal of a free culture and the
further production of creative, cultural and scientific works, or to gain
reputation or greater distribution for their Work in part through the use and
efforts of others.
For these and/or other purposes and motivations, and without any expectation
of additional consideration or compensation, the person associating CC0 with a
Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
and publicly distribute the Work under its terms, with knowledge of his or her
Copyright and Related Rights in the Work and the meaning and intended legal
effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not limited
to, the following:
i. the right to reproduce, adapt, distribute, perform, display, communicate,
and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or likeness
depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data in
a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation thereof,
including any amended or successor version of such directive); and
vii. other similar, equivalent or corresponding rights throughout the world
based on applicable law or treaty, and any national implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention of,
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
and Related Rights and associated claims and causes of action, whether now
known or unknown (including existing as well as future claims and causes of
action), in the Work (i) in all territories worldwide, (ii) for the maximum
duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
the Waiver for the benefit of each member of the public at large and to the
detriment of Affirmer's heirs and successors, fully intending that such Waiver
shall not be subject to revocation, rescission, cancellation, termination, or
any other legal or equitable action to disrupt the quiet enjoyment of the Work
by the public as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason be
judged legally invalid or ineffective under applicable law, then the Waiver
shall be preserved to the maximum extent permitted taking into account
Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
is so judged Affirmer hereby grants to each affected person a royalty-free,
non transferable, non sublicensable, non exclusive, irrevocable and
unconditional license to exercise Affirmer's Copyright and Related Rights in
the Work (i) in all territories worldwide, (ii) for the maximum duration
provided by applicable law or treaty (including future time extensions), (iii)
in any current or future medium and for any number of copies, and (iv) for any
purpose whatsoever, including without limitation commercial, advertising or
promotional purposes (the "License"). The License shall be deemed effective as
of the date CC0 was applied by Affirmer to the Work. Should any part of the
License for any reason be judged legally invalid or ineffective under
applicable law, such partial invalidity or ineffectiveness shall not
invalidate the remainder of the License, and in such case Affirmer hereby
affirms that he or she will not (i) exercise any of his or her remaining
Copyright and Related Rights in the Work or (ii) assert any associated claims
and causes of action with respect to the Work, in either case contrary to
Affirmer's express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or warranties
of any kind concerning the Work, express, implied, statutory or otherwise,
including without limitation warranties of title, merchantability, fitness
for a particular purpose, non infringement, or the absence of latent or
other defects, accuracy, or the present or absence of errors, whether or not
discoverable, all to the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without limitation
any person's Copyright and Related Rights in the Work. Further, Affirmer
disclaims responsibility for obtaining any necessary consents, permissions
or other rights required for any use of the Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to this
CC0 or use of the Work.
For more information, please see
<http://creativecommons.org/publicdomain/zero/1.0/>

142
node_modules/badge-maker/README.md generated vendored Normal file
View File

@@ -0,0 +1,142 @@
# badge-maker
[![npm version](https://img.shields.io/npm/v/badge-maker.svg)](https://npmjs.org/package/badge-maker)
[![npm license](https://img.shields.io/npm/l/badge-maker.svg)](https://npmjs.org/package/badge-maker)
[![npm type definitions](https://img.shields.io/npm/types/badge-maker)](https://npmjs.org/package/badge-maker)
## Installation
```sh
npm install badge-maker
```
## Usage
### On the console
```sh
npm install -g badge-maker
badge build passed :green > mybadge.svg
```
### As a library
With CommonJS in JavaScript,
```js
const { makeBadge, ValidationError } = require('badge-maker')
```
With ESM or TypeScript,
```ts
import { makeBadge, ValidationError } from 'badge-maker'
```
```js
const format = {
label: 'build',
message: 'passed',
color: 'green',
}
const svg = makeBadge(format)
console.log(svg) // <svg...
try {
makeBadge({})
} catch (e) {
console.log(e) // ValidationError: Field `message` is required
}
```
### Node version support
The latest version of badge-maker supports all currently maintained Node
versions. See the [Node Release Schedule][].
[node release schedule]: https://github.com/nodejs/Release#release-schedule
## Format
The format is the following:
```js
{
label: 'build', // (Optional) Badge label
message: 'passed', // (Required) Badge message
labelColor: '#555', // (Optional) Label color
color: '#4c1', // (Optional) Message color
// (Optional) One of: 'plastic', 'flat', 'flat-square', 'for-the-badge' or 'social'
// Each offers a different visual design.
style: 'flat',
}
```
## Colors
There are three ways to specify `color` and `labelColor`:
1. One of the [Shields named colors](./lib/color.js):
- ![][brightgreen]
- ![][green]
- ![][yellow]
- ![][yellowgreen]
- ![][orange]
- ![][red]
- ![][blue]
- ![][grey] ![][gray] the default `labelColor`
- ![][lightgrey] ![][lightgray] the default `color`
- ![][success]
- ![][important]
- ![][critical]
- ![][informational]
- ![][inactive] the default `color`
2. A three- or six-character hex color, optionally prefixed with `#`:
- ![][9cf]
- ![][#007fff]
- etc.
3. [Any valid CSS color][css color], e.g.
- `rgb(...)`, `rgba(...)`
- `hsl(...)`, `hsla(...)`
- ![][aqua] ![][fuchsia] ![][lightslategray] etc.
[brightgreen]: https://img.shields.io/badge/brightgreen-brightgreen.svg
[success]: https://img.shields.io/badge/success-success.svg
[green]: https://img.shields.io/badge/green-green.svg
[yellow]: https://img.shields.io/badge/yellow-yellow.svg
[yellowgreen]: https://img.shields.io/badge/yellowgreen-yellowgreen.svg
[orange]: https://img.shields.io/badge/orange-orange.svg
[important]: https://img.shields.io/badge/important-important.svg
[red]: https://img.shields.io/badge/red-red.svg
[critical]: https://img.shields.io/badge/critical-critical.svg
[blue]: https://img.shields.io/badge/blue-blue.svg
[informational]: https://img.shields.io/badge/informational-informational.svg
[grey]: https://img.shields.io/badge/grey-grey.svg
[gray]: https://img.shields.io/badge/gray-gray.svg
[lightgrey]: https://img.shields.io/badge/lightgrey-lightgrey.svg
[lightgray]: https://img.shields.io/badge/lightgray-lightgray.svg
[inactive]: https://img.shields.io/badge/inactive-inactive.svg
[9cf]: https://img.shields.io/badge/9cf-9cf.svg
[#007fff]: https://img.shields.io/badge/%23007fff-007fff.svg
[aqua]: https://img.shields.io/badge/aqua-aqua.svg
[fuchsia]: https://img.shields.io/badge/fuchsia-fuchsia.svg
[lightslategray]: https://img.shields.io/badge/lightslategray-lightslategray.svg
[css color]: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value
[css/svg color]: http://www.w3.org/TR/SVG/types.html#DataTypeColor
## Raster Formats
Conversion to raster formats is no longer directly supported. In javascript
code, SVG badges can be converted to raster formats using a library like
[gm](https://www.npmjs.com/package/gm). On the console, the output of `badge`
can be piped to a utility like
[imagemagick](https://imagemagick.org/script/command-line-processing.php)
e.g: `badge build passed :green | magick svg:- gif:-`.

11
node_modules/badge-maker/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
interface Format {
label?: string
message: string
labelColor?: string
color?: string
style?: 'plastic' | 'flat' | 'flat-square' | 'for-the-badge' | 'social'
}
export declare class ValidationError extends Error {}
export declare function makeBadge(format: Format): string

65
node_modules/badge-maker/lib/badge-cli.js generated vendored Executable file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/env node
'use strict'
const { namedColors } = require('./color')
const { makeBadge } = require('./index')
if (process.argv.length < 4) {
console.log('Usage: badge label message [:color] [@style]')
console.log('Or: badge label message color [labelColor] [@style]')
console.log()
console.log(' color, labelColor:')
console.log(` one of ${Object.keys(namedColors).join(', ')}.`)
console.log(' #xxx (three hex digits)')
console.log(' #xxxxxx (six hex digits)')
console.log(' color (CSS color)')
console.log()
console.log('Eg: badge cactus grown :green @flat')
console.log()
process.exit()
}
// Find a format specifier.
let style = ''
for (let i = 4; i < process.argv.length; i++) {
if (process.argv[i][0] === '@') {
style = process.argv[i].slice(1)
process.argv.splice(i, 1)
continue
}
}
const label = process.argv[2]
const message = process.argv[3]
let color = process.argv[4] || ':green'
const labelColor = process.argv[5]
const badgeData = { label, message }
if (style) {
badgeData.style = style
}
if (color[0] === ':') {
color = color.slice(1)
if (namedColors[color] == null) {
// Colorscheme not found.
console.error('Invalid color scheme.')
process.exit(1)
}
badgeData.color = color
} else {
badgeData.color = color
if (labelColor) {
badgeData.labelColor = labelColor
}
}
;(() => {
try {
console.log(makeBadge(badgeData))
} catch (e) {
console.error(e)
process.exit(1)
}
})()

807
node_modules/badge-maker/lib/badge-renderers.js generated vendored Normal file
View File

@@ -0,0 +1,807 @@
'use strict'
const anafanafo = require('anafanafo')
const { brightness } = require('./color')
const { XmlElement, escapeXml } = require('./xml')
// https://github.com/badges/shields/pull/1132
const FONT_SCALE_UP_FACTOR = 10
const FONT_SCALE_DOWN_VALUE = 'scale(.1)'
const FONT_FAMILY = 'Verdana,Geneva,DejaVu Sans,sans-serif'
const fontFamily = `font-family="${FONT_FAMILY}"`
const socialFontFamily =
'font-family="Helvetica Neue,Helvetica,Arial,sans-serif"'
const brightnessThreshold = 0.69
function capitalize(s) {
return `${s.charAt(0).toUpperCase()}${s.slice(1)}`
}
function colorsForBackground(color) {
if (brightness(color) <= brightnessThreshold) {
return { textColor: '#fff', shadowColor: '#010101' }
} else {
return { textColor: '#333', shadowColor: '#ccc' }
}
}
function roundUpToOdd(val) {
return val % 2 === 0 ? val + 1 : val
}
function preferredWidthOf(str, options) {
// Increase chances of pixel grid alignment.
return roundUpToOdd(anafanafo(str, options) | 0)
}
function createAccessibleText({ label, message }) {
const labelPrefix = label ? `${label}: ` : ''
return labelPrefix + message
}
function hasLinks({ links }) {
const [leftLink, rightLink] = links || []
const hasLeftLink = leftLink && leftLink.length
const hasRightLink = rightLink && rightLink.length
const hasLink = hasLeftLink && hasRightLink
return { hasLink, hasLeftLink, hasRightLink }
}
function shouldWrapBodyWithLink({ links }) {
const { hasLeftLink, hasRightLink } = hasLinks({ links })
return hasLeftLink && !hasRightLink
}
function renderAriaAttributes({ accessibleText, links }) {
const { hasLink } = hasLinks({ links })
return hasLink ? '' : `role="img" aria-label="${escapeXml(accessibleText)}"`
}
function renderTitle({ accessibleText, links }) {
const { hasLink } = hasLinks({ links })
return hasLink ? '' : `<title>${escapeXml(accessibleText)}</title>`
}
function renderLogo({
logo,
badgeHeight,
horizPadding,
logoWidth = 14,
logoPadding = 0,
}) {
if (logo) {
const logoHeight = 14
const y = (badgeHeight - logoHeight) / 2
const x = horizPadding
return {
hasLogo: true,
totalLogoWidth: logoWidth + logoPadding,
renderedLogo: `<image x="${x}" y="${y}" width="${logoWidth}" height="${logoHeight}" xlink:href="${escapeXml(
logo
)}"/>`,
}
} else {
return { hasLogo: false, totalLogoWidth: 0, renderedLogo: '' }
}
}
function renderLink({
link,
height,
textLength,
horizPadding,
leftMargin,
renderedText,
}) {
const rectHeight = height
const rectWidth = textLength + horizPadding * 2
const rectX = leftMargin > 1 ? leftMargin + 1 : 0
return `<a target="_blank" xlink:href="${escapeXml(link)}">
<rect width="${rectWidth}" x="${rectX}" height="${rectHeight}" fill="rgba(0,0,0,0)" />
${renderedText}
</a>`
}
function renderText({
leftMargin,
horizPadding = 0,
content,
link,
height,
verticalMargin = 0,
shadow = false,
color,
}) {
if (!content.length) {
return { renderedText: '', width: 0 }
}
const textLength = preferredWidthOf(content, { font: '11px Verdana' })
const escapedContent = escapeXml(content)
const shadowMargin = 150 + verticalMargin
const textMargin = 140 + verticalMargin
const outTextLength = 10 * textLength
const x = 10 * (leftMargin + 0.5 * textLength + horizPadding)
let renderedText = ''
const { textColor, shadowColor } = colorsForBackground(color)
if (shadow) {
renderedText = `<text aria-hidden="true" x="${x}" y="${shadowMargin}" fill="${shadowColor}" fill-opacity=".3" transform="scale(.1)" textLength="${outTextLength}">${escapedContent}</text>`
}
renderedText += `<text x="${x}" y="${textMargin}" transform="scale(.1)" fill="${textColor}" textLength="${outTextLength}">${escapedContent}</text>`
return {
renderedText: link
? renderLink({
link,
height,
textLength,
horizPadding,
leftMargin,
renderedText,
})
: renderedText,
width: textLength,
}
}
function renderBadge(
{ links, leftWidth, rightWidth, height, accessibleText },
main
) {
const width = leftWidth + rightWidth
const leftLink = escapeXml(links[0])
return `
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${width}" height="${height}" ${renderAriaAttributes(
{ links, accessibleText }
)}>
${renderTitle({ accessibleText, links })}
${
shouldWrapBodyWithLink({ links })
? `<a target="_blank" xlink:href="${leftLink}">${main}</a>`
: main
}
</svg>`
}
class Badge {
static get fontFamily() {
throw new Error('Not implemented')
}
static get height() {
throw new Error('Not implemented')
}
static get verticalMargin() {
throw new Error('Not implemented')
}
static get shadow() {
throw new Error('Not implemented')
}
constructor({
label,
message,
links,
logo,
logoWidth,
logoPadding,
color = '#4c1',
labelColor,
}) {
const horizPadding = 5
const { hasLogo, totalLogoWidth, renderedLogo } = renderLogo({
logo,
badgeHeight: this.constructor.height,
horizPadding,
logoWidth,
logoPadding,
})
const hasLabel = label.length || labelColor
if (labelColor == null) {
labelColor = '#555'
}
const [leftLink, rightLink] = links
labelColor = hasLabel || hasLogo ? labelColor : color
labelColor = escapeXml(labelColor)
color = escapeXml(color)
const labelMargin = totalLogoWidth + 1
const { renderedText: renderedLabel, width: labelWidth } = renderText({
leftMargin: labelMargin,
horizPadding,
content: label,
link: !shouldWrapBodyWithLink({ links }) && leftLink,
height: this.constructor.height,
verticalMargin: this.constructor.verticalMargin,
shadow: this.constructor.shadow,
color: labelColor,
})
const leftWidth = hasLabel
? labelWidth + 2 * horizPadding + totalLogoWidth
: 0
let messageMargin = leftWidth - (message.length ? 1 : 0)
if (!hasLabel) {
if (hasLogo) {
messageMargin = messageMargin + totalLogoWidth + horizPadding
} else {
messageMargin = messageMargin + 1
}
}
const { renderedText: renderedMessage, width: messageWidth } = renderText({
leftMargin: messageMargin,
horizPadding,
content: message,
link: rightLink,
height: this.constructor.height,
verticalMargin: this.constructor.verticalMargin,
shadow: this.constructor.shadow,
color,
})
let rightWidth = messageWidth + 2 * horizPadding
if (hasLogo && !hasLabel) {
rightWidth += totalLogoWidth + horizPadding - 1
}
const width = leftWidth + rightWidth
const accessibleText = createAccessibleText({ label, message })
this.links = links
this.leftWidth = leftWidth
this.rightWidth = rightWidth
this.width = width
this.labelColor = labelColor
this.color = color
this.label = label
this.message = message
this.accessibleText = accessibleText
this.renderedLogo = renderedLogo
this.renderedLabel = renderedLabel
this.renderedMessage = renderedMessage
}
static render(params) {
return new this(params).render()
}
render() {
throw new Error('Not implemented')
}
}
class Plastic extends Badge {
static get fontFamily() {
return fontFamily
}
static get height() {
return 18
}
static get verticalMargin() {
return -10
}
static get shadow() {
return true
}
render() {
return renderBadge(
{
links: this.links,
leftWidth: this.leftWidth,
rightWidth: this.rightWidth,
accessibleText: this.accessibleText,
height: this.constructor.height,
},
`
<linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#fff" stop-opacity=".7"/>
<stop offset=".1" stop-color="#aaa" stop-opacity=".1"/>
<stop offset=".9" stop-color="#000" stop-opacity=".3"/>
<stop offset="1" stop-color="#000" stop-opacity=".5"/>
</linearGradient>
<clipPath id="r">
<rect width="${this.width}" height="${this.constructor.height}" rx="4" fill="#fff"/>
</clipPath>
<g clip-path="url(#r)">
<rect width="${this.leftWidth}" height="${this.constructor.height}" fill="${this.labelColor}"/>
<rect x="${this.leftWidth}" width="${this.rightWidth}" height="${this.constructor.height}" fill="${this.color}"/>
<rect width="${this.width}" height="${this.constructor.height}" fill="url(#s)"/>
</g>
<g fill="#fff" text-anchor="middle" ${this.constructor.fontFamily} text-rendering="geometricPrecision" font-size="110">
${this.renderedLogo}
${this.renderedLabel}
${this.renderedMessage}
</g>`
)
}
}
class Flat extends Badge {
static get fontFamily() {
return fontFamily
}
static get height() {
return 20
}
static get verticalMargin() {
return 0
}
static get shadow() {
return true
}
render() {
return renderBadge(
{
links: this.links,
leftWidth: this.leftWidth,
rightWidth: this.rightWidth,
accessibleText: this.accessibleText,
height: this.constructor.height,
},
`
<linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<clipPath id="r">
<rect width="${this.width}" height="${this.constructor.height}" rx="3" fill="#fff"/>
</clipPath>
<g clip-path="url(#r)">
<rect width="${this.leftWidth}" height="${this.constructor.height}" fill="${this.labelColor}"/>
<rect x="${this.leftWidth}" width="${this.rightWidth}" height="${this.constructor.height}" fill="${this.color}"/>
<rect width="${this.width}" height="${this.constructor.height}" fill="url(#s)"/>
</g>
<g fill="#fff" text-anchor="middle" ${this.constructor.fontFamily} text-rendering="geometricPrecision" font-size="110">
${this.renderedLogo}
${this.renderedLabel}
${this.renderedMessage}
</g>`
)
}
}
class FlatSquare extends Badge {
static get fontFamily() {
return fontFamily
}
static get height() {
return 20
}
static get verticalMargin() {
return 0
}
static get shadow() {
return false
}
render() {
return renderBadge(
{
links: this.links,
leftWidth: this.leftWidth,
rightWidth: this.rightWidth,
accessibleText: this.accessibleText,
height: this.constructor.height,
},
`
<g shape-rendering="crispEdges">
<rect width="${this.leftWidth}" height="${this.constructor.height}" fill="${this.labelColor}"/>
<rect x="${this.leftWidth}" width="${this.rightWidth}" height="${this.constructor.height}" fill="${this.color}"/>
</g>
<g fill="#fff" text-anchor="middle" ${this.constructor.fontFamily} text-rendering="geometricPrecision" font-size="110">
${this.renderedLogo}
${this.renderedLabel}
${this.renderedMessage}
</g>`
)
}
}
function social({
label,
message,
links = [],
logo,
logoWidth,
logoPadding,
color = '#4c1',
labelColor = '#555',
}) {
// Social label is styled with a leading capital. Convert to caps here so
// width can be measured using the correct characters.
label = capitalize(label)
const externalHeight = 20
const internalHeight = 19
const labelHorizPadding = 5
const messageHorizPadding = 4
const horizGutter = 6
const { totalLogoWidth, renderedLogo } = renderLogo({
logo,
badgeHeight: externalHeight,
horizPadding: labelHorizPadding,
logoWidth,
logoPadding,
})
const hasMessage = message.length
const font = 'bold 11px Helvetica'
const labelTextWidth = preferredWidthOf(label, { font })
const messageTextWidth = preferredWidthOf(message, { font })
const labelRectWidth = labelTextWidth + totalLogoWidth + 2 * labelHorizPadding
const messageRectWidth = messageTextWidth + 2 * messageHorizPadding
let [leftLink, rightLink] = links
leftLink = escapeXml(leftLink)
rightLink = escapeXml(rightLink)
const { hasLeftLink, hasRightLink, hasLink } = hasLinks({ links })
const accessibleText = createAccessibleText({ label, message })
function renderMessageBubble() {
const messageBubbleMainX = labelRectWidth + horizGutter + 0.5
const messageBubbleNotchX = labelRectWidth + horizGutter
return `
<rect x="${messageBubbleMainX}" y="0.5" width="${messageRectWidth}" height="${internalHeight}" rx="2" fill="#fafafa"/>
<rect x="${messageBubbleNotchX}" y="7.5" width="0.5" height="5" stroke="#fafafa"/>
<path d="M${messageBubbleMainX} 6.5 l-3 3v1 l3 3" stroke="d5d5d5" fill="#fafafa"/>
`
}
function renderLabelText() {
const labelTextX =
10 * (totalLogoWidth + labelTextWidth / 2 + labelHorizPadding)
const labelTextLength = 10 * labelTextWidth
const escapedLabel = escapeXml(label)
const shouldWrapWithLink = hasLeftLink && !shouldWrapBodyWithLink({ links })
const rect = `<rect id="llink" stroke="#d5d5d5" fill="url(#a)" x=".5" y=".5" width="${labelRectWidth}" height="${internalHeight}" rx="2" />`
const shadow = `<text aria-hidden="true" x="${labelTextX}" y="150" fill="#fff" transform="scale(.1)" textLength="${labelTextLength}">${escapedLabel}</text>`
const text = `<text x="${labelTextX}" y="140" transform="scale(.1)" textLength="${labelTextLength}">${escapedLabel}</text>`
return shouldWrapWithLink
? `
<a target="_blank" xlink:href="${leftLink}">
${shadow}
${text}
${rect}
</a>
`
: `
${rect}
${shadow}
${text}
`
}
function renderMessageText() {
const messageTextX =
10 * (labelRectWidth + horizGutter + messageRectWidth / 2)
const messageTextLength = 10 * messageTextWidth
const escapedMessage = escapeXml(message)
const rect = `<rect width="${messageRectWidth + 1}" x="${
labelRectWidth + horizGutter
}" height="${internalHeight + 1}" fill="rgba(0,0,0,0)" />`
const shadow = `<text aria-hidden="true" x="${messageTextX}" y="150" fill="#fff" transform="scale(.1)" textLength="${messageTextLength}">${escapedMessage}</text>`
const text = `<text id="rlink" x="${messageTextX}" y="140" transform="scale(.1)" textLength="${messageTextLength}">${escapedMessage}</text>`
return hasRightLink
? `
<a target="_blank" xlink:href="${rightLink}">
${rect}
${shadow}
${text}
</a>
`
: `
${shadow}
${text}
`
}
return renderBadge(
{
links,
leftWidth: labelRectWidth + 1,
rightWidth: hasMessage ? horizGutter + messageRectWidth : 0,
accessibleText,
height: externalHeight,
},
`
<style>a:hover #llink{fill:url(#b);stroke:#ccc}a:hover #rlink{fill:#4183c4}</style>
<linearGradient id="a" x2="0" y2="100%">
<stop offset="0" stop-color="#fcfcfc" stop-opacity="0"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<linearGradient id="b" x2="0" y2="100%">
<stop offset="0" stop-color="#ccc" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<g stroke="#d5d5d5">
<rect stroke="none" fill="#fcfcfc" x="0.5" y="0.5" width="${labelRectWidth}" height="${internalHeight}" rx="2"/>
${hasMessage ? renderMessageBubble() : ''}
</g>
${renderedLogo}
<g aria-hidden="${!hasLink}" fill="#333" text-anchor="middle" ${socialFontFamily} text-rendering="geometricPrecision" font-weight="700" font-size="110px" line-height="14px">
${renderLabelText()}
${hasMessage ? renderMessageText() : ''}
</g>
`
)
}
function forTheBadge({
label,
message,
links,
logo,
logoWidth,
color = '#4c1',
labelColor,
}) {
const FONT_SIZE = 10
const BADGE_HEIGHT = 28
const LOGO_HEIGHT = 14
const TEXT_MARGIN = 12
const LOGO_MARGIN = 9
const LOGO_TEXT_GUTTER = 6
const LETTER_SPACING = 1.25
// Prepare content. For the Badge is styled in all caps. It's important to to
// convert to uppercase first so the widths can be measured using the correct
// symbols.
label = label.toUpperCase()
message = message.toUpperCase()
const [leftLink, rightLink] = links
const { hasLeftLink, hasRightLink } = hasLinks({ links })
const outLabelColor = labelColor || '#555'
// Compute text width.
// TODO: This really should count the symbols rather than just using `.length`.
// https://mathiasbynens.be/notes/javascript-unicode
// This is not using `preferredWidthOf()` as it tends to produce larger
// inconsistencies in the letter spacing. The badges look fine, however if you
// replace `textLength` with `letterSpacing` in the rendered SVG, you can see
// the discrepancy. Ideally, swapping out `textLength` for `letterSpacing`
// should not affect the appearance.
const labelTextWidth = label.length
? (anafanafo(label, { font: `${FONT_SIZE}px Verdana` }) | 0) +
LETTER_SPACING * label.length
: 0
const messageTextWidth = message.length
? (anafanafo(message, { font: `bold ${FONT_SIZE}px Verdana` }) | 0) +
LETTER_SPACING * message.length
: 0
// Compute horizontal layout.
// If a `labelColor` is set, the logo is always set against it, even when
// there is no label. When `needsLabelRect` is true, render a label rect and a
// message rect; when false, only a message rect.
const hasLabel = Boolean(label.length)
const needsLabelRect = hasLabel || (logo && labelColor)
let logoMinX, labelTextMinX
if (logo) {
logoMinX = LOGO_MARGIN
labelTextMinX = logoMinX + logoWidth + LOGO_TEXT_GUTTER
} else {
labelTextMinX = TEXT_MARGIN
}
let labelRectWidth, messageTextMinX, messageRectWidth
if (needsLabelRect) {
if (hasLabel) {
labelRectWidth = labelTextMinX + labelTextWidth + TEXT_MARGIN
} else {
labelRectWidth = 2 * LOGO_MARGIN + logoWidth
}
messageTextMinX = labelRectWidth + TEXT_MARGIN
messageRectWidth = 2 * TEXT_MARGIN + messageTextWidth
} else {
if (logo) {
messageTextMinX = TEXT_MARGIN + logoWidth + LOGO_TEXT_GUTTER
messageRectWidth =
2 * TEXT_MARGIN + logoWidth + LOGO_TEXT_GUTTER + messageTextWidth
} else {
messageTextMinX = TEXT_MARGIN
messageRectWidth = 2 * TEXT_MARGIN + messageTextWidth
}
}
const logoElement = new XmlElement({
name: 'image',
attrs: {
x: logoMinX,
y: 0.5 * (BADGE_HEIGHT - LOGO_HEIGHT),
width: logoWidth,
height: LOGO_HEIGHT,
'xlink:href': logo,
},
})
function getLabelElement() {
const { textColor } = colorsForBackground(outLabelColor)
const midX = labelTextMinX + 0.5 * labelTextWidth
const text = new XmlElement({
name: 'text',
content: [label],
attrs: {
transform: FONT_SCALE_DOWN_VALUE,
x: FONT_SCALE_UP_FACTOR * midX,
y: 175,
textLength: FONT_SCALE_UP_FACTOR * labelTextWidth,
fill: textColor,
},
})
if (hasLeftLink && !shouldWrapBodyWithLink({ links })) {
const rect = new XmlElement({
name: 'rect',
attrs: {
width: labelRectWidth,
height: BADGE_HEIGHT,
fill: 'rgba(0,0,0,0)',
},
})
return new XmlElement({
name: 'a',
content: [rect, text],
attrs: {
target: '_blank',
'xlink:href': leftLink,
},
})
} else {
return text
}
}
function getMessageElement() {
const { textColor } = colorsForBackground(color)
const midX = messageTextMinX + 0.5 * messageTextWidth
const text = new XmlElement({
name: 'text',
content: [message],
attrs: {
transform: FONT_SCALE_DOWN_VALUE,
x: FONT_SCALE_UP_FACTOR * midX,
y: 175,
textLength: FONT_SCALE_UP_FACTOR * messageTextWidth,
fill: textColor,
'font-weight': 'bold',
},
})
if (hasRightLink) {
const rect = new XmlElement({
name: 'rect',
attrs: {
width: messageRectWidth,
height: BADGE_HEIGHT,
x: labelRectWidth || 0,
fill: 'rgba(0,0,0,0)',
},
})
return new XmlElement({
name: 'a',
content: [rect, text],
attrs: {
target: '_blank',
'xlink:href': rightLink,
},
})
} else {
return text
}
}
let backgroundContent
if (needsLabelRect) {
backgroundContent = [
new XmlElement({
name: 'rect',
attrs: {
width: labelRectWidth,
height: BADGE_HEIGHT,
fill: outLabelColor,
},
}),
new XmlElement({
name: 'rect',
attrs: {
x: labelRectWidth,
width: messageRectWidth,
height: BADGE_HEIGHT,
fill: color,
},
}),
]
} else {
backgroundContent = [
new XmlElement({
name: 'rect',
attrs: {
width: messageRectWidth,
height: BADGE_HEIGHT,
fill: color,
},
}),
]
}
const backgroundGroup = new XmlElement({
name: 'g',
content: backgroundContent,
attrs: {
'shape-rendering': 'crispEdges',
},
})
const foregroundGroup = new XmlElement({
name: 'g',
content: [
logo ? logoElement : '',
hasLabel ? getLabelElement() : '',
getMessageElement(),
],
attrs: {
fill: '#fff',
'text-anchor': 'middle',
'font-family': FONT_FAMILY,
'text-rendering': 'geometricPrecision',
'font-size': FONT_SCALE_UP_FACTOR * FONT_SIZE,
},
})
// Render.
return renderBadge(
{
links,
leftWidth: labelRectWidth || 0,
rightWidth: messageRectWidth,
accessibleText: createAccessibleText({ label, message }),
height: BADGE_HEIGHT,
},
[backgroundGroup.render(), foregroundGroup.render()].join('')
)
}
module.exports = {
plastic: params => Plastic.render(params),
flat: params => Flat.render(params),
'flat-square': params => FlatSquare.render(params),
social,
'for-the-badge': forTheBadge,
}

88
node_modules/badge-maker/lib/color.js generated vendored Normal file
View File

@@ -0,0 +1,88 @@
'use strict'
const { fromString } = require('css-color-converter')
// When updating these, be sure also to update the list in `badge-maker/README.md`.
const namedColors = {
brightgreen: '#4c1',
green: '#97ca00',
yellow: '#dfb317',
yellowgreen: '#a4a61d',
orange: '#fe7d37',
red: '#e05d44',
blue: '#007ec6',
grey: '#555',
lightgrey: '#9f9f9f',
}
const aliases = {
gray: 'grey',
lightgray: 'lightgrey',
critical: 'red',
important: 'orange',
success: 'brightgreen',
informational: 'blue',
inactive: 'lightgrey',
}
const resolvedAliases = {}
Object.entries(aliases).forEach(([alias, original]) => {
resolvedAliases[alias] = namedColors[original]
})
// This function returns false for `#ccc`. However `isCSSColor('#ccc')` is
// true.
const hexColorRegex = /^([\da-f]{3}){1,2}$/i
function isHexColor(s = '') {
return hexColorRegex.test(s)
}
function isCSSColor(color) {
return typeof color === 'string' && fromString(color.trim())
}
function normalizeColor(color) {
if (color === undefined) {
return undefined
} else if (color in namedColors) {
return color
} else if (color in aliases) {
return aliases[color]
} else if (isHexColor(color)) {
return `#${color.toLowerCase()}`
} else if (isCSSColor(color)) {
return color.toLowerCase()
} else {
return undefined
}
}
function toSvgColor(color) {
const normalized = normalizeColor(color)
if (normalized in namedColors) {
return namedColors[normalized]
} else if (normalized in resolvedAliases) {
return resolvedAliases[normalized]
} else {
return normalized
}
}
function brightness(color) {
if (color) {
const cssColor = fromString(color)
if (cssColor) {
const rgb = cssColor.toRgbaArray()
return +((rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 255000).toFixed(2)
}
}
return 0
}
module.exports = {
namedColors,
isHexColor,
normalizeColor,
toSvgColor,
brightness,
}

81
node_modules/badge-maker/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
'use strict'
/**
* @module badge-maker
*/
const _makeBadge = require('./make-badge')
class ValidationError extends Error {}
function _validate(format) {
if (format !== Object(format)) {
throw new ValidationError('makeBadge takes an argument of type object')
}
if (!('message' in format)) {
throw new ValidationError('Field `message` is required')
}
const stringFields = ['labelColor', 'color', 'message', 'label']
stringFields.forEach(function (field) {
if (field in format && typeof format[field] !== 'string') {
throw new ValidationError(`Field \`${field}\` must be of type string`)
}
})
const styleValues = [
'plastic',
'flat',
'flat-square',
'for-the-badge',
'social',
]
if ('style' in format && !styleValues.includes(format.style)) {
throw new ValidationError(
`Field \`style\` must be one of (${styleValues.toString()})`
)
}
}
function _clean(format) {
const expectedKeys = ['label', 'message', 'labelColor', 'color', 'style']
const cleaned = {}
Object.keys(format).forEach(key => {
if (format[key] != null && expectedKeys.includes(key)) {
cleaned[key] = format[key]
} else {
throw new ValidationError(
`Unexpected field '${key}'. Allowed values are (${expectedKeys.toString()})`
)
}
})
// Legacy.
cleaned.label = cleaned.label || ''
return cleaned
}
/**
* Create a badge
*
* @param {object} format Object specifying badge data
* @param {string} format.label (Optional) Badge label (e.g: 'build')
* @param {string} format.message (Required) Badge message (e.g: 'passing')
* @param {string} format.labelColor (Optional) Label color
* @param {string} format.color (Optional) Message color
* @param {string} format.style (Optional) Visual style e.g: 'flat'
* @returns {string} Badge in SVG format
* @see https://github.com/badges/shields/tree/master/badge-maker/README.md
*/
function makeBadge(format) {
_validate(format)
const cleanedFormat = _clean(format)
return _makeBadge(cleanedFormat)
}
module.exports = {
makeBadge,
ValidationError,
}

63
node_modules/badge-maker/lib/make-badge.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
'use strict'
const { normalizeColor, toSvgColor } = require('./color')
const badgeRenderers = require('./badge-renderers')
const { stripXmlWhitespace } = require('./xml')
/*
note: makeBadge() is fairly thinly wrapped so if we are making changes here
it is likely this will impact on the package's public interface in index.js
*/
module.exports = function makeBadge({
format,
style = 'flat',
label,
message,
color,
labelColor,
logo,
logoPosition,
logoWidth,
links = ['', ''],
}) {
// String coercion and whitespace removal.
label = `${label}`.trim()
message = `${message}`.trim()
// This ought to be the responsibility of the server, not `makeBadge`.
if (format === 'json') {
return JSON.stringify({
label,
message,
logoWidth,
// Only call normalizeColor for the JSON case: this is handled
// internally by toSvgColor in the SVG case.
color: normalizeColor(color),
labelColor: normalizeColor(labelColor),
link: links,
name: label,
value: message,
})
}
const render = badgeRenderers[style]
if (!render) {
throw new Error(`Unknown badge style: '${style}'`)
}
logoWidth = +logoWidth || (logo ? 14 : 0)
return stripXmlWhitespace(
render({
label,
message,
links,
logo,
logoPosition,
logoWidth,
logoPadding: logo && label.length ? 3 : 0,
color: toSvgColor(color),
labelColor: toSvgColor(labelColor),
})
)
}

76
node_modules/badge-maker/lib/xml.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
/**
* @module
*/
'use strict'
function stripXmlWhitespace(xml) {
return xml.replace(/>\s+/g, '>').replace(/<\s+/g, '<').trim()
}
function escapeXml(s) {
if (typeof s === 'number') {
return s
} else if (s === undefined || typeof s !== 'string') {
return undefined
} else {
return s
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;')
}
}
/**
* Representation of an XML element
*/
class XmlElement {
/**
* Xml Element Constructor
*
* @param {object} attrs Refer to individual attrs
* @param {string} attrs.name
* Name of the XML tag
* @param {Array.<string|module:badge-maker/lib/xml-element~XmlElement>} [attrs.content=[]]
* Array of objects to render inside the tag. content may contain a mix of
* string and XmlElement objects. If content is `[]` or ommitted the
* element will be rendered as a self-closing element.
* @param {object} [attrs.attrs={}]
* Object representing the tag's attributes as name/value pairs
*/
constructor({ name, content = [], attrs = {} }) {
this.name = name
this.content = content
this.attrs = attrs
}
/**
* Render the XML element to a string, applying appropriate escaping
*
* @returns {string} String representation of the XML element
*/
render() {
const attrsStr = Object.entries(this.attrs)
.map(([k, v]) => ` ${k}="${escapeXml(v)}"`)
.join('')
if (this.content.length > 0) {
const content = this.content
.map(function (el) {
if (el instanceof XmlElement) {
return el.render()
} else {
return escapeXml(el)
}
})
.join(' ')
return stripXmlWhitespace(
`<${this.name}${attrsStr}>${content}</${this.name}>`
)
}
return stripXmlWhitespace(`<${this.name}${attrsStr}/>`)
}
}
module.exports = { escapeXml, stripXmlWhitespace, XmlElement }

44
node_modules/badge-maker/package.json generated vendored Normal file
View File

@@ -0,0 +1,44 @@
{
"name": "badge-maker",
"version": "3.3.1",
"description": "Shields.io badge library",
"keywords": [
"GitHub",
"badge",
"SVG",
"image",
"shields.io"
],
"types": "index.d.ts",
"main": "lib/index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/badges/shields.git",
"directory": "badge-maker"
},
"author": "Thaddée Tyl <thaddee.tyl@gmail.com>",
"license": "CC0-1.0",
"bugs": {
"url": "https://github.com/badges/shields/issues"
},
"homepage": "http://shields.io",
"bin": {
"badge": "lib/badge-cli.js"
},
"engines": {
"node": ">= 10",
"npm": ">= 5"
},
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/shields",
"logo": "https://opencollective.com/opencollective/logo.txt"
},
"dependencies": {
"anafanafo": "2.0.0",
"css-color-converter": "^2.0.0"
},
"scripts": {
"test": "echo 'Run tests from parent dir'; false"
}
}

6
node_modules/binary-search/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,6 @@
language: node_js
node_js:
- '6'
cache:
directories:
- node_modules

46
node_modules/binary-search/README.md generated vendored Normal file
View File

@@ -0,0 +1,46 @@
binary-search
=============
This is a really tiny, stupid, simple binary search library for Node.JS. We
wrote it because existing solutions were bloated and incorrect.
This version is a straight port of the Java version mentioned by Joshua Bloch
in his article, [Nearly All Binary Searches and Merge Sorts are Broken](http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html).
Thanks to [Conrad Irwin](https://github.com/ConradIrwin) and [Michael
Marino](https://github.com/mgmarino) for, ironically, pointing out bugs.
Example
-------
```js
var bs = require("binary-search");
bs([1, 2, 3, 4], 3, function(element, needle) { return element - needle; });
// => 2
bs([1, 2, 4, 5], 3, function(element, needle) { return element - needle; });
// => -3
```
Be advised that passing in a comparator function is *required*. Since you're
probably using one for your sort function anyway, this isn't a big deal.
The comparator takes a 1st and 2nd argument of element and needle, respectively.
The comparator also takes a 3rd and 4th argument, the current index and array,
respectively. You shouldn't normally need the index or array to compare values,
but it's there if you do.
You may also, optionally, specify an input range as the final two parameters,
in case you want to limit the search to a particular range of inputs. However,
be advised that this is generally a bad idea (but sometimes bad ideas are
necessary).
License
-------
To the extent possible by law, The Dark Sky Company, LLC has [waived all
copyright and related or neighboring rights][cc0] to this library.
[cc0]: http://creativecommons.org/publicdomain/zero/1.0/

22
node_modules/binary-search/binary-search.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
//Typescript type definition for:
//https://github.com/darkskyapp/binary-search
declare module 'binary-search' {
function binarySearch<A, B>(
haystack: ArrayLike<A>,
needle: B,
comparator: (a: A, b: B, index?: number, haystack?: A[]) => any,
// Notes about comparator return value:
// * when a<b the comparator's returned value should be:
// * negative number or a value such that `+value` is a negative number
// * examples: `-1` or the string `"-1"`
// * when a>b the comparator's returned value should be:
// * positive number or a value such that `+value` is a positive number
// * examples: `1` or the string `"1"`
// * when a===b
// * any value other than the return cases for a<b and a>b
// * examples: undefined, NaN, 'abc'
low?: number,
high?: number): number; //returns index of found result or number < 0 if not found
export = binarySearch;
}

45
node_modules/binary-search/index.js generated vendored Normal file
View File

@@ -0,0 +1,45 @@
module.exports = function(haystack, needle, comparator, low, high) {
var mid, cmp;
if(low === undefined)
low = 0;
else {
low = low|0;
if(low < 0 || low >= haystack.length)
throw new RangeError("invalid lower bound");
}
if(high === undefined)
high = haystack.length - 1;
else {
high = high|0;
if(high < low || high >= haystack.length)
throw new RangeError("invalid upper bound");
}
while(low <= high) {
// The naive `low + high >>> 1` could fail for array lengths > 2**31
// because `>>>` converts its operands to int32. `low + (high - low >>> 1)`
// works for array lengths <= 2**32-1 which is also Javascript's max array
// length.
mid = low + ((high - low) >>> 1);
cmp = +comparator(haystack[mid], needle, mid, haystack);
// Too low.
if(cmp < 0.0)
low = mid + 1;
// Too high.
else if(cmp > 0.0)
high = mid - 1;
// Key found.
else
return mid;
}
// Key not found.
return ~low;
}

28
node_modules/binary-search/package.json generated vendored Normal file
View File

@@ -0,0 +1,28 @@
{
"name": "binary-search",
"version": "1.3.6",
"description": "tiny binary search function with comparators",
"license": "CC0-1.0",
"typings": "./binary-search.d.ts",
"author": {
"name": "The Dark Sky Company, LLC",
"email": "support@darkskyapp.com"
},
"contributors": [
{
"name": "Darcy Parker",
"web": "https://github.com/darcyparker"
}
],
"repository": {
"type": "git",
"url": "git://github.com/darkskyapp/binary-search.git"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^5.2.0"
},
"scripts": {
"test": "mocha"
}
}

46
node_modules/binary-search/test.js generated vendored Normal file
View File

@@ -0,0 +1,46 @@
var expect = require("chai").expect;
describe("binarysearch", function() {
var bs = require("./"),
arr = [1, 2, 2, 2, 3, 5, 9],
cmp = function(a, b) { return a - b; };
it("should bail if not passed an array", function() {
expect(function() { bs(undefined, 3, cmp); }).to.throw(TypeError);
});
it("should bail if not passed a comparator", function() {
expect(function() { bs(arr, 3, undefined); }).to.throw(TypeError);
});
it("should return the index of an item in a sorted array", function() {
expect(bs(arr, 3, cmp)).to.equal(4);
});
it("should return the index of where the item would go plus one, negated, if the item is not found", function() {
expect(bs(arr, 4, cmp)).to.equal(-6);
});
it("should return any valid index if an item exists multiple times in the array", function() {
expect(bs(arr, 2, cmp)).to.equal(3);
});
it("should work even on empty arrays", function() {
expect(bs([], 42, cmp)).to.equal(-1);
});
it("should work even on arrays of doubles", function() {
expect(bs([0.0, 0.1, 0.2, 0.3, 0.4], 0.25, cmp)).to.equal(-4);
});
it("should pass the index and array parameters to the comparator", function() {
var indexes = [],
indexCmp = function(a, b, i, array) {
expect(array).to.equal(arr);
indexes.push(i);
return cmp(a, b);
};
bs(arr, 3, indexCmp);
expect(indexes).to.deep.equal([3, 5, 4])
});
});

18
node_modules/char-width-table-consumer/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,18 @@
# Changelog
## 1.0.0 Apr 12, 2019
- Update dependencies.
- Same API as previous release.
## 0.2.1 Nov 15, 2018
No external changes.
## 0.2.0 Nov 13, 2018
- Add `loadConsumerSync()` function.
## 0.1.0 Nov 13, 2018
Initial release.

21
node_modules/char-width-table-consumer/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2018 Metabolize LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

32
node_modules/char-width-table-consumer/README.md generated vendored Normal file
View File

@@ -0,0 +1,32 @@
# char-width-table-consumer
[![version](https://img.shields.io/npm/v/char-width-table-consumer.svg?style=flat-square)][npm]
[![license](https://img.shields.io/npm/l/char-width-table-consumer.svg?style=flat-square)][npm]
[![build](https://img.shields.io/circleci/project/github/metabolize/anafanafo.svg?style=flat-square)][build]
[![code style](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)][prettier]
[![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg?style=flat-square)][lerna]
[npm]: https://npmjs.com/char-width-table-consumer
[build]: https://circleci.com/gh/metabolize/anafanafo/tree/master
[prettier]: https://prettier.io/
[lerna]: https://lernajs.io/
Measure text using a character width table.
[puppeteer]: https://pptr.dev/
## Features
This library allows efficient text measuring using a character width table.
Create the tables using companion package [char-width-table-builder][].
This performs a simple lookup, without considering kerning.
Built with [Shields][] in mind.
[char-width-table-builder]: https://www.npmjs.com/package/char-width-table-builder
[shields]: https://github.com/badges/shields/
## License
This project is licensed under the MIT license.

16
node_modules/char-width-table-consumer/package.json generated vendored Normal file
View File

@@ -0,0 +1,16 @@
{
"name": "char-width-table-consumer",
"version": "1.0.0",
"repository": "metabolize/anafanafo",
"description": "Measure text using a character width table",
"main": "src",
"scripts": {
"test": "jest"
},
"author": "Metabolize",
"license": "MIT",
"dependencies": {
"binary-search": "^1.3.5"
},
"gitHead": "4bd230d372ffe93cd9bf7f036b83be6ef5dab75e"
}

79
node_modules/char-width-table-consumer/src/consumer.js generated vendored Normal file
View File

@@ -0,0 +1,79 @@
'use strict'
const fs = require('fs')
const bs = require('binary-search')
const { promisify } = require('util')
const readFile = promisify(fs.readFile)
module.exports = class CharWidthTableConsumer {
constructor(data) {
this.data = data
this.emWidth = this.widthOf('m')
}
static create(data) {
return new CharWidthTableConsumer(data)
}
static async load(path) {
const json = await readFile(path)
const data = JSON.parse(json)
return new CharWidthTableConsumer(data)
}
static loadSync(path) {
const json = fs.readFileSync(path)
const data = JSON.parse(json)
return new CharWidthTableConsumer(data)
}
static isControlChar(charCode) {
return charCode <= 31 || charCode === 127
}
widthOfCharCode(charCode) {
if (this.constructor.isControlChar(charCode)) {
return 0.0
}
// https://github.com/darkskyapp/binary-search/pull/18
const index = bs(this.data, charCode, ([lower], needle) => lower - needle)
if (index >= 0) {
// The index matches the beginning of a range.
const [, , width] = this.data[index]
return width
} else {
// The index does not match the beginning of a range, which means it
// should be in the preceeding range A return value of `-x` means the
// needle would be at `x - 1`, and we want to check the element before
// that.
const candidateIndex = -index - 2
const [lower, upper, width] = this.data[candidateIndex]
if (charCode >= lower && charCode <= upper) {
return width
} else {
return undefined
}
}
}
widthOf(text, { guess = true } = {}) {
// Array.from() will split a string into an array of strings, each of
// which contains a single code point.
// https://stackoverflow.com/a/42596897/893113
return Array.from(text).reduce((accumWidth, char) => {
const charWidth = this.widthOfCharCode(char.codePointAt(0))
if (charWidth === undefined) {
if (guess) {
return accumWidth + this.emWidth
} else {
throw Error(
`No width available for character code ${char.codePointAt(0)}`
)
}
} else {
return accumWidth + charWidth
}
}, 0.0)
}
}

16
node_modules/char-width-table-consumer/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
'use strict'
const CharWidthTableConsumer = require('./consumer')
const {
create: createConsumer,
load: loadConsumer,
loadSync: loadConsumerSync,
} = CharWidthTableConsumer
module.exports = {
createConsumer,
loadConsumer,
loadConsumerSync,
CharWidthTableConsumer,
}

1
node_modules/color-convert/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1 @@
language: node_js

4
node_modules/color-convert/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,4 @@
# 0.5.3 - 2015-06-02
- Fixed: hsl2hsv does not return `NaN` anymore when using `[0,0,0]`
([#15](https://github.com/harthur/color-convert/issues/15))

21
node_modules/color-convert/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
Copyright (c) 2011 Heather Arthur <fayearthur@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

57
node_modules/color-convert/README.md generated vendored Normal file
View File

@@ -0,0 +1,57 @@
# color-convert [![Build Status](https://travis-ci.org/harthur/color-convert.svg?branch=master)](https://travis-ci.org/harthur/color-convert)
Color-convert is a color conversion library for JavaScript and node. It converts all ways between `rgb`, `hsl`, `hsv`, `hwb`, `cmyk`, and CSS keywords:
```js
var converter = require("color-convert")();
converter.rgb(140, 200, 100).hsl() // [96, 48, 59]
converter.keyword("blue").rgb() // [0, 0, 255]
```
# Install
```console
npm install color-convert
```
# API
Color-convert exports a converter object with getter/setter methods for each color space. It caches conversions:
```js
var converter = require("color-convert")();
converter.rgb(140, 200, 100).hsl() // [96, 48, 59]
converter.rgb([140, 200, 100]) // args can be an array
```
### Plain functions
Get direct conversion functions with no fancy objects:
```js
require("color-convert").rgb2hsl([140, 200, 100]); // [96, 48, 59]
```
### Unrounded
To get the unrounded conversion, append `Raw` to the function name:
```js
convert.rgb2hslRaw([140, 200, 100]); // [95.99999999999999, 47.619047619047606, 58.82352941176471]
```
### Hash
There's also a hash of the conversion functions keyed first by the "from" color space, then by the "to" color space:
```js
convert["hsl"]["hsv"]([160, 0, 20]) == convert.hsl2hsv([160, 0, 20])
```
### Other spaces
There are some conversions from rgb (sRGB) to XYZ and LAB too, available as `rgb2xyz()`, `rgb2lab()`, `xyz2rgb()`, and `xyz2lab()`.
# Contribute
Please fork, add conversions, figure out color profile stuff for XYZ, LAB, etc. This is meant to be a basic library that can be used by other libraries to wrap color calculations in some cool way.

9
node_modules/color-convert/component.json generated vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"name": "color-convert",
"description": "Plain color conversion functions",
"version": "0.5.3",
"author": "Heather Arthur <fayearthur@gmail.com>",
"repository": "harthur/color-convert",
"keywords": ["color", "colour", "rgb"],
"scripts": ["index.js", "conversions.js"]
}

698
node_modules/color-convert/conversions.js generated vendored Normal file
View File

@@ -0,0 +1,698 @@
/* MIT license */
module.exports = {
rgb2hsl: rgb2hsl,
rgb2hsv: rgb2hsv,
rgb2hwb: rgb2hwb,
rgb2cmyk: rgb2cmyk,
rgb2keyword: rgb2keyword,
rgb2xyz: rgb2xyz,
rgb2lab: rgb2lab,
rgb2lch: rgb2lch,
hsl2rgb: hsl2rgb,
hsl2hsv: hsl2hsv,
hsl2hwb: hsl2hwb,
hsl2cmyk: hsl2cmyk,
hsl2keyword: hsl2keyword,
hsv2rgb: hsv2rgb,
hsv2hsl: hsv2hsl,
hsv2hwb: hsv2hwb,
hsv2cmyk: hsv2cmyk,
hsv2keyword: hsv2keyword,
hwb2rgb: hwb2rgb,
hwb2hsl: hwb2hsl,
hwb2hsv: hwb2hsv,
hwb2cmyk: hwb2cmyk,
hwb2keyword: hwb2keyword,
cmyk2rgb: cmyk2rgb,
cmyk2hsl: cmyk2hsl,
cmyk2hsv: cmyk2hsv,
cmyk2hwb: cmyk2hwb,
cmyk2keyword: cmyk2keyword,
keyword2rgb: keyword2rgb,
keyword2hsl: keyword2hsl,
keyword2hsv: keyword2hsv,
keyword2hwb: keyword2hwb,
keyword2cmyk: keyword2cmyk,
keyword2lab: keyword2lab,
keyword2xyz: keyword2xyz,
xyz2rgb: xyz2rgb,
xyz2lab: xyz2lab,
xyz2lch: xyz2lch,
lab2xyz: lab2xyz,
lab2rgb: lab2rgb,
lab2lch: lab2lch,
lch2lab: lch2lab,
lch2xyz: lch2xyz,
lch2rgb: lch2rgb
}
function rgb2hsl(rgb) {
var r = rgb[0]/255,
g = rgb[1]/255,
b = rgb[2]/255,
min = Math.min(r, g, b),
max = Math.max(r, g, b),
delta = max - min,
h, s, l;
if (max == min)
h = 0;
else if (r == max)
h = (g - b) / delta;
else if (g == max)
h = 2 + (b - r) / delta;
else if (b == max)
h = 4 + (r - g)/ delta;
h = Math.min(h * 60, 360);
if (h < 0)
h += 360;
l = (min + max) / 2;
if (max == min)
s = 0;
else if (l <= 0.5)
s = delta / (max + min);
else
s = delta / (2 - max - min);
return [h, s * 100, l * 100];
}
function rgb2hsv(rgb) {
var r = rgb[0],
g = rgb[1],
b = rgb[2],
min = Math.min(r, g, b),
max = Math.max(r, g, b),
delta = max - min,
h, s, v;
if (max == 0)
s = 0;
else
s = (delta/max * 1000)/10;
if (max == min)
h = 0;
else if (r == max)
h = (g - b) / delta;
else if (g == max)
h = 2 + (b - r) / delta;
else if (b == max)
h = 4 + (r - g) / delta;
h = Math.min(h * 60, 360);
if (h < 0)
h += 360;
v = ((max / 255) * 1000) / 10;
return [h, s, v];
}
function rgb2hwb(rgb) {
var r = rgb[0],
g = rgb[1],
b = rgb[2],
h = rgb2hsl(rgb)[0],
w = 1/255 * Math.min(r, Math.min(g, b)),
b = 1 - 1/255 * Math.max(r, Math.max(g, b));
return [h, w * 100, b * 100];
}
function rgb2cmyk(rgb) {
var r = rgb[0] / 255,
g = rgb[1] / 255,
b = rgb[2] / 255,
c, m, y, k;
k = Math.min(1 - r, 1 - g, 1 - b);
c = (1 - r - k) / (1 - k) || 0;
m = (1 - g - k) / (1 - k) || 0;
y = (1 - b - k) / (1 - k) || 0;
return [c * 100, m * 100, y * 100, k * 100];
}
function rgb2keyword(rgb) {
return reverseKeywords[JSON.stringify(rgb)];
}
function rgb2xyz(rgb) {
var r = rgb[0] / 255,
g = rgb[1] / 255,
b = rgb[2] / 255;
// assume sRGB
r = r > 0.04045 ? Math.pow(((r + 0.055) / 1.055), 2.4) : (r / 12.92);
g = g > 0.04045 ? Math.pow(((g + 0.055) / 1.055), 2.4) : (g / 12.92);
b = b > 0.04045 ? Math.pow(((b + 0.055) / 1.055), 2.4) : (b / 12.92);
var x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
var y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
var z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
return [x * 100, y *100, z * 100];
}
function rgb2lab(rgb) {
var xyz = rgb2xyz(rgb),
x = xyz[0],
y = xyz[1],
z = xyz[2],
l, a, b;
x /= 95.047;
y /= 100;
z /= 108.883;
x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);
y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);
z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);
l = (116 * y) - 16;
a = 500 * (x - y);
b = 200 * (y - z);
return [l, a, b];
}
function rgb2lch(args) {
return lab2lch(rgb2lab(args));
}
function hsl2rgb(hsl) {
var h = hsl[0] / 360,
s = hsl[1] / 100,
l = hsl[2] / 100,
t1, t2, t3, rgb, val;
if (s == 0) {
val = l * 255;
return [val, val, val];
}
if (l < 0.5)
t2 = l * (1 + s);
else
t2 = l + s - l * s;
t1 = 2 * l - t2;
rgb = [0, 0, 0];
for (var i = 0; i < 3; i++) {
t3 = h + 1 / 3 * - (i - 1);
t3 < 0 && t3++;
t3 > 1 && t3--;
if (6 * t3 < 1)
val = t1 + (t2 - t1) * 6 * t3;
else if (2 * t3 < 1)
val = t2;
else if (3 * t3 < 2)
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
else
val = t1;
rgb[i] = val * 255;
}
return rgb;
}
function hsl2hsv(hsl) {
var h = hsl[0],
s = hsl[1] / 100,
l = hsl[2] / 100,
sv, v;
if(l === 0) {
// no need to do calc on black
// also avoids divide by 0 error
return [0, 0, 0];
}
l *= 2;
s *= (l <= 1) ? l : 2 - l;
v = (l + s) / 2;
sv = (2 * s) / (l + s);
return [h, sv * 100, v * 100];
}
function hsl2hwb(args) {
return rgb2hwb(hsl2rgb(args));
}
function hsl2cmyk(args) {
return rgb2cmyk(hsl2rgb(args));
}
function hsl2keyword(args) {
return rgb2keyword(hsl2rgb(args));
}
function hsv2rgb(hsv) {
var h = hsv[0] / 60,
s = hsv[1] / 100,
v = hsv[2] / 100,
hi = Math.floor(h) % 6;
var f = h - Math.floor(h),
p = 255 * v * (1 - s),
q = 255 * v * (1 - (s * f)),
t = 255 * v * (1 - (s * (1 - f))),
v = 255 * v;
switch(hi) {
case 0:
return [v, t, p];
case 1:
return [q, v, p];
case 2:
return [p, v, t];
case 3:
return [p, q, v];
case 4:
return [t, p, v];
case 5:
return [v, p, q];
}
}
function hsv2hsl(hsv) {
var h = hsv[0],
s = hsv[1] / 100,
v = hsv[2] / 100,
sl, l;
l = (2 - s) * v;
sl = s * v;
sl /= (l <= 1) ? l : 2 - l;
sl = sl || 0;
l /= 2;
return [h, sl * 100, l * 100];
}
function hsv2hwb(args) {
return rgb2hwb(hsv2rgb(args))
}
function hsv2cmyk(args) {
return rgb2cmyk(hsv2rgb(args));
}
function hsv2keyword(args) {
return rgb2keyword(hsv2rgb(args));
}
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
function hwb2rgb(hwb) {
var h = hwb[0] / 360,
wh = hwb[1] / 100,
bl = hwb[2] / 100,
ratio = wh + bl,
i, v, f, n;
// wh + bl cant be > 1
if (ratio > 1) {
wh /= ratio;
bl /= ratio;
}
i = Math.floor(6 * h);
v = 1 - bl;
f = 6 * h - i;
if ((i & 0x01) != 0) {
f = 1 - f;
}
n = wh + f * (v - wh); // linear interpolation
switch (i) {
default:
case 6:
case 0: r = v; g = n; b = wh; break;
case 1: r = n; g = v; b = wh; break;
case 2: r = wh; g = v; b = n; break;
case 3: r = wh; g = n; b = v; break;
case 4: r = n; g = wh; b = v; break;
case 5: r = v; g = wh; b = n; break;
}
return [r * 255, g * 255, b * 255];
}
function hwb2hsl(args) {
return rgb2hsl(hwb2rgb(args));
}
function hwb2hsv(args) {
return rgb2hsv(hwb2rgb(args));
}
function hwb2cmyk(args) {
return rgb2cmyk(hwb2rgb(args));
}
function hwb2keyword(args) {
return rgb2keyword(hwb2rgb(args));
}
function cmyk2rgb(cmyk) {
var c = cmyk[0] / 100,
m = cmyk[1] / 100,
y = cmyk[2] / 100,
k = cmyk[3] / 100,
r, g, b;
r = 1 - Math.min(1, c * (1 - k) + k);
g = 1 - Math.min(1, m * (1 - k) + k);
b = 1 - Math.min(1, y * (1 - k) + k);
return [r * 255, g * 255, b * 255];
}
function cmyk2hsl(args) {
return rgb2hsl(cmyk2rgb(args));
}
function cmyk2hsv(args) {
return rgb2hsv(cmyk2rgb(args));
}
function cmyk2hwb(args) {
return rgb2hwb(cmyk2rgb(args));
}
function cmyk2keyword(args) {
return rgb2keyword(cmyk2rgb(args));
}
function xyz2rgb(xyz) {
var x = xyz[0] / 100,
y = xyz[1] / 100,
z = xyz[2] / 100,
r, g, b;
r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
// assume sRGB
r = r > 0.0031308 ? ((1.055 * Math.pow(r, 1.0 / 2.4)) - 0.055)
: r = (r * 12.92);
g = g > 0.0031308 ? ((1.055 * Math.pow(g, 1.0 / 2.4)) - 0.055)
: g = (g * 12.92);
b = b > 0.0031308 ? ((1.055 * Math.pow(b, 1.0 / 2.4)) - 0.055)
: b = (b * 12.92);
r = Math.min(Math.max(0, r), 1);
g = Math.min(Math.max(0, g), 1);
b = Math.min(Math.max(0, b), 1);
return [r * 255, g * 255, b * 255];
}
function xyz2lab(xyz) {
var x = xyz[0],
y = xyz[1],
z = xyz[2],
l, a, b;
x /= 95.047;
y /= 100;
z /= 108.883;
x = x > 0.008856 ? Math.pow(x, 1/3) : (7.787 * x) + (16 / 116);
y = y > 0.008856 ? Math.pow(y, 1/3) : (7.787 * y) + (16 / 116);
z = z > 0.008856 ? Math.pow(z, 1/3) : (7.787 * z) + (16 / 116);
l = (116 * y) - 16;
a = 500 * (x - y);
b = 200 * (y - z);
return [l, a, b];
}
function xyz2lch(args) {
return lab2lch(xyz2lab(args));
}
function lab2xyz(lab) {
var l = lab[0],
a = lab[1],
b = lab[2],
x, y, z, y2;
if (l <= 8) {
y = (l * 100) / 903.3;
y2 = (7.787 * (y / 100)) + (16 / 116);
} else {
y = 100 * Math.pow((l + 16) / 116, 3);
y2 = Math.pow(y / 100, 1/3);
}
x = x / 95.047 <= 0.008856 ? x = (95.047 * ((a / 500) + y2 - (16 / 116))) / 7.787 : 95.047 * Math.pow((a / 500) + y2, 3);
z = z / 108.883 <= 0.008859 ? z = (108.883 * (y2 - (b / 200) - (16 / 116))) / 7.787 : 108.883 * Math.pow(y2 - (b / 200), 3);
return [x, y, z];
}
function lab2lch(lab) {
var l = lab[0],
a = lab[1],
b = lab[2],
hr, h, c;
hr = Math.atan2(b, a);
h = hr * 360 / 2 / Math.PI;
if (h < 0) {
h += 360;
}
c = Math.sqrt(a * a + b * b);
return [l, c, h];
}
function lab2rgb(args) {
return xyz2rgb(lab2xyz(args));
}
function lch2lab(lch) {
var l = lch[0],
c = lch[1],
h = lch[2],
a, b, hr;
hr = h / 360 * 2 * Math.PI;
a = c * Math.cos(hr);
b = c * Math.sin(hr);
return [l, a, b];
}
function lch2xyz(args) {
return lab2xyz(lch2lab(args));
}
function lch2rgb(args) {
return lab2rgb(lch2lab(args));
}
function keyword2rgb(keyword) {
return cssKeywords[keyword];
}
function keyword2hsl(args) {
return rgb2hsl(keyword2rgb(args));
}
function keyword2hsv(args) {
return rgb2hsv(keyword2rgb(args));
}
function keyword2hwb(args) {
return rgb2hwb(keyword2rgb(args));
}
function keyword2cmyk(args) {
return rgb2cmyk(keyword2rgb(args));
}
function keyword2lab(args) {
return rgb2lab(keyword2rgb(args));
}
function keyword2xyz(args) {
return rgb2xyz(keyword2rgb(args));
}
var cssKeywords = {
aliceblue: [240,248,255],
antiquewhite: [250,235,215],
aqua: [0,255,255],
aquamarine: [127,255,212],
azure: [240,255,255],
beige: [245,245,220],
bisque: [255,228,196],
black: [0,0,0],
blanchedalmond: [255,235,205],
blue: [0,0,255],
blueviolet: [138,43,226],
brown: [165,42,42],
burlywood: [222,184,135],
cadetblue: [95,158,160],
chartreuse: [127,255,0],
chocolate: [210,105,30],
coral: [255,127,80],
cornflowerblue: [100,149,237],
cornsilk: [255,248,220],
crimson: [220,20,60],
cyan: [0,255,255],
darkblue: [0,0,139],
darkcyan: [0,139,139],
darkgoldenrod: [184,134,11],
darkgray: [169,169,169],
darkgreen: [0,100,0],
darkgrey: [169,169,169],
darkkhaki: [189,183,107],
darkmagenta: [139,0,139],
darkolivegreen: [85,107,47],
darkorange: [255,140,0],
darkorchid: [153,50,204],
darkred: [139,0,0],
darksalmon: [233,150,122],
darkseagreen: [143,188,143],
darkslateblue: [72,61,139],
darkslategray: [47,79,79],
darkslategrey: [47,79,79],
darkturquoise: [0,206,209],
darkviolet: [148,0,211],
deeppink: [255,20,147],
deepskyblue: [0,191,255],
dimgray: [105,105,105],
dimgrey: [105,105,105],
dodgerblue: [30,144,255],
firebrick: [178,34,34],
floralwhite: [255,250,240],
forestgreen: [34,139,34],
fuchsia: [255,0,255],
gainsboro: [220,220,220],
ghostwhite: [248,248,255],
gold: [255,215,0],
goldenrod: [218,165,32],
gray: [128,128,128],
green: [0,128,0],
greenyellow: [173,255,47],
grey: [128,128,128],
honeydew: [240,255,240],
hotpink: [255,105,180],
indianred: [205,92,92],
indigo: [75,0,130],
ivory: [255,255,240],
khaki: [240,230,140],
lavender: [230,230,250],
lavenderblush: [255,240,245],
lawngreen: [124,252,0],
lemonchiffon: [255,250,205],
lightblue: [173,216,230],
lightcoral: [240,128,128],
lightcyan: [224,255,255],
lightgoldenrodyellow: [250,250,210],
lightgray: [211,211,211],
lightgreen: [144,238,144],
lightgrey: [211,211,211],
lightpink: [255,182,193],
lightsalmon: [255,160,122],
lightseagreen: [32,178,170],
lightskyblue: [135,206,250],
lightslategray: [119,136,153],
lightslategrey: [119,136,153],
lightsteelblue: [176,196,222],
lightyellow: [255,255,224],
lime: [0,255,0],
limegreen: [50,205,50],
linen: [250,240,230],
magenta: [255,0,255],
maroon: [128,0,0],
mediumaquamarine: [102,205,170],
mediumblue: [0,0,205],
mediumorchid: [186,85,211],
mediumpurple: [147,112,219],
mediumseagreen: [60,179,113],
mediumslateblue: [123,104,238],
mediumspringgreen: [0,250,154],
mediumturquoise: [72,209,204],
mediumvioletred: [199,21,133],
midnightblue: [25,25,112],
mintcream: [245,255,250],
mistyrose: [255,228,225],
moccasin: [255,228,181],
navajowhite: [255,222,173],
navy: [0,0,128],
oldlace: [253,245,230],
olive: [128,128,0],
olivedrab: [107,142,35],
orange: [255,165,0],
orangered: [255,69,0],
orchid: [218,112,214],
palegoldenrod: [238,232,170],
palegreen: [152,251,152],
paleturquoise: [175,238,238],
palevioletred: [219,112,147],
papayawhip: [255,239,213],
peachpuff: [255,218,185],
peru: [205,133,63],
pink: [255,192,203],
plum: [221,160,221],
powderblue: [176,224,230],
purple: [128,0,128],
rebeccapurple: [102, 51, 153],
red: [255,0,0],
rosybrown: [188,143,143],
royalblue: [65,105,225],
saddlebrown: [139,69,19],
salmon: [250,128,114],
sandybrown: [244,164,96],
seagreen: [46,139,87],
seashell: [255,245,238],
sienna: [160,82,45],
silver: [192,192,192],
skyblue: [135,206,235],
slateblue: [106,90,205],
slategray: [112,128,144],
slategrey: [112,128,144],
snow: [255,250,250],
springgreen: [0,255,127],
steelblue: [70,130,180],
tan: [210,180,140],
teal: [0,128,128],
thistle: [216,191,216],
tomato: [255,99,71],
turquoise: [64,224,208],
violet: [238,130,238],
wheat: [245,222,179],
white: [255,255,255],
whitesmoke: [245,245,245],
yellow: [255,255,0],
yellowgreen: [154,205,50]
};
var reverseKeywords = {};
for (var key in cssKeywords) {
reverseKeywords[JSON.stringify(cssKeywords[key])] = key;
}

92
node_modules/color-convert/index.js generated vendored Normal file
View File

@@ -0,0 +1,92 @@
var conversions = require("./conversions");
var convert = function() {
return new Converter();
}
for (var func in conversions) {
// export Raw versions
convert[func + "Raw"] = (function(func) {
// accept array or plain args
return function(arg) {
if (typeof arg == "number")
arg = Array.prototype.slice.call(arguments);
return conversions[func](arg);
}
})(func);
var pair = /(\w+)2(\w+)/.exec(func),
from = pair[1],
to = pair[2];
// export rgb2hsl and ["rgb"]["hsl"]
convert[from] = convert[from] || {};
convert[from][to] = convert[func] = (function(func) {
return function(arg) {
if (typeof arg == "number")
arg = Array.prototype.slice.call(arguments);
var val = conversions[func](arg);
if (typeof val == "string" || val === undefined)
return val; // keyword
for (var i = 0; i < val.length; i++)
val[i] = Math.round(val[i]);
return val;
}
})(func);
}
/* Converter does lazy conversion and caching */
var Converter = function() {
this.convs = {};
};
/* Either get the values for a space or
set the values for a space, depending on args */
Converter.prototype.routeSpace = function(space, args) {
var values = args[0];
if (values === undefined) {
// color.rgb()
return this.getValues(space);
}
// color.rgb(10, 10, 10)
if (typeof values == "number") {
values = Array.prototype.slice.call(args);
}
return this.setValues(space, values);
};
/* Set the values for a space, invalidating cache */
Converter.prototype.setValues = function(space, values) {
this.space = space;
this.convs = {};
this.convs[space] = values;
return this;
};
/* Get the values for a space. If there's already
a conversion for the space, fetch it, otherwise
compute it */
Converter.prototype.getValues = function(space) {
var vals = this.convs[space];
if (!vals) {
var fspace = this.space,
from = this.convs[fspace];
vals = convert[fspace][space](from);
this.convs[space] = vals;
}
return vals;
};
["rgb", "hsl", "hsv", "cmyk", "keyword"].forEach(function(space) {
Converter.prototype[space] = function(vals) {
return this.routeSpace(space, arguments);
}
});
module.exports = convert;

20
node_modules/color-convert/package.json generated vendored Normal file
View File

@@ -0,0 +1,20 @@
{
"name": "color-convert",
"description": "Plain color conversion functions",
"version": "0.5.3",
"author": "Heather Arthur <fayearthur@gmail.com>",
"repository": {
"type": "git",
"url": "http://github.com/harthur/color-convert.git"
},
"devDependencies": {
},
"scripts": {
"test": "node test/basic.js"
},
"keywords": [
"color",
"colour",
"rgb"
]
}

187
node_modules/color-convert/test/basic.js generated vendored Normal file
View File

@@ -0,0 +1,187 @@
var convert = require("../index"),
assert = require("assert");
assert.deepEqual(convert.rgb2hsl([140, 200, 100]), [96, 48, 59]);
assert.deepEqual(convert.rgb2hsv([140, 200, 100]), [96, 50, 78]);
assert.deepEqual(convert.rgb2hwb([140, 200, 100]), [96, 39, 22]);
assert.deepEqual(convert.rgb2cmyk([140, 200, 100]), [30, 0, 50, 22]);
assert.deepEqual(convert.rgb2cmyk([0,0,0,1]), [0,0,0,100]);
assert.deepEqual(convert.rgb2keyword([255, 228, 196]), "bisque");
assert.deepEqual(convert.rgb2xyz([92, 191, 84]), [25, 40, 15]);
assert.deepEqual(convert.rgb2lab([92, 191, 84]), [70, -50, 45]);
assert.deepEqual(convert.rgb2lch([92, 191, 84]), [70, 67, 138]);
assert.deepEqual(convert.hsl2rgb([96, 48, 59]), [140, 201, 100]);
assert.deepEqual(convert.hsl2hsv([96, 48, 59]), [96, 50, 79]); // colorpicker says [96,50,79]
assert.deepEqual(convert.hsl2hwb([96, 48, 59]), [96, 39, 21]); // computer round to 21, should be 22
assert.deepEqual(convert.hsl2cmyk([96, 48, 59]), [30, 0, 50, 21]);
assert.deepEqual(convert.hsl2keyword([240, 100, 50]), "blue");
assert.deepEqual(convert.hsv2rgb([96, 50, 78]), [139, 199, 99]);
assert.deepEqual(convert.hsv2hsl([96, 50, 78]), [96, 47, 59]);
assert.deepEqual(convert.hsv2hsl([0,0,0]), [0,0,0]);
assert.deepEqual(convert.hsv2hwb([96, 50, 78]), [96, 39, 22]);
assert.deepEqual(convert.hsv2cmyk([96, 50, 78]), [30, 0, 50, 22]);
assert.deepEqual(convert.hsv2keyword([240, 100, 100]), "blue");
assert.deepEqual(convert.cmyk2rgb([30, 0, 50, 22]), [139, 199, 99]);
assert.deepEqual(convert.cmyk2hsl([30, 0, 50, 22]), [96, 47, 59]);
assert.deepEqual(convert.cmyk2hsv([30, 0, 50, 22]), [96, 50, 78]);
assert.deepEqual(convert.cmyk2hwb([30, 0, 50, 22]), [96, 39, 22]);
assert.deepEqual(convert.cmyk2keyword([100, 100, 0, 0]), "blue");
assert.deepEqual(convert.keyword2rgb("blue"), [0, 0, 255]);
assert.deepEqual(convert.keyword2hsl("blue"), [240, 100, 50]);
assert.deepEqual(convert.keyword2hsv("blue"), [240, 100, 100]);
assert.deepEqual(convert.keyword2hwb("blue"), [240, 0, 0]);
assert.deepEqual(convert.keyword2cmyk("blue"), [100, 100, 0, 0]);
assert.deepEqual(convert.keyword2lab("blue"), [32, 79, -108]);
assert.deepEqual(convert.keyword2xyz("blue"), [18, 7, 95]);
assert.deepEqual(convert.xyz2rgb([25, 40, 15]), [97, 190, 85]);
assert.deepEqual(convert.xyz2rgb([50, 100, 100]), [0, 255, 241]);
assert.deepEqual(convert.xyz2lab([25, 40, 15]), [69, -48, 44]);
assert.deepEqual(convert.xyz2lch([25, 40, 15]), [69, 65, 137]);
assert.deepEqual(convert.lab2xyz([69, -48, 44]), [25, 39, 15]);
assert.deepEqual(convert.lab2rgb([75, 20, -30]), [194, 175, 240]);
assert.deepEqual(convert.lab2lch([69, -48, 44]), [69, 65, 137]);
assert.deepEqual(convert.lch2lab([69, 65, 137]), [69, -48, 44]);
assert.deepEqual(convert.lch2xyz([69, 65, 137]), [25, 39, 15]);
assert.deepEqual(convert.lch2rgb([69, 65, 137]), [98, 188, 83]);
// non-array arguments
assert.deepEqual(convert.hsl2rgb(96, 48, 59), [140, 201, 100]);
// raw functions
function round(vals) {
for (var i = 0; i < vals.length; i++)
vals[i] = vals[i].toFixed(1);
return vals;
}
assert.deepEqual(round(convert.hsl2rgbRaw([96, 48, 59])), [140.4, 200.6, 100.3]);
assert.deepEqual(round(convert.rgb2hslRaw([140, 200, 100])), [96, 47.6, 58.8]);
assert.deepEqual(round(convert.hsv2rgbRaw([96, 50, 78])), [139.2, 198.9, 99.5]);
assert.deepEqual(round(convert.rgb2hsvRaw([140, 200, 100])), [96, 50, 78.4]);
assert.deepEqual(round(convert.hwb2rgbRaw([96, 39, 22])), [139.2, 198.9, 99.5]);
assert.deepEqual(round(convert.rgb2hwbRaw([140, 200, 100])), [96, 39.2, 21.6]);
assert.deepEqual(round(convert.cmyk2rgbRaw([30, 0, 50, 22])), [139.2, 198.9, 99.5]);
assert.deepEqual(round(convert.rgb2cmykRaw([140, 200, 100])), [30, 0, 50, 21.6]);
assert.deepEqual(round(convert.keyword2rgbRaw("blue")), [0, 0, 255]);
assert.deepEqual(convert.rgb2keywordRaw([255, 228, 196]), "bisque");
assert.deepEqual(round(convert.hsv2hslRaw([96, 50, 78])), [96, 47, 58.5]);
assert.deepEqual(round(convert.hsl2hsvRaw([96, 48, 59])), [96, 50, 78.7]);
assert.deepEqual(round(convert.hsl2hsvRaw([96, 48, 59])), [96, 50, 78.7]);
assert.deepEqual(round(convert.xyz2rgbRaw([25, 40, 15])), [97.4, 189.9, 85]);
assert.deepEqual(round(convert.rgb2xyzRaw([92, 191, 84])), [24.6, 40.2, 14.8]);
assert.deepEqual(round(convert.rgb2labRaw([92, 191, 84])), [69.6, -50.1, 44.6]);
// hashed
var val = [140, 200, 100];
assert.deepEqual(convert["rgb"]["hsl"](val), convert.rgb2hsl(val));
assert.deepEqual(convert["rgb"]["hsv"](val), convert.rgb2hsv(val));
assert.deepEqual(convert["rgb"]["hwb"](val), convert.rgb2hwb(val));
assert.deepEqual(convert["rgb"]["cmyk"](val), convert.rgb2cmyk(val));
assert.deepEqual(convert["rgb"]["xyz"](val), convert.rgb2xyz(val));
assert.deepEqual(convert["rgb"]["lab"](val), convert.rgb2lab(val));
assert.deepEqual(convert["rgb"]["keyword"]([255, 228, 196]), "bisque");
val = [96, 48, 59];
assert.deepEqual(convert["hsl"]["rgb"](val), convert.hsl2rgb(val));
assert.deepEqual(convert["hsl"]["hsv"](val), convert.hsl2hsv(val));
assert.deepEqual(convert["hsl"]["hwb"](val), convert.hsl2hwb(val));
assert.deepEqual(convert["hsl"]["cmyk"](val), convert.hsl2cmyk(val));
assert.deepEqual(convert["hsl"]["keyword"](val), convert.hsl2keyword(val ));
val = [96, 50, 78];
assert.deepEqual(convert["hsv"]["rgb"](val), convert.hsv2rgb(val));
assert.deepEqual(convert["hsv"]["hsl"](val), convert.hsv2hsl(val));
assert.deepEqual(convert["hsv"]["hwb"](val), convert.hsv2hwb(val));
assert.deepEqual(convert["hsv"]["cmyk"](val), convert.hsv2cmyk(val));
assert.deepEqual(convert["hsv"]["keyword"](val), convert.hsv2keyword(val));
val = [30, 0, 50, 22];
assert.deepEqual(convert["cmyk"]["rgb"](val), convert.cmyk2rgb(val));
assert.deepEqual(convert["cmyk"]["hsl"](val), convert.cmyk2hsl(val));
assert.deepEqual(convert["cmyk"]["hsv"](val), convert.cmyk2hsv(val));
assert.deepEqual(convert["cmyk"]["hwb"](val), convert.cmyk2hwb(val));
assert.deepEqual(convert["cmyk"]["keyword"](val), convert.cmyk2keyword(val));
val = "blue";
assert.deepEqual(convert["keyword"]["rgb"](val), convert.keyword2rgb(val));
assert.deepEqual(convert["keyword"]["hsl"](val), convert.keyword2hsl(val));
assert.deepEqual(convert["keyword"]["hsv"](val), convert.keyword2hsv(val));
assert.deepEqual(convert["keyword"]["hwb"](val), convert.keyword2hwb(val));
assert.deepEqual(convert["keyword"]["cmyk"](val), convert.keyword2cmyk(val));
assert.deepEqual(convert["keyword"]["lab"](val), convert.keyword2lab(val));
assert.deepEqual(convert["keyword"]["xyz"](val), convert.keyword2xyz(val));
val = [25, 40, 15]
assert.deepEqual(convert["xyz"]["rgb"](val), convert.xyz2rgb(val));
assert.deepEqual(convert["xyz"]["lab"](val), convert.xyz2lab(val));
val = [69, -48, 44];
assert.deepEqual(convert["lab"]["xyz"](val), [25, 39, 15]);
// converter
var converter = convert();
var vals = [140, 200, 100];
converter.rgb(140, 200, 100);
assert.deepEqual(converter.hsl(), convert.rgb2hsl(vals));
assert.deepEqual(converter.hsv(), convert.rgb2hsv(vals));
assert.deepEqual(converter.cmyk(), convert.rgb2cmyk(vals));
assert.deepEqual(converter.rgb(), vals);
assert.deepEqual(converter.rgb([255, 228, 196]).keyword(), "bisque");
vals = [96, 48, 59];
converter.hsl(vals);
assert.deepEqual(converter.rgb(), convert.hsl2rgb(vals));
assert.deepEqual(converter.hsv(), convert.hsl2hsv(vals));
assert.deepEqual(converter.cmyk(), convert.hsl2cmyk(vals));
assert.deepEqual(converter.keyword(), convert.hsl2keyword(vals));
// hwb
// http://dev.w3.org/csswg/css-color/#hwb-examples
// all extrem value should give black, white or grey
for(var angle = 0; angle <= 360; angle ++) {
assert.deepEqual(convert.hwb2rgb([angle, 0, 100]), [0, 0, 0]);
assert.deepEqual(convert.hwb2rgb([angle, 100, 0]), [255, 255, 255]);
assert.deepEqual(convert.hwb2rgb([angle, 100, 100]), [128, 128, 128]);
}
assert.deepEqual(convert.hwb2rgb([0, 0, 0]), [255,0,0]);
assert.deepEqual(convert.hwb2rgb([0, 20, 40]), [153, 51, 51]);
assert.deepEqual(convert.hwb2rgb([0, 40, 40]), [153, 102, 102]);
assert.deepEqual(convert.hwb2rgb([0, 40, 20]), [204, 102, 102]);
assert.deepEqual(convert.hwb2rgb([120, 0, 0]), [0,255,0]);
assert.deepEqual(convert.hwb2rgb([120, 20, 40]), [51, 153, 51]);
assert.deepEqual(convert.hwb2rgb([120, 40, 40]), [102, 153, 102]);
assert.deepEqual(convert.hwb2rgb([120, 40, 20]), [102, 204, 102]);
assert.deepEqual(convert.hwb2rgb([240, 0, 0]), [0,0,255]);
assert.deepEqual(convert.hwb2rgb([240, 20, 40]), [51, 51, 153]);
assert.deepEqual(convert.hwb2rgb([240, 40, 40]), [102, 102, 153]);
assert.deepEqual(convert.hwb2rgb([240, 40, 20]), [102, 102, 204]);
// black should always stay black
val = [0, 0, 0];
assert.deepEqual(convert.hsl2hsv(val), val);
assert.deepEqual(convert.hsl2rgb(val), val);
assert.deepEqual(convert.hsl2hwb(val), [0, 0, 100]);
assert.deepEqual(convert.hsl2cmyk(val), [0, 0, 0, 100]);

23
node_modules/color-convert/test/speed.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
var convert = require("../index");
var converter = convert();
var times = 10000;
console.time("cached");
converter.rgb(10, 2, 30);
for(var i = 0; i < times; i++) {
converter.hsv();
converter.hsl();
converter.cmyk();
}
console.timeEnd("cached");
console.time("uncached");
for(var i = 0; i < times; i++) {
convert.rgb2hsl(10, 2, 30);
convert.rgb2hsv(10, 2, 30);
convert.rgb2cmyk(10, 2, 30);
}
console.timeEnd("uncached");

8
node_modules/color-name/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2015 Dmitry Ivanov
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

11
node_modules/color-name/README.md generated vendored Normal file
View File

@@ -0,0 +1,11 @@
A JSON with color names and its values. Based on http://dev.w3.org/csswg/css-color/#named-colors.
[![NPM](https://nodei.co/npm/color-name.png?mini=true)](https://nodei.co/npm/color-name/)
```js
var colors = require('color-name');
colors.red //[255,0,0]
```
<a href="LICENSE"><img src="https://upload.wikimedia.org/wikipedia/commons/0/0c/MIT_logo.svg" width="120"/></a>

152
node_modules/color-name/index.js generated vendored Normal file
View File

@@ -0,0 +1,152 @@
'use strict'
module.exports = {
"aliceblue": [240, 248, 255],
"antiquewhite": [250, 235, 215],
"aqua": [0, 255, 255],
"aquamarine": [127, 255, 212],
"azure": [240, 255, 255],
"beige": [245, 245, 220],
"bisque": [255, 228, 196],
"black": [0, 0, 0],
"blanchedalmond": [255, 235, 205],
"blue": [0, 0, 255],
"blueviolet": [138, 43, 226],
"brown": [165, 42, 42],
"burlywood": [222, 184, 135],
"cadetblue": [95, 158, 160],
"chartreuse": [127, 255, 0],
"chocolate": [210, 105, 30],
"coral": [255, 127, 80],
"cornflowerblue": [100, 149, 237],
"cornsilk": [255, 248, 220],
"crimson": [220, 20, 60],
"cyan": [0, 255, 255],
"darkblue": [0, 0, 139],
"darkcyan": [0, 139, 139],
"darkgoldenrod": [184, 134, 11],
"darkgray": [169, 169, 169],
"darkgreen": [0, 100, 0],
"darkgrey": [169, 169, 169],
"darkkhaki": [189, 183, 107],
"darkmagenta": [139, 0, 139],
"darkolivegreen": [85, 107, 47],
"darkorange": [255, 140, 0],
"darkorchid": [153, 50, 204],
"darkred": [139, 0, 0],
"darksalmon": [233, 150, 122],
"darkseagreen": [143, 188, 143],
"darkslateblue": [72, 61, 139],
"darkslategray": [47, 79, 79],
"darkslategrey": [47, 79, 79],
"darkturquoise": [0, 206, 209],
"darkviolet": [148, 0, 211],
"deeppink": [255, 20, 147],
"deepskyblue": [0, 191, 255],
"dimgray": [105, 105, 105],
"dimgrey": [105, 105, 105],
"dodgerblue": [30, 144, 255],
"firebrick": [178, 34, 34],
"floralwhite": [255, 250, 240],
"forestgreen": [34, 139, 34],
"fuchsia": [255, 0, 255],
"gainsboro": [220, 220, 220],
"ghostwhite": [248, 248, 255],
"gold": [255, 215, 0],
"goldenrod": [218, 165, 32],
"gray": [128, 128, 128],
"green": [0, 128, 0],
"greenyellow": [173, 255, 47],
"grey": [128, 128, 128],
"honeydew": [240, 255, 240],
"hotpink": [255, 105, 180],
"indianred": [205, 92, 92],
"indigo": [75, 0, 130],
"ivory": [255, 255, 240],
"khaki": [240, 230, 140],
"lavender": [230, 230, 250],
"lavenderblush": [255, 240, 245],
"lawngreen": [124, 252, 0],
"lemonchiffon": [255, 250, 205],
"lightblue": [173, 216, 230],
"lightcoral": [240, 128, 128],
"lightcyan": [224, 255, 255],
"lightgoldenrodyellow": [250, 250, 210],
"lightgray": [211, 211, 211],
"lightgreen": [144, 238, 144],
"lightgrey": [211, 211, 211],
"lightpink": [255, 182, 193],
"lightsalmon": [255, 160, 122],
"lightseagreen": [32, 178, 170],
"lightskyblue": [135, 206, 250],
"lightslategray": [119, 136, 153],
"lightslategrey": [119, 136, 153],
"lightsteelblue": [176, 196, 222],
"lightyellow": [255, 255, 224],
"lime": [0, 255, 0],
"limegreen": [50, 205, 50],
"linen": [250, 240, 230],
"magenta": [255, 0, 255],
"maroon": [128, 0, 0],
"mediumaquamarine": [102, 205, 170],
"mediumblue": [0, 0, 205],
"mediumorchid": [186, 85, 211],
"mediumpurple": [147, 112, 219],
"mediumseagreen": [60, 179, 113],
"mediumslateblue": [123, 104, 238],
"mediumspringgreen": [0, 250, 154],
"mediumturquoise": [72, 209, 204],
"mediumvioletred": [199, 21, 133],
"midnightblue": [25, 25, 112],
"mintcream": [245, 255, 250],
"mistyrose": [255, 228, 225],
"moccasin": [255, 228, 181],
"navajowhite": [255, 222, 173],
"navy": [0, 0, 128],
"oldlace": [253, 245, 230],
"olive": [128, 128, 0],
"olivedrab": [107, 142, 35],
"orange": [255, 165, 0],
"orangered": [255, 69, 0],
"orchid": [218, 112, 214],
"palegoldenrod": [238, 232, 170],
"palegreen": [152, 251, 152],
"paleturquoise": [175, 238, 238],
"palevioletred": [219, 112, 147],
"papayawhip": [255, 239, 213],
"peachpuff": [255, 218, 185],
"peru": [205, 133, 63],
"pink": [255, 192, 203],
"plum": [221, 160, 221],
"powderblue": [176, 224, 230],
"purple": [128, 0, 128],
"rebeccapurple": [102, 51, 153],
"red": [255, 0, 0],
"rosybrown": [188, 143, 143],
"royalblue": [65, 105, 225],
"saddlebrown": [139, 69, 19],
"salmon": [250, 128, 114],
"sandybrown": [244, 164, 96],
"seagreen": [46, 139, 87],
"seashell": [255, 245, 238],
"sienna": [160, 82, 45],
"silver": [192, 192, 192],
"skyblue": [135, 206, 235],
"slateblue": [106, 90, 205],
"slategray": [112, 128, 144],
"slategrey": [112, 128, 144],
"snow": [255, 250, 250],
"springgreen": [0, 255, 127],
"steelblue": [70, 130, 180],
"tan": [210, 180, 140],
"teal": [0, 128, 128],
"thistle": [216, 191, 216],
"tomato": [255, 99, 71],
"turquoise": [64, 224, 208],
"violet": [238, 130, 238],
"wheat": [245, 222, 179],
"white": [255, 255, 255],
"whitesmoke": [245, 245, 245],
"yellow": [255, 255, 0],
"yellowgreen": [154, 205, 50]
};

28
node_modules/color-name/package.json generated vendored Normal file
View File

@@ -0,0 +1,28 @@
{
"name": "color-name",
"version": "1.1.4",
"description": "A list of color names and its values",
"main": "index.js",
"files": [
"index.js"
],
"scripts": {
"test": "node test.js"
},
"repository": {
"type": "git",
"url": "git@github.com:colorjs/color-name.git"
},
"keywords": [
"color-name",
"color",
"color-keyword",
"keyword"
],
"author": "DY <dfcreative@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/colorjs/color-name/issues"
},
"homepage": "https://github.com/colorjs/color-name"
}

22
node_modules/css-color-converter/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,22 @@
# 2.0.0 - 2020-09-24
* Rewrite as ES module. Some breaking changes to the API surface has been made as a result.
* Better adhere to CSS specification (#4).
* Add support for CSS Color Module Level 4 syntax.
* Update dependencies.
* Add eslint.
* Add babel.
# 1.1.1 - 2020-03-20
* Fix alpha 0 incorrectly defaulting to 1 (#2). Thanks to jedwards1211.
# 1.1.0 - 2016-08-13
* Add `toHslaArray` method.
# 1.0.2 - 2015-05-27
* Fix typo causing `rgba()` to return incorrect results.
# 1.0.1 - 2015-05-27
* Fix `toHexString()` not padding values.
# 1.0.0 - 2015-05-27
* Initial release.

20
node_modules/css-color-converter/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright 2015 Andy Jansson <andyjansson@users.noreply.github.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

92
node_modules/css-color-converter/README.md generated vendored Normal file
View File

@@ -0,0 +1,92 @@
# css-color-converter [![Build Status][ci-img]][ci]
Converts CSS colors from one representation to another
[ci-img]: https://travis-ci.org/andyjansson/css-color-converter.svg
[ci]: https://travis-ci.org/andyjansson/css-color-converter
## Installation
```js
npm install css-color-converter
```
## Usage
**Example usage**:
```js
import { fromString } from 'css-color-converter';
fromString('rgb(255, 255, 255)').toHslString(); // hsl(0, 0%, 100%)
fromString('rgba(255, 255, 255, 0.5)').toHslString(); // hsla(0, 0%, 100%, 0.5)
fromString('blue').toRgbString(); // rgb(0, 0, 255)
fromString('red').toHexString(); // #ff0000
```
## Functions
### `fromString(str)`
| parameter | type | description |
| --------- | ------ | ---------------------------------------------- |
| `str` | string | Supports named colors, hex, rgb/rgba, hsl/hsla |
**Returns** [`instance`](#Methods) if valid, `null` if invalid.
### `fromRgb([r, g, b])`
| parameter | type | description |
| --------- | ------ | ------------- |
| `r` | int | red (0-255) |
| `g` | int | green (0-255) |
| `b` | int | blue (0-255) |
**Returns** [`instance`](#Methods)
### `fromRgba([r, g, b, a])`
| parameter | type | description |
| --------- | ------ | ------------- |
| `r` | int | red (0-255) |
| `g` | int | green (0-255) |
| `b` | int | blue (0-255) |
| `a` | float | alpha (0-1) |
**Returns** [`instance`](#Methods)
### `fromHsl([h, s, l])`
| parameter | type | description |
| --------- | ------ | ------------------ |
| `h` | int | hue (0-360) |
| `s` | int | saturation (0-100) |
| `l` | int | luminosity (0-100) |
**Returns** [`instance`](#Methods)
### `fromHsla([h, s, l, a])`
| parameter | type | description |
| --------- | ------ | ------------------ |
| `h` | int | hue (0-360) |
| `s` | int | saturation (0-100) |
| `l` | int | luminosity (0-100) |
| `a` | float | alpha (0-1) |
**Returns** [`instance`](#Methods)
## Methods
### `toRgbString()`
**Returns** `rgb()` or `rgba()`, depending on the alpha.
### `toHslString()`
**Returns** `hsl()` or `hsla()`, depending on the alpha.
### `toHexString()`
**Returns** 6-digit or 8-digit `hex`, depending on the alpha.
### `toRgbaArray()`
**Returns** `[r, g, b, a]` array.

314
node_modules/css-color-converter/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,314 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fromRgba = fromRgba;
exports.fromRgb = fromRgb;
exports.fromHsla = fromHsla;
exports.fromHsl = fromHsl;
exports.fromString = fromString;
exports["default"] = void 0;
var _colorName = _interopRequireDefault(require("color-name"));
var _cssUnitConverter = _interopRequireDefault(require("css-unit-converter"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var hex = /^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?$/;
var shortHex = /^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])?$/;
var rgb = /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(0|1|0?\.\d+|\d+%))?\s*\)$/;
var rgbfn = /^rgba?\(\s*(\d+)\s+(\d+)\s+(\d+)(?:\s*\/\s*(0|1|0?\.\d+|\d+%))?\s*\)$/;
var rgbperc = /^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(0|1|0?\.\d+|\d+%))?\s*\)$/;
var rgbpercfn = /^rgba?\(\s*(\d+%)\s+(\d+%)\s+(\d+%)(?:\s*\/\s*(0|1|0?\.\d+|\d+%))?\s*\)$/;
var hsl = /^hsla?\(\s*(\d+)(deg|rad|grad|turn)?\s*,\s*(\d+)%\s*,\s*(\d+)%(?:\s*,\s*(0|1|0?\.\d+|\d+%))?\s*\)$/;
function contains(haystack, needle) {
return haystack.indexOf(needle) > -1;
}
function rgbToHsl(r, g, b) {
var rprim = r / 255;
var gprim = g / 255;
var bprim = b / 255;
var cmax = Math.max(rprim, gprim, bprim);
var cmin = Math.min(rprim, gprim, bprim);
var delta = cmax - cmin;
var l = (cmax + cmin) / 2;
if (delta === 0) {
return [0, 0, l * 100];
}
var s = delta / (1 - Math.abs(2 * l - 1));
var h = function () {
switch (cmax) {
case rprim:
{
return (gprim - bprim) / delta % 6;
}
case gprim:
{
return (bprim - rprim) / delta + 2;
}
default:
{
return (rprim - gprim) / delta + 4;
}
}
}();
return [h * 60, s * 100, l * 100];
}
function hslToRgb(h, s, l) {
var hprim = h / 60;
var sprim = s / 100;
var lprim = l / 100;
var c = (1 - Math.abs(2 * lprim - 1)) * sprim;
var x = c * (1 - Math.abs(hprim % 2 - 1));
var m = lprim - c / 2;
var _ref = function () {
if (hprim < 1) return [c, x, 0];
if (hprim < 2) return [x, c, 0];
if (hprim < 3) return [0, c, x];
if (hprim < 4) return [0, x, c];
if (hprim < 5) return [x, 0, c];
return [c, 0, x];
}(),
_ref2 = _slicedToArray(_ref, 3),
rprim = _ref2[0],
gprim = _ref2[1],
bprim = _ref2[2];
return [(rprim + m) * 255, (gprim + m) * 255, (bprim + m) * 255];
}
var Color = /*#__PURE__*/function () {
function Color(_ref3) {
var _ref4 = _slicedToArray(_ref3, 4),
r = _ref4[0],
g = _ref4[1],
b = _ref4[2],
a = _ref4[3];
_classCallCheck(this, Color);
this.values = [Math.max(Math.min(parseInt(r, 10), 255), 0), Math.max(Math.min(parseInt(g, 10), 255), 0), Math.max(Math.min(parseInt(b, 10), 255), 0), a == null ? 1 : Math.max(Math.min(parseFloat(a), 255), 0)];
}
_createClass(Color, [{
key: "toRgbString",
value: function toRgbString() {
var _this$values = _slicedToArray(this.values, 4),
r = _this$values[0],
g = _this$values[1],
b = _this$values[2],
a = _this$values[3];
if (a === 1) {
return "rgb(".concat(r, ", ").concat(g, ", ").concat(b, ")");
}
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(a, ")");
}
}, {
key: "toHslString",
value: function toHslString() {
var _this$toHslaArray = this.toHslaArray(),
_this$toHslaArray2 = _slicedToArray(_this$toHslaArray, 4),
h = _this$toHslaArray2[0],
s = _this$toHslaArray2[1],
l = _this$toHslaArray2[2],
a = _this$toHslaArray2[3];
if (a === 1) {
return "hsl(".concat(h, ", ").concat(s, "%, ").concat(l, "%)");
}
return "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(a, ")");
}
}, {
key: "toHexString",
value: function toHexString() {
var _this$values2 = _slicedToArray(this.values, 4),
r = _this$values2[0],
g = _this$values2[1],
b = _this$values2[2],
a = _this$values2[3];
r = Number(r).toString(16).padStart(2, '0');
g = Number(g).toString(16).padStart(2, '0');
b = Number(b).toString(16).padStart(2, '0');
a = a < 1 ? parseInt(a * 255, 10).toString(16).padStart(2, '0') : '';
return "#".concat(r).concat(g).concat(b).concat(a);
}
}, {
key: "toRgbaArray",
value: function toRgbaArray() {
return this.values;
}
}, {
key: "toHslaArray",
value: function toHslaArray() {
var _this$values3 = _slicedToArray(this.values, 4),
r = _this$values3[0],
g = _this$values3[1],
b = _this$values3[2],
a = _this$values3[3];
var _rgbToHsl = rgbToHsl(r, g, b),
_rgbToHsl2 = _slicedToArray(_rgbToHsl, 3),
h = _rgbToHsl2[0],
s = _rgbToHsl2[1],
l = _rgbToHsl2[2];
return [h, s, l, a];
}
}]);
return Color;
}();
function fromRgba(_ref5) {
var _ref6 = _slicedToArray(_ref5, 4),
r = _ref6[0],
g = _ref6[1],
b = _ref6[2],
a = _ref6[3];
return new Color([r, g, b, a]);
}
function fromRgb(_ref7) {
var _ref8 = _slicedToArray(_ref7, 3),
r = _ref8[0],
g = _ref8[1],
b = _ref8[2];
return fromRgba([r, g, b, 1]);
}
function fromHsla(_ref9) {
var _ref10 = _slicedToArray(_ref9, 4),
h = _ref10[0],
s = _ref10[1],
l = _ref10[2],
a = _ref10[3];
var _hslToRgb = hslToRgb(h, s, l),
_hslToRgb2 = _slicedToArray(_hslToRgb, 3),
r = _hslToRgb2[0],
g = _hslToRgb2[1],
b = _hslToRgb2[2];
return fromRgba([r, g, b, a]);
}
function fromHsl(_ref11) {
var _ref12 = _slicedToArray(_ref11, 3),
h = _ref12[0],
s = _ref12[1],
l = _ref12[2];
return fromHsla([h, s, l, 1]);
}
function fromHexString(str) {
var _ref13 = hex.exec(str) || shortHex.exec(str),
_ref14 = _slicedToArray(_ref13, 5),
r = _ref14[1],
g = _ref14[2],
b = _ref14[3],
a = _ref14[4];
r = parseInt(r.length < 2 ? r.repeat(2) : r, 16);
g = parseInt(g.length < 2 ? g.repeat(2) : g, 16);
b = parseInt(b.length < 2 ? b.repeat(2) : b, 16);
a = a && (parseInt(a.length < 2 ? a.repeat(2) : a, 16) / 255).toPrecision(1) || 1;
return fromRgba([r, g, b, a]);
}
function fromRgbString(str) {
var _ref15 = rgb.exec(str) || rgbperc.exec(str) || rgbfn.exec(str) || rgbpercfn.exec(str),
_ref16 = _slicedToArray(_ref15, 5),
r = _ref16[1],
g = _ref16[2],
b = _ref16[3],
a = _ref16[4];
r = contains(r, '%') ? parseInt(r, 10) * 255 / 100 : parseInt(r, 10);
g = contains(g, '%') ? parseInt(g, 10) * 255 / 100 : parseInt(g, 10);
b = contains(b, '%') > 0 ? parseInt(b, 10) * 255 / 100 : parseInt(b, 10);
a = a === undefined ? 1 : parseFloat(a) / (contains(a, '%') ? 100 : 1);
return fromRgba([r, g, b, a]);
}
function fromHslString(str) {
var _hsl$exec = hsl.exec(str),
_hsl$exec2 = _slicedToArray(_hsl$exec, 6),
h = _hsl$exec2[1],
unit = _hsl$exec2[2],
s = _hsl$exec2[3],
l = _hsl$exec2[4],
a = _hsl$exec2[5];
unit = unit || 'deg';
h = (0, _cssUnitConverter["default"])(parseFloat(h), unit, 'deg');
s = parseFloat(s);
l = parseFloat(l);
a = a === undefined ? 1 : parseFloat(a) / (contains(a, '%') ? 100 : 1);
return fromHsla([h, s, l, a]);
}
function fromString(str) {
if (_colorName["default"][str]) {
return fromRgb(_colorName["default"][str]);
}
if (hex.test(str) || shortHex.test(str)) {
return fromHexString(str);
}
if (rgb.test(str) || rgbperc.test(str) || rgbfn.test(str) || rgbpercfn.test(str)) {
return fromRgbString(str);
}
if (hsl.test(str)) {
return fromHslString(str);
}
return null;
}
var _default = {
fromString: fromString,
fromRgb: fromRgb,
fromRgba: fromRgba,
fromHsl: fromHsl,
fromHsla: fromHsla
};
exports["default"] = _default;

42
node_modules/css-color-converter/package.json generated vendored Normal file
View File

@@ -0,0 +1,42 @@
{
"name": "css-color-converter",
"version": "2.0.0",
"description": "Converts CSS colors from one representation to another",
"main": "lib/index.js",
"scripts": {
"prepublish": "npm run lint && npm run build",
"lint": "eslint --ext .mjs src",
"build": "babel src -d lib",
"pretest": "npm run lint",
"test": "node src/__tests__/test.mjs"
},
"repository": {
"type": "git",
"url": "https://github.com/andyjansson/css-color-converter.git"
},
"keywords": [
"css",
"color",
"conversions",
"converter"
],
"author": "Andy Jansson",
"license": "MIT",
"bugs": {
"url": "https://github.com/andyjansson/css-color-converter/issues"
},
"homepage": "https://github.com/andyjansson/css-color-converter",
"dependencies": {
"color-convert": "^0.5.2",
"color-name": "^1.1.4",
"css-unit-converter": "^1.1.2"
},
"devDependencies": {
"@babel/cli": "^7.11.6",
"@babel/core": "^7.11.6",
"@babel/preset-env": "^7.11.5",
"eslint": "^7.9.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.0"
}
}

15
node_modules/css-unit-converter/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,15 @@
# 1.1.2 - 2020-05-16
* Add TypeScript definitions (thanks to @seaneking)
# 1.1.1 - 2017-01-25
* Change decimal rounding technique
# 1.1 - 2017-01-24
* Add optional precision argument
# 1.0 - 2015-05-18
* Initial release

20
node_modules/css-unit-converter/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright 2015 Andy Jansson <andyjansson@users.noreply.github.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

26
node_modules/css-unit-converter/README.md generated vendored Normal file
View File

@@ -0,0 +1,26 @@
# css-unit-converter [![Build Status][ci-img]][ci]
Converts CSS values from one unit to another
[PostCSS]: https://github.com/postcss/css-unit-converter
[ci-img]: https://travis-ci.org/andyjansson/css-unit-converter.svg
[ci]: https://travis-ci.org/andyjansson/css-unit-converter
## Installation
```js
npm install css-unit-converter
```
## Usage
```js
var convert = require('css-unit-converter');
//convert 1 inch to pc
convert(1, 'in', 'pc'); // 6
//convert 10px to cm with a maximum of 10 decimals
convert(10, 'px', 'cm', 10); // 0.2645833333
```

10
node_modules/css-unit-converter/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
declare module 'css-unit-converter' {
export type CSSUnits = 'px' | 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'deg' | 'grad' | 'rad' | 'turn' | 's' | 'ms' | 'Hz' | 'kHz' | 'dpi' | 'dpcm' | 'dppx';
export default function (
value: number,
sourceUnit: CSSUnits,
targetUnit: CSSUnits,
precision?: number
): number;
}

127
node_modules/css-unit-converter/index.js generated vendored Normal file
View File

@@ -0,0 +1,127 @@
var conversions = {
// length
'px': {
'px': 1,
'cm': 96.0/2.54,
'mm': 96.0/25.4,
'in': 96,
'pt': 96.0/72.0,
'pc': 16
},
'cm': {
'px': 2.54/96.0,
'cm': 1,
'mm': 0.1,
'in': 2.54,
'pt': 2.54/72.0,
'pc': 2.54/6.0
},
'mm': {
'px': 25.4/96.0,
'cm': 10,
'mm': 1,
'in': 25.4,
'pt': 25.4/72.0,
'pc': 25.4/6.0
},
'in': {
'px': 1.0/96.0,
'cm': 1.0/2.54,
'mm': 1.0/25.4,
'in': 1,
'pt': 1.0/72.0,
'pc': 1.0/6.0
},
'pt': {
'px': 0.75,
'cm': 72.0/2.54,
'mm': 72.0/25.4,
'in': 72,
'pt': 1,
'pc': 12
},
'pc': {
'px': 6.0/96.0,
'cm': 6.0/2.54,
'mm': 6.0/25.4,
'in': 6,
'pt': 6.0/72.0,
'pc': 1
},
// angle
'deg': {
'deg': 1,
'grad': 0.9,
'rad': 180/Math.PI,
'turn': 360
},
'grad': {
'deg': 400/360,
'grad': 1,
'rad': 200/Math.PI,
'turn': 400
},
'rad': {
'deg': Math.PI/180,
'grad': Math.PI/200,
'rad': 1,
'turn': Math.PI*2
},
'turn': {
'deg': 1/360,
'grad': 1/400,
'rad': 0.5/Math.PI,
'turn': 1
},
// time
's': {
's': 1,
'ms': 1/1000
},
'ms': {
's': 1000,
'ms': 1
},
// frequency
'Hz': {
'Hz': 1,
'kHz': 1000
},
'kHz': {
'Hz': 1/1000,
'kHz': 1
},
// resolution
'dpi': {
'dpi': 1,
'dpcm': 1.0/2.54,
'dppx': 1/96
},
'dpcm': {
'dpi': 2.54,
'dpcm': 1,
'dppx': 2.54/96.0
},
'dppx': {
'dpi': 96,
'dpcm': 96.0/2.54,
'dppx': 1
}
};
module.exports = function (value, sourceUnit, targetUnit, precision) {
if (!conversions.hasOwnProperty(targetUnit))
throw new Error("Cannot convert to " + targetUnit);
if (!conversions[targetUnit].hasOwnProperty(sourceUnit))
throw new Error("Cannot convert from " + sourceUnit + " to " + targetUnit);
var converted = conversions[targetUnit][sourceUnit] * value;
if (precision !== false) {
precision = Math.pow(10, parseInt(precision) || 5);
return Math.round(converted * precision) / precision;
}
return converted;
};

29
node_modules/css-unit-converter/package.json generated vendored Normal file
View File

@@ -0,0 +1,29 @@
{
"name": "css-unit-converter",
"version": "1.1.2",
"description": "Converts CSS values from one unit to another",
"main": "index.js",
"scripts": {
"test": "node test/test.js"
},
"repository": {
"type": "git",
"url": "https://github.com/andyjansson/css-unit-converter.git"
},
"keywords": [
"css",
"value",
"unit",
"converter",
"convert"
],
"author": "Andy Jansson",
"license": "MIT",
"bugs": {
"url": "https://github.com/andyjansson/css-unit-converter/issues"
},
"homepage": "https://github.com/andyjansson/css-unit-converter",
"devDependencies": {
"tape": "^4.6.3"
}
}

120
package-lock.json generated
View File

@@ -9,7 +9,8 @@
"version": "1.5.0",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.0"
"@actions/core": "^1.10.0",
"badge-maker": "^3.3.1"
}
},
"node_modules/@actions/core": {
@@ -29,6 +30,68 @@
"tunnel": "^0.0.6"
}
},
"node_modules/anafanafo": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/anafanafo/-/anafanafo-2.0.0.tgz",
"integrity": "sha512-Nlfq7NC4AOkTJerWRIZcOAiMNtIDVIGWGvQ98O7Jl6Kr2Dk0dX5u4MqN778kSRTy5KRqchpLdF2RtLFEz9FVkQ==",
"dependencies": {
"char-width-table-consumer": "^1.0.0"
}
},
"node_modules/badge-maker": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/badge-maker/-/badge-maker-3.3.1.tgz",
"integrity": "sha512-OO/PS7Zg2E6qaUWzHEHt21Q5VjcFBAJVA8ztgT/fIdSZFBUwoyeo0ZhA6V5tUM8Vcjq8DJl6jfGhpjESssyqMQ==",
"dependencies": {
"anafanafo": "2.0.0",
"css-color-converter": "^2.0.0"
},
"bin": {
"badge": "lib/badge-cli.js"
},
"engines": {
"node": ">= 10",
"npm": ">= 5"
}
},
"node_modules/binary-search": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/binary-search/-/binary-search-1.3.6.tgz",
"integrity": "sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA=="
},
"node_modules/char-width-table-consumer": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/char-width-table-consumer/-/char-width-table-consumer-1.0.0.tgz",
"integrity": "sha512-Fz4UD0LBpxPgL9i29CJ5O4KANwaMnX/OhhbxzvNa332h+9+nRKyeuLw4wA51lt/ex67+/AdsoBQJF3kgX2feYQ==",
"dependencies": {
"binary-search": "^1.3.5"
}
},
"node_modules/color-convert": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-0.5.3.tgz",
"integrity": "sha512-RwBeO/B/vZR3dfKL1ye/vx8MHZ40ugzpyfeVG5GsiuGnrlMWe2o8wxBbLCpw9CsxV+wHuzYlCiWnybrIA0ling=="
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/css-color-converter": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/css-color-converter/-/css-color-converter-2.0.0.tgz",
"integrity": "sha512-oLIG2soZz3wcC3aAl/7Us5RS8Hvvc6I8G8LniF/qfMmrm7fIKQ8RIDDRZeKyGL2SrWfNqYspuLShbnjBMVWm8g==",
"dependencies": {
"color-convert": "^0.5.2",
"color-name": "^1.1.4",
"css-unit-converter": "^1.1.2"
}
},
"node_modules/css-unit-converter": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/css-unit-converter/-/css-unit-converter-1.1.2.tgz",
"integrity": "sha512-IiJwMC8rdZE0+xiEZHeru6YoONC4rfPMqGm2W85jMIbkFvv5nFTwJVFHam2eFrN6txmoUYFAFXiv8ICVeTO0MA=="
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
@@ -64,6 +127,61 @@
"tunnel": "^0.0.6"
}
},
"anafanafo": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/anafanafo/-/anafanafo-2.0.0.tgz",
"integrity": "sha512-Nlfq7NC4AOkTJerWRIZcOAiMNtIDVIGWGvQ98O7Jl6Kr2Dk0dX5u4MqN778kSRTy5KRqchpLdF2RtLFEz9FVkQ==",
"requires": {
"char-width-table-consumer": "^1.0.0"
}
},
"badge-maker": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/badge-maker/-/badge-maker-3.3.1.tgz",
"integrity": "sha512-OO/PS7Zg2E6qaUWzHEHt21Q5VjcFBAJVA8ztgT/fIdSZFBUwoyeo0ZhA6V5tUM8Vcjq8DJl6jfGhpjESssyqMQ==",
"requires": {
"anafanafo": "2.0.0",
"css-color-converter": "^2.0.0"
}
},
"binary-search": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/binary-search/-/binary-search-1.3.6.tgz",
"integrity": "sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA=="
},
"char-width-table-consumer": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/char-width-table-consumer/-/char-width-table-consumer-1.0.0.tgz",
"integrity": "sha512-Fz4UD0LBpxPgL9i29CJ5O4KANwaMnX/OhhbxzvNa332h+9+nRKyeuLw4wA51lt/ex67+/AdsoBQJF3kgX2feYQ==",
"requires": {
"binary-search": "^1.3.5"
}
},
"color-convert": {
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-0.5.3.tgz",
"integrity": "sha512-RwBeO/B/vZR3dfKL1ye/vx8MHZ40ugzpyfeVG5GsiuGnrlMWe2o8wxBbLCpw9CsxV+wHuzYlCiWnybrIA0ling=="
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"css-color-converter": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/css-color-converter/-/css-color-converter-2.0.0.tgz",
"integrity": "sha512-oLIG2soZz3wcC3aAl/7Us5RS8Hvvc6I8G8LniF/qfMmrm7fIKQ8RIDDRZeKyGL2SrWfNqYspuLShbnjBMVWm8g==",
"requires": {
"color-convert": "^0.5.2",
"color-name": "^1.1.4",
"css-unit-converter": "^1.1.2"
}
},
"css-unit-converter": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/css-unit-converter/-/css-unit-converter-1.1.2.tgz",
"integrity": "sha512-IiJwMC8rdZE0+xiEZHeru6YoONC4rfPMqGm2W85jMIbkFvv5nFTwJVFHam2eFrN6txmoUYFAFXiv8ICVeTO0MA=="
},
"tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",

View File

@@ -2,6 +2,7 @@
"name": "dynamic-badges-action",
"version": "1.5.0",
"description": "A GitHub Action which uses shields.io to create custom badges and uploads the to a gist.",
"type": "module",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
@@ -18,6 +19,7 @@
},
"homepage": "https://github.com/Schneegans/dynamic-badges-action#readme",
"dependencies": {
"@actions/core": "^1.10.0"
"@actions/core": "^1.10.0",
"badge-maker": "^3.3.1"
}
}
}