diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 74a78db..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index 7234299..8a496e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -*.app \ No newline at end of file +*.app +.DS_Store +node_modules/ diff --git a/app/.DS_Store b/app/.DS_Store deleted file mode 100644 index 062e8f6..0000000 Binary files a/app/.DS_Store and /dev/null differ diff --git a/assets/node_modules/.package-lock.json b/assets/node_modules/.package-lock.json deleted file mode 100644 index 7e77032..0000000 --- a/assets/node_modules/.package-lock.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "name": "asset-compiler", - "version": "0.0.1", - "lockfileVersion": 2, - "requires": true, - "packages": { - "node_modules/@resvg/resvg-js": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@resvg/resvg-js/-/resvg-js-2.4.1.tgz", - "integrity": "sha512-wTOf1zerZX8qYcMmLZw3czR4paI4hXqPjShNwJRh5DeHxvgffUS5KM7XwxtbIheUW6LVYT5fhT2AJiP6mU7U4A==", - "engines": { - "node": ">= 10" - }, - "optionalDependencies": { - "@resvg/resvg-js-android-arm-eabi": "2.4.1", - "@resvg/resvg-js-android-arm64": "2.4.1", - "@resvg/resvg-js-darwin-arm64": "2.4.1", - "@resvg/resvg-js-darwin-x64": "2.4.1", - "@resvg/resvg-js-linux-arm-gnueabihf": "2.4.1", - "@resvg/resvg-js-linux-arm64-gnu": "2.4.1", - "@resvg/resvg-js-linux-arm64-musl": "2.4.1", - "@resvg/resvg-js-linux-x64-gnu": "2.4.1", - "@resvg/resvg-js-linux-x64-musl": "2.4.1", - "@resvg/resvg-js-win32-arm64-msvc": "2.4.1", - "@resvg/resvg-js-win32-ia32-msvc": "2.4.1", - "@resvg/resvg-js-win32-x64-msvc": "2.4.1" - } - }, - "node_modules/@resvg/resvg-js-darwin-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@resvg/resvg-js-darwin-arm64/-/resvg-js-darwin-arm64-2.4.1.tgz", - "integrity": "sha512-U1oMNhea+kAXgiEXgzo7EbFGCD1Edq5aSlQoe6LMly6UjHzgx2W3N5kEXCwU/CgN5FiQhZr7PlSJSlcr7mdhfg==", - "cpu": [ - "arm64" - ], - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 10" - } - } - } -} diff --git a/assets/node_modules/@resvg/resvg-js-darwin-arm64/README.md b/assets/node_modules/@resvg/resvg-js-darwin-arm64/README.md deleted file mode 100644 index f0f01d7..0000000 --- a/assets/node_modules/@resvg/resvg-js-darwin-arm64/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# `@resvg/resvg-js-darwin-arm64` - -This is the **aarch64-apple-darwin** binary for `@resvg/resvg-js` diff --git a/assets/node_modules/@resvg/resvg-js-darwin-arm64/package.json b/assets/node_modules/@resvg/resvg-js-darwin-arm64/package.json deleted file mode 100644 index 4acacf0..0000000 --- a/assets/node_modules/@resvg/resvg-js-darwin-arm64/package.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "@resvg/resvg-js-darwin-arm64", - "version": "2.4.1", - "os": [ - "darwin" - ], - "cpu": [ - "arm64" - ], - "main": "resvgjs.darwin-arm64.node", - "files": [ - "resvgjs.darwin-arm64.node" - ], - "description": "A high-performance SVG renderer and toolkit, powered by Rust based resvg and napi-rs", - "keywords": [ - "resvg", - "svg", - "node-resvg", - "resvg-js", - "resvg-node", - "rust", - "svg2png", - "svg2img", - "svg to png" - ], - "license": "MPL-2.0", - "engines": { - "node": ">= 10" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "repository": "git@github.com:yisibl/resvg-js.git" -} \ No newline at end of file diff --git a/assets/node_modules/@resvg/resvg-js-darwin-arm64/resvgjs.darwin-arm64.node b/assets/node_modules/@resvg/resvg-js-darwin-arm64/resvgjs.darwin-arm64.node deleted file mode 100644 index 7742d50..0000000 Binary files a/assets/node_modules/@resvg/resvg-js-darwin-arm64/resvgjs.darwin-arm64.node and /dev/null differ diff --git a/assets/node_modules/@resvg/resvg-js/LICENSE b/assets/node_modules/@resvg/resvg-js/LICENSE deleted file mode 100644 index fa0086a..0000000 --- a/assets/node_modules/@resvg/resvg-js/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. \ No newline at end of file diff --git a/assets/node_modules/@resvg/resvg-js/README.md b/assets/node_modules/@resvg/resvg-js/README.md deleted file mode 100755 index 5737658..0000000 --- a/assets/node_modules/@resvg/resvg-js/README.md +++ /dev/null @@ -1,277 +0,0 @@ -# resvg-js - -GitHub CI Status -@resvg/resvg-js npm version -@resvg/resvg-js downloads -[![Rust 1.65+](https://img.shields.io/badge/rust-1.65+-orange.svg)](https://www.rust-lang.org) - -> resvg-js is a high-performance SVG renderer and toolkit, powered by Rust based [resvg](https://github.com/RazrFalcon/resvg/), with Node.js backend using [napi-rs](https://github.com/napi-rs/napi-rs), also a pure WebAssembly backend. - -## Features - -- Fast, safe and zero dependencies, with correct output. -- Convert SVG to PNG, includes cropping, scaling and setting the background color. -- Support system fonts and custom fonts in SVG text. -- `v2`: Gets the width and height of the SVG and the generated PNG. -- `v2`: Support for outputting simplified SVG strings, such as converting shapes(rect, circle, etc) to ``. -- `v2`: Support WebAssembly. -- `v2`: Support to get SVG bounding box and crop according to bounding box. -- `v2`: Support for loading images of external links in ``. -- No need for node-gyp and postinstall, the `.node` file has been compiled for you. -- Cross-platform support, including [Apple M Chips](https://www.apple.com/newsroom/2020/11/apple-unleashes-m1/). -- Support for running as native addons in Deno. - -## Installation - -### Node.js - -```shell -npm i @resvg/resvg-js -``` - -### Browser(Wasm) - -```html - -``` - -## Example - -### [Node.js Example](example/index.js) - -This example will load Source Han Serif, and then render the SVG to PNG. - -```shell -node example/index.js - -Loaded 1 font faces in 0ms. -Font './example/SourceHanSerifCN-Light-subset.ttf':0 found in 0.006ms. -✨ Done in 55.65491008758545 ms -``` - -### [Deno Example](example/index-deno.js) - -```shell -deno run --unstable --allow-read --allow-write --allow-ffi example/index-deno.js - -[2022-11-16T15:03:29Z DEBUG resvg_js::fonts] Loaded 1 font faces in 0.067ms. -[2022-11-16T15:03:29Z DEBUG resvg_js::fonts] Font './example/SourceHanSerifCN-Light-subset.ttf':0 found in 0.001ms. -Original SVG Size: 1324 x 687 -Output PNG Size : 1200 x 623 -✨ Done in 66 ms -``` - -| SVG | PNG | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| | | - -## Usage - -### Node.js - -```js -const { promises } = require('fs') -const { join } = require('path') -const { Resvg } = require('@resvg/resvg-js') - -async function main() { - const svg = await promises.readFile(join(__dirname, './text.svg')) - const opts = { - background: 'rgba(238, 235, 230, .9)', - fitTo: { - mode: 'width', - value: 1200, - }, - font: { - fontFiles: ['./example/SourceHanSerifCN-Light-subset.ttf'], // Load custom fonts. - loadSystemFonts: false, // It will be faster to disable loading system fonts. - defaultFontFamily: 'Source Han Serif CN Light', - }, - } - const resvg = new Resvg(svg, opts) - const pngData = resvg.render() - const pngBuffer = pngData.asPng() - - console.info('Original SVG Size:', `${resvg.width} x ${resvg.height}`) - console.info('Output PNG Size :', `${pngData.width} x ${pngData.height}`) - - await promises.writeFile(join(__dirname, './text-out.png'), pngBuffer) -} - -main() -``` - -### Deno - -Starting with [Deno 1.26.1](https://github.com/denoland/deno/releases/tag/v1.26.1), there is support for running Native Addons directly from Node.js. -This allows for performance that is close to that found in Node.js. - -```shell -deno run --unstable --allow-read --allow-write --allow-ffi example/index-deno.js -``` - -```js -import * as path from 'https://deno.land/std@0.159.0/path/mod.ts' -import { Resvg } from 'npm:@resvg/resvg-js' -const __dirname = path.dirname(path.fromFileUrl(import.meta.url)) - -const svg = await Deno.readFile(path.join(__dirname, './text.svg')) -const opts = { - fitTo: { - mode: 'width', - value: 1200, - }, -} - -const t = performance.now() -const resvg = new Resvg(svg, opts) -const pngData = resvg.render() -const pngBuffer = pngData.asPng() -console.info('Original SVG Size:', `${resvg.width} x ${resvg.height}`) -console.info('Output PNG Size :', `${pngData.width} x ${pngData.height}`) -console.info('✨ Done in', performance.now() - t, 'ms') - -await Deno.writeFile(path.join(__dirname, './text-out-deno.png'), pngBuffer) -``` - -### WebAssembly - -This package also ships a pure WebAssembly artifact built with `wasm-bindgen` to run in browsers. - -#### Browser - -```html - - -``` - -See [playground](wasm/index.html), it is also possible to [call Wasm in Node.js](example/wasm-node.js), but it is slower. - -## Sample Benchmark - -```shell -npm i benny@3.x sharp@0.x @types/sharp svg2img@0.x -npm run bench -``` - -```shell -Running "resize width" suite... - resvg-js(Rust): - 12 ops/s - - sharp: - 9 ops/s - - skr-canvas(Rust): - 7 ops/s - - svg2img(canvg and node-canvas): - 6 ops/s -``` - -## Support matrix - -| | Node.js 12 | Node.js 14 | Node.js 16 | Node.js 18 | npm | -| ---------------- | ---------- | ---------- | ---------- | ---------- | --- | -| Windows x64 | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-win32-x64-msvc.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-win32-x64-msvc) | -| Windows x32 | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-win32-ia32-msvc.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-win32-ia32-msvc) | -| Windows arm64 | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-win32-arm64-msvc.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-win32-arm64-msvc) | -| macOS x64 | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-darwin-x64.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-darwin-x64) | -| macOS arm64(M1) | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-darwin-arm64.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-darwin-arm64) | -| Linux x64 gnu | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-linux-x64-gnu.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-linux-x64-gnu) | -| Linux x64 musl | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-linux-x64-musl.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-linux-x64-musl) | -| Linux arm gnu | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-linux-arm-gnueabihf.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-linux-arm-gnueabihf) | -| Linux arm64 gnu | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-linux-arm64-gnu.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-linux-arm64-gnu) | -| Linux arm64 musl | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-linux-arm64-musl.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-linux-arm64-musl) | -| Android arm64 | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-android-arm64.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-android-arm64) | -| Android armv7 | ✓ | ✓ | ✓ | ✓ |[![npm version](https://img.shields.io/npm/v/@resvg/resvg-js-android-arm-eabi.svg?sanitize=true)](https://www.npmjs.com/package/@resvg/resvg-js-android-arm-eabi) | - -## Test or Contributing - -- Install latest `Rust` -- Install `Node.js@10+` which fully supported `Node-API` -- Install `wasm-pack` - - ```bash - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - ``` - - Normally `wasm-pack` will install `wasm-bindgen` automatically, but if the installation [fails due to network reasons](https://github.com/rustwasm/wasm-pack-template/issues/44#issuecomment-521657516), please try to install it manually. - - ```bash - cargo install wasm-bindgen-cli - ``` - - On computers with Apple M chips, the following error message may appear: - - > Error: failed to download from https://github.com/WebAssembly/binaryen/releases/download/version_90/binaryen-version_90-x86_64-apple-darwin.tar.gz - - Please install binaryen manually: - - ```bash - brew install binaryen - ``` - -### Build Node.js bindings - -```bash -npm i -npm run build -npm test -``` - -### Build WebAssembly bindings - -```bash -npm i -npm run build:wasm -npm run test:wasm -``` - -## Roadmap - -I will consider implementing the following features, if you happen to be interested, -please feel free to discuss with me or submit a PR. - -- [x] Support async API -- [x] Upgrade to napi-rs v2 -- [x] Support WebAssembly -- [x] Output usvg-simplified SVG string -- [x] Support for getting SVG Bounding box -- [ ] Support for generating more lossless bitmap formats, e.g. avif, webp, JPEG XL - -## Release package - -We use GitHub actions to automatically publish npm packages. - -```bash -# 1.0.0 => 1.0.1 -npm version patch - -# or 1.0.0 => 1.1.0 -npm version minor -``` - -## License - -[MPLv2.0](https://www.mozilla.org/en-US/MPL/) - -Copyright (c) 2021-present, yisibl(一丝) diff --git a/assets/node_modules/@resvg/resvg-js/index.d.ts b/assets/node_modules/@resvg/resvg-js/index.d.ts deleted file mode 100755 index 57a5fa3..0000000 --- a/assets/node_modules/@resvg/resvg-js/index.d.ts +++ /dev/null @@ -1,98 +0,0 @@ -/// - -export type ResvgRenderOptions = { - font?: { - loadSystemFonts?: boolean - fontFiles?: string[] - fontDirs?: string[] - defaultFontFamily?: string - defaultFontSize?: number - serifFamily?: string - sansSerifFamily?: string - cursiveFamily?: string - fantasyFamily?: string - monospaceFamily?: string - } - dpi?: number - languages?: string[] - shapeRendering?: - | 0 // optimizeSpeed - | 1 // crispEdges - | 2 // geometricPrecision - textRendering?: - | 0 // optimizeSpeed - | 1 // optimizeLegibility - | 2 // geometricPrecision' - imageRendering?: - | 0 // optimizeQuality - | 1 // optimizeSpeed - fitTo?: - | { mode: 'original' } - | { mode: 'width'; value: number } - | { mode: 'height'; value: number } - | { mode: 'zoom'; value: number } - background?: string // Support CSS3 color, e.g. rgba(255, 255, 255, .8) - crop?: { - left: number - top: number - right?: number - bottom?: number - } - logLevel?: 'off' | 'error' | 'warn' | 'info' | 'debug' | 'trace' -} -export class BBox { - x: number - y: number - width: number - height: number -} - -export function renderAsync( - svg: string | Buffer, - options?: ResvgRenderOptions | null, - signal?: AbortSignal | null, -): Promise -export class Resvg { - constructor(svg: Buffer | string, options?: ResvgRenderOptions | null) - toString(): string - render(): RenderedImage - /** - * Calculate a maximum bounding box of all visible elements in this SVG. - * - * Note: path bounding box are approx values. - */ - innerBBox(): BBox | undefined - /** - * Calculate a maximum bounding box of all visible elements in this SVG. - * This will first apply transform. - * Similar to `SVGGraphicsElement.getBBox()` DOM API. - */ - getBBox(): BBox | undefined - /** - * Use a given `BBox` to crop the svg. Currently this method simply changes - * the viewbox/size of the svg and do not move the elements for simplicity - */ - cropByBBox(bbox: BBox): void - - imagesToResolve(): Array - resolveImage(href: string, buffer: Buffer): void - - /** Get the SVG width */ - get width(): number - - /** Get the SVG height */ - get height(): number -} -export class RenderedImage { - /** Write the image data to Buffer */ - asPng(): Buffer - - /** Get the RGBA pixels of the image */ - get pixels(): Buffer - - /** Get the PNG width */ - get width(): number - - /** Get the PNG height */ - get height(): number -} diff --git a/assets/node_modules/@resvg/resvg-js/index.js b/assets/node_modules/@resvg/resvg-js/index.js deleted file mode 100755 index 4578b70..0000000 --- a/assets/node_modules/@resvg/resvg-js/index.js +++ /dev/null @@ -1,23 +0,0 @@ -const { render: _render, renderAsync: _renderAsync, Resvg: _Resvg } = require('./js-binding.js') - -module.exports.render = function render(svg, options) { - if (options) { - return _render(svg, JSON.stringify(options)) - } - return _render(svg) -} - -module.exports.renderAsync = function renderAsync(svg, options, signal) { - if (options) { - return _renderAsync(svg, JSON.stringify(options), signal) - } - return _renderAsync(svg, null, signal) -} - -module.exports.Resvg = class Resvg extends _Resvg { - constructor(svg, options) { - super(svg, JSON.stringify(options)) - } -} - -// module.exports.Resvg = _Resvg diff --git a/assets/node_modules/@resvg/resvg-js/js-binding.d.ts b/assets/node_modules/@resvg/resvg-js/js-binding.d.ts deleted file mode 100644 index c51bd16..0000000 --- a/assets/node_modules/@resvg/resvg-js/js-binding.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ - -/* auto-generated by NAPI-RS */ - -export function renderAsync(svg: string | Buffer, options?: string | undefined | null, signal?: AbortSignal | undefined | null): Promise -export class BBox { - x: number - y: number - width: number - height: number -} -export class Resvg { - constructor(svg: string | Buffer, options?: string | undefined | null) - /** Renders an SVG in Node.js */ - render(): RenderedImage - /** Output usvg-simplified SVG string */ - toString(): string - /** - * Calculate a maximum bounding box of all visible elements in this SVG. - * - * Note: path bounding box are approx values. - */ - innerBBox(): BBox | undefined - /** - * Calculate a maximum bounding box of all visible elements in this SVG. - * This will first apply transform. - * Similar to `SVGGraphicsElement.getBBox()` DOM API. - */ - getBBox(): BBox | undefined - /** - * Use a given `BBox` to crop the svg. Currently this method simply changes - * the viewbox/size of the svg and do not move the elements for simplicity - */ - cropByBBox(bbox: BBox): void - imagesToResolve(): Array - resolveImage(href: string, buffer: Buffer): void - /** Get the SVG width */ - get width(): number - /** Get the SVG height */ - get height(): number -} -export class RenderedImage { - /** Write the image data to Buffer */ - asPng(): Buffer - /** Get the RGBA pixels of the image */ - get pixels(): Buffer - /** Get the PNG width */ - get width(): number - /** Get the PNG height */ - get height(): number -} diff --git a/assets/node_modules/@resvg/resvg-js/js-binding.js b/assets/node_modules/@resvg/resvg-js/js-binding.js deleted file mode 100644 index eab173b..0000000 --- a/assets/node_modules/@resvg/resvg-js/js-binding.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";const{existsSync,readFileSync}=require("fs"),{join}=require("path"),{platform,arch}=process;let nativeBinding=null,localFileExisted=!1,loadError=null;function isMusl(){if(!process.report||typeof process.report.getReport!="function")try{const e=require("child_process").execSync("which ldd").toString().trim();return readFileSync(e,"utf8").includes("musl")}catch(e){return!0}else{const{glibcVersionRuntime:e}=process.report.getReport().header;return!e}}switch(platform){case"android":switch(arch){case"arm64":localFileExisted=existsSync(join(__dirname,"resvgjs.android-arm64.node"));try{localFileExisted?nativeBinding=require("./resvgjs.android-arm64.node"):nativeBinding=require("@resvg/resvg-js-android-arm64")}catch(e){loadError=e}break;case"arm":localFileExisted=existsSync(join(__dirname,"resvgjs.android-arm-eabi.node"));try{localFileExisted?nativeBinding=require("./resvgjs.android-arm-eabi.node"):nativeBinding=require("@resvg/resvg-js-android-arm-eabi")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on Android ${arch}`)}break;case"win32":switch(arch){case"x64":localFileExisted=existsSync(join(__dirname,"resvgjs.win32-x64-msvc.node"));try{localFileExisted?nativeBinding=require("./resvgjs.win32-x64-msvc.node"):nativeBinding=require("@resvg/resvg-js-win32-x64-msvc")}catch(e){loadError=e}break;case"ia32":localFileExisted=existsSync(join(__dirname,"resvgjs.win32-ia32-msvc.node"));try{localFileExisted?nativeBinding=require("./resvgjs.win32-ia32-msvc.node"):nativeBinding=require("@resvg/resvg-js-win32-ia32-msvc")}catch(e){loadError=e}break;case"arm64":localFileExisted=existsSync(join(__dirname,"resvgjs.win32-arm64-msvc.node"));try{localFileExisted?nativeBinding=require("./resvgjs.win32-arm64-msvc.node"):nativeBinding=require("@resvg/resvg-js-win32-arm64-msvc")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on Windows: ${arch}`)}break;case"darwin":localFileExisted=existsSync(join(__dirname,"resvgjs.darwin-universal.node"));try{localFileExisted?nativeBinding=require("./resvgjs.darwin-universal.node"):nativeBinding=require("@resvg/resvg-js-darwin-universal");break}catch(e){}switch(arch){case"x64":localFileExisted=existsSync(join(__dirname,"resvgjs.darwin-x64.node"));try{localFileExisted?nativeBinding=require("./resvgjs.darwin-x64.node"):nativeBinding=require("@resvg/resvg-js-darwin-x64")}catch(e){loadError=e}break;case"arm64":localFileExisted=existsSync(join(__dirname,"resvgjs.darwin-arm64.node"));try{localFileExisted?nativeBinding=require("./resvgjs.darwin-arm64.node"):nativeBinding=require("@resvg/resvg-js-darwin-arm64")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on macOS: ${arch}`)}break;case"freebsd":if(arch!=="x64")throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);localFileExisted=existsSync(join(__dirname,"resvgjs.freebsd-x64.node"));try{localFileExisted?nativeBinding=require("./resvgjs.freebsd-x64.node"):nativeBinding=require("@resvg/resvg-js-freebsd-x64")}catch(e){loadError=e}break;case"linux":switch(arch){case"x64":if(isMusl()){localFileExisted=existsSync(join(__dirname,"resvgjs.linux-x64-musl.node"));try{localFileExisted?nativeBinding=require("./resvgjs.linux-x64-musl.node"):nativeBinding=require("@resvg/resvg-js-linux-x64-musl")}catch(e){loadError=e}}else{localFileExisted=existsSync(join(__dirname,"resvgjs.linux-x64-gnu.node"));try{localFileExisted?nativeBinding=require("./resvgjs.linux-x64-gnu.node"):nativeBinding=require("@resvg/resvg-js-linux-x64-gnu")}catch(e){loadError=e}}break;case"arm64":if(isMusl()){localFileExisted=existsSync(join(__dirname,"resvgjs.linux-arm64-musl.node"));try{localFileExisted?nativeBinding=require("./resvgjs.linux-arm64-musl.node"):nativeBinding=require("@resvg/resvg-js-linux-arm64-musl")}catch(e){loadError=e}}else{localFileExisted=existsSync(join(__dirname,"resvgjs.linux-arm64-gnu.node"));try{localFileExisted?nativeBinding=require("./resvgjs.linux-arm64-gnu.node"):nativeBinding=require("@resvg/resvg-js-linux-arm64-gnu")}catch(e){loadError=e}}break;case"arm":localFileExisted=existsSync(join(__dirname,"resvgjs.linux-arm-gnueabihf.node"));try{localFileExisted?nativeBinding=require("./resvgjs.linux-arm-gnueabihf.node"):nativeBinding=require("@resvg/resvg-js-linux-arm-gnueabihf")}catch(e){loadError=e}break;default:throw new Error(`Unsupported architecture on Linux: ${arch}`)}break;default:throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)}if(!nativeBinding)throw loadError||new Error("Failed to load native binding");const{BBox,Resvg,RenderedImage,renderAsync}=nativeBinding;module.exports.BBox=BBox,module.exports.Resvg=Resvg,module.exports.RenderedImage=RenderedImage,module.exports.renderAsync=renderAsync; diff --git a/assets/node_modules/@resvg/resvg-js/package.json b/assets/node_modules/@resvg/resvg-js/package.json deleted file mode 100644 index 4ac5817..0000000 --- a/assets/node_modules/@resvg/resvg-js/package.json +++ /dev/null @@ -1,151 +0,0 @@ -{ - "name": "@resvg/resvg-js", - "version": "2.4.1", - "description": "A high-performance SVG renderer and toolkit, powered by Rust based resvg and napi-rs", - "main": "index.js", - "repository": "git@github.com:yisibl/resvg-js.git", - "license": "MPL-2.0", - "keywords": [ - "resvg", - "svg", - "node-resvg", - "resvg-js", - "resvg-node", - "rust", - "svg2png", - "svg2img", - "svg to png" - ], - "files": [ - "index.d.ts", - "index.js", - "js-binding.js", - "js-binding.d.ts" - ], - "napi": { - "name": "resvgjs", - "triples": { - "defaults": true, - "additional": [ - "x86_64-unknown-linux-musl", - "aarch64-unknown-linux-gnu", - "i686-pc-windows-msvc", - "armv7-unknown-linux-gnueabihf", - "aarch64-apple-darwin", - "aarch64-linux-android", - "arm-linux-androideabi", - "aarch64-unknown-linux-musl", - "aarch64-pc-windows-msvc" - ] - } - }, - "engines": { - "node": ">= 10" - }, - "publishConfig": { - "registry": "https://registry.npmjs.org/", - "access": "public" - }, - "scripts": { - "artifacts": "napi artifacts", - "bench": "node -r @swc-node/register benchmark/bench.ts", - "bundle": "run-p 'bundle:*'", - "bundle:js": "node bundle.js", - "bundle:dts": "dts-bundle-generator --external-types -o wasm/index.d.ts wasm-binding.ts", - "build": "napi build --platform --release --js js-binding.js --dts js-binding.d.ts", - "build:debug": "napi build --platform --js js-binding.js --dts js-binding.d.ts", - "build:wasm": "run-s build:wasm-web copy-wasm bundle", - "build:wasm-web": "wasm-pack build --target web --out-name index --out-dir wasm/dist --release", - "copy-wasm": "copyfiles -f wasm/dist/index_bg.wasm ./wasm", - "playground": "copyfiles -f playground/index.html ./wasm", - "format": "run-p format:md format:json format:yaml format:source format:rs", - "format:md": "prettier --parser markdown --write './**/*.md'", - "format:json": "prettier --parser json --write './**/*.json'", - "format:svg": "prettier --parser html --write './**/*.svg'", - "format:rs": "cargo fmt", - "format:source": "prettier --config ./package.json --write './**/*.{js,ts,mjs}'", - "format:yaml": "prettier --parser yaml --write './**/*.{yml,yaml}'", - "lint": "eslint . -c ./.eslintrc.yml './**/*.{ts,tsx,js}'", - "lint:fix": "eslint . -c ./.eslintrc.yml './**/*.{ts,tsx,js}' --fix", - "prepublishOnly": "napi prepublish -t npm && esbuild js-binding.js --minify --allow-overwrite --outfile=js-binding.js", - "test": "ava __test__/**/index*.*", - "test:wasm": "ava __test__/**/wasm*.*", - "version": "napi version" - }, - "devDependencies": { - "@napi-rs/cli": "^2.14.6", - "@swc-node/register": "^1.5.1", - "@types/node": "^18.0.0", - "@typescript-eslint/eslint-plugin": "^5.30.3", - "@typescript-eslint/parser": "^5.30.3", - "ava": "^5.0.0", - "copyfiles": "^2.4.1", - "dts-bundle-generator": "^6.12.0", - "esbuild": "^0.17.0", - "eslint": "^8.19.0", - "eslint-config-prettier": "^8.5.0", - "eslint-plugin-import": "^2.26.0", - "eslint-plugin-prettier": "^4.2.1", - "eslint-plugin-sonarjs": "^0.18.0", - "husky": "^8.0.0", - "jimp-compact": "^0.16.1-2", - "lint-staged": "^12.5.0", - "node-fetch": "2.x", - "npm-run-all": "^4.1.5", - "prettier": "^2.7.1", - "typescript": "^4.7.4" - }, - "lint-staged": { - "*.@(js|ts|tsx)": [ - "prettier --write", - "eslint -c .eslintrc.yml --fix" - ], - "*.@(yml|yaml)": [ - "prettier --parser yaml --write" - ], - "*.md": [ - "prettier --parser markdown --write" - ], - "*.json": [ - "prettier --parser json --write" - ], - "*.svg": [ - "prettier --parser html --write" - ] - }, - "ava": { - "require": [ - "@swc-node/register" - ], - "extensions": [ - "ts" - ], - "timeout": "3m", - "environmentVariables": { - "TS_NODE_PROJECT": "./tsconfig.json" - } - }, - "prettier": { - "printWidth": 120, - "semi": false, - "trailingComma": "all", - "singleQuote": true, - "arrowParens": "always", - "parser": "typescript" - }, - "packageManager": "yarn@3.4.1", - "optionalDependencies": { - "@resvg/resvg-js-win32-x64-msvc": "2.4.1", - "@resvg/resvg-js-darwin-x64": "2.4.1", - "@resvg/resvg-js-linux-x64-gnu": "2.4.1", - "@resvg/resvg-js-linux-x64-musl": "2.4.1", - "@resvg/resvg-js-linux-arm64-gnu": "2.4.1", - "@resvg/resvg-js-win32-ia32-msvc": "2.4.1", - "@resvg/resvg-js-linux-arm-gnueabihf": "2.4.1", - "@resvg/resvg-js-darwin-arm64": "2.4.1", - "@resvg/resvg-js-android-arm64": "2.4.1", - "@resvg/resvg-js-android-arm-eabi": "2.4.1", - "@resvg/resvg-js-linux-arm64-musl": "2.4.1", - "@resvg/resvg-js-win32-arm64-msvc": "2.4.1" - } -} \ No newline at end of file