-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added `/napi-rs` engine feat: added `createImageData()` feat: added `createConicGradient()` feat: added `printConicColorGradient()` feat: added `printConicStrokeGradient()` refactor: renamed `resolveImage` to `loadImage` refactor: renamed `registerFont` to `loadFont` feat(cairo): added `jpeg()` feat(cairo): added `jpegAsync()` feat(cairo): added `pdf()` feat(cairo): added `pdfAsync()` feat(cairo): added `png()` feat(cairo): added `pngAsync()` feat(skia): added `jpegAsync()` feat(skia): added `pdfAsync()` feat(skia): added `pngAsync()` feat(skia): added `svgAsync()` docs: add `@note`s defining which methods are engine-specific BREAKING CHANGE: refactor: removed `cb` parameter in `getImageData()` BREAKING CHANGE: refactor: removed `cb` parameter in `measureText()` BREAKING CHANGE: refactor: removed `cb` parameter in `createPattern()` BREAKING CHANGE: refactor: removed `cb` parameter in `wrapText()` BREAKING CHANGE: refactor(cairo): renamed `createJPEGStream()` to `jpegStream()` BREAKING CHANGE: refactor(cairo): renamed `createPDFStream()` to `pdfStream()` BREAKING CHANGE: refactor(cairo): renamed `createPNGStream()` to `pngStream()` BREAKING CHANGE: refactor(cairo): renamed `setAntiAliasing()` to `setAntialiasMode()` BREAKING CHANGE: refactor(skia): `jpg()` now returns a synchronous response BREAKING CHANGE: refactor(skia): `pdf()` now returns a synchronous response BREAKING CHANGE: refactor(skia): `png()` now returns a synchronous response BREAKING CHANGE: refactor(skia): `svg()` now returns a synchronous response BREAKING CHANGE: refactor(skia): removed `cb` parameter in `getFontVariant()` BREAKING CHANGE: refactor(skia): removed `cb` parameter in `getTextTracking()` BREAKING CHANGE: refactor(skia): removed `cb` parameter in `getTextWrap()` BREAKING CHANGE: refactor(skia): renamed `getPages()` to `get pages` BREAKING CHANGE: refactor(skia): renamed `jpg()` to `jpeg()` BREAKING CHANGE: refactor(skia): renamed `newPages()` to `addPage()`
- Loading branch information
Showing
24 changed files
with
3,377 additions
and
3,005 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
node_modules/ | ||
dist/ | ||
*.js | ||
*.mjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"main": "./src/main.tst", | ||
"output": "./src/[name].ts", | ||
"entries": [ | ||
{ | ||
"name": "browser", | ||
"defines": ["BROWSER"] | ||
}, | ||
{ | ||
"name": "cairo", | ||
"defines": ["CAIRO"] | ||
}, | ||
{ | ||
"name": "napi-rs", | ||
"defines": ["NAPI_RS"] | ||
}, | ||
{ | ||
"name": "skia", | ||
"defines": ["SKIA"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { readFile, writeFile } from 'node:fs/promises'; | ||
import configuration from '../generator.config.json' assert { type: 'json' }; | ||
|
||
const root = new URL('../', import.meta.url); | ||
const input = new URL(configuration.main, root); | ||
console.debug(`Input file: '${input.href}'`); | ||
|
||
const text = await readFile(input, 'utf8'); | ||
|
||
for (const entry of configuration.entries) { | ||
const output = new URL(configuration.output.replace('[name]', entry.name), root); | ||
|
||
const content = replaceAll(entry.defines); | ||
await writeFile(output, content, 'utf8'); | ||
console.info(`Written ${content.length.toLocaleString('en-US')} bytes into`, output.href, '...'); | ||
} | ||
|
||
/** | ||
* @param {string} variables The variable to check. | ||
* @param {string[]} defines | ||
*/ | ||
function isIncluded(variables, defines) { | ||
for (const variable of variables.split(',')) { | ||
if (variable.startsWith('!')) { | ||
return !defines.includes(variable.slice(1)); | ||
} else if (defines.includes(variable)) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* @param {string} content | ||
* @param {string} header | ||
* @returns {string} | ||
*/ | ||
function getContent(content, header) { | ||
return content.includes('\n') | ||
? content | ||
.slice(8 + header.length) | ||
.replaceAll('\\\n', '\n') | ||
.split('\n') | ||
.map((line) => line.trimEnd()) | ||
.join('\n') | ||
: content.slice(8 + header.length).trim(); | ||
} | ||
|
||
/** | ||
* @param {string[]} defines | ||
* @returns {string} | ||
*/ | ||
function replaceAll(defines) { | ||
return text | ||
.replaceAll(/\/\/ IF\(([A-Z_,!]+)\):([^\n]|(?<=\\)\n)+/g, (match, variables) => | ||
isIncluded(variables, defines) ? getContent(match, variables) : '' | ||
) | ||
.replaceAll(/\n\n+/g, '\n\n'); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.