Skip to content

Commit cae17d2

Browse files
committed
Initial commit
0 parents  commit cae17d2

16 files changed

+2374
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
node_modules/
3+
4+
/.vscode
5+
/build
6+
/electron/*
7+
!/electron/.gclient

.prettierrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"semi": false,
5+
"tabWidth": 4
6+
}

Dockerfile

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM debian:11 AS chromium-build
2+
3+
WORKDIR /app
4+
5+
ENV PATH="${PATH}:/app/depot_tools"
6+
ENV CCACHE_DIR=/app/.ccache
7+
ENV GIT_CACHE_PATH=/app/.git_cache
8+
ENV DEBIAN_FRONTEND=noninteractive
9+
ENV CHROMIUM_BUILDTOOLS_PATH=/app/electron/src/buildtools
10+
RUN apt-get update && \
11+
apt-get install -y git sudo curl ccache python3 bzip2 xz-utils && \
12+
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
13+
apt-get install -y nodejs && \
14+
git clone --depth 1 --single-branch https://chromium.googlesource.com/chromium/tools/depot_tools.git
15+
16+
COPY electron/.gclient electron/
17+
COPY scripts/gclient.sh scripts/
18+
RUN --mount=type=cache,target=/app/.git_cache scripts/gclient.sh
19+
20+
RUN electron/src/build/install-build-deps.sh
21+
22+
COPY scripts/patch.sh /app/scripts/
23+
COPY src/chromium.patch /app/src/
24+
RUN scripts/patch.sh
25+
26+
FROM chromium-build AS chromium-arm64
27+
28+
RUN electron/src/build/linux/sysroot_scripts/install-sysroot.py --arch=arm64
29+
30+
COPY scripts/gn.sh /app/scripts/
31+
RUN GN_ARGS='target_cpu="arm64" cc_wrapper="env CCACHE_DIR=/app/.ccache CCACHE_SLOPPINESS=time_macros ccache"' \
32+
scripts/gn.sh release
33+
34+
COPY scripts/ninja.sh /app/scripts/
35+
RUN --mount=type=cache,target=/app/.ccache \
36+
--mount=type=cache,target=/app/.git_cache \
37+
electron/src/build/linux/sysroot_scripts/install-sysroot.py --arch=arm64 && \
38+
scripts/ninja.sh release -j200
39+
40+
FROM chromium-arm64
41+
42+
COPY --from=chromium-build /app/electron/src/out /app/electron/src/out

electron/.gclient

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
solutions = [
2+
{ "name" : 'src/electron',
3+
"url" : 'https://github.com/electron/electron',
4+
"deps_file" : 'DEPS',
5+
"managed" : False,
6+
"custom_deps" : {
7+
},
8+
"custom_vars": {},
9+
},
10+
]

google.svg

+106
Loading

package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "html2svg",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"scripts": {
7+
"gclient": "scripts/gclient.sh",
8+
"gn": "scripts/gn.sh",
9+
"ninja": "scripts/ninja.sh",
10+
"build": "tsc -b ."
11+
},
12+
"devDependencies": {
13+
"@electron/build-tools": "^1.1.0",
14+
"@types/node": "^18.11.3",
15+
"electron": "^21.2.0",
16+
"npm-run-all": "^4.1.5",
17+
"typescript": "^4.8.4"
18+
}
19+
}

readme.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# `html2svg`
2+
3+
Convert HTML and `<canvas>` to SVG using Chromium.
4+
5+
## Usage
6+
7+
### CLI
8+
9+
```shell
10+
$ html2svg http://google.com > google.svg
11+
```
12+
13+
### Server
14+
15+
```shell
16+
$ html2svg serve --port 8765
17+
$ curl -d http://google.com http://localhost:8765 > google.svg
18+
```
19+
20+
## Development
21+
22+
> - Building Chromium for ARM on Linux or Windows is not officially supported, cross-compile from x64 instead.
23+
24+
1. Fetch dependencies:
25+
```shell
26+
$ yarn
27+
```
28+
2. Clone Electron.js and Chromium using `gclient`:
29+
```shell
30+
$ yarn gclient
31+
```
32+
3. Configure the build system using `gn` using one of these commands:
33+
```shell
34+
# for local developement
35+
$ yarn gn testing
36+
# or for releasing
37+
$ yarn gn release
38+
# add --ide=xcode if you'd like to generate an Xcode project on macOS
39+
$ yarn gn release --ide=xcode
40+
```
41+
4. Build using `ninja` using one of these commands:
42+
```shell
43+
# make a testing build
44+
$ yarn ninja testing
45+
# make a release build
46+
$ yarn ninja release
47+
```

scripts/gclient.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -exo pipefail
4+
5+
cd electron
6+
7+
gclient sync --with_tags "$@"

scripts/gn.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -eo pipefail
4+
5+
mode="$1"
6+
shift
7+
8+
cd electron/src
9+
CHROMIUM_BUILDTOOLS_PATH=`pwd`/buildtools \
10+
gn gen "out/${mode}" --args="import(\"//electron/build/args/$mode.gn\") ${GN_ARGS}" "$@"

scripts/ninja.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
set -eo pipefail
4+
5+
mode="$1"
6+
shift
7+
8+
ninja -C "electron/src/out/$mode" electron "$@"

scripts/patch.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
set -eo pipefail
4+
5+
git -C electron/src apply --ignore-space-change --ignore-whitespace < src/chromium.patch
6+
git -C electron/src/third_party/skia apply --ignore-space-change --ignore-whitespace < src/skia.patch

0 commit comments

Comments
 (0)