skia-canvas 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/lib/browser.js +0 -2
- package/lib/classes/imagery.js +1 -1
- package/lib/classes/typography.js +3 -8
- package/lib/fetch.js +4 -0
- package/lib/prebuild.mjs +24 -8
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -16,6 +16,12 @@
|
|
|
16
16
|
<a href="https://github.com/samizdatco/skia-canvas/discussions">Discussion Forum</a>
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
|
+
<div align="center">
|
|
20
|
+
|
|
21
|
+
### [Version 3.0 now available](https://github.com/samizdatco/skia-canvas/discussions/255)
|
|
22
|
+
|
|
23
|
+
</div>
|
|
24
|
+
|
|
19
25
|
---
|
|
20
26
|
|
|
21
27
|
Skia Canvas is a Node.js implementation of the HTML Canvas drawing [API](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API) for both on- and off-screen rendering. Since it uses Google’s [Skia](https://skia.org) graphics engine, its output is very similar to Chrome’s [`<canvas>`](https://html.spec.whatwg.org/multipage/canvas.html) element — though it's also capable of things the browser’s Canvas still can't achieve.
|
package/lib/browser.js
CHANGED
|
@@ -24,8 +24,6 @@ class Canvas{
|
|
|
24
24
|
let elt = document.createElement('canvas'),
|
|
25
25
|
pages = []
|
|
26
26
|
|
|
27
|
-
Object.defineProperty(elt, "async", {value:true, writable:false, enumerable:true})
|
|
28
|
-
|
|
29
27
|
for (var [prop, get] of Object.entries({
|
|
30
28
|
png: () => asBuffer(elt, 'image/png'),
|
|
31
29
|
jpg: () => asBuffer(elt, 'image/jpeg'),
|
package/lib/classes/imagery.js
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
7
|
const {RustClass, core, readOnly, inspect, neon, argc, REPR} = require('./neon'),
|
|
8
|
+
{fetch} = require('../fetch'),
|
|
8
9
|
{EventEmitter} = require('events'),
|
|
9
10
|
{readFile} = require('fs/promises'),
|
|
10
|
-
{fetch} = require('cross-fetch'),
|
|
11
11
|
url = require('url')
|
|
12
12
|
|
|
13
13
|
//
|
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
"use strict"
|
|
6
6
|
|
|
7
|
-
const {RustClass, readOnly, signature, inspect, REPR} = require('./neon')
|
|
8
|
-
{globSync, convertPathToPattern:quote} = require('fast-glob'),
|
|
9
|
-
glob = paths => globSync(
|
|
10
|
-
[paths].flat(2).map(p => p.indexOf('\\')>=0 ? quote(p) : p),
|
|
11
|
-
{dot:true}
|
|
12
|
-
)
|
|
7
|
+
const {RustClass, readOnly, signature, inspect, REPR} = require('./neon')
|
|
13
8
|
|
|
14
9
|
class FontLibrary extends RustClass {
|
|
15
10
|
constructor(){
|
|
@@ -27,11 +22,11 @@ class FontLibrary extends RustClass {
|
|
|
27
22
|
if (sig=='o'){
|
|
28
23
|
let results = {}
|
|
29
24
|
for (let [alias, paths] of Object.entries(args.shift())){
|
|
30
|
-
results[alias] = this.ƒ("addFamily", alias,
|
|
25
|
+
results[alias] = this.ƒ("addFamily", alias, [paths].flat())
|
|
31
26
|
}
|
|
32
27
|
return results
|
|
33
28
|
}else if (sig.match(/^s?[as]$/)){
|
|
34
|
-
let fonts =
|
|
29
|
+
let fonts = [args.pop()].flat()
|
|
35
30
|
let alias = args.shift()
|
|
36
31
|
return this.ƒ("addFamily", alias, fonts)
|
|
37
32
|
}else{
|
package/lib/fetch.js
ADDED
package/lib/prebuild.mjs
CHANGED
|
@@ -6,9 +6,9 @@ import {createReadStream, createWriteStream, existsSync} from 'fs'
|
|
|
6
6
|
import {readFile, writeFile, rm} from 'fs/promises'
|
|
7
7
|
import {resolve} from 'path'
|
|
8
8
|
import {promisify} from 'util'
|
|
9
|
-
import fetch from 'cross-fetch'
|
|
10
9
|
import {family} from 'detect-libc'
|
|
11
|
-
import {
|
|
10
|
+
import {fetch} from "./fetch.js"
|
|
11
|
+
import {HttpsProxyAgent} from 'https-proxy-agent'
|
|
12
12
|
|
|
13
13
|
const pipeline = promisify(stream.pipeline)
|
|
14
14
|
const exec = promisify(child_process.exec);
|
|
@@ -26,6 +26,23 @@ const CARGO_FEATURES = {
|
|
|
26
26
|
win32: "vulkan,window",
|
|
27
27
|
}[process.platform]
|
|
28
28
|
|
|
29
|
+
class Hasher extends stream.Transform {
|
|
30
|
+
#digest
|
|
31
|
+
constructor(options) {
|
|
32
|
+
super(options)
|
|
33
|
+
this.hash = crypto.createHash('sha256')
|
|
34
|
+
}
|
|
35
|
+
_transform(chunk, encoding, callback) {
|
|
36
|
+
this.hash.update(chunk)
|
|
37
|
+
this.push(chunk)
|
|
38
|
+
callback()
|
|
39
|
+
}
|
|
40
|
+
get digest(){
|
|
41
|
+
this.#digest = this.#digest || `sha256:${this.hash.digest('hex')}`
|
|
42
|
+
return this.#digest
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
29
46
|
async function config(){
|
|
30
47
|
let package_json = JSON.parse(await readFile(PACKAGE_JSON)),
|
|
31
48
|
{platform, arch} = process,
|
|
@@ -71,18 +88,17 @@ async function download(...args){
|
|
|
71
88
|
if (status==404) throw Error(`Prebuilt library not found at "${url}" (HTTP error ${status})`)
|
|
72
89
|
else throw Error(`Failed to load prebuilt binary from "${url}" (HTTP error ${status})`)
|
|
73
90
|
}else{
|
|
74
|
-
console.log(`
|
|
91
|
+
console.log(`Fetching prebuilt libary from "${url}"`)
|
|
75
92
|
}
|
|
76
93
|
|
|
77
94
|
// write to /lib/skia.node while also hashing the .gz file
|
|
78
|
-
let
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
])
|
|
95
|
+
let sha = new Hasher()
|
|
96
|
+
let gunzip = zlib.createGunzip()
|
|
97
|
+
await pipeline(body, sha, gunzip, createWriteStream(BINARY_PATH))
|
|
82
98
|
|
|
83
99
|
// verify hash if `prebuild` obj exists in package.json (i.e., this is a published module, not a repo copy)
|
|
84
100
|
let official = (prebuild || {})[`${triplet}.gz`],
|
|
85
|
-
actual =
|
|
101
|
+
actual = sha.digest
|
|
86
102
|
if (official && actual != official){
|
|
87
103
|
await rm(BINARY_PATH, {force:true})
|
|
88
104
|
throw Error(`Prebuilt library file '${triplet}.gz' failed integrity check\nDownloaded: ${url}\nExpected: ${official}\nReceived: ${actual}`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skia-canvas",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "A multi-threaded, GPU-accelerated, Canvas API for Node",
|
|
5
5
|
"author": "Christian Swinehart <drafting@samizdat.co>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,10 +28,9 @@
|
|
|
28
28
|
"test": "jest"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"cross-fetch": "^4.1.0",
|
|
32
31
|
"detect-libc": "^2.0.4",
|
|
33
|
-
"fast-glob": "^3.3.3",
|
|
34
32
|
"https-proxy-agent": "^7.0.6",
|
|
33
|
+
"node-fetch": "^2.7.0",
|
|
35
34
|
"string-split-by": "^1.0.0"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
@@ -40,6 +39,7 @@
|
|
|
40
39
|
"@types/node": "^24.2.1",
|
|
41
40
|
"cargo-cp-artifact": "^0.1",
|
|
42
41
|
"express": "^5.1.0",
|
|
42
|
+
"fast-glob": "^3.3.3",
|
|
43
43
|
"jest": "^30.0.5",
|
|
44
44
|
"lodash": "^4.17.21",
|
|
45
45
|
"nodemon": "^3.1.10",
|
|
@@ -70,15 +70,15 @@
|
|
|
70
70
|
"rust"
|
|
71
71
|
],
|
|
72
72
|
"prebuild": {
|
|
73
|
-
"aws-lambda-arm64.zip": "sha256:
|
|
74
|
-
"aws-lambda-x64.zip": "sha256:
|
|
75
|
-
"darwin-arm64.gz": "sha256:
|
|
76
|
-
"darwin-x64.gz": "sha256:
|
|
77
|
-
"linux-arm64-glibc.gz": "sha256:
|
|
78
|
-
"linux-arm64-musl.gz": "sha256:
|
|
79
|
-
"linux-x64-glibc.gz": "sha256:
|
|
80
|
-
"linux-x64-musl.gz": "sha256:
|
|
81
|
-
"win32-arm64.gz": "sha256:
|
|
82
|
-
"win32-x64.gz": "sha256:
|
|
73
|
+
"aws-lambda-arm64.zip": "sha256:c9b4d687110cc2a9246cfa0688f20100828cc2f4e239ffdccb4efe45fdec0b84",
|
|
74
|
+
"aws-lambda-x64.zip": "sha256:bdd29bf8be43f1b1d106d30e36a916406cbb0ba755d58b75dfb11f2eb2acc1dd",
|
|
75
|
+
"darwin-arm64.gz": "sha256:4a4c3aa2729aa77faa189815354ce917361c00f99d69afde3b30ac45894eaeab",
|
|
76
|
+
"darwin-x64.gz": "sha256:4ad7daa6d6236fe5a241ad3bf404d36b06418cb4e0f9e741deb2be2a590da52a",
|
|
77
|
+
"linux-arm64-glibc.gz": "sha256:73b66d5a9e5cf8841b94462f313323c4bad755d7a0e8202393fac6cdb31e4db8",
|
|
78
|
+
"linux-arm64-musl.gz": "sha256:3b704353a36428f31eaefe0870da29a1ad433272b81c1088efe770850b812609",
|
|
79
|
+
"linux-x64-glibc.gz": "sha256:80f9f5a54c92d99cb0cc6da23d7e0c12011b2e53f3c8540864007e1e83e82f65",
|
|
80
|
+
"linux-x64-musl.gz": "sha256:82fd698d543347ba49a531acad350dd146473c8bbac3e2c6fd137de7cdb02b01",
|
|
81
|
+
"win32-arm64.gz": "sha256:4b7cb850e87b084c785d7412b0c466daffcd5c7e89f359aa6ee23a36ae87abbb",
|
|
82
|
+
"win32-x64.gz": "sha256:95fdd138d2863f5fa1cf2e34947da3374f64df86eb88d0de0b3d8bee81d2a5c3"
|
|
83
83
|
}
|
|
84
84
|
}
|