@oscharko-dev/keiko 0.2.0-beta.0 → 0.2.0-beta.1
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 -5
- package/dist/ui/csp-hashes.json +18 -18
- package/dist/ui/static/404.html +1 -1
- package/dist/ui/static/_next/static/chunks/{422-70c16ea4b1f77f2e.js → 923-4141696576191bc0.js} +1 -1
- package/dist/ui/static/_next/static/chunks/app/_not-found/page-03d642dcd0f15b52.js +1 -0
- package/dist/ui/static/_next/static/chunks/app/launch/page-c725ff0c02b50663.js +1 -0
- package/dist/ui/static/_next/static/chunks/app/layout-aadefe615729db05.js +1 -0
- package/dist/ui/static/_next/static/chunks/app/local-knowledge/capsule/{page-0dc74e194a1f0092.js → page-4a7f242906e19a07.js} +1 -1
- package/dist/ui/static/_next/static/chunks/app/local-knowledge/page-3361769b8964e659.js +1 -0
- package/dist/ui/static/_next/static/chunks/app/memoriaviva/consolidation/{page-dc6c6bd180bc47a3.js → page-44b3f4fa3e10085f.js} +1 -1
- package/dist/ui/static/_next/static/chunks/app/memoriaviva/detail/{page-659e308e68ab2b1e.js → page-0cdfb3eeb659daeb.js} +1 -1
- package/dist/ui/static/_next/static/chunks/app/memoriaviva/{page-d6ba78f54207b69f.js → page-e78e0cd2876fec41.js} +1 -1
- package/dist/ui/static/_next/static/chunks/app/memoriaviva/review-queue/page-e32fe86466827484.js +1 -0
- package/dist/ui/static/_next/static/chunks/app/page-9ad91065d05ddfa0.js +1 -0
- package/dist/ui/static/_next/static/chunks/{main-app-5b043f6c611974ae.js → main-app-b52a8fa1d8127a5f.js} +1 -1
- package/dist/ui/static/index.html +1 -1
- package/dist/ui/static/index.txt +2 -2
- package/dist/ui/static/launch.html +1 -1
- package/dist/ui/static/launch.txt +2 -2
- package/dist/ui/static/local-knowledge/capsule.html +1 -1
- package/dist/ui/static/local-knowledge/capsule.txt +2 -2
- package/dist/ui/static/local-knowledge.html +1 -1
- package/dist/ui/static/local-knowledge.txt +2 -2
- package/dist/ui/static/memoriaviva/consolidation.html +1 -1
- package/dist/ui/static/memoriaviva/consolidation.txt +2 -2
- package/dist/ui/static/memoriaviva/detail.html +1 -1
- package/dist/ui/static/memoriaviva/detail.txt +2 -2
- package/dist/ui/static/memoriaviva/review-queue.html +1 -1
- package/dist/ui/static/memoriaviva/review-queue.txt +2 -2
- package/dist/ui/static/memoriaviva.html +1 -1
- package/dist/ui/static/memoriaviva.txt +2 -2
- package/node_modules/@oscharko-dev/keiko-cli/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-cli/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/dist/index.js +1 -1
- package/node_modules/@oscharko-dev/keiko-contracts/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-evaluations/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-evaluations/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-evidence/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-evidence/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-harness/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-harness/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/parsers/pdf-parser.d.ts.map +1 -1
- package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/parsers/pdf-parser.js +2 -2
- package/node_modules/@oscharko-dev/keiko-local-knowledge/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-capture/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-consolidation/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-governance/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-retrieval/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-vault/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-memory-vault/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-model-gateway/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-quality-intelligence/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-quality-intelligence/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-sdk/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-sdk/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-security/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-security/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-server/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-server/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-tools/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-tools/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-verification/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-verification/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-workflows/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-workflows/package.json +1 -1
- package/node_modules/@oscharko-dev/keiko-workspace/dist/.tsbuildinfo +1 -1
- package/node_modules/@oscharko-dev/keiko-workspace/package.json +1 -1
- package/package.json +4 -3
- package/dist/ui/static/_next/static/chunks/app/_not-found/page-c4d800f366186be0.js +0 -1
- package/dist/ui/static/_next/static/chunks/app/launch/page-08afd1a052e7662c.js +0 -1
- package/dist/ui/static/_next/static/chunks/app/layout-0f75a39edc90325d.js +0 -1
- package/dist/ui/static/_next/static/chunks/app/local-knowledge/page-48bd57c5e542349e.js +0 -1
- package/dist/ui/static/_next/static/chunks/app/memoriaviva/review-queue/page-7186cd8b22efc78b.js +0 -1
- package/dist/ui/static/_next/static/chunks/app/page-f8386b8e05b3db03.js +0 -1
- package/node_modules/@napi-rs/canvas/LICENSE +0 -21
- package/node_modules/@napi-rs/canvas/README.md +0 -448
- package/node_modules/@napi-rs/canvas/geometry.js +0 -873
- package/node_modules/@napi-rs/canvas/index.d.ts +0 -1097
- package/node_modules/@napi-rs/canvas/index.js +0 -196
- package/node_modules/@napi-rs/canvas/js-binding.js +0 -464
- package/node_modules/@napi-rs/canvas/load-image.js +0 -156
- package/node_modules/@napi-rs/canvas/node-canvas.d.ts +0 -216
- package/node_modules/@napi-rs/canvas/node-canvas.js +0 -379
- package/node_modules/@napi-rs/canvas/package.json +0 -179
- package/node_modules/@napi-rs/canvas-linux-x64-gnu/README.md +0 -3
- package/node_modules/@napi-rs/canvas-linux-x64-gnu/package.json +0 -47
- package/node_modules/@napi-rs/canvas-linux-x64-gnu/skia.linux-x64-gnu.node +0 -0
- package/node_modules/@napi-rs/canvas-linux-x64-musl/README.md +0 -3
- package/node_modules/@napi-rs/canvas-linux-x64-musl/package.json +0 -47
- package/node_modules/@napi-rs/canvas-linux-x64-musl/skia.linux-x64-musl.node +0 -0
- /package/dist/ui/static/_next/static/{IZjQES_2JaG9qZ7_fkEPl → 12efBQERZ9Itf_HaPzx5q}/_buildManifest.js +0 -0
- /package/dist/ui/static/_next/static/{IZjQES_2JaG9qZ7_fkEPl → 12efBQERZ9Itf_HaPzx5q}/_ssgManifest.js +0 -0
|
@@ -1,379 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { Readable } = require('node:stream')
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
createCanvas: _createCanvas,
|
|
7
|
-
Canvas,
|
|
8
|
-
CanvasElement,
|
|
9
|
-
SVGCanvas,
|
|
10
|
-
GlobalFonts,
|
|
11
|
-
Image,
|
|
12
|
-
ImageData,
|
|
13
|
-
Path2D,
|
|
14
|
-
DOMPoint,
|
|
15
|
-
DOMMatrix,
|
|
16
|
-
DOMRect,
|
|
17
|
-
loadImage,
|
|
18
|
-
PDFDocument,
|
|
19
|
-
SvgExportFlag,
|
|
20
|
-
} = require('./index.js')
|
|
21
|
-
|
|
22
|
-
// CanvasRenderingContext2D is not re-exported by index.js, grab from native bindings
|
|
23
|
-
const { CanvasRenderingContext2D } = require('./js-binding')
|
|
24
|
-
|
|
25
|
-
// node-canvas defaults JPEG quality to 0.75 across all paths.
|
|
26
|
-
// @napi-rs/canvas native default is 0.92 (matching Blink/Chrome).
|
|
27
|
-
const NODE_CANVAS_DEFAULT_QUALITY = 0.75
|
|
28
|
-
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
// Stream classes (node-canvas returns Node.js Readable streams)
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
|
|
33
|
-
class PNGStream extends Readable {
|
|
34
|
-
constructor(canvas, options) {
|
|
35
|
-
super()
|
|
36
|
-
this._canvas = canvas
|
|
37
|
-
this._options = options || {}
|
|
38
|
-
this._done = false
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
_read() {
|
|
42
|
-
if (this._done) return
|
|
43
|
-
this._done = true
|
|
44
|
-
this._canvas
|
|
45
|
-
.encode('png')
|
|
46
|
-
.then((buf) => {
|
|
47
|
-
this.push(buf)
|
|
48
|
-
this.push(null)
|
|
49
|
-
})
|
|
50
|
-
.catch((err) => {
|
|
51
|
-
this.destroy(err)
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
class JPEGStream extends Readable {
|
|
57
|
-
constructor(canvas, options) {
|
|
58
|
-
super()
|
|
59
|
-
this._canvas = canvas
|
|
60
|
-
const opts = options || {}
|
|
61
|
-
// node-canvas quality: 0-1 (default 0.75), encode() expects 0-100
|
|
62
|
-
this._quality = Math.round((opts.quality != null ? opts.quality : NODE_CANVAS_DEFAULT_QUALITY) * 100)
|
|
63
|
-
this._done = false
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
_read() {
|
|
67
|
-
if (this._done) return
|
|
68
|
-
this._done = true
|
|
69
|
-
this._canvas
|
|
70
|
-
.encode('jpeg', this._quality)
|
|
71
|
-
.then((buf) => {
|
|
72
|
-
this.push(buf)
|
|
73
|
-
this.push(null)
|
|
74
|
-
})
|
|
75
|
-
.catch((err) => {
|
|
76
|
-
this.destroy(err)
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// ---------------------------------------------------------------------------
|
|
82
|
-
// Quality normalization helpers
|
|
83
|
-
// ---------------------------------------------------------------------------
|
|
84
|
-
|
|
85
|
-
const MIME_FORMAT_MAP = {
|
|
86
|
-
'image/png': 'png',
|
|
87
|
-
'image/jpeg': 'jpeg',
|
|
88
|
-
'image/webp': 'webp',
|
|
89
|
-
'image/avif': 'avif',
|
|
90
|
-
'image/gif': 'gif',
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Extract quality from a node-canvas config object or number.
|
|
95
|
-
* Returns the raw 0-1 quality value, defaulting to NODE_CANVAS_DEFAULT_QUALITY
|
|
96
|
-
* for JPEG/WebP when not specified.
|
|
97
|
-
*
|
|
98
|
-
* @param {string} mime
|
|
99
|
-
* @param {number|object|undefined} configOrQuality
|
|
100
|
-
* @returns {number|undefined} 0-1 scale for JPEG/WebP, undefined for other mimes
|
|
101
|
-
*/
|
|
102
|
-
function _extractQuality(mime, configOrQuality) {
|
|
103
|
-
if (mime !== 'image/jpeg' && mime !== 'image/webp') return undefined
|
|
104
|
-
if (configOrQuality == null) return NODE_CANVAS_DEFAULT_QUALITY
|
|
105
|
-
if (typeof configOrQuality === 'number') return configOrQuality
|
|
106
|
-
if (typeof configOrQuality === 'object' && configOrQuality.quality != null) {
|
|
107
|
-
return configOrQuality.quality
|
|
108
|
-
}
|
|
109
|
-
return NODE_CANVAS_DEFAULT_QUALITY
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// ---------------------------------------------------------------------------
|
|
113
|
-
// Compat methods added to each canvas instance created via this module
|
|
114
|
-
// ---------------------------------------------------------------------------
|
|
115
|
-
|
|
116
|
-
// Keep references to the original prototype methods
|
|
117
|
-
const _origToBuffer = CanvasElement.prototype.toBuffer
|
|
118
|
-
const _origToDataURL = CanvasElement.prototype.toDataURL
|
|
119
|
-
|
|
120
|
-
function _compatCreatePNGStream(options) {
|
|
121
|
-
return new PNGStream(this, options)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function _compatCreateJPEGStream(options) {
|
|
125
|
-
return new JPEGStream(this, options)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* node-canvas compatible toBuffer:
|
|
130
|
-
* - toBuffer() → PNG (sync)
|
|
131
|
-
* - toBuffer('image/png', config?) → PNG (sync)
|
|
132
|
-
* - toBuffer('image/jpeg', config?) → JPEG (sync, quality 0-1)
|
|
133
|
-
* - toBuffer('raw') → raw pixel data (sync)
|
|
134
|
-
* - toBuffer(callback) → PNG (async)
|
|
135
|
-
* - toBuffer(callback, mime, config?) → specified format (async)
|
|
136
|
-
*/
|
|
137
|
-
function _compatToBuffer(mimeOrCallback, configOrQuality) {
|
|
138
|
-
// Callback form: toBuffer(callback) or toBuffer(callback, mime, config)
|
|
139
|
-
if (typeof mimeOrCallback === 'function') {
|
|
140
|
-
const callback = mimeOrCallback
|
|
141
|
-
const mime = typeof configOrQuality === 'string' ? configOrQuality : 'image/png'
|
|
142
|
-
const config = arguments[2]
|
|
143
|
-
|
|
144
|
-
if (mime === 'raw') {
|
|
145
|
-
let buf
|
|
146
|
-
try {
|
|
147
|
-
buf = this.data()
|
|
148
|
-
} catch (err) {
|
|
149
|
-
callback(err)
|
|
150
|
-
return
|
|
151
|
-
}
|
|
152
|
-
callback(null, buf)
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const format = MIME_FORMAT_MAP[mime]
|
|
157
|
-
if (!format) {
|
|
158
|
-
callback(new TypeError(`Unsupported MIME type "${mime}". Supported: ${Object.keys(MIME_FORMAT_MAP).join(', ')}`))
|
|
159
|
-
return
|
|
160
|
-
}
|
|
161
|
-
const q = _extractQuality(mime, config)
|
|
162
|
-
this.encode(format, q != null ? Math.round(q * 100) : undefined).then(
|
|
163
|
-
(buf) => callback(null, buf),
|
|
164
|
-
(err) => callback(err),
|
|
165
|
-
)
|
|
166
|
-
return
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Sync: no args → PNG
|
|
170
|
-
if (mimeOrCallback === undefined) {
|
|
171
|
-
return _origToBuffer.call(this, 'image/png')
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Sync: raw pixel data
|
|
175
|
-
if (mimeOrCallback === 'raw') {
|
|
176
|
-
return this.data()
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Sync: extract quality (0-1) and scale to 0-100 for native toBuffer
|
|
180
|
-
const q = _extractQuality(mimeOrCallback, configOrQuality)
|
|
181
|
-
return _origToBuffer.call(this, mimeOrCallback, q != null ? Math.round(q * 100) : undefined)
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* node-canvas compatible toDataURL:
|
|
186
|
-
* - toDataURL() → PNG data URL (sync)
|
|
187
|
-
* - toDataURL('image/jpeg', quality) → JPEG data URL, quality 0-1 (sync)
|
|
188
|
-
* - toDataURL(callback) → PNG data URL (async)
|
|
189
|
-
* - toDataURL(mime, callback) → data URL (async)
|
|
190
|
-
* - toDataURL(mime, quality, callback) → data URL with quality (async)
|
|
191
|
-
*/
|
|
192
|
-
function _compatToDataURL(mimeOrCallback, qualityOrCallback) {
|
|
193
|
-
// toDataURL(callback)
|
|
194
|
-
if (typeof mimeOrCallback === 'function') {
|
|
195
|
-
this.toDataURLAsync('image/png').then(
|
|
196
|
-
(url) => mimeOrCallback(null, url),
|
|
197
|
-
(err) => mimeOrCallback(err),
|
|
198
|
-
)
|
|
199
|
-
return
|
|
200
|
-
}
|
|
201
|
-
// toDataURL(mime, callback)
|
|
202
|
-
if (typeof qualityOrCallback === 'function') {
|
|
203
|
-
this.toDataURLAsync(mimeOrCallback, _extractQuality(mimeOrCallback, undefined)).then(
|
|
204
|
-
(url) => qualityOrCallback(null, url),
|
|
205
|
-
(err) => qualityOrCallback(err),
|
|
206
|
-
)
|
|
207
|
-
return
|
|
208
|
-
}
|
|
209
|
-
// toDataURL(mime, quality, callback)
|
|
210
|
-
const cb = arguments[2]
|
|
211
|
-
if (typeof cb === 'function') {
|
|
212
|
-
// Native toDataURLAsync expects 0-1 (f64) — pass quality through as-is
|
|
213
|
-
const quality = _extractQuality(mimeOrCallback, qualityOrCallback)
|
|
214
|
-
this.toDataURLAsync(mimeOrCallback, quality).then(
|
|
215
|
-
(url) => cb(null, url),
|
|
216
|
-
(err) => cb(err),
|
|
217
|
-
)
|
|
218
|
-
return
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Sync form: native toDataURL expects 0-1 (f64) — pass quality through as-is
|
|
222
|
-
const quality = _extractQuality(mimeOrCallback, qualityOrCallback)
|
|
223
|
-
return _origToDataURL.call(this, mimeOrCallback, quality)
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Attach node-canvas compatible methods to a CanvasElement instance.
|
|
228
|
-
*/
|
|
229
|
-
function _addCompatMethods(canvas) {
|
|
230
|
-
canvas.createPNGStream = _compatCreatePNGStream
|
|
231
|
-
canvas.createJPEGStream = _compatCreateJPEGStream
|
|
232
|
-
canvas.toBuffer = _compatToBuffer
|
|
233
|
-
canvas.toDataURL = _compatToDataURL
|
|
234
|
-
return canvas
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// ---------------------------------------------------------------------------
|
|
238
|
-
// Public API: registerFont / deregisterAllFonts
|
|
239
|
-
// ---------------------------------------------------------------------------
|
|
240
|
-
|
|
241
|
-
// Track FontKeys from registerFont() so deregisterAllFonts() can remove
|
|
242
|
-
// only user-registered fonts (matching node-canvas behavior which leaves
|
|
243
|
-
// system fonts untouched).
|
|
244
|
-
const _registeredFontKeys = []
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Register a font file with the specified font face properties.
|
|
248
|
-
* Compatible with node-canvas's registerFont(path, { family, weight?, style? }).
|
|
249
|
-
*
|
|
250
|
-
* Note: @napi-rs/canvas auto-detects weight and style from font file metadata
|
|
251
|
-
* (matching browser behavior). The weight and style properties in fontFace are
|
|
252
|
-
* accepted for API compatibility but the actual values are read from the font.
|
|
253
|
-
*
|
|
254
|
-
* @param {string} path Absolute path to the font file (.ttf, .otf, etc.)
|
|
255
|
-
* @param {{ family: string, weight?: string, style?: string }} fontFace
|
|
256
|
-
*/
|
|
257
|
-
function registerFont(path, fontFace) {
|
|
258
|
-
if (!fontFace || typeof fontFace.family !== 'string') {
|
|
259
|
-
throw new TypeError('registerFont requires a fontFace with a "family" property')
|
|
260
|
-
}
|
|
261
|
-
const key = GlobalFonts.registerFromPath(path, fontFace.family)
|
|
262
|
-
if (!key) {
|
|
263
|
-
throw new Error(`Failed to register font from "${path}" with family "${fontFace.family}"`)
|
|
264
|
-
}
|
|
265
|
-
_registeredFontKeys.push(key)
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Deregister all fonts previously registered via registerFont().
|
|
270
|
-
* Compatible with node-canvas's deregisterAllFonts() which only removes
|
|
271
|
-
* user-registered fonts and leaves system fonts untouched.
|
|
272
|
-
*/
|
|
273
|
-
function deregisterAllFonts() {
|
|
274
|
-
if (_registeredFontKeys.length > 0) {
|
|
275
|
-
GlobalFonts.removeBatch(_registeredFontKeys)
|
|
276
|
-
_registeredFontKeys.length = 0
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// ---------------------------------------------------------------------------
|
|
281
|
-
// Public API: createCanvas / createImageData
|
|
282
|
-
// ---------------------------------------------------------------------------
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* Create a new canvas instance with node-canvas compatible API.
|
|
286
|
-
*
|
|
287
|
-
* @param {number} width
|
|
288
|
-
* @param {number} height
|
|
289
|
-
* @param {'image'|'svg'} [type='image']
|
|
290
|
-
* @returns {Canvas}
|
|
291
|
-
*/
|
|
292
|
-
function createCanvas(width, height, type) {
|
|
293
|
-
if (type === 'svg') {
|
|
294
|
-
// SvgExportFlag enum requires a valid variant; NoPrettyXML (0x02) is the
|
|
295
|
-
// least impactful on rendering behavior (only affects XML whitespace).
|
|
296
|
-
return _createCanvas(width, height, SvgExportFlag.NoPrettyXML)
|
|
297
|
-
}
|
|
298
|
-
if (type === 'pdf') {
|
|
299
|
-
throw new Error(
|
|
300
|
-
'createCanvas with type "pdf" is not supported. Use the PDFDocument class from @napi-rs/canvas directly.',
|
|
301
|
-
)
|
|
302
|
-
}
|
|
303
|
-
if (type != null && type !== 'image') {
|
|
304
|
-
throw new TypeError(`createCanvas: unknown type "${type}". Supported types: "image", "svg".`)
|
|
305
|
-
}
|
|
306
|
-
return _addCompatMethods(_createCanvas(width, height))
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Create an ImageData instance.
|
|
311
|
-
* Compatible with node-canvas's createImageData().
|
|
312
|
-
*
|
|
313
|
-
* @param {Uint8ClampedArray|number} dataOrWidth
|
|
314
|
-
* @param {number} widthOrHeight
|
|
315
|
-
* @param {number} [height]
|
|
316
|
-
* @returns {ImageData}
|
|
317
|
-
*/
|
|
318
|
-
function createImageData(dataOrWidth, widthOrHeight, height) {
|
|
319
|
-
if (typeof dataOrWidth === 'number') {
|
|
320
|
-
return new ImageData(dataOrWidth, widthOrHeight)
|
|
321
|
-
}
|
|
322
|
-
if (height != null) {
|
|
323
|
-
return new ImageData(dataOrWidth, widthOrHeight, height)
|
|
324
|
-
}
|
|
325
|
-
return new ImageData(dataOrWidth, widthOrHeight)
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// ---------------------------------------------------------------------------
|
|
329
|
-
// Canvas constructor wrapper
|
|
330
|
-
// ---------------------------------------------------------------------------
|
|
331
|
-
|
|
332
|
-
// In node-canvas, `new Canvas(w, h)` and `createCanvas(w, h)` produce
|
|
333
|
-
// equivalent canvases. Wrap the native Canvas constructor so that
|
|
334
|
-
// `new Canvas(w, h)` also gets compat methods, without polluting the
|
|
335
|
-
// prototype (which would affect @napi-rs/canvas users who don't use
|
|
336
|
-
// this compat layer).
|
|
337
|
-
const CompatCanvas = new Proxy(Canvas, {
|
|
338
|
-
construct(target, args) {
|
|
339
|
-
const canvas = new target(...args)
|
|
340
|
-
if (canvas instanceof CanvasElement) {
|
|
341
|
-
return _addCompatMethods(canvas)
|
|
342
|
-
}
|
|
343
|
-
return canvas
|
|
344
|
-
},
|
|
345
|
-
})
|
|
346
|
-
|
|
347
|
-
// ---------------------------------------------------------------------------
|
|
348
|
-
// Exports (matches node-canvas export shape)
|
|
349
|
-
// ---------------------------------------------------------------------------
|
|
350
|
-
|
|
351
|
-
module.exports = {
|
|
352
|
-
// Factory functions
|
|
353
|
-
Canvas: CompatCanvas,
|
|
354
|
-
createCanvas,
|
|
355
|
-
createImageData,
|
|
356
|
-
loadImage,
|
|
357
|
-
registerFont,
|
|
358
|
-
deregisterAllFonts,
|
|
359
|
-
|
|
360
|
-
// Classes
|
|
361
|
-
Image,
|
|
362
|
-
ImageData,
|
|
363
|
-
CanvasRenderingContext2D,
|
|
364
|
-
Context2d: CanvasRenderingContext2D,
|
|
365
|
-
PNGStream,
|
|
366
|
-
JPEGStream,
|
|
367
|
-
Path2D,
|
|
368
|
-
|
|
369
|
-
// Geometry
|
|
370
|
-
DOMPoint,
|
|
371
|
-
DOMMatrix,
|
|
372
|
-
DOMRect,
|
|
373
|
-
|
|
374
|
-
// @napi-rs/canvas extras (available but not part of node-canvas)
|
|
375
|
-
GlobalFonts,
|
|
376
|
-
PDFDocument,
|
|
377
|
-
CanvasElement,
|
|
378
|
-
SVGCanvas,
|
|
379
|
-
}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@napi-rs/canvas",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Canvas for Node.js with skia backend",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/Brooooooklyn/canvas.git"
|
|
9
|
-
},
|
|
10
|
-
"workspaces": [
|
|
11
|
-
"e2e/*"
|
|
12
|
-
],
|
|
13
|
-
"license": "MIT",
|
|
14
|
-
"keywords": [
|
|
15
|
-
"napi-rs",
|
|
16
|
-
"NAPI",
|
|
17
|
-
"N-API",
|
|
18
|
-
"Rust",
|
|
19
|
-
"node-addon",
|
|
20
|
-
"node-addon-api",
|
|
21
|
-
"canvas",
|
|
22
|
-
"image",
|
|
23
|
-
"pdf",
|
|
24
|
-
"svg",
|
|
25
|
-
"skia"
|
|
26
|
-
],
|
|
27
|
-
"files": [
|
|
28
|
-
"index.d.ts",
|
|
29
|
-
"index.js",
|
|
30
|
-
"geometry.js",
|
|
31
|
-
"js-binding.js",
|
|
32
|
-
"load-image.js",
|
|
33
|
-
"node-canvas.js",
|
|
34
|
-
"node-canvas.d.ts"
|
|
35
|
-
],
|
|
36
|
-
"napi": {
|
|
37
|
-
"binaryName": "skia",
|
|
38
|
-
"targets": [
|
|
39
|
-
"x86_64-unknown-linux-gnu",
|
|
40
|
-
"x86_64-apple-darwin",
|
|
41
|
-
"x86_64-pc-windows-msvc",
|
|
42
|
-
"aarch64-pc-windows-msvc",
|
|
43
|
-
"armv7-unknown-linux-gnueabihf",
|
|
44
|
-
"x86_64-unknown-linux-musl",
|
|
45
|
-
"aarch64-unknown-linux-gnu",
|
|
46
|
-
"aarch64-unknown-linux-musl",
|
|
47
|
-
"aarch64-apple-darwin",
|
|
48
|
-
"aarch64-linux-android",
|
|
49
|
-
"riscv64-unknown-linux-gnu"
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
"engines": {
|
|
53
|
-
"node": ">= 10"
|
|
54
|
-
},
|
|
55
|
-
"publishConfig": {
|
|
56
|
-
"registry": "https://registry.npmjs.org/",
|
|
57
|
-
"access": "public"
|
|
58
|
-
},
|
|
59
|
-
"scripts": {
|
|
60
|
-
"artifacts": "napi artifacts",
|
|
61
|
-
"bench": "node --import @oxc-node/core/register benchmark/bench.ts",
|
|
62
|
-
"build": "napi build --platform --release --js js-binding.js",
|
|
63
|
-
"build:debug": "napi build --platform --js js-binding.js",
|
|
64
|
-
"example-lottie": "yarn oxnode ./example/lottie-to-video.ts",
|
|
65
|
-
"format": "run-p format:source format:rs format:toml",
|
|
66
|
-
"format:rs": "cargo fmt",
|
|
67
|
-
"format:source": "prettier . -w",
|
|
68
|
-
"format:toml": "taplo format",
|
|
69
|
-
"lint": "oxlint",
|
|
70
|
-
"prepublishOnly": "pinst --disable && napi prepublish -t npm",
|
|
71
|
-
"postpublish": "pinst --enable",
|
|
72
|
-
"test:ci": "NODE_OPTIONS='--import=core-js/proposals/iterator-helpers.js' ava -c 1",
|
|
73
|
-
"test": "NODE_OPTIONS='--import=core-js/proposals/iterator-helpers.js' ava",
|
|
74
|
-
"e2e": "yarn workspace @napi-rs/canvas-e2e-webpack test",
|
|
75
|
-
"version": "napi version && conventional-changelog -p angular -i CHANGELOG.md -s && git add ."
|
|
76
|
-
},
|
|
77
|
-
"devDependencies": {
|
|
78
|
-
"@jimp/core": "^1.6.0",
|
|
79
|
-
"@jimp/custom": "^0.22.12",
|
|
80
|
-
"@jimp/jpeg": "^0.22.12",
|
|
81
|
-
"@jimp/png": "^0.22.12",
|
|
82
|
-
"@napi-rs/cli": "^3.5.0",
|
|
83
|
-
"@napi-rs/webcodecs": "^1.1.1",
|
|
84
|
-
"@octokit/rest": "^22.0.1",
|
|
85
|
-
"@oxc-node/cli": "^0.1.0",
|
|
86
|
-
"@oxc-node/core": "^0.1.0",
|
|
87
|
-
"@taplo/cli": "^0.7.0",
|
|
88
|
-
"@types/lodash": "^4.17.21",
|
|
89
|
-
"@types/node": "^25.0.3",
|
|
90
|
-
"@types/semver": "^7",
|
|
91
|
-
"ava": "^8.0.0",
|
|
92
|
-
"canvas": "^3.2.0",
|
|
93
|
-
"canvaskit-wasm": "^0.41.0",
|
|
94
|
-
"colorette": "^2.0.20",
|
|
95
|
-
"conventional-changelog-cli": "^5.0.0",
|
|
96
|
-
"core-js": "^3.47.0",
|
|
97
|
-
"echarts": "^6.0.0",
|
|
98
|
-
"electron": "^41.0.0",
|
|
99
|
-
"husky": "^9.1.7",
|
|
100
|
-
"lint-staged": "^16.2.7",
|
|
101
|
-
"lodash": "^4.17.21",
|
|
102
|
-
"npm-run-all2": "^8.0.4",
|
|
103
|
-
"oxlint": "^1.34.0",
|
|
104
|
-
"oxlint-tsgolint": "^0.22.0",
|
|
105
|
-
"pinst": "^3.0.0",
|
|
106
|
-
"png.js": "^0.2.1",
|
|
107
|
-
"prettier": "^3.7.4",
|
|
108
|
-
"pretty-bytes": "^7.1.0",
|
|
109
|
-
"semver": "^7.7.3",
|
|
110
|
-
"skia-canvas": "^3.0.8",
|
|
111
|
-
"table": "^6.9.0",
|
|
112
|
-
"tinybench": "^6.0.0",
|
|
113
|
-
"typescript": "^6.0.0"
|
|
114
|
-
},
|
|
115
|
-
"lint-staged": {
|
|
116
|
-
"*.@(js|ts|tsx|yml|yaml|md|json|html)": [
|
|
117
|
-
"prettier --write"
|
|
118
|
-
],
|
|
119
|
-
"*.@(js|ts|tsx)": [
|
|
120
|
-
"oxlint --fix"
|
|
121
|
-
]
|
|
122
|
-
},
|
|
123
|
-
"ava": {
|
|
124
|
-
"nodeArguments": [
|
|
125
|
-
"--import=@oxc-node/core/register",
|
|
126
|
-
"--import=core-js/proposals/promise-with-resolvers.js"
|
|
127
|
-
],
|
|
128
|
-
"extensions": [
|
|
129
|
-
"ts"
|
|
130
|
-
],
|
|
131
|
-
"files": [
|
|
132
|
-
"__test__/**/*.spec.ts",
|
|
133
|
-
"scripts/__test__/**/*.spec.ts"
|
|
134
|
-
],
|
|
135
|
-
"workerThreads": false,
|
|
136
|
-
"cache": false,
|
|
137
|
-
"timeout": "3m",
|
|
138
|
-
"environmentVariables": {
|
|
139
|
-
"SWC_NODE_PROJECT": "./tsconfig.json",
|
|
140
|
-
"NODE_ENV": "ava"
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
"prettier": {
|
|
144
|
-
"printWidth": 120,
|
|
145
|
-
"semi": false,
|
|
146
|
-
"trailingComma": "all",
|
|
147
|
-
"singleQuote": true,
|
|
148
|
-
"arrowParens": "always"
|
|
149
|
-
},
|
|
150
|
-
"funding": {
|
|
151
|
-
"type": "github",
|
|
152
|
-
"url": "https://github.com/sponsors/Brooooooklyn"
|
|
153
|
-
},
|
|
154
|
-
"packageManager": "yarn@4.14.1",
|
|
155
|
-
"dependenciesMeta": {
|
|
156
|
-
"canvas": {
|
|
157
|
-
"built": true
|
|
158
|
-
},
|
|
159
|
-
"skia-canvas": {
|
|
160
|
-
"built": true
|
|
161
|
-
}
|
|
162
|
-
},
|
|
163
|
-
"resolutions": {
|
|
164
|
-
"@napi-rs/canvas": "workspace:"
|
|
165
|
-
},
|
|
166
|
-
"optionalDependencies": {
|
|
167
|
-
"@napi-rs/canvas-linux-x64-gnu": "1.0.0",
|
|
168
|
-
"@napi-rs/canvas-darwin-x64": "1.0.0",
|
|
169
|
-
"@napi-rs/canvas-win32-x64-msvc": "1.0.0",
|
|
170
|
-
"@napi-rs/canvas-win32-arm64-msvc": "1.0.0",
|
|
171
|
-
"@napi-rs/canvas-linux-arm-gnueabihf": "1.0.0",
|
|
172
|
-
"@napi-rs/canvas-linux-x64-musl": "1.0.0",
|
|
173
|
-
"@napi-rs/canvas-linux-arm64-gnu": "1.0.0",
|
|
174
|
-
"@napi-rs/canvas-linux-arm64-musl": "1.0.0",
|
|
175
|
-
"@napi-rs/canvas-darwin-arm64": "1.0.0",
|
|
176
|
-
"@napi-rs/canvas-android-arm64": "1.0.0",
|
|
177
|
-
"@napi-rs/canvas-linux-riscv64-gnu": "1.0.0"
|
|
178
|
-
}
|
|
179
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@napi-rs/canvas-linux-x64-gnu",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"os": [
|
|
5
|
-
"linux"
|
|
6
|
-
],
|
|
7
|
-
"cpu": [
|
|
8
|
-
"x64"
|
|
9
|
-
],
|
|
10
|
-
"main": "skia.linux-x64-gnu.node",
|
|
11
|
-
"files": [
|
|
12
|
-
"skia.linux-x64-gnu.node"
|
|
13
|
-
],
|
|
14
|
-
"description": "Canvas for Node.js with skia backend",
|
|
15
|
-
"keywords": [
|
|
16
|
-
"napi-rs",
|
|
17
|
-
"NAPI",
|
|
18
|
-
"N-API",
|
|
19
|
-
"Rust",
|
|
20
|
-
"node-addon",
|
|
21
|
-
"node-addon-api",
|
|
22
|
-
"canvas",
|
|
23
|
-
"image",
|
|
24
|
-
"pdf",
|
|
25
|
-
"svg",
|
|
26
|
-
"skia"
|
|
27
|
-
],
|
|
28
|
-
"license": "MIT",
|
|
29
|
-
"engines": {
|
|
30
|
-
"node": ">= 10"
|
|
31
|
-
},
|
|
32
|
-
"publishConfig": {
|
|
33
|
-
"registry": "https://registry.npmjs.org/",
|
|
34
|
-
"access": "public"
|
|
35
|
-
},
|
|
36
|
-
"repository": {
|
|
37
|
-
"type": "git",
|
|
38
|
-
"url": "git+https://github.com/Brooooooklyn/canvas.git"
|
|
39
|
-
},
|
|
40
|
-
"libc": [
|
|
41
|
-
"glibc"
|
|
42
|
-
],
|
|
43
|
-
"funding": {
|
|
44
|
-
"type": "github",
|
|
45
|
-
"url": "https://github.com/sponsors/Brooooooklyn"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
Binary file
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@napi-rs/canvas-linux-x64-musl",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"os": [
|
|
5
|
-
"linux"
|
|
6
|
-
],
|
|
7
|
-
"cpu": [
|
|
8
|
-
"x64"
|
|
9
|
-
],
|
|
10
|
-
"main": "skia.linux-x64-musl.node",
|
|
11
|
-
"files": [
|
|
12
|
-
"skia.linux-x64-musl.node"
|
|
13
|
-
],
|
|
14
|
-
"description": "Canvas for Node.js with skia backend",
|
|
15
|
-
"keywords": [
|
|
16
|
-
"napi-rs",
|
|
17
|
-
"NAPI",
|
|
18
|
-
"N-API",
|
|
19
|
-
"Rust",
|
|
20
|
-
"node-addon",
|
|
21
|
-
"node-addon-api",
|
|
22
|
-
"canvas",
|
|
23
|
-
"image",
|
|
24
|
-
"pdf",
|
|
25
|
-
"svg",
|
|
26
|
-
"skia"
|
|
27
|
-
],
|
|
28
|
-
"license": "MIT",
|
|
29
|
-
"engines": {
|
|
30
|
-
"node": ">= 10"
|
|
31
|
-
},
|
|
32
|
-
"publishConfig": {
|
|
33
|
-
"registry": "https://registry.npmjs.org/",
|
|
34
|
-
"access": "public"
|
|
35
|
-
},
|
|
36
|
-
"repository": {
|
|
37
|
-
"type": "git",
|
|
38
|
-
"url": "git+https://github.com/Brooooooklyn/canvas.git"
|
|
39
|
-
},
|
|
40
|
-
"libc": [
|
|
41
|
-
"musl"
|
|
42
|
-
],
|
|
43
|
-
"funding": {
|
|
44
|
-
"type": "github",
|
|
45
|
-
"url": "https://github.com/sponsors/Brooooooklyn"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
Binary file
|
|
File without changes
|
/package/dist/ui/static/_next/static/{IZjQES_2JaG9qZ7_fkEPl → 12efBQERZ9Itf_HaPzx5q}/_ssgManifest.js
RENAMED
|
File without changes
|