@ohos-ports/canvas 3.2.3-beta.0 → 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.
Files changed (67) hide show
  1. package/build/Release/canvas-postbuild.node +0 -0
  2. package/build/Release/canvas.node +0 -0
  3. package/build/Release/libcairo.so.2.11802.2 +0 -0
  4. package/build/Release/libexpat.so +0 -0
  5. package/build/Release/libffi.so.8.1.3 +0 -0
  6. package/build/Release/libfontconfig.so.1.15.0 +0 -0
  7. package/build/Release/libfribidi.so.0.4.0 +0 -0
  8. package/build/Release/libjpeg.so +0 -0
  9. package/build/Release/liblibpng16.so +0 -0
  10. package/build/Release/libpango-1.0.so.0.5000.14 +0 -0
  11. package/build/Release/libpangocairo-1.0.so.0.5000.14 +0 -0
  12. package/build/Release/libpangoft2-1.0.so.0.5000.14 +0 -0
  13. package/build/Release/libpcre2-8.so.0.11.0 +0 -0
  14. package/build/Release/libpixman-1.so.0.46.4 +0 -0
  15. package/build/Release/libpng16.so.16 +0 -0
  16. package/index.js +9 -91
  17. package/install.js +64 -0
  18. package/package.json +11 -66
  19. package/Readme.md +0 -657
  20. package/binding.gyp +0 -229
  21. package/browser.js +0 -31
  22. package/index.d.ts +0 -507
  23. package/install-prebuilt.js +0 -117
  24. package/lib/DOMMatrix.js +0 -678
  25. package/lib/bindings.js +0 -43
  26. package/lib/canvas.js +0 -113
  27. package/lib/context2d.js +0 -11
  28. package/lib/image.js +0 -97
  29. package/lib/jpegstream.js +0 -41
  30. package/lib/pattern.js +0 -15
  31. package/lib/pdfstream.js +0 -35
  32. package/lib/pngstream.js +0 -42
  33. package/src/Backends.h +0 -9
  34. package/src/Canvas.cc +0 -1026
  35. package/src/Canvas.h +0 -128
  36. package/src/CanvasError.h +0 -37
  37. package/src/CanvasGradient.cc +0 -113
  38. package/src/CanvasGradient.h +0 -20
  39. package/src/CanvasPattern.cc +0 -129
  40. package/src/CanvasPattern.h +0 -33
  41. package/src/CanvasRenderingContext2d.cc +0 -3527
  42. package/src/CanvasRenderingContext2d.h +0 -238
  43. package/src/CharData.h +0 -233
  44. package/src/FontParser.cc +0 -605
  45. package/src/FontParser.h +0 -115
  46. package/src/Image.cc +0 -1719
  47. package/src/Image.h +0 -146
  48. package/src/ImageData.cc +0 -138
  49. package/src/ImageData.h +0 -26
  50. package/src/InstanceData.h +0 -12
  51. package/src/JPEGStream.h +0 -157
  52. package/src/PNG.h +0 -292
  53. package/src/Point.h +0 -11
  54. package/src/Util.h +0 -9
  55. package/src/bmp/BMPParser.cc +0 -459
  56. package/src/bmp/BMPParser.h +0 -60
  57. package/src/bmp/LICENSE.md +0 -24
  58. package/src/closure.cc +0 -52
  59. package/src/closure.h +0 -98
  60. package/src/color.cc +0 -796
  61. package/src/color.h +0 -30
  62. package/src/dll_visibility.h +0 -20
  63. package/src/init.cc +0 -114
  64. package/src/register_font.cc +0 -352
  65. package/src/register_font.h +0 -7
  66. package/util/has_lib.js +0 -119
  67. package/util/win_jpeg_lookup.js +0 -21
package/lib/canvas.js DELETED
@@ -1,113 +0,0 @@
1
- 'use strict'
2
-
3
- /*!
4
- * Canvas
5
- * Copyright (c) 2010 LearnBoost <tj@learnboost.com>
6
- * MIT Licensed
7
- */
8
-
9
- const bindings = require('./bindings')
10
- const Canvas = module.exports = bindings.Canvas
11
- const Context2d = require('./context2d')
12
- const PNGStream = require('./pngstream')
13
- const PDFStream = require('./pdfstream')
14
- const JPEGStream = require('./jpegstream')
15
- const FORMATS = ['image/png', 'image/jpeg']
16
- const util = require('util')
17
-
18
- // TODO || is for Node.js pre-v6.6.0
19
- Canvas.prototype[util.inspect.custom || 'inspect'] = function () {
20
- return `[Canvas ${this.width}x${this.height}]`
21
- }
22
-
23
- Canvas.prototype.getContext = function (contextType, contextAttributes) {
24
- if (contextType == '2d') {
25
- const ctx = this._context2d || (this._context2d = new Context2d(this, contextAttributes))
26
- this.context = ctx
27
- ctx.canvas = this
28
- return ctx
29
- }
30
- }
31
-
32
- Canvas.prototype.pngStream =
33
- Canvas.prototype.createPNGStream = function (options) {
34
- return new PNGStream(this, options)
35
- }
36
-
37
- Canvas.prototype.pdfStream =
38
- Canvas.prototype.createPDFStream = function (options) {
39
- return new PDFStream(this, options)
40
- }
41
-
42
- Canvas.prototype.jpegStream =
43
- Canvas.prototype.createJPEGStream = function (options) {
44
- return new JPEGStream(this, options)
45
- }
46
-
47
- Canvas.prototype.toDataURL = function (a1, a2, a3) {
48
- // valid arg patterns (args -> [type, opts, fn]):
49
- // [] -> ['image/png', null, null]
50
- // [qual] -> ['image/png', null, null]
51
- // [undefined] -> ['image/png', null, null]
52
- // ['image/png'] -> ['image/png', null, null]
53
- // ['image/png', qual] -> ['image/png', null, null]
54
- // [fn] -> ['image/png', null, fn]
55
- // [type, fn] -> [type, null, fn]
56
- // [undefined, fn] -> ['image/png', null, fn]
57
- // ['image/png', qual, fn] -> ['image/png', null, fn]
58
- // ['image/jpeg', fn] -> ['image/jpeg', null, fn]
59
- // ['image/jpeg', opts, fn] -> ['image/jpeg', opts, fn]
60
- // ['image/jpeg', qual, fn] -> ['image/jpeg', {quality: qual}, fn]
61
- // ['image/jpeg', undefined, fn] -> ['image/jpeg', null, fn]
62
- // ['image/jpeg'] -> ['image/jpeg', null, fn]
63
- // ['image/jpeg', opts] -> ['image/jpeg', opts, fn]
64
- // ['image/jpeg', qual] -> ['image/jpeg', {quality: qual}, fn]
65
-
66
- let type = 'image/png'
67
- let opts = {}
68
- let fn
69
-
70
- if (typeof a1 === 'function') {
71
- fn = a1
72
- } else {
73
- if (typeof a1 === 'string' && FORMATS.includes(a1.toLowerCase())) {
74
- type = a1.toLowerCase()
75
- }
76
-
77
- if (typeof a2 === 'function') {
78
- fn = a2
79
- } else {
80
- if (typeof a2 === 'object') {
81
- opts = a2
82
- } else if (typeof a2 === 'number') {
83
- opts = { quality: Math.max(0, Math.min(1, a2)) }
84
- }
85
-
86
- if (typeof a3 === 'function') {
87
- fn = a3
88
- } else if (undefined !== a3) {
89
- throw new TypeError(`${typeof a3} is not a function`)
90
- }
91
- }
92
- }
93
-
94
- if (this.width === 0 || this.height === 0) {
95
- // Per spec, if the bitmap has no pixels, return this string:
96
- const str = 'data:,'
97
- if (fn) {
98
- setTimeout(() => fn(null, str))
99
- return
100
- } else {
101
- return str
102
- }
103
- }
104
-
105
- if (fn) {
106
- this.toBuffer((err, buf) => {
107
- if (err) return fn(err)
108
- fn(null, `data:${type};base64,${buf.toString('base64')}`)
109
- }, type, opts)
110
- } else {
111
- return `data:${type};base64,${this.toBuffer(type, opts).toString('base64')}`
112
- }
113
- }
package/lib/context2d.js DELETED
@@ -1,11 +0,0 @@
1
- 'use strict'
2
-
3
- /*!
4
- * Canvas - Context2d
5
- * Copyright (c) 2010 LearnBoost <tj@learnboost.com>
6
- * MIT Licensed
7
- */
8
-
9
- const bindings = require('./bindings')
10
-
11
- module.exports = bindings.CanvasRenderingContext2d
package/lib/image.js DELETED
@@ -1,97 +0,0 @@
1
- 'use strict'
2
-
3
- /*!
4
- * Canvas - Image
5
- * Copyright (c) 2010 LearnBoost <tj@learnboost.com>
6
- * MIT Licensed
7
- */
8
-
9
- /**
10
- * Module dependencies.
11
- */
12
-
13
- const bindings = require('./bindings')
14
- const Image = module.exports = bindings.Image
15
- const util = require('util')
16
-
17
- const { GetSource, SetSource } = bindings
18
-
19
- Object.defineProperty(Image.prototype, 'src', {
20
- /**
21
- * src setter. Valid values:
22
- * * `data:` URI
23
- * * Local file path
24
- * * HTTP or HTTPS URL
25
- * * Buffer containing image data (i.e. not a `data:` URI stored in a Buffer)
26
- *
27
- * @param {String|Buffer} val filename, buffer, data URI, URL
28
- * @api public
29
- */
30
- set (val) {
31
- if (typeof val === 'string') {
32
- if (/^\s*data:/.test(val)) { // data: URI
33
- const commaI = val.indexOf(',')
34
- // 'base64' must come before the comma
35
- const isBase64 = val.lastIndexOf('base64', commaI) !== -1
36
- const content = val.slice(commaI + 1)
37
- setSource(this, Buffer.from(content, isBase64 ? 'base64' : 'utf8'), val)
38
- } else if (/^\s*https?:\/\//.test(val)) { // remote URL
39
- const onerror = err => {
40
- if (typeof this.onerror === 'function') {
41
- this.onerror(err)
42
- } else {
43
- throw err
44
- }
45
- }
46
-
47
- fetch(val, {
48
- method: 'GET',
49
- headers: { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36' }
50
- })
51
- .then(res => {
52
- if (!res.ok) {
53
- throw new Error(`Server responded with ${res.status}`)
54
- }
55
- return res.arrayBuffer()
56
- })
57
- .then(data => {
58
- setSource(this, Buffer.from(data))
59
- })
60
- .catch(onerror)
61
- } else { // local file path assumed
62
- setSource(this, val)
63
- }
64
- } else if (Buffer.isBuffer(val)) {
65
- setSource(this, val)
66
- } else {
67
- const err = new Error("Invalid image source")
68
- if (typeof this.onerror === 'function') this.onerror(err)
69
- else throw err
70
- }
71
- },
72
-
73
- get () {
74
- // TODO https://github.com/Automattic/node-canvas/issues/118
75
- return getSource(this)
76
- },
77
-
78
- configurable: true
79
- })
80
-
81
- // TODO || is for Node.js pre-v6.6.0
82
- Image.prototype[util.inspect.custom || 'inspect'] = function () {
83
- return '[Image' +
84
- (this.complete ? ':' + this.width + 'x' + this.height : '') +
85
- (this.src ? ' ' + this.src : '') +
86
- (this.complete ? ' complete' : '') +
87
- ']'
88
- }
89
-
90
- function getSource (img) {
91
- return img._originalSource || GetSource.call(img)
92
- }
93
-
94
- function setSource (img, src, origSrc) {
95
- SetSource.call(img, src)
96
- img._originalSource = origSrc
97
- }
package/lib/jpegstream.js DELETED
@@ -1,41 +0,0 @@
1
- 'use strict'
2
-
3
- /*!
4
- * Canvas - JPEGStream
5
- * Copyright (c) 2010 LearnBoost <tj@learnboost.com>
6
- * MIT Licensed
7
- */
8
-
9
- const { Readable } = require('stream')
10
- function noop () {}
11
-
12
- class JPEGStream extends Readable {
13
- constructor (canvas, options) {
14
- super()
15
-
16
- if (canvas.streamJPEGSync === undefined) {
17
- throw new Error('node-canvas was built without JPEG support.')
18
- }
19
-
20
- this.options = options
21
- this.canvas = canvas
22
- }
23
-
24
- _read () {
25
- // For now we're not controlling the c++ code's data emission, so we only
26
- // call canvas.streamJPEGSync once and let it emit data at will.
27
- this._read = noop
28
-
29
- this.canvas.streamJPEGSync(this.options, (err, chunk) => {
30
- if (err) {
31
- this.emit('error', err)
32
- } else if (chunk) {
33
- this.push(chunk)
34
- } else {
35
- this.push(null)
36
- }
37
- })
38
- }
39
- };
40
-
41
- module.exports = JPEGStream
package/lib/pattern.js DELETED
@@ -1,15 +0,0 @@
1
- 'use strict'
2
-
3
- /*!
4
- * Canvas - CanvasPattern
5
- * Copyright (c) 2010 LearnBoost <tj@learnboost.com>
6
- * MIT Licensed
7
- */
8
-
9
- const bindings = require('./bindings')
10
-
11
- module.exports = bindings.CanvasPattern
12
-
13
- bindings.CanvasPattern.prototype.toString = function () {
14
- return '[object CanvasPattern]'
15
- }
package/lib/pdfstream.js DELETED
@@ -1,35 +0,0 @@
1
- 'use strict'
2
-
3
- /*!
4
- * Canvas - PDFStream
5
- */
6
-
7
- const { Readable } = require('stream')
8
- function noop () {}
9
-
10
- class PDFStream extends Readable {
11
- constructor (canvas, options) {
12
- super()
13
-
14
- this.canvas = canvas
15
- this.options = options
16
- }
17
-
18
- _read () {
19
- // For now we're not controlling the c++ code's data emission, so we only
20
- // call canvas.streamPDFSync once and let it emit data at will.
21
- this._read = noop
22
-
23
- this.canvas.streamPDFSync((err, chunk, len) => {
24
- if (err) {
25
- this.emit('error', err)
26
- } else if (len) {
27
- this.push(chunk)
28
- } else {
29
- this.push(null)
30
- }
31
- }, this.options)
32
- }
33
- }
34
-
35
- module.exports = PDFStream
package/lib/pngstream.js DELETED
@@ -1,42 +0,0 @@
1
- 'use strict'
2
-
3
- /*!
4
- * Canvas - PNGStream
5
- * Copyright (c) 2010 LearnBoost <tj@learnboost.com>
6
- * MIT Licensed
7
- */
8
-
9
- const { Readable } = require('stream')
10
- function noop () {}
11
-
12
- class PNGStream extends Readable {
13
- constructor (canvas, options) {
14
- super()
15
-
16
- if (options &&
17
- options.palette instanceof Uint8ClampedArray &&
18
- options.palette.length % 4 !== 0) {
19
- throw new Error('Palette length must be a multiple of 4.')
20
- }
21
- this.canvas = canvas
22
- this.options = options || {}
23
- }
24
-
25
- _read () {
26
- // For now we're not controlling the c++ code's data emission, so we only
27
- // call canvas.streamPNGSync once and let it emit data at will.
28
- this._read = noop
29
-
30
- this.canvas.streamPNGSync((err, chunk, len) => {
31
- if (err) {
32
- this.emit('error', err)
33
- } else if (len) {
34
- this.push(chunk)
35
- } else {
36
- this.push(null)
37
- }
38
- }, this.options)
39
- }
40
- }
41
-
42
- module.exports = PNGStream
package/src/Backends.h DELETED
@@ -1,9 +0,0 @@
1
- #pragma once
2
-
3
- #include "backend/Backend.h"
4
- #include <napi.h>
5
-
6
- class Backends : public Napi::ObjectWrap<Backends> {
7
- public:
8
- static void Initialize(Napi::Env env, Napi::Object exports);
9
- };