@ohos-ports/canvas 3.2.3-beta.1 → 3.2.3-beta.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/build/Release/canvas-postbuild.node +0 -0
- package/build/Release/canvas.node +0 -0
- package/build/Release/libcairo.so.2.11802.2 +0 -0
- package/build/Release/libexpat.so +0 -0
- package/build/Release/libffi.so.8.1.3 +0 -0
- package/build/Release/libfontconfig.so.1.15.0 +0 -0
- package/build/Release/libfribidi.so.0.4.0 +0 -0
- package/build/Release/libjpeg.so +0 -0
- package/build/Release/liblibpng16.so +0 -0
- package/build/Release/libpango-1.0.so.0.5000.14 +0 -0
- package/build/Release/libpangocairo-1.0.so.0.5000.14 +0 -0
- package/build/Release/libpangoft2-1.0.so.0.5000.14 +0 -0
- package/build/Release/libpcre2-8.so.0.11.0 +0 -0
- package/build/Release/libpixman-1.so.0.46.4 +0 -0
- package/build/Release/libpng16.so.16 +0 -0
- package/index.js +9 -96
- package/install.js +64 -0
- package/package.json +11 -66
- package/Readme.md +0 -657
- package/binding.gyp +0 -229
- package/browser.js +0 -31
- package/index.d.ts +0 -507
- package/install-prebuilt.js +0 -142
- package/lib/DOMMatrix.js +0 -678
- package/lib/bindings.js +0 -56
- package/lib/canvas.js +0 -113
- package/lib/context2d.js +0 -11
- package/lib/image.js +0 -97
- package/lib/jpegstream.js +0 -41
- package/lib/pattern.js +0 -15
- package/lib/pdfstream.js +0 -35
- package/lib/pngstream.js +0 -42
- package/src/Canvas.cc +0 -1026
- package/src/Canvas.h +0 -128
- package/src/CanvasError.h +0 -37
- package/src/CanvasGradient.cc +0 -113
- package/src/CanvasGradient.h +0 -20
- package/src/CanvasPattern.cc +0 -129
- package/src/CanvasPattern.h +0 -33
- package/src/CanvasRenderingContext2d.cc +0 -3527
- package/src/CanvasRenderingContext2d.h +0 -238
- package/src/CharData.h +0 -233
- package/src/FontParser.cc +0 -605
- package/src/FontParser.h +0 -115
- package/src/Image.cc +0 -1719
- package/src/Image.h +0 -146
- package/src/ImageData.cc +0 -138
- package/src/ImageData.h +0 -26
- package/src/InstanceData.h +0 -12
- package/src/JPEGStream.h +0 -157
- package/src/PNG.h +0 -292
- package/src/Point.h +0 -11
- package/src/Util.h +0 -9
- package/src/bmp/BMPParser.cc +0 -459
- package/src/bmp/BMPParser.h +0 -60
- package/src/bmp/LICENSE.md +0 -24
- package/src/closure.cc +0 -52
- package/src/closure.h +0 -98
- package/src/color.cc +0 -796
- package/src/color.h +0 -30
- package/src/dll_visibility.h +0 -20
- package/src/init.cc +0 -114
- package/src/register_font.cc +0 -352
- package/src/register_font.h +0 -7
- package/util/has_lib.js +0 -119
- package/util/win_jpeg_lookup.js +0 -21
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -1,99 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
const Image = require('./lib/image')
|
|
3
|
-
const CanvasRenderingContext2D = require('./lib/context2d')
|
|
4
|
-
const CanvasPattern = require('./lib/pattern')
|
|
5
|
-
const packageJson = require('./package.json')
|
|
6
|
-
const bindings = require('./lib/bindings')
|
|
7
|
-
const fs = require('fs')
|
|
8
|
-
const PNGStream = require('./lib/pngstream')
|
|
9
|
-
const PDFStream = require('./lib/pdfstream')
|
|
10
|
-
const JPEGStream = require('./lib/jpegstream')
|
|
11
|
-
const { DOMPoint, DOMMatrix } = require('./lib/DOMMatrix')
|
|
1
|
+
"use strict";
|
|
12
2
|
|
|
13
|
-
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const fs = require("fs");
|
|
14
5
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
6
|
+
// 模块入口:只导出 build 目录路径
|
|
7
|
+
const buildDir = path.join(__dirname, "build", "Release");
|
|
18
8
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
function loadImage (src) {
|
|
24
|
-
return new Promise((resolve, reject) => {
|
|
25
|
-
const image = new Image()
|
|
26
|
-
|
|
27
|
-
function cleanup () {
|
|
28
|
-
image.onload = null
|
|
29
|
-
image.onerror = null
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
image.onload = () => { cleanup(); resolve(image) }
|
|
33
|
-
image.onerror = (err) => { cleanup(); reject(err) }
|
|
34
|
-
|
|
35
|
-
image.src = src
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Resolve paths for registerFont. Must be called *before* creating a Canvas
|
|
41
|
-
* instance.
|
|
42
|
-
* @param src {string} Path to font file.
|
|
43
|
-
* @param fontFace {{family: string, weight?: string, style?: string}} Object
|
|
44
|
-
* specifying font information. `weight` and `style` default to `"normal"`.
|
|
45
|
-
*/
|
|
46
|
-
function registerFont (src, fontFace) {
|
|
47
|
-
// TODO this doesn't need to be on Canvas; it should just be a static method
|
|
48
|
-
// of `bindings`.
|
|
49
|
-
return Canvas._registerFont(fs.realpathSync(src), fontFace)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Unload all fonts from pango to free up memory
|
|
54
|
-
*/
|
|
55
|
-
function deregisterAllFonts () {
|
|
56
|
-
return Canvas._deregisterAllFonts()
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
exports.Canvas = Canvas
|
|
60
|
-
exports.Context2d = CanvasRenderingContext2D // Legacy/compat export
|
|
61
|
-
exports.CanvasRenderingContext2D = CanvasRenderingContext2D
|
|
62
|
-
exports.CanvasGradient = bindings.CanvasGradient
|
|
63
|
-
exports.CanvasPattern = CanvasPattern
|
|
64
|
-
exports.Image = Image
|
|
65
|
-
exports.ImageData = bindings.ImageData
|
|
66
|
-
exports.PNGStream = PNGStream
|
|
67
|
-
exports.PDFStream = PDFStream
|
|
68
|
-
exports.JPEGStream = JPEGStream
|
|
69
|
-
exports.DOMMatrix = DOMMatrix
|
|
70
|
-
exports.DOMPoint = DOMPoint
|
|
71
|
-
|
|
72
|
-
exports.registerFont = registerFont
|
|
73
|
-
exports.deregisterAllFonts = deregisterAllFonts
|
|
74
|
-
|
|
75
|
-
exports.createCanvas = createCanvas
|
|
76
|
-
exports.createImageData = createImageData
|
|
77
|
-
exports.loadImage = loadImage
|
|
78
|
-
|
|
79
|
-
// Backends is declared in src/Backends.h but not yet implemented (no
|
|
80
|
-
// Backends.cc, not registered in init.cc). Only export it when the
|
|
81
|
-
// native module actually provides it.
|
|
82
|
-
if (bindings.Backends) {
|
|
83
|
-
exports.backends = bindings.Backends
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** Library version. */
|
|
87
|
-
exports.version = packageJson.version
|
|
88
|
-
/** Cairo version. */
|
|
89
|
-
exports.cairoVersion = bindings.cairoVersion
|
|
90
|
-
/** jpeglib version. */
|
|
91
|
-
exports.jpegVersion = bindings.jpegVersion
|
|
92
|
-
/** gif_lib version. */
|
|
93
|
-
exports.gifVersion = bindings.gifVersion ? bindings.gifVersion.replace(/[^.\d]/g, '') : undefined
|
|
94
|
-
/** freetype version. */
|
|
95
|
-
exports.freetypeVersion = bindings.freetypeVersion
|
|
96
|
-
/** rsvg version. */
|
|
97
|
-
exports.rsvgVersion = bindings.rsvgVersion
|
|
98
|
-
/** pango version. */
|
|
99
|
-
exports.pangoVersion = bindings.pangoVersion
|
|
9
|
+
module.exports = {
|
|
10
|
+
buildDir,
|
|
11
|
+
canvas: path.join(buildDir, "canvas.node"),
|
|
12
|
+
};
|
package/install.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { execSync } = require("child_process");
|
|
6
|
+
|
|
7
|
+
const releaseDir = path.join(__dirname, "build", "Release");
|
|
8
|
+
|
|
9
|
+
// 从 ELF 文件中提取所有 NEEDED soname
|
|
10
|
+
function getNeededSonames(elfPath) {
|
|
11
|
+
try {
|
|
12
|
+
const output = execSync(`readelf -d "${elfPath}" 2>/dev/null`, {
|
|
13
|
+
encoding: "utf8",
|
|
14
|
+
});
|
|
15
|
+
const needed = [];
|
|
16
|
+
for (const line of output.split("\n")) {
|
|
17
|
+
const match = line.match(/\(NEEDED\).*\[(.+?)\]/);
|
|
18
|
+
if (match) needed.push(match[1]);
|
|
19
|
+
}
|
|
20
|
+
return needed;
|
|
21
|
+
} catch {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function run() {
|
|
27
|
+
// 1. 列出目录下所有实际 .so 文件
|
|
28
|
+
const allFiles = fs.readdirSync(releaseDir);
|
|
29
|
+
const soFiles = allFiles.filter(
|
|
30
|
+
(f) => f.endsWith(".so") || /\.so\.\d/.test(f)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// 2. 收集所有 ELF 文件的 NEEDED(不只是 canvas.node,还包括所有 .so 的级联依赖)
|
|
34
|
+
const elfFiles = allFiles.filter(
|
|
35
|
+
(f) => f.endsWith(".node") || f.endsWith(".so") || /\.so\.\d/.test(f)
|
|
36
|
+
);
|
|
37
|
+
const allNeeded = new Set();
|
|
38
|
+
for (const f of elfFiles) {
|
|
39
|
+
for (const soname of getNeededSonames(path.join(releaseDir, f))) {
|
|
40
|
+
allNeeded.add(soname);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 3. 为每个缺失的 soname 找到匹配的实际文件并创建符号链接
|
|
45
|
+
let created = 0;
|
|
46
|
+
for (const soname of allNeeded) {
|
|
47
|
+
if (fs.existsSync(path.join(releaseDir, soname))) continue;
|
|
48
|
+
const match = soFiles.find((f) => f.startsWith(soname) && f !== soname);
|
|
49
|
+
if (!match) continue;
|
|
50
|
+
fs.symlinkSync(match, path.join(releaseDir, soname));
|
|
51
|
+
console.log(` ${soname} -> ${match}`);
|
|
52
|
+
created++;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (created > 0) {
|
|
56
|
+
console.log(`Created ${created} soname symlink(s)`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
run();
|
|
62
|
+
} catch (e) {
|
|
63
|
+
console.warn("Warning: failed to create soname symlinks:", e.message);
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,75 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/canvas",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"author": "TJ Holowaychuk <tj@learnboost.com>",
|
|
3
|
+
"version": "3.2.3-beta.2",
|
|
4
|
+
"description": "Prebuilt native binaries for canvas on OpenHarmony arm64",
|
|
6
5
|
"main": "index.js",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"contributors": [
|
|
10
|
-
"Nathan Rajlich <nathan@tootallnate.net>",
|
|
11
|
-
"Rod Vagg <r@va.gg>",
|
|
12
|
-
"Juriy Zaytsev <kangax@gmail.com>"
|
|
6
|
+
"os": [
|
|
7
|
+
"openharmony"
|
|
13
8
|
],
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"graphic",
|
|
17
|
-
"graphics",
|
|
18
|
-
"pixman",
|
|
19
|
-
"cairo",
|
|
20
|
-
"image",
|
|
21
|
-
"images",
|
|
22
|
-
"pdf"
|
|
9
|
+
"cpu": [
|
|
10
|
+
"arm64"
|
|
23
11
|
],
|
|
24
|
-
"homepage": "https://github.com/Automattic/node-canvas",
|
|
25
|
-
"repository": "git://github.com/Automattic/node-canvas.git",
|
|
26
|
-
"scripts": {
|
|
27
|
-
"prebenchmark": "node-gyp build",
|
|
28
|
-
"benchmark": "node benchmarks/run.js",
|
|
29
|
-
"lint": "standard examples/*.js test/server.js test/public/*.js benchmarks/run.js lib/context2d.js util/has_lib.js browser.js index.js",
|
|
30
|
-
"test": "mocha test/*.test.js",
|
|
31
|
-
"pretest-server": "node-gyp build",
|
|
32
|
-
"test-server": "node test/server.js",
|
|
33
|
-
"generate-wpt": "node ./test/wpt/generate.js",
|
|
34
|
-
"test-wpt": "mocha test/wpt/generated/*.js",
|
|
35
|
-
"install": "node install-prebuilt.js || node-gyp rebuild",
|
|
36
|
-
"tsd": "tsd"
|
|
37
|
-
},
|
|
38
12
|
"files": [
|
|
39
|
-
"
|
|
40
|
-
"browser.js",
|
|
41
|
-
"index.d.ts",
|
|
13
|
+
"build/",
|
|
42
14
|
"index.js",
|
|
43
|
-
"install
|
|
44
|
-
"lib/",
|
|
45
|
-
"src/",
|
|
46
|
-
"util/"
|
|
15
|
+
"install.js"
|
|
47
16
|
],
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
"optionalDependencies": {
|
|
53
|
-
"@ohos-ports/canvas-prebuilt-openharmony-arm64": "3.2.3-beta.0"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@types/node": "^10.12.18",
|
|
57
|
-
"assert-rejects": "^1.0.0",
|
|
58
|
-
"express": "^4.16.3",
|
|
59
|
-
"js-yaml": "^4.1.0",
|
|
60
|
-
"mocha": "^5.2.0",
|
|
61
|
-
"pixelmatch": "^4.0.2",
|
|
62
|
-
"standard": "^12.0.1",
|
|
63
|
-
"tsd": "^0.29.0",
|
|
64
|
-
"typescript": "^4.2.2"
|
|
65
|
-
},
|
|
66
|
-
"engines": {
|
|
67
|
-
"node": "^18.12.0 || >= 20.9.0"
|
|
68
|
-
},
|
|
69
|
-
"binary": {
|
|
70
|
-
"napi_versions": [
|
|
71
|
-
7
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
"license": "MIT"
|
|
17
|
+
"scripts": {
|
|
18
|
+
"install": "node install.js"
|
|
19
|
+
}
|
|
75
20
|
}
|